@Test(expected = WebSuitesException.class) public void testArgumentErrorWrongArgumentCount() { sut.instantiateCommand( "sample simple value", // without tabs new String[] {}, source()); fail("command should not be craeted"); }
@Test public void testNoArgCommand() { Command command = sut.instantiateCommand("noArg", new String[] {}, source()); assertNotNull(command); assertTrue(command instanceof NoArgCommand); }
@Test public void shouldDetectCustomScanPathPackage() { // given WebSuitesConfig.initializeWebsuitesConfig(CustomPackageRunner.class); sut = new StandardCommandBuilder(); // when Command command = sut.instantiateCommand("customUserCommand", new String[] {}, new SourceLine("", "", 0)); // then assertThat(command).isInstanceOf(CustomCommandInClasspath.class); }
@Test public void testSimpleCommand() { Command command = sut.instantiateCommand("sample", new String[] {"command argument"}, source()); assertNotNull(command); assertTrue(command instanceof SampleCommand); assertEquals("command argument", Deencapsulation.getField(command, "arg")); }
@Test public void testMultiArgCommand() { Command command = sut.instantiateCommand( "multiArg", new String[] {"string value", "5687", "true", "23"}, source()); assertNotNull(command); assertTrue(command instanceof MultiArgCommand); assertEquals("string value", Deencapsulation.getField(command, "string")); assertEquals(5687, Deencapsulation.getField(command, "integer")); assertEquals(true, Deencapsulation.getField(command, "bool")); assertEquals((byte) 23, Deencapsulation.getField(command, "bytee")); }
@Test(expected = WebSuitesException.class) public void testArgumentErrorToManyArguments() { sut.instantiateCommand("sample", new String[] {"param", "another not expected"}, source()); fail("command should not be craeted"); }