Search in sources :

Example 36 with ExecutorTest

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

Example 37 with ExecutorTest

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

Example 38 with ExecutorTest

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

Example 39 with ExecutorTest

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

Example 40 with ExecutorTest

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);
}
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)

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