use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetBlock2_1.
@Test
public void testSetBlock2_1() throws Exception {
// {block id} {block data} {Location instance}
World mockWorld = mock(World.class);
Player player = mock(Player.class);
Block block = mock(Block.class);
when(player.getWorld()).thenReturn(mockWorld);
when(mockWorld.getBlockAt(any(Location.class))).thenReturn(block);
when(server.getWorld("world")).thenReturn(mockWorld);
new ExecutorTest(engine, "SETBLOCK").addVariable("player", player).withArgs("GLASS", 2, new Location(mockWorld, 33, 96, -15)).test();
verify(block).setType(eq(Material.GLASS));
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testPlayer_SetFlySpeed.
@Test
public void testPlayer_SetFlySpeed() throws Exception {
Player player = mock(Player.class);
JsTest test = new ExecutorTest(engine, "SETFLYSPEED").addVariable("player", player);
// only case
test.withArgs(0.5).test();
verify(player).setFlySpeed(0.5F);
// Unexpected cases
assertJSError(() -> test.withArgs().test(), "Incorrect Number of arguments for Executor SETFLYSPEED");
assertJSError(() -> test.withArgs(0.5, 13).test(), "Incorrect Number of arguments for Executor SETFLYSPEED");
assertJSError(() -> test.withArgs("HI").test(), "Invalid argument for SETFLYSPEED: HI");
assertJSError(() -> test.withArgs(4).test(), "Argument for Executor SETFLYSPEED is outside of range -1..1");
assertJSError(() -> test.withArgs(-4).test(), "Argument for Executor SETFLYSPEED is outside of range -1..1");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testPlayer_SetGameMode.
@Test
public void testPlayer_SetGameMode() throws Exception {
Player player = mock(Player.class);
JsTest test = new ExecutorTest(engine, "SETGAMEMODE").addVariable("player", player);
// only case
test.withArgs("creative").test();
verify(player).setGameMode(GameMode.valueOf("CREATIVE"));
// case2
test.withArgs(2).test();
verify(player).setGameMode(GameMode.valueOf("ADVENTURE"));
// Unexpected Cases
assertJSError(() -> test.withArgs().test(), "Incorrect number of arguments for executor SETGAMEMODE");
assertJSError(() -> test.withArgs(34).test(), "Invalid argument for Executor SETGAMEMODE: 34");
assertJSError(() -> test.withArgs("hElLo").test(), "Unknown GAEMMODE value hElLo");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testServer.
@Test
public void testServer() throws Exception {
BukkitTriggerReactorCore plugin = mock(BukkitTriggerReactorCore.class);
AbstractJavaPlugin.BungeeCordHelper helper = mock(AbstractJavaPlugin.BungeeCordHelper.class);
Player player = mock(Player.class);
when(plugin.getBungeeHelper()).thenReturn(helper);
new ExecutorTest(engine, "SERVER").addVariable("player", player).addVariable("plugin", plugin).withArgs("someServer").test();
verify(helper).sendToServer(player, "someServer");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testMessageNull.
@Test
public void testMessageNull() throws Exception {
Player mockPlayer = mock(Player.class);
new ExecutorTest(engine, "MESSAGE").addVariable("player", mockPlayer).withArgs(new Object[] { null }).test();
String expected = "null";
verify(mockPlayer).sendMessage(argThat((String str) -> expected.equals(str)));
}
Aggregations