use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testScoreboard.
@Test
public void testScoreboard() throws Exception {
Player player = mock(Player.class);
Scoreboard scoreboard = mock(Scoreboard.class);
Team team = mock(Team.class);
when(player.getScoreboard()).thenReturn(scoreboard);
when(scoreboard.getTeam(anyString())).thenReturn(team);
new ExecutorTest(engine, "SCOREBOARD").withArgs("TEAM", "someteam", "ADD", "wysohn").addVariable("player", player).test();
verify(team).addEntry("wysohn");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSetBlock1_1.
@Test
public void testSetBlock1_1() throws Exception {
// {block id} {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", 33, 96, -15).test();
verify(block).setType(eq(Material.GLASS));
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSpawn.
@Test
public void testSpawn() throws Exception {
Player player = mock(Player.class);
World world = mock(World.class);
Location location = new Location(world, 3, 4, 5);
when(player.getWorld()).thenReturn(world);
new ExecutorTest(engine, "SPAWN").addVariable("player", player).withArgs(location, EntityType.CREEPER.name()).test();
verify(world).spawnEntity(location, EntityType.CREEPER);
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testGUI.
@Test
public void testGUI() throws Exception {
IPlayer vip = mock(IPlayer.class);
TriggerReactorCore tr = mock(TriggerReactorCore.class);
AbstractInventoryTriggerManager invManager = mock(AbstractInventoryTriggerManager.class);
IInventory iInv = mock(IInventory.class);
JsTest test = new ExecutorTest(engine, "GUI").addVariable("player", vip).addVariable("plugin", tr);
when(tr.getInvManager()).thenReturn(invManager);
when(invManager.openGUI(vip, "Hi")).thenReturn(iInv);
test.withArgs("Hi").test();
verify(invManager).openGUI(vip, "Hi");
assertJSError(() -> test.withArgs().test(), "Invalid parameters. Need [String]");
when(invManager.openGUI(vip, "hello")).thenReturn(null);
assertJSError(() -> test.withArgs("hello").test(), "No such Inventory Trigger named hello");
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testClearEntity.
@Test
public void testClearEntity() throws Exception {
Player player = mock(Player.class);
List<Entity> entities = new ArrayList<>();
for (int i = 0; i < 10; i++) {
entities.add(mock(Entity.class));
}
JsTest test = new ExecutorTest(engine, "CLEARENTITY").addVariable("player", player);
when(player.getNearbyEntities(2d, 2d, 2d)).thenReturn(entities);
test.withArgs(2).test();
for (Entity ve : entities) {
verify(ve).remove();
}
assertJSError(() -> test.withArgs().test(), "Invalid parameters! [Number]");
assertJSError(() -> test.withArgs("NO").test(), "Invalid parameters! [Number]");
}
Aggregations