Search in sources :

Example 16 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testKill.

@Test
public void testKill() throws Exception {
    Player player = mock(Player.class);
    JsTest test = new ExecutorTest(engine, "KILL").addVariable("player", player);
    test.withArgs().test();
    verify(player).setHealth(0d);
}
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 17 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testSetType.

@Test
public void testSetType() throws Exception {
    ItemStack vItem = mock(ItemStack.class);
    Material stone = Material.valueOf("STONE");
    Material newDirt = Material.valueOf("DIRT");
    when(vItem.getType()).thenReturn(stone);
    ExecutorTest test = new ExecutorTest(engine, "SETTYPE");
    test.withArgs("DIRT", vItem).test();
    verify(vItem).setType(newDirt);
    test.assertValid("STONE", vItem);
    test.assertInvalid(1, vItem);
    test.assertInvalid(1, 3);
    test.assertInvalid("h", "d");
    test.assertInvalid(vItem, 2);
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) ExecutorTest(js.ExecutorTest) ExecutorTest(js.ExecutorTest) Test(org.junit.Test) JsTest(js.JsTest)

Example 18 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testPlayer_SetWalkSpeed.

@Test
public void testPlayer_SetWalkSpeed() throws Exception {
    Player player = mock(Player.class);
    JsTest test = new ExecutorTest(engine, "SETWALKSPEED").addVariable("player", player);
    // case1
    test.withArgs(1).test();
    verify(player).setWalkSpeed(1.0F);
    // case2
    test.withArgs(0.7).test();
    verify(player).setWalkSpeed(0.7F);
    // Unexpected Cases
    assertJSError(() -> test.withArgs().test(), "Incorrect Number of arguments for Executor SETWALKSPEED");
    assertJSError(() -> test.withArgs("NUU").test(), "Invalid argument for SETWALKSPEED: NUU");
    assertJSError(() -> test.withArgs(-3).test(), "Argument for Executor SETWALKSPEED is outside of the allowable range -1..1");
}
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 19 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testCmdCon.

@Test
public void testCmdCon() throws Exception {
    Player player = mock(Player.class);
    ConsoleCommandSender sender = mock(ConsoleCommandSender.class);
    when(player.getServer()).thenReturn(server);
    when(server.getConsoleSender()).thenReturn(sender);
    new ExecutorTest(engine, "CMDCON").withArgs("some command line").test();
    verify(server).dispatchCommand(sender, "some command line");
}
Also used : Player(org.bukkit.entity.Player) IPlayer(io.github.wysohn.triggerreactor.core.bridge.entity.IPlayer) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ExecutorTest(js.ExecutorTest) ExecutorTest(js.ExecutorTest) Test(org.junit.Test) JsTest(js.JsTest)

Example 20 with ExecutorTest

use of js.ExecutorTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testSetItemName.

@Test
public void testSetItemName() throws Exception {
    ItemStack vItem = mock(ItemStack.class);
    ItemMeta vIM = mock(ItemMeta.class);
    Material stone = Material.valueOf("STONE");
    ExecutorTest test = new ExecutorTest(engine, "SETITEMNAME");
    when(vItem.getItemMeta()).thenReturn(vIM);
    when(vItem.getType()).thenReturn(stone);
    test.withArgs("NO--NO", vItem).test();
    verify(vIM).setDisplayName("NO--NO");
    verify(vItem).setItemMeta(vIM);
    test.assertValid("herllo", vItem);
    test.assertInvalid(0);
    test.assertInvalid("HELLO");
    test.assertInvalid(0, "hu");
    test.assertInvalid(true, 0);
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta) 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