Search in sources :

Example 56 with ExecutorTest

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));
}
Also used : Player(org.bukkit.entity.Player) IPlayer(io.github.wysohn.triggerreactor.core.bridge.entity.IPlayer) ExecutorTest(js.ExecutorTest) ExecutorTest(js.ExecutorTest) Test(org.junit.Test) JsTest(js.JsTest)

Example 57 with ExecutorTest

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)));
}
Also used : Player(org.bukkit.entity.Player) IPlayer(io.github.wysohn.triggerreactor.core.bridge.entity.IPlayer) ExecutorTest(js.ExecutorTest) ExecutorTest(js.ExecutorTest) Test(org.junit.Test) JsTest(js.JsTest)

Example 58 with ExecutorTest

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);
}
Also used : Player(org.bukkit.entity.Player) IPlayer(io.github.wysohn.triggerreactor.core.bridge.entity.IPlayer) ExecutorTest(js.ExecutorTest) ExecutorTest(js.ExecutorTest) Test(org.junit.Test) JsTest(js.JsTest)

Example 59 with ExecutorTest

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));
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) World(org.bukkit.World) Location(org.bukkit.Location) ExecutorTest(js.ExecutorTest) Test(org.junit.Test) ExecutorTest(js.ExecutorTest) JsTest(js.JsTest)

Example 60 with ExecutorTest

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]");
}
Also used : Player(org.bukkit.entity.Player) VaultSupport(io.github.wysohn.triggerreactor.bukkit.manager.trigger.share.api.vault.VaultSupport) JsTest(js.JsTest) ExecutorTest(js.ExecutorTest) Test(org.junit.Test) ExecutorTest(js.ExecutorTest) JsTest(js.JsTest)

Aggregations

ExecutorTest (js.ExecutorTest)63 JsTest (js.JsTest)61 Test (org.junit.Test)60 Player (org.bukkit.entity.Player)48 IPlayer (io.github.wysohn.triggerreactor.core.bridge.entity.IPlayer)43 Block (org.bukkit.block.Block)16 ItemStack (org.bukkit.inventory.ItemStack)11 Location (org.bukkit.Location)6 World (org.bukkit.World)5 PlayerInventory (org.bukkit.inventory.PlayerInventory)5 BlockState (org.bukkit.block.BlockState)4 ArrayList (java.util.ArrayList)3 Entity (org.bukkit.entity.Entity)3 ItemMeta (org.bukkit.inventory.meta.ItemMeta)3 Lever (org.bukkit.material.Lever)3 BukkitTriggerReactorCore (io.github.wysohn.triggerreactor.bukkit.main.BukkitTriggerReactorCore)2 IInventory (io.github.wysohn.triggerreactor.core.bridge.IInventory)2 AbstractJavaPlugin (io.github.wysohn.triggerreactor.bukkit.main.AbstractJavaPlugin)1 VaultSupport (io.github.wysohn.triggerreactor.bukkit.manager.trigger.share.api.vault.VaultSupport)1 TriggerReactorCore (io.github.wysohn.triggerreactor.core.main.TriggerReactorCore)1