-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/test/java/net/estools/Commands/DismountCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.estools.Commands; | ||
|
||
import net.estools.EsToolsUnitTest; | ||
import net.estools.Implementation.TestPlayer; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
// /dismount [rider1] [rider2]... | ||
public class DismountCommandTest extends EsToolsUnitTest { | ||
|
||
@Test | ||
public void noArg() { | ||
executeAssertOneError("dismount"); | ||
} | ||
|
||
@Test | ||
public void invalidArg() { | ||
executeAssertOneError("dismount invalid"); | ||
} | ||
|
||
@Test | ||
public void dismountFromSelf() { | ||
TestPlayer p2 = createPlayer(); | ||
p2.getPassengers().clear(); | ||
player.addPassenger(p2); | ||
executeAssertSuccess("dismount " + p2.getName()); | ||
|
||
Assertions.assertFalse(player.getPassengers().contains(p2)); | ||
} | ||
|
||
@Test | ||
public void dismountSelf() { | ||
TestPlayer ridee = createPlayer(); | ||
ridee.addPassenger(player); | ||
|
||
executeAssertSuccess("dismount"); | ||
|
||
Assertions.assertFalse(ridee.getPassengers().contains(player)); | ||
} | ||
} |
116 changes: 116 additions & 0 deletions
116
src/test/java/net/estools/Commands/PotionCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package net.estools.Commands; | ||
|
||
import net.estools.EsToolsUnitTest; | ||
import net.estools.Implementation.TestItemStack; | ||
import net.estools.Implementation.TestPlayer; | ||
import net.estools.Implementation.TestPotion; | ||
import net.estools.ServerApi.EsPotType; | ||
import net.estools.ServerApi.EsPotionEffectType; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
// /potion <effect> [amplifier] [duration] [amount] [drink/splash/lingering] [player] | ||
public class PotionCommandTest extends EsToolsUnitTest { | ||
|
||
@Test | ||
public void noArg() { | ||
executeAssertOneError("potion"); | ||
} | ||
|
||
@Test | ||
public void invalidEffect() { | ||
executeAssertOneError("potion invalid"); | ||
} | ||
|
||
@Test | ||
public void createPot() { | ||
player.getInventory().clear(); | ||
executeAssertSuccess("potion speed"); | ||
TestItemStack slot0 = (TestItemStack) player.getInventory().getItem(0); | ||
Assertions.assertInstanceOf(TestPotion.class, slot0); | ||
|
||
TestPotion pot = (TestPotion) slot0; | ||
|
||
Assertions.assertEquals(EsPotType.drink, pot.getPotionType()); | ||
Assertions.assertEquals(pot.getEffects()[0].getType(), EsPotionEffectType.fromKey("speed")); | ||
} | ||
|
||
@Test | ||
public void validAmp() { | ||
player.getInventory().clear(); | ||
executeAssertSuccess("potion speed 2"); | ||
TestItemStack slot0 = (TestItemStack) player.getInventory().getItem(0); | ||
Assertions.assertInstanceOf(TestPotion.class, slot0); | ||
|
||
TestPotion pot = (TestPotion) slot0; | ||
|
||
Assertions.assertEquals(EsPotType.drink, pot.getPotionType()); | ||
Assertions.assertEquals(pot.getEffects()[0].getType(), EsPotionEffectType.fromKey("speed")); | ||
Assertions.assertEquals(1, pot.getEffects()[0].getAmp()); | ||
} | ||
|
||
@Test | ||
public void validDuration() { | ||
player.getInventory().clear(); | ||
executeAssertSuccess("potion speed 2 5"); | ||
TestItemStack slot0 = (TestItemStack) player.getInventory().getItem(0); | ||
Assertions.assertInstanceOf(TestPotion.class, slot0); | ||
|
||
TestPotion pot = (TestPotion) slot0; | ||
|
||
Assertions.assertEquals(EsPotType.drink, pot.getPotionType()); | ||
Assertions.assertEquals(pot.getEffects()[0].getType(), EsPotionEffectType.fromKey("speed")); | ||
Assertions.assertEquals(1, pot.getEffects()[0].getAmp()); | ||
Assertions.assertEquals(5*20, pot.getEffects()[0].getDuration()); | ||
} | ||
|
||
@Test | ||
public void validAmount() { | ||
player.getInventory().clear(); | ||
executeAssertSuccess("potion speed 2 5 69"); | ||
TestItemStack slot0 = (TestItemStack) player.getInventory().getItem(0); | ||
Assertions.assertInstanceOf(TestPotion.class, slot0); | ||
|
||
TestPotion pot = (TestPotion) slot0; | ||
|
||
Assertions.assertEquals(EsPotType.drink, pot.getPotionType()); | ||
Assertions.assertEquals(pot.getEffects()[0].getType(), EsPotionEffectType.fromKey("speed")); | ||
Assertions.assertEquals(1, pot.getEffects()[0].getAmp()); | ||
Assertions.assertEquals(5*20, pot.getEffects()[0].getDuration()); | ||
Assertions.assertEquals(69, pot.getAmount()); | ||
} | ||
|
||
@Test | ||
public void validType() { | ||
player.getInventory().clear(); | ||
executeAssertSuccess("potion speed 2 5 69 splash"); | ||
TestItemStack slot0 = (TestItemStack) player.getInventory().getItem(0); | ||
Assertions.assertInstanceOf(TestPotion.class, slot0); | ||
|
||
TestPotion pot = (TestPotion) slot0; | ||
|
||
Assertions.assertEquals(EsPotType.splash, pot.getPotionType()); | ||
Assertions.assertEquals(pot.getEffects()[0].getType(), EsPotionEffectType.fromKey("speed")); | ||
Assertions.assertEquals(1, pot.getEffects()[0].getAmp()); | ||
Assertions.assertEquals(5*20, pot.getEffects()[0].getDuration()); | ||
Assertions.assertEquals(69, pot.getAmount()); | ||
} | ||
|
||
@Test | ||
public void anotherPlayer() { | ||
TestPlayer p = createPlayer(); | ||
|
||
p.getInventory().clear(); | ||
executeAssertSuccess("potion speed 2 5 69 splash " + p.getName()); | ||
TestItemStack slot0 = (TestItemStack) p.getInventory().getItem(0); | ||
Assertions.assertInstanceOf(TestPotion.class, slot0); | ||
|
||
TestPotion pot = (TestPotion) slot0; | ||
|
||
Assertions.assertEquals(EsPotType.splash, pot.getPotionType()); | ||
Assertions.assertEquals(pot.getEffects()[0].getType(), EsPotionEffectType.fromKey("speed")); | ||
Assertions.assertEquals(1, pot.getEffects()[0].getAmp()); | ||
Assertions.assertEquals(5*20, pot.getEffects()[0].getDuration()); | ||
Assertions.assertEquals(69, pot.getAmount()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package net.estools.Implementation; | ||
|
||
import net.estools.ServerApi.EsMaterial; | ||
import net.estools.ServerApi.EsPotType; | ||
import net.estools.ServerApi.EsPotionEffect; | ||
import net.estools.ServerApi.Interfaces.EsPotion; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class TestPotion extends TestItemStack implements EsPotion { | ||
private final EsPotType potType; | ||
private final List<EsPotionEffect> effects; | ||
|
||
public TestPotion(int amount, EsPotType potType, EsPotionEffect effect) { | ||
super(EsMaterial.fromKey("POTION"), amount); | ||
this.potType = potType; | ||
effects = new ArrayList<>(); | ||
effects.add(effect); | ||
} | ||
|
||
@Override | ||
public EsPotionEffect[] getEffects() { | ||
return effects.toArray(new EsPotionEffect[0]); | ||
} | ||
|
||
@Override | ||
public EsPotType getPotionType() { | ||
return potType; | ||
} | ||
|
||
@Override | ||
public void addEffect(EsPotionEffect effect) { | ||
effects.add(effect); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters