Add more tests
Dieser Commit ist enthalten in:
Ursprung
8575c92c44
Commit
f3363ecedf
24
testsrc/de/steamwar/command/GuardCommand.java
Normale Datei
24
testsrc/de/steamwar/command/GuardCommand.java
Normale Datei
@ -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);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
33
testsrc/de/steamwar/command/GuardCommandTest.java
Normale Datei
33
testsrc/de/steamwar/command/GuardCommandTest.java
Normale Datei
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
testsrc/de/steamwar/command/TypeMapperCommand.java
Normale Datei
21
testsrc/de/steamwar/command/TypeMapperCommand.java
Normale Datei
@ -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");
|
||||||
|
}
|
||||||
|
}
|
17
testsrc/de/steamwar/command/TypeMapperCommandTest.java
Normale Datei
17
testsrc/de/steamwar/command/TypeMapperCommandTest.java
Normale Datei
@ -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");
|
||||||
|
}
|
||||||
|
}
|
@ -2,5 +2,5 @@ package de.steamwar.command.dto;
|
|||||||
|
|
||||||
import de.steamwar.command.AbstractTypeMapper;
|
import de.steamwar.command.AbstractTypeMapper;
|
||||||
|
|
||||||
public interface TestTypeChecker<T> extends AbstractTypeMapper<String, T> {
|
public interface TestTypeMapper<T> extends AbstractTypeMapper<String, T> {
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren