Dieser Commit ist enthalten in:
yoyosource 2022-04-26 09:04:36 +02:00
Ursprung 8575c92c44
Commit f3363ecedf
5 geänderte Dateien mit 96 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,24 @@
package de.steamwar.command;
import de.steamwar.command.dto.ExecutionIdentifier;
import de.steamwar.command.dto.TestGuardChecker;
import de.steamwar.command.dto.TestSWCommand;
public class GuardCommand extends TestSWCommand {
public GuardCommand() {
super("typemapper");
}
@Register
public void test(@Guard String sender) {
throw new ExecutionIdentifier("RunTypeMapper");
}
@ClassGuard(value = String.class, local = true)
public AbstractGuardChecker<String> getGuardChecker() {
return (TestGuardChecker) (s, guardCheckType, previousArguments, s2) -> {
throw new ExecutionIdentifier("GuardChecker " + guardCheckType);
};
}
}

Datei anzeigen

@ -0,0 +1,33 @@
package de.steamwar.command;
import de.steamwar.command.dto.ExecutionIdentifier;
import org.junit.Test;
import static de.steamwar.AssertionUtils.assertCMDFramework;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
public class GuardCommandTest {
@Test
public void test() {
GuardCommand cmd = new GuardCommand();
try {
cmd.execute("test", "", new String[0]);
} catch (Exception e) {
assertCMDFramework(e, ExecutionIdentifier.class, "RunTypeMapper");
}
}
@Test
public void testTabComplete() {
GuardCommand cmd = new GuardCommand();
try {
cmd.tabComplete("test", "", new String[]{""});
} catch (Exception e) {
assertThat(e, is(instanceOf(ExecutionIdentifier.class)));
assertThat(e.getMessage(), is("GuardChecker TAB_COMPLETE"));
}
}
}

Datei anzeigen

@ -0,0 +1,21 @@
package de.steamwar.command;
import de.steamwar.command.dto.ExecutionIdentifier;
import de.steamwar.command.dto.TestSWCommand;
public class TypeMapperCommand extends TestSWCommand {
public TypeMapperCommand() {
super("typemapper");
}
@Register
public void test(String sender, String s) {
throw new ExecutionIdentifier("RunTypeMapper with CustomMapper");
}
@ClassMapper(value = String.class, local = true)
public AbstractTypeMapper<String, String> getTypeMapper() {
return SWCommandUtils.createMapper("1", "2", "3", "4", "5");
}
}

Datei anzeigen

@ -0,0 +1,17 @@
package de.steamwar.command;
import org.junit.Test;
import java.util.List;
import static de.steamwar.AssertionUtils.assertTabCompletes;
public class TypeMapperCommandTest {
@Test
public void testTabComplete() {
TypeMapperCommand cmd = new TypeMapperCommand();
List<String> strings = cmd.tabComplete("test", "", new String[]{""});
assertTabCompletes(strings, "1", "2", "3", "4", "5");
}
}

Datei anzeigen

@ -2,5 +2,5 @@ package de.steamwar.command.dto;
import de.steamwar.command.AbstractTypeMapper;
public interface TestTypeChecker<T> extends AbstractTypeMapper<String, T> {
public interface TestTypeMapper<T> extends AbstractTypeMapper<String, T> {
}