Search in sources :

Example 6 with JsTest

use of js.JsTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testPlayer_SetHealth.

@Test
public void testPlayer_SetHealth() throws Exception {
    Player player = mock(Player.class);
    JsTest test = new ExecutorTest(engine, "SETHEALTH").addVariable("player", player);
    when(player.getMaxHealth()).thenReturn(20.0);
    // case1
    test.withArgs(2).test();
    verify(player).setHealth(2.0);
    // case2
    test.withArgs(3.0).test();
    verify(player).setHealth(3.0);
    // Unexpected Cases
    assertJSError(() -> test.withArgs(1, 334).test(), "Incorrect Number of arguments for executor SETHEALTH");
    assertJSError(() -> test.withArgs("yeah").test(), "Invalid argument for SETHEALTH: yeah");
    assertJSError(() -> test.withArgs(-17).test(), "Argument for Exector SETHEALTH should not be negative");
    assertJSError(() -> test.withArgs(50).test(), "Argument for Executor SETHEALTH is greater than the max health");
}
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 7 with JsTest

use of js.JsTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testCloseGUI.

@Test
public void testCloseGUI() throws Exception {
    Player player = mock(Player.class);
    JsTest test = new ExecutorTest(engine, "CLOSEGUI").addVariable("player", player);
    // only happy case
    test.withArgs().test();
    verify(player).closeInventory();
}
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 8 with JsTest

use of js.JsTest 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 9 with JsTest

use of js.JsTest 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 10 with JsTest

use of js.JsTest in project TriggerReactor by wysohn.

the class AbstractTestExecutors method testPlayer_SetFood.

@Test
public void testPlayer_SetFood() throws Exception {
    Player player = mock(Player.class);
    JsTest test = new ExecutorTest(engine, "SETFOOD").addVariable("player", player);
    // case1
    test.withArgs(3).test();
    verify(player).setFoodLevel(3);
    // case2
    test.withArgs(4.0).test();
    verify(player).setFoodLevel(4);
    // Unexpected Cases
    assertJSError(() -> test.withArgs().test(), "Incorrect Number of arguments for Executor SETFOOD");
    assertJSError(() -> test.withArgs("HI").test(), "Invalid argument for Executor SETFOOD: HI");
    assertJSError(() -> test.withArgs(3.4).test(), "Argument for Executor SETFOOD should be a whole number");
    assertJSError(() -> test.withArgs(-3.0).test(), "Argument for Executor SETFOOD should not be negative");
}
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)

Aggregations

JsTest (js.JsTest)31 Test (org.junit.Test)30 ExecutorTest (js.ExecutorTest)27 Player (org.bukkit.entity.Player)19 IPlayer (io.github.wysohn.triggerreactor.core.bridge.entity.IPlayer)18 Block (org.bukkit.block.Block)6 PlaceholderTest (js.PlaceholderTest)4 Entity (org.bukkit.entity.Entity)4 BlockState (org.bukkit.block.BlockState)3 Lever (org.bukkit.material.Lever)3 ArrayList (java.util.ArrayList)2 Callable (java.util.concurrent.Callable)2 ExecutorService (java.util.concurrent.ExecutorService)2 BukkitTriggerReactorCore (io.github.wysohn.triggerreactor.bukkit.main.BukkitTriggerReactorCore)1 VaultSupport (io.github.wysohn.triggerreactor.bukkit.manager.trigger.share.api.vault.VaultSupport)1 IInventory (io.github.wysohn.triggerreactor.core.bridge.IInventory)1 TriggerReactorCore (io.github.wysohn.triggerreactor.core.main.TriggerReactorCore)1 AbstractInventoryTriggerManager (io.github.wysohn.triggerreactor.core.manager.trigger.inventory.AbstractInventoryTriggerManager)1 World (org.bukkit.World)1 ItemFrame (org.bukkit.entity.ItemFrame)1