use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testCmd.
@Test
public void testCmd() throws Exception {
Player player = mock(Player.class);
when(player.getServer()).thenReturn(server);
JsTest test = new ExecutorTest(engine, "CMD").addVariable("player", player);
// only happy case
test.withArgs("some command line").test();
verify(server).dispatchCommand(player, "some command line");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetBlock1_2.
@Test
public void testSetBlock1_2() throws Exception {
// {block id} {block data} {x} {y} {z}
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", 3, 33, 96, -15).test();
verify(block).setType(eq(Material.GLASS));
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetBlock2.
@Test
public void testSetBlock2() throws Exception {
// {block id} {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", 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 testModifyHeldItem.
@Test
public void testModifyHeldItem() throws Exception {
Player player = mock(Player.class);
ItemStack held = mock(ItemStack.class);
ItemMeta meta = mock(ItemMeta.class);
when(player.getItemInHand()).thenReturn(held);
when(held.getType()).thenReturn(Material.STONE);
when(held.getItemMeta()).thenReturn(meta);
new ExecutorTest(engine, "MODIFYHELDITEM").addVariable("player", player).withArgs("TITLE", "some title").test();
verify(meta).setDisplayName("some title");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSoundAll.
@Test
public void testSoundAll() throws Exception {
Player player = mock(Player.class);
Location location = mock(Location.class);
World world = mock(World.class);
when(player.getLocation()).thenReturn(location);
when(location.getWorld()).thenReturn(world);
new ExecutorTest(engine, "SOUNDALL").withArgs(location, "BOO", 1.0, 1.0).addVariable("player", player).test();
verify(world).playSound(location, "BOO", 1.0f, 1.0f);
}
Aggregations