use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetOffHand.
@Test
public void testSetOffHand() throws Exception {
Player player = mock(Player.class);
ItemStack vItem = mock(ItemStack.class);
PlayerInventory vInv = mock(PlayerInventory.class);
ExecutorTest test = new ExecutorTest(engine, "SETOFFHAND");
test.addVariable("player", player);
when(player.getInventory()).thenReturn(vInv);
test.withArgs(vItem).test();
verify(vInv).setItemInOffHand(vItem);
test.assertInvalid(0);
test.assertInvalid("HELLO");
test.assertInvalid(true);
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetCount.
@Test
public void testSetCount() throws Exception {
ItemStack vItem = mock(ItemStack.class);
Material stone = Material.valueOf("STONE");
when(vItem.getType()).thenReturn(stone);
ExecutorTest test = new ExecutorTest(engine, "SETCOUNT");
test.withArgs(3, vItem).test();
verify(vItem).setAmount(3);
test.assertValid(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 testLightning.
@Test
public void testLightning() throws Exception {
Location vLoc = mock(Location.class);
World vWorld = mock(World.class);
JsTest test = new ExecutorTest(engine, "LIGHTNING");
when(vLoc.getWorld()).thenReturn(vWorld);
test.withArgs(vLoc).test();
verify(vWorld).strikeLightning(vLoc);
assertJSError(() -> test.withArgs().test(), "Invalid parameters! [String, Number, Number, Number] or [Location]");
assertJSError(() -> test.withArgs("hff").test(), "Invalid parameters! [String, Number, Number, Number] or [Location]");
// TODO - need test for the situation of args.length == 4
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testPlayer_SetFlyMode.
@Test
public void testPlayer_SetFlyMode() throws Exception {
Player mockPlayer = mock(Player.class);
JsTest test = new ExecutorTest(engine, "SETFLYMODE").addVariable("player", mockPlayer);
for (boolean b : new boolean[] { true, false }) {
test.withArgs(b).test();
verify(mockPlayer).setAllowFlight(eq(b));
verify(mockPlayer).setFlying(eq(b));
}
assertJSError(() -> test.withArgs(true, true).test(), "Incorrect number of arguments for executor SETFLYMODE");
assertJSError(() -> test.withArgs("merp").test(), "Invalid argument for executor SETFLYMODE: merp");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testVelocity.
@Test
public void testVelocity() throws Exception {
Player player = mock(Player.class);
new ExecutorTest(engine, "VELOCITY").withArgs(1, -2, 3).addVariable("player", player).test();
verify(player).setVelocity(new Vector(1, -2, 3));
}
Aggregations