Search in sources :

Example 61 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class TestExecutors method testRotateBlock.

@Override
public void testRotateBlock() throws Exception {
    Location location = mock(Location.class);
    Block block = mock(Block.class);
    BlockState state = mock(BlockState.class);
    Stairs data = mock(Stairs.class);
    when(location.getBlock()).thenReturn(block);
    when(block.getState()).thenReturn(state);
    when(state.getData()).thenReturn(data);
    new ExecutorTest(engine, "ROTATEBLOCK").withArgs(BlockFace.NORTH.name(), location).test();
    verify(data).setFacingDirection(BlockFace.NORTH);
    verify(state).setData(data);
}
Also used : BlockState(org.bukkit.block.BlockState) Stairs(org.bukkit.material.Stairs) Block(org.bukkit.block.Block) Location(org.bukkit.Location) ExecutorTest(js.ExecutorTest)

Example 62 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class TestExecutors method testSignEdit.

@Override
public void testSignEdit() throws Exception {
    Player player = mock(Player.class);
    Location location = mock(Location.class);
    Block block = mock(Block.class);
    Sign sign = mock(Sign.class);
    when(location.getBlock()).thenReturn(block);
    when(block.getType()).thenReturn(Material.SIGN_POST);
    when(block.getState()).thenReturn(sign);
    new ExecutorTest(engine, "SIGNEDIT").withArgs(0, "line1", location).addVariable("player", player).test();
    verify(sign).setLine(0, "line1");
    verify(sign).update();
}
Also used : Player(org.bukkit.entity.Player) Block(org.bukkit.block.Block) Sign(org.bukkit.block.Sign) Location(org.bukkit.Location) ExecutorTest(js.ExecutorTest)

Example 63 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class TestExecutors method testSetBlock1_Legacy.

@Test
public void testSetBlock1_Legacy() 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);
    assertJSError(() -> new ExecutorTest(engine, "SETBLOCK").addVariable("player", player).withArgs(1, 33, 96, -15).test(), "Cannot use a number as block type after 1.12.2. Use material name directly.");
}
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)

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