use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetItemLore.
@Test
public void testSetItemLore() throws Exception {
ItemStack vItem = mock(ItemStack.class);
ItemMeta vIM = mock(ItemMeta.class);
ExecutorTest test = new ExecutorTest(engine, "SETITEMLORE");
when(vItem.getItemMeta()).thenReturn(vIM);
test.withArgs("NO\nNO", vItem).test();
verify(vItem).setItemMeta(vIM);
test.assertValid("herllo", vItem);
test.assertInvalid(0);
test.assertInvalid("HELLO");
test.assertInvalid(0, "hu");
test.assertInvalid(true, 0);
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testFallingBlock.
@Test
public void testFallingBlock() throws Exception {
Player player = mock(Player.class);
World world = mock(World.class);
when(player.getWorld()).thenReturn(world);
new ExecutorTest(engine, "FALLINGBLOCK").addVariable("player", player).withArgs("STONE", 44.5, 6, 78.9).test();
verify(world).spawnFallingBlock(new Location(world, 44.5, 6, 78.9), Material.STONE, (byte) 0);
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testTppos.
@Test
public void testTppos() throws Exception {
Player player = mock(Player.class);
World world = mock(World.class);
Location location = new Location(world, 1, 1, 1);
when(player.getWorld()).thenReturn(world);
when(player.getLocation()).thenReturn(location);
new ExecutorTest(engine, "TPPOS").withArgs("~33 ~-2 ~9").addVariable("player", player).test();
verify(player).teleport(new Location(world, 1 + 33, 1 - 2, 1 + 9));
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testLeverOff.
@Test
public void testLeverOff() throws Exception {
Location vLoc = mock(Location.class);
Block vBlock = mock(Block.class);
BlockState vBS = mock(BlockState.class);
Lever vLever = mock(Lever.class);
JsTest test = new ExecutorTest(engine, "LEVEROFF");
when(vLoc.getBlock()).thenReturn(vBlock);
when(vBlock.getState()).thenReturn(vBS);
when(vBS.getData()).thenReturn(vLever);
test.withArgs(vLoc).test();
verify(vLever).setPowered(false);
assertJSError(() -> test.withArgs().test(), "Invalid parameters. Need [Location<location or number number number>]");
// TODO - need test for the situation of args.length == 3
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testPlayer_SetSaturation.
@Test
public void testPlayer_SetSaturation() throws Exception {
Player player = mock(Player.class);
JsTest test = new ExecutorTest(engine, "SETSATURATION").addVariable("player", player);
// case1
test.withArgs(25).test();
verify(player).setSaturation(25.0F);
// case2
test.withArgs(44.0).test();
verify(player).setSaturation(44.0F);
// Unexpected Cases
assertJSError(() -> test.withArgs().test(), "Incorrect Number of arguments for Executor SETSATURATION");
assertJSError(() -> test.withArgs("Hi").test(), "Invalid argument for SETSATURATION: Hi");
assertJSError(() -> test.withArgs(-45).test(), "Argument for Executor SETSATURATION should not be negative");
}
Aggregations