use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testTp.
@Test
public void testTp() throws Exception {
Player player = mock(Player.class);
World world = mock(World.class);
when(player.getWorld()).thenReturn(world);
new ExecutorTest(engine, "TP").withArgs(1, 2.5, 3).addVariable("player", player).test();
verify(player).teleport(new Location(world, 1, 2.5, 3));
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testMessage.
@Test
public void testMessage() throws Exception {
Player mockPlayer = mock(Player.class);
new ExecutorTest(engine, "MESSAGE").addVariable("player", mockPlayer).withArgs("&cTest Message").test();
String expected = ChatColor.translateAlternateColorCodes('&', "&cTest Message");
verify(mockPlayer).sendMessage(argThat((String str) -> expected.equals(str)));
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class AbstractTestExecutors method testSound.
@Test
public void testSound() throws Exception {
Player player = mock(Player.class);
Location location = mock(Location.class);
when(player.getLocation()).thenReturn(location);
new ExecutorTest(engine, "SOUND").withArgs(location, "BOO", 1.0, 1.0).addVariable("player", player).test();
verify(player).playSound(location, "BOO", 1.0f, 1.0f);
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class TestExecutors method testSetBlockSetData1_1.
@Test
public void testSetBlockSetData1_1() throws Exception {
// {block id} {x} {y} {z}
World mockWorld = Mockito.mock(World.class);
Player player = Mockito.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(1, 33, 96, -15).test();
verify(block).setType(eq(Material.STONE));
verify(block).setData(eq((byte) 0));
}
use of js.ExecutorTest in project TriggerReactor by wysohn.
the class TestExecutors method testMoney.
@Test
public void testMoney() throws Exception {
VaultSupport vVault = Mockito.mock(VaultSupport.class);
Player vp = Mockito.mock(Player.class);
JsTest test = new ExecutorTest(engine, "MONEY").addVariable("vault", vVault).addVariable("player", vp);
test.withArgs(30).test();
Mockito.verify(vVault).give(vp, 30);
test.withArgs(-30).test();
Mockito.verify(vVault).take(vp, 30);
assertJSError(() -> test.withArgs().test(), "Invalid parameter! [Number]");
assertJSError(() -> test.withArgs("nuu").test(), "Invalid parameter! [Number]");
}
Aggregations