use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testKill.
@Test
public void testKill() throws Exception {
Player player = mock(Player.class);
JsTest test = new ExecutorTest(engine, "KILL").addVariable("player", player);
test.withArgs().test();
verify(player).setHealth(0d);
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetType.
@Test
public void testSetType() throws Exception {
ItemStack vItem = mock(ItemStack.class);
Material stone = Material.valueOf("STONE");
Material newDirt = Material.valueOf("DIRT");
when(vItem.getType()).thenReturn(stone);
ExecutorTest test = new ExecutorTest(engine, "SETTYPE");
test.withArgs("DIRT", vItem).test();
verify(vItem).setType(newDirt);
test.assertValid("STONE", vItem);
test.assertInvalid(1, vItem);
test.assertInvalid(1, 3);
test.assertInvalid("h", "d");
test.assertInvalid(vItem, 2);
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testPlayer_SetWalkSpeed.
@Test
public void testPlayer_SetWalkSpeed() throws Exception {
Player player = mock(Player.class);
JsTest test = new ExecutorTest(engine, "SETWALKSPEED").addVariable("player", player);
// case1
test.withArgs(1).test();
verify(player).setWalkSpeed(1.0F);
// case2
test.withArgs(0.7).test();
verify(player).setWalkSpeed(0.7F);
// Unexpected Cases
assertJSError(() -> test.withArgs().test(), "Incorrect Number of arguments for Executor SETWALKSPEED");
assertJSError(() -> test.withArgs("NUU").test(), "Invalid argument for SETWALKSPEED: NUU");
assertJSError(() -> test.withArgs(-3).test(), "Argument for Executor SETWALKSPEED is outside of the allowable range -1..1");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testCmdCon.
@Test
public void testCmdCon() throws Exception {
Player player = mock(Player.class);
ConsoleCommandSender sender = mock(ConsoleCommandSender.class);
when(player.getServer()).thenReturn(server);
when(server.getConsoleSender()).thenReturn(sender);
new ExecutorTest(engine, "CMDCON").withArgs("some command line").test();
verify(server).dispatchCommand(sender, "some command line");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetItemName.
@Test
public void testSetItemName() throws Exception {
ItemStack vItem = mock(ItemStack.class);
ItemMeta vIM = mock(ItemMeta.class);
Material stone = Material.valueOf("STONE");
ExecutorTest test = new ExecutorTest(engine, "SETITEMNAME");
when(vItem.getItemMeta()).thenReturn(vIM);
when(vItem.getType()).thenReturn(stone);
test.withArgs("NO--NO", vItem).test();
verify(vIM).setDisplayName("NO--NO");
verify(vItem).setItemMeta(vIM);
test.assertValid("herllo", vItem);
test.assertInvalid(0);
test.assertInvalid("HELLO");
test.assertInvalid(0, "hu");
test.assertInvalid(true, 0);
}
Aggregations