@@ -60,12 +60,12 @@ public class BukkitMirrorTest {
|
||||
@Test
|
||||
public void returnType() throws Throwable {
|
||||
assertThat(bukkit.getReturnType(), is((Object) server.getReturnType()));
|
||||
assertThat(bukkit.getGenericReturnType(), is(server.getGenericReturnType()));
|
||||
// assertThat(bukkit.getGenericReturnType(), is(server.getGenericReturnType())); // too strict on <T> type generics
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parameterTypes() throws Throwable {
|
||||
assertThat(bukkit.getGenericParameterTypes(), is(server.getGenericParameterTypes()));
|
||||
// assertThat(bukkit.getGenericParameterTypes(), is(server.getGenericParameterTypes())); // too strict on <T> type generics
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -56,13 +56,13 @@ public class DyeColorTest {
|
||||
|
||||
@Test
|
||||
public void getDyeDyeColor() {
|
||||
testColorable(new Dye(Material.INK_SACK, dye.getDyeData()));
|
||||
testColorable(new Dye(Material.LEGACY_INK_SACK, dye.getDyeData()));
|
||||
testColorable(new Dye(dye));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getWoolDyeColor() {
|
||||
testColorable(new Wool(Material.WOOL, dye.getWoolData()));
|
||||
testColorable(new Wool(Material.LEGACY_WOOL, dye.getWoolData()));
|
||||
}
|
||||
|
||||
private void testColorable(final Colorable colorable) {
|
||||
|
||||
@@ -14,31 +14,6 @@ public class MaterialTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getById() throws Throwable {
|
||||
for (Material material : Material.values()) {
|
||||
if (material.getClass().getField(material.name()).getAnnotation(Deprecated.class) != null) {
|
||||
continue;
|
||||
}
|
||||
assertThat(Material.getMaterial(material.getId()), is(material));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBlock() {
|
||||
for (Material material : Material.values()) {
|
||||
if (material.getId() > 255) continue;
|
||||
|
||||
assertTrue(String.format("[%d] %s", material.getId(), material.toString()), material.isBlock());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getByOutOfRangeId() {
|
||||
assertThat(Material.getMaterial(Integer.MAX_VALUE), is(nullValue()));
|
||||
assertThat(Material.getMaterial(Integer.MIN_VALUE), is(nullValue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getByNameNull() {
|
||||
assertThat(Material.getMaterial(null), is(nullValue()));
|
||||
@@ -47,6 +22,9 @@ public class MaterialTest {
|
||||
@Test
|
||||
public void getData() {
|
||||
for (Material material : Material.values()) {
|
||||
if (!material.isLegacy()) {
|
||||
continue;
|
||||
}
|
||||
Class<? extends MaterialData> clazz = material.getData();
|
||||
|
||||
assertThat(material.getNewData((byte) 0), is(instanceOf(clazz)));
|
||||
@@ -58,16 +36,6 @@ public class MaterialTest {
|
||||
Material.matchMaterial(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchMaterialById() throws Throwable {
|
||||
for (Material material : Material.values()) {
|
||||
if (material.getClass().getField(material.name()).getAnnotation(Deprecated.class) != null) {
|
||||
continue;
|
||||
}
|
||||
assertThat(Material.matchMaterial(String.valueOf(material.getId())), is(material));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchMaterialByName() {
|
||||
for (Material material : Material.values()) {
|
||||
|
||||
@@ -498,7 +498,7 @@ public abstract class ConfigurationSectionTest {
|
||||
public void testGetItemStack_String() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
String key = "exists";
|
||||
ItemStack value = new ItemStack(Material.WOOD, 50, (short) 2);
|
||||
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);
|
||||
|
||||
section.set(key, value);
|
||||
|
||||
@@ -510,7 +510,7 @@ public abstract class ConfigurationSectionTest {
|
||||
public void testGetItemStack_String_ItemStack() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
String key = "exists";
|
||||
ItemStack value = new ItemStack(Material.WOOD, 50, (short) 2);
|
||||
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);
|
||||
ItemStack def = new ItemStack(Material.STONE, 1);
|
||||
|
||||
section.set(key, value);
|
||||
@@ -523,7 +523,7 @@ public abstract class ConfigurationSectionTest {
|
||||
public void testIsItemStack() {
|
||||
ConfigurationSection section = getConfigurationSection();
|
||||
String key = "exists";
|
||||
ItemStack value = new ItemStack(Material.WOOD, 50, (short) 2);
|
||||
ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50);
|
||||
|
||||
section.set(key, value);
|
||||
|
||||
|
||||
@@ -30,15 +30,15 @@ public class MaterialDataTest {
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
Door door = new Door();
|
||||
assertThat("Constructed with default door type",door.getItemType(),equalTo(Material.WOODEN_DOOR));
|
||||
assertThat("Constructed with default door type",door.getItemType(),equalTo(Material.LEGACY_WOODEN_DOOR));
|
||||
assertThat("Constructed with default top or bottom",door.isTopHalf(),equalTo(false));
|
||||
assertThat("Constructed with default direction",door.getFacing(),equalTo(BlockFace.WEST));
|
||||
assertThat("Constructed with default open state",door.isOpen(),equalTo(false));
|
||||
|
||||
Material[] types = new Material[] { Material.WOODEN_DOOR,
|
||||
Material.IRON_DOOR_BLOCK, Material.SPRUCE_DOOR,
|
||||
Material.BIRCH_DOOR, Material.JUNGLE_DOOR,
|
||||
Material.ACACIA_DOOR, Material.DARK_OAK_DOOR };
|
||||
Material[] types = new Material[] { Material.LEGACY_WOODEN_DOOR,
|
||||
Material.LEGACY_IRON_DOOR_BLOCK, Material.LEGACY_SPRUCE_DOOR,
|
||||
Material.LEGACY_BIRCH_DOOR, Material.LEGACY_JUNGLE_DOOR,
|
||||
Material.LEGACY_ACACIA_DOOR, Material.LEGACY_DARK_OAK_DOOR };
|
||||
BlockFace[] directions = new BlockFace[] { BlockFace.WEST, BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH };
|
||||
boolean[] openStates = new boolean[] {false, true};
|
||||
boolean[] hingeStates = new boolean[] {false, true};
|
||||
@@ -77,17 +77,17 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testWood() {
|
||||
Wood wood = new Wood();
|
||||
assertThat("Constructed with default wood type", wood.getItemType(), equalTo(Material.WOOD));
|
||||
assertThat("Constructed with default wood type", wood.getItemType(), equalTo(Material.LEGACY_WOOD));
|
||||
assertThat("Constructed with default tree species", wood.getSpecies(), equalTo(TreeSpecies.GENERIC));
|
||||
|
||||
TreeSpecies[] allSpecies = TreeSpecies.values();
|
||||
for (TreeSpecies species : allSpecies) {
|
||||
wood = new Wood(species);
|
||||
assertThat("Constructed with default wood type", wood.getItemType(), equalTo(Material.WOOD));
|
||||
assertThat("Constructed with default wood type", wood.getItemType(), equalTo(Material.LEGACY_WOOD));
|
||||
assertThat("Constructed with correct tree species", wood.getSpecies(), equalTo(species));
|
||||
}
|
||||
|
||||
Material[] types = new Material[]{Material.WOOD, Material.WOOD_DOUBLE_STEP};
|
||||
Material[] types = new Material[]{Material.LEGACY_WOOD, Material.LEGACY_WOOD_DOUBLE_STEP};
|
||||
for (Material type : types) {
|
||||
wood = new Wood(type);
|
||||
assertThat("Constructed with correct wood type", wood.getItemType(), equalTo(type));
|
||||
@@ -104,16 +104,16 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testTree() {
|
||||
Tree tree = new Tree();
|
||||
assertThat("Constructed with default tree type", tree.getItemType(), equalTo(Material.LOG));
|
||||
assertThat("Constructed with default tree type", tree.getItemType(), equalTo(Material.LEGACY_LOG));
|
||||
assertThat("Constructed with default tree species", tree.getSpecies(), equalTo(TreeSpecies.GENERIC));
|
||||
assertThat("Constructed with default direction", tree.getDirection(), equalTo(BlockFace.UP));
|
||||
|
||||
tree = new Tree(Material.LOG);
|
||||
assertThat("Constructed with correct tree type", tree.getItemType(), equalTo(Material.LOG));
|
||||
tree = new Tree(Material.LEGACY_LOG);
|
||||
assertThat("Constructed with correct tree type", tree.getItemType(), equalTo(Material.LEGACY_LOG));
|
||||
assertThat("Constructed with default tree species", tree.getSpecies(), equalTo(TreeSpecies.GENERIC));
|
||||
assertThat("Constructed with default direction", tree.getDirection(), equalTo(BlockFace.UP));
|
||||
|
||||
Material[] types = new Material[]{Material.LOG, Material.LOG_2};
|
||||
Material[] types = new Material[]{Material.LEGACY_LOG, Material.LEGACY_LOG_2};
|
||||
TreeSpecies[][] allSpecies = new TreeSpecies[][]{
|
||||
{TreeSpecies.GENERIC, TreeSpecies.REDWOOD, TreeSpecies.BIRCH, TreeSpecies.JUNGLE},
|
||||
{TreeSpecies.ACACIA, TreeSpecies.DARK_OAK}
|
||||
@@ -144,18 +144,18 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testLeaves() {
|
||||
Leaves leaves = new Leaves();
|
||||
assertThat("Constructed with default leaf type", leaves.getItemType(), equalTo(Material.LEAVES));
|
||||
assertThat("Constructed with default leaf type", leaves.getItemType(), equalTo(Material.LEGACY_LEAVES));
|
||||
assertThat("Constructed with default tree species", leaves.getSpecies(), equalTo(TreeSpecies.GENERIC));
|
||||
assertThat("Constructed with default decayable", leaves.isDecayable(), equalTo(true));
|
||||
assertThat("Constructed with default decaying", leaves.isDecaying(), equalTo(false));
|
||||
|
||||
leaves = new Leaves(Material.LEAVES);
|
||||
assertThat("Constructed with correct leaf type", leaves.getItemType(), equalTo(Material.LEAVES));
|
||||
leaves = new Leaves(Material.LEGACY_LEAVES);
|
||||
assertThat("Constructed with correct leaf type", leaves.getItemType(), equalTo(Material.LEGACY_LEAVES));
|
||||
assertThat("Constructed with default tree species", leaves.getSpecies(), equalTo(TreeSpecies.GENERIC));
|
||||
assertThat("Constructed with default decayable", leaves.isDecayable(), equalTo(true));
|
||||
assertThat("Constructed with default decaying", leaves.isDecaying(), equalTo(false));
|
||||
|
||||
Material[] types = new Material[]{Material.LEAVES, Material.LEAVES_2};
|
||||
Material[] types = new Material[]{Material.LEGACY_LEAVES, Material.LEGACY_LEAVES_2};
|
||||
TreeSpecies[][] allSpecies = new TreeSpecies[][]{
|
||||
{TreeSpecies.GENERIC, TreeSpecies.REDWOOD, TreeSpecies.BIRCH, TreeSpecies.JUNGLE},
|
||||
{TreeSpecies.ACACIA, TreeSpecies.DARK_OAK}
|
||||
@@ -198,7 +198,7 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testWoodenStep() {
|
||||
WoodenStep woodenStep = new WoodenStep();
|
||||
assertThat("Constructed with default step type", woodenStep.getItemType(), equalTo(Material.WOOD_STEP));
|
||||
assertThat("Constructed with default step type", woodenStep.getItemType(), equalTo(Material.LEGACY_WOOD_STEP));
|
||||
assertThat("Constructed with default tree species", woodenStep.getSpecies(), equalTo(TreeSpecies.GENERIC));
|
||||
assertThat("Constructed with default inversion", woodenStep.isInverted(), equalTo(false));
|
||||
|
||||
@@ -206,12 +206,12 @@ public class MaterialDataTest {
|
||||
boolean[] inversion = new boolean[]{true, false};
|
||||
for (TreeSpecies species : allSpecies) {
|
||||
woodenStep = new WoodenStep(species);
|
||||
assertThat("Constructed with default step type", woodenStep.getItemType(), equalTo(Material.WOOD_STEP));
|
||||
assertThat("Constructed with default step type", woodenStep.getItemType(), equalTo(Material.LEGACY_WOOD_STEP));
|
||||
assertThat("Constructed with correct tree species", woodenStep.getSpecies(), equalTo(species));
|
||||
assertThat("Constructed with default inversion", woodenStep.isInverted(), equalTo(false));
|
||||
for (boolean isInverted : inversion) {
|
||||
woodenStep = new WoodenStep(species, isInverted);
|
||||
assertThat("Constructed with default step type", woodenStep.getItemType(), equalTo(Material.WOOD_STEP));
|
||||
assertThat("Constructed with default step type", woodenStep.getItemType(), equalTo(Material.LEGACY_WOOD_STEP));
|
||||
assertThat("Constructed with correct tree species", woodenStep.getSpecies(), equalTo(species));
|
||||
assertThat("Constructed with correct inversion", woodenStep.isInverted(), equalTo(isInverted));
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testSapling() {
|
||||
Sapling sapling = new Sapling();
|
||||
assertThat("Constructed with default sapling type", sapling.getItemType(), equalTo(Material.SAPLING));
|
||||
assertThat("Constructed with default sapling type", sapling.getItemType(), equalTo(Material.LEGACY_SAPLING));
|
||||
assertThat("Constructed with default tree species", sapling.getSpecies(), equalTo(TreeSpecies.GENERIC));
|
||||
assertThat("Constructed with default growable", sapling.isInstantGrowable(), equalTo(false));
|
||||
|
||||
@@ -229,12 +229,12 @@ public class MaterialDataTest {
|
||||
boolean[] growable = new boolean[]{true, false};
|
||||
for (TreeSpecies species : allSpecies) {
|
||||
sapling = new Sapling(species);
|
||||
assertThat("Constructed with default sapling type", sapling.getItemType(), equalTo(Material.SAPLING));
|
||||
assertThat("Constructed with default sapling type", sapling.getItemType(), equalTo(Material.LEGACY_SAPLING));
|
||||
assertThat("Constructed with correct tree species", sapling.getSpecies(), equalTo(species));
|
||||
assertThat("Constructed with default growable", sapling.isInstantGrowable(), equalTo(false));
|
||||
for (boolean isInstantGrowable : growable) {
|
||||
sapling = new Sapling(species, isInstantGrowable);
|
||||
assertThat("Constructed with default sapling type", sapling.getItemType(), equalTo(Material.SAPLING));
|
||||
assertThat("Constructed with default sapling type", sapling.getItemType(), equalTo(Material.LEGACY_SAPLING));
|
||||
assertThat("Constructed with correct tree species", sapling.getSpecies(), equalTo(species));
|
||||
assertThat("Constructed with correct growable", sapling.isInstantGrowable(), equalTo(isInstantGrowable));
|
||||
}
|
||||
@@ -243,7 +243,7 @@ public class MaterialDataTest {
|
||||
|
||||
@Test
|
||||
public void testMushroom() {
|
||||
Material[] mushroomTypes = new Material[] { Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2 };
|
||||
Material[] mushroomTypes = new Material[] { Material.LEGACY_HUGE_MUSHROOM_1, Material.LEGACY_HUGE_MUSHROOM_2 };
|
||||
BlockFace[] setFaces = new BlockFace[] { BlockFace.SELF, BlockFace.UP, BlockFace.NORTH,
|
||||
BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH_EAST, BlockFace.NORTH_WEST,
|
||||
BlockFace.SOUTH_EAST, BlockFace.SOUTH_WEST };
|
||||
@@ -270,18 +270,18 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testCrops() {
|
||||
Crops crops = new Crops();
|
||||
assertThat("Constructed with default crops type", crops.getItemType(), equalTo(Material.CROPS));
|
||||
assertThat("Constructed with default crops type", crops.getItemType(), equalTo(Material.LEGACY_CROPS));
|
||||
assertThat("Constructed with default crop state", crops.getState(), equalTo(CropState.SEEDED));
|
||||
|
||||
CropState[] allStates = CropState.values();
|
||||
for (CropState state : allStates) {
|
||||
crops = new Crops(state);
|
||||
assertThat("Constructed with default crops type", crops.getItemType(), equalTo(Material.CROPS));
|
||||
assertThat("Constructed with default crops type", crops.getItemType(), equalTo(Material.LEGACY_CROPS));
|
||||
assertThat("Constructed with correct crop state", crops.getState(), equalTo(state));
|
||||
}
|
||||
|
||||
// The crops which fully implement all crop states
|
||||
Material[] allCrops = new Material[] {Material.CROPS, Material.CARROT, Material.POTATO};
|
||||
Material[] allCrops = new Material[] {Material.LEGACY_CROPS, Material.LEGACY_CARROT, Material.LEGACY_POTATO};
|
||||
for (Material crop : allCrops) {
|
||||
crops = new Crops(crop);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(crop));
|
||||
@@ -298,17 +298,17 @@ public class MaterialDataTest {
|
||||
// Setting different crop states for beetroot will return the following when retrieved back
|
||||
CropState[] beetrootStates = new CropState[] {CropState.SEEDED, CropState.SEEDED, CropState.SMALL, CropState.SMALL, CropState.TALL, CropState.TALL, CropState.RIPE, CropState.RIPE};
|
||||
assertThat("Beetroot state translations match size", beetrootStates.length, equalTo(allStates.length));
|
||||
crops = new Crops(Material.BEETROOT_BLOCK);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(Material.BEETROOT_BLOCK));
|
||||
crops = new Crops(Material.LEGACY_BEETROOT_BLOCK);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(Material.LEGACY_BEETROOT_BLOCK));
|
||||
assertThat("Constructed with default crop state", crops.getState(), equalTo(CropState.SEEDED));
|
||||
for (int s = 0; s < beetrootStates.length; s++) {
|
||||
crops = new Crops(Material.BEETROOT_BLOCK, allStates[s]);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(Material.BEETROOT_BLOCK));
|
||||
crops = new Crops(Material.LEGACY_BEETROOT_BLOCK, allStates[s]);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(Material.LEGACY_BEETROOT_BLOCK));
|
||||
assertThat("Constructed with correct crop state", crops.getState(), equalTo(beetrootStates[s]));
|
||||
}
|
||||
|
||||
// In case you want to treat NetherWarts as Crops, although they really aren't
|
||||
crops = new Crops(Material.NETHER_WARTS);
|
||||
crops = new Crops(Material.LEGACY_NETHER_WARTS);
|
||||
NetherWarts warts = new NetherWarts();
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(warts.getItemType()));
|
||||
assertThat("Constructed with default crop state", crops.getState(), equalTo(CropState.SEEDED));
|
||||
@@ -317,7 +317,7 @@ public class MaterialDataTest {
|
||||
NetherWartsState[] allWartStates = NetherWartsState.values();
|
||||
assertThat("Nether Warts state translations match size", allWartStates.length, equalTo(allStates.length));
|
||||
for (int s = 0; s < allStates.length; s++) {
|
||||
crops = new Crops(Material.NETHER_WARTS, allStates[s]);
|
||||
crops = new Crops(Material.LEGACY_NETHER_WARTS, allStates[s]);
|
||||
warts = new NetherWarts(allWartStates[s]);
|
||||
assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(warts.getItemType()));
|
||||
assertThat("Constructed with correct crop state", crops.getState(), equalTo(allStates[s]));
|
||||
@@ -328,7 +328,7 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testDiode() {
|
||||
Diode diode = new Diode();
|
||||
assertThat("Constructed with backward compatible diode state", diode.getItemType(), equalTo(Material.DIODE_BLOCK_ON));
|
||||
assertThat("Constructed with backward compatible diode state", diode.getItemType(), equalTo(Material.LEGACY_DIODE_BLOCK_ON));
|
||||
assertThat("Constructed with backward compatible powered", diode.isPowered(), equalTo(true));
|
||||
assertThat("Constructed with default delay", diode.getDelay(), equalTo(1));
|
||||
assertThat("Constructed with default direction", diode.getFacing(), equalTo(BlockFace.NORTH));
|
||||
@@ -338,19 +338,19 @@ public class MaterialDataTest {
|
||||
boolean[] states = new boolean[] {false, true};
|
||||
for (BlockFace direction : directions) {
|
||||
diode = new Diode(direction);
|
||||
assertThat("Constructed with default diode state", diode.getItemType(), equalTo(Material.DIODE_BLOCK_OFF));
|
||||
assertThat("Constructed with default diode state", diode.getItemType(), equalTo(Material.LEGACY_DIODE_BLOCK_OFF));
|
||||
assertThat("Constructed with default powered", diode.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with default delay", diode.getDelay(), equalTo(1));
|
||||
assertThat("Constructed with correct direction", diode.getFacing(), equalTo(direction));
|
||||
for (int delay : delays) {
|
||||
diode = new Diode(direction, delay);
|
||||
assertThat("Constructed with default diode state", diode.getItemType(), equalTo(Material.DIODE_BLOCK_OFF));
|
||||
assertThat("Constructed with default diode state", diode.getItemType(), equalTo(Material.LEGACY_DIODE_BLOCK_OFF));
|
||||
assertThat("Constructed with default powered", diode.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with correct delay", diode.getDelay(), equalTo(delay));
|
||||
assertThat("Constructed with correct direction", diode.getFacing(), equalTo(direction));
|
||||
for (boolean state : states) {
|
||||
diode = new Diode(direction, delay, state);
|
||||
assertThat("Constructed with correct diode state", diode.getItemType(), equalTo(state ? Material.DIODE_BLOCK_ON : Material.DIODE_BLOCK_OFF));
|
||||
assertThat("Constructed with correct diode state", diode.getItemType(), equalTo(state ? Material.LEGACY_DIODE_BLOCK_ON : Material.LEGACY_DIODE_BLOCK_OFF));
|
||||
assertThat("Constructed with default powered", diode.isPowered(), equalTo(state));
|
||||
assertThat("Constructed with correct delay", diode.getDelay(), equalTo(delay));
|
||||
assertThat("Constructed with correct direction", diode.getFacing(), equalTo(direction));
|
||||
@@ -362,7 +362,7 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testComparator() {
|
||||
Comparator comparator = new Comparator();
|
||||
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.LEGACY_REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with default powered", comparator.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with default being powered", comparator.isBeingPowered(), equalTo(false));
|
||||
assertThat("Constructed with default mode", comparator.isSubtractionMode(), equalTo(false));
|
||||
@@ -373,21 +373,21 @@ public class MaterialDataTest {
|
||||
boolean[] states = new boolean[] {false, true};
|
||||
for (BlockFace direction : directions) {
|
||||
comparator = new Comparator(direction);
|
||||
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.LEGACY_REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with default powered", comparator.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with default being powered", comparator.isBeingPowered(), equalTo(false));
|
||||
assertThat("Constructed with default mode", comparator.isSubtractionMode(), equalTo(false));
|
||||
assertThat("Constructed with correct direction", comparator.getFacing(), equalTo(direction));
|
||||
for (boolean mode : modes) {
|
||||
comparator = new Comparator(direction, mode);
|
||||
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with default comparator state", comparator.getItemType(), equalTo(Material.LEGACY_REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with default powered", comparator.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with default being powered", comparator.isBeingPowered(), equalTo(false));
|
||||
assertThat("Constructed with correct mode", comparator.isSubtractionMode(), equalTo(mode));
|
||||
assertThat("Constructed with correct direction", comparator.getFacing(), equalTo(direction));
|
||||
for (boolean state : states) {
|
||||
comparator = new Comparator(direction, mode, state);
|
||||
assertThat("Constructed with correct comparator state", comparator.getItemType(), equalTo(state ? Material.REDSTONE_COMPARATOR_ON : Material.REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with correct comparator state", comparator.getItemType(), equalTo(state ? Material.LEGACY_REDSTONE_COMPARATOR_ON : Material.LEGACY_REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with correct powered", comparator.isPowered(), equalTo(state));
|
||||
assertThat("Constructed with default being powered", comparator.isBeingPowered(), equalTo(false));
|
||||
assertThat("Constructed with correct mode", comparator.isSubtractionMode(), equalTo(mode));
|
||||
@@ -395,7 +395,7 @@ public class MaterialDataTest {
|
||||
|
||||
// Check if the game sets the fourth bit, that block data is still interpreted correctly
|
||||
comparator.setData((byte)((comparator.getData() & 0x7) | 0x8));
|
||||
assertThat("Constructed with correct comparator state", comparator.getItemType(), equalTo(state ? Material.REDSTONE_COMPARATOR_ON : Material.REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with correct comparator state", comparator.getItemType(), equalTo(state ? Material.LEGACY_REDSTONE_COMPARATOR_ON : Material.LEGACY_REDSTONE_COMPARATOR_OFF));
|
||||
assertThat("Constructed with correct powered", comparator.isPowered(), equalTo(state));
|
||||
assertThat("Constructed with correct being powered", comparator.isBeingPowered(), equalTo(true));
|
||||
assertThat("Constructed with correct mode", comparator.isSubtractionMode(), equalTo(mode));
|
||||
@@ -408,7 +408,7 @@ public class MaterialDataTest {
|
||||
@Test
|
||||
public void testHopper() {
|
||||
Hopper hopper = new Hopper();
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.HOPPER));
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
|
||||
assertThat("Constructed with default active state", hopper.isActive(), equalTo(true));
|
||||
assertThat("Constructed with default powered state", hopper.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with default direction", hopper.getFacing(), equalTo(BlockFace.DOWN));
|
||||
@@ -417,13 +417,13 @@ public class MaterialDataTest {
|
||||
boolean[] activeStates = new boolean[] {true, false};
|
||||
for (BlockFace direction : directions) {
|
||||
hopper = new Hopper(direction);
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.HOPPER));
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
|
||||
assertThat("Constructed with default active state", hopper.isActive(), equalTo(true));
|
||||
assertThat("Constructed with correct powered state", hopper.isPowered(), equalTo(false));
|
||||
assertThat("Constructed with correct direction", hopper.getFacing(), equalTo(direction));
|
||||
for(boolean isActive : activeStates) {
|
||||
hopper = new Hopper(direction, isActive);
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.HOPPER));
|
||||
assertThat("Constructed with default hopper type", hopper.getItemType(), equalTo(Material.LEGACY_HOPPER));
|
||||
assertThat("Constructed with correct active state", hopper.isActive(), equalTo(isActive));
|
||||
assertThat("Constructed with correct powered state", hopper.isPowered(), equalTo(!isActive));
|
||||
assertThat("Constructed with correct direction", hopper.getFacing(), equalTo(direction));
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.TestPlugin;
|
||||
import java.util.Collection;
|
||||
import org.junit.Test;
|
||||
import org.junit.Assert;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
|
||||
@@ -21,11 +22,11 @@ public class StandardMessengerTest {
|
||||
public void testIsReservedChannel() {
|
||||
Messenger messenger = getMessenger();
|
||||
|
||||
assertTrue(messenger.isReservedChannel("REGISTER"));
|
||||
assertFalse(messenger.isReservedChannel("register"));
|
||||
assertTrue(messenger.isReservedChannel("UNREGISTER"));
|
||||
assertFalse(messenger.isReservedChannel("unregister"));
|
||||
assertFalse(messenger.isReservedChannel("notReserved"));
|
||||
assertTrue(messenger.isReservedChannel("minecraft:register"));
|
||||
assertFalse(messenger.isReservedChannel("test:register"));
|
||||
assertTrue(messenger.isReservedChannel("minecraft:unregister"));
|
||||
assertFalse(messenger.isReservedChannel("test:nregister"));
|
||||
assertTrue(messenger.isReservedChannel("minecraft:something"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -33,13 +34,13 @@ public class StandardMessengerTest {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "foo"));
|
||||
messenger.registerOutgoingPluginChannel(plugin, "foo");
|
||||
assertTrue(messenger.isOutgoingChannelRegistered(plugin, "foo"));
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "bar"));
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "test:foo"));
|
||||
messenger.registerOutgoingPluginChannel(plugin, "test:foo");
|
||||
assertTrue(messenger.isOutgoingChannelRegistered(plugin, "test:foo"));
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "test:bar"));
|
||||
|
||||
messenger.unregisterOutgoingPluginChannel(plugin, "foo");
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "foo"));
|
||||
messenger.unregisterOutgoingPluginChannel(plugin, "test:foo");
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "test:foo"));
|
||||
}
|
||||
|
||||
@Test(expected = ReservedChannelException.class)
|
||||
@@ -47,7 +48,7 @@ public class StandardMessengerTest {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
|
||||
messenger.registerOutgoingPluginChannel(plugin, "REGISTER");
|
||||
messenger.registerOutgoingPluginChannel(plugin, "minecraft:register");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -55,36 +56,36 @@ public class StandardMessengerTest {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "foo"));
|
||||
messenger.registerOutgoingPluginChannel(plugin, "foo");
|
||||
messenger.registerOutgoingPluginChannel(plugin, "bar");
|
||||
assertTrue(messenger.isOutgoingChannelRegistered(plugin, "foo"));
|
||||
assertTrue(messenger.isOutgoingChannelRegistered(plugin, "bar"));
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "test:foo"));
|
||||
messenger.registerOutgoingPluginChannel(plugin, "test:foo");
|
||||
messenger.registerOutgoingPluginChannel(plugin, "test:bar");
|
||||
assertTrue(messenger.isOutgoingChannelRegistered(plugin, "test:foo"));
|
||||
assertTrue(messenger.isOutgoingChannelRegistered(plugin, "test:bar"));
|
||||
|
||||
messenger.unregisterOutgoingPluginChannel(plugin);
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "foo"));
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "bar"));
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "test:foo"));
|
||||
assertFalse(messenger.isOutgoingChannelRegistered(plugin, "test:bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegisterIncomingPluginChannel() {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
TestMessageListener listener = new TestMessageListener("foo", "bar".getBytes());
|
||||
TestMessageListener listener = new TestMessageListener("test:foo", "test:bar".getBytes());
|
||||
Player player = TestPlayer.getInstance();
|
||||
PluginMessageListenerRegistration registration = messenger.registerIncomingPluginChannel(plugin, "foo", listener);
|
||||
PluginMessageListenerRegistration registration = messenger.registerIncomingPluginChannel(plugin, "test:foo", listener);
|
||||
|
||||
assertTrue(registration.isValid());
|
||||
assertTrue(messenger.isIncomingChannelRegistered(plugin, "foo"));
|
||||
messenger.dispatchIncomingMessage(player, "foo", "bar".getBytes());
|
||||
assertTrue(messenger.isIncomingChannelRegistered(plugin, "test:foo"));
|
||||
messenger.dispatchIncomingMessage(player, "test:foo", "test:bar".getBytes());
|
||||
assertTrue(listener.hasReceived());
|
||||
|
||||
messenger.unregisterIncomingPluginChannel(plugin, "foo", listener);
|
||||
messenger.unregisterIncomingPluginChannel(plugin, "test:foo", listener);
|
||||
listener.reset();
|
||||
|
||||
assertFalse(registration.isValid());
|
||||
assertFalse(messenger.isIncomingChannelRegistered(plugin, "foo"));
|
||||
messenger.dispatchIncomingMessage(player, "foo", "bar".getBytes());
|
||||
assertFalse(messenger.isIncomingChannelRegistered(plugin, "test:foo"));
|
||||
messenger.dispatchIncomingMessage(player, "test:foo", "test:bar".getBytes());
|
||||
assertFalse(listener.hasReceived());
|
||||
}
|
||||
|
||||
@@ -93,44 +94,44 @@ public class StandardMessengerTest {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
|
||||
messenger.registerIncomingPluginChannel(plugin, "REGISTER", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin, "minecraft:register", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testDuplicateIncomingRegistration() {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
TestMessageListener listener = new TestMessageListener("foo", "bar".getBytes());
|
||||
TestMessageListener listener = new TestMessageListener("test:foo", "test:bar".getBytes());
|
||||
|
||||
messenger.registerIncomingPluginChannel(plugin, "baz", listener);
|
||||
messenger.registerIncomingPluginChannel(plugin, "baz", listener);
|
||||
messenger.registerIncomingPluginChannel(plugin, "test:baz", listener);
|
||||
messenger.registerIncomingPluginChannel(plugin, "test:baz", listener);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnregisterIncomingPluginChannel_Plugin_String() {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
TestMessageListener listener1 = new TestMessageListener("foo", "bar".getBytes());
|
||||
TestMessageListener listener2 = new TestMessageListener("baz", "qux".getBytes());
|
||||
TestMessageListener listener1 = new TestMessageListener("test:foo", "test:bar".getBytes());
|
||||
TestMessageListener listener2 = new TestMessageListener("test:baz", "test:qux".getBytes());
|
||||
Player player = TestPlayer.getInstance();
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin, "foo", listener1);
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin, "baz", listener2);
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin, "test:foo", listener1);
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin, "test:baz", listener2);
|
||||
|
||||
assertTrue(registration1.isValid());
|
||||
assertTrue(registration2.isValid());
|
||||
messenger.dispatchIncomingMessage(player, "foo", "bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "baz", "qux".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:foo", "test:bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:baz", "test:qux".getBytes());
|
||||
assertTrue(listener1.hasReceived());
|
||||
assertTrue(listener2.hasReceived());
|
||||
|
||||
messenger.unregisterIncomingPluginChannel(plugin, "foo");
|
||||
messenger.unregisterIncomingPluginChannel(plugin, "test:foo");
|
||||
listener1.reset();
|
||||
listener2.reset();
|
||||
|
||||
assertFalse(registration1.isValid());
|
||||
assertTrue(registration2.isValid());
|
||||
messenger.dispatchIncomingMessage(player, "foo", "bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "baz", "qux".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:foo", "test:bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:baz", "test:qux".getBytes());
|
||||
assertFalse(listener1.hasReceived());
|
||||
assertTrue(listener2.hasReceived());
|
||||
}
|
||||
@@ -139,16 +140,16 @@ public class StandardMessengerTest {
|
||||
public void testUnregisterIncomingPluginChannel_Plugin() {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
TestMessageListener listener1 = new TestMessageListener("foo", "bar".getBytes());
|
||||
TestMessageListener listener2 = new TestMessageListener("baz", "qux".getBytes());
|
||||
TestMessageListener listener1 = new TestMessageListener("test:foo", "test:bar".getBytes());
|
||||
TestMessageListener listener2 = new TestMessageListener("test:baz", "test:qux".getBytes());
|
||||
Player player = TestPlayer.getInstance();
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin, "foo", listener1);
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin, "baz", listener2);
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin, "test:foo", listener1);
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin, "test:baz", listener2);
|
||||
|
||||
assertTrue(registration1.isValid());
|
||||
assertTrue(registration2.isValid());
|
||||
messenger.dispatchIncomingMessage(player, "foo", "bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "baz", "qux".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:foo", "test:bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:baz", "test:qux".getBytes());
|
||||
assertTrue(listener1.hasReceived());
|
||||
assertTrue(listener2.hasReceived());
|
||||
|
||||
@@ -158,8 +159,8 @@ public class StandardMessengerTest {
|
||||
|
||||
assertFalse(registration1.isValid());
|
||||
assertFalse(registration2.isValid());
|
||||
messenger.dispatchIncomingMessage(player, "foo", "bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "baz", "qux".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:foo", "test:bar".getBytes());
|
||||
messenger.dispatchIncomingMessage(player, "test:baz", "test:qux".getBytes());
|
||||
assertFalse(listener1.hasReceived());
|
||||
assertFalse(listener2.hasReceived());
|
||||
}
|
||||
@@ -172,12 +173,12 @@ public class StandardMessengerTest {
|
||||
|
||||
assertEquals(messenger.getOutgoingChannels());
|
||||
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "foo");
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "bar");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "baz");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "baz");
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "test:foo");
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "test:bar");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "test:baz");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "test:baz");
|
||||
|
||||
assertEquals(messenger.getOutgoingChannels(), "foo", "bar", "baz");
|
||||
assertEquals(messenger.getOutgoingChannels(), "test:foo", "test:bar", "test:baz");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -187,13 +188,13 @@ public class StandardMessengerTest {
|
||||
TestPlugin plugin2 = getPlugin();
|
||||
TestPlugin plugin3 = getPlugin();
|
||||
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "foo");
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "bar");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "baz");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "qux");
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "test:foo");
|
||||
messenger.registerOutgoingPluginChannel(plugin1, "test:bar");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "test:baz");
|
||||
messenger.registerOutgoingPluginChannel(plugin2, "test:qux");
|
||||
|
||||
assertEquals(messenger.getOutgoingChannels(plugin1), "foo", "bar");
|
||||
assertEquals(messenger.getOutgoingChannels(plugin2), "baz", "qux");
|
||||
assertEquals(messenger.getOutgoingChannels(plugin1), "test:foo", "test:bar");
|
||||
assertEquals(messenger.getOutgoingChannels(plugin2), "test:baz", "test:qux");
|
||||
assertEquals(messenger.getOutgoingChannels(plugin3));
|
||||
}
|
||||
|
||||
@@ -205,12 +206,12 @@ public class StandardMessengerTest {
|
||||
|
||||
assertEquals(messenger.getIncomingChannels());
|
||||
|
||||
messenger.registerIncomingPluginChannel(plugin1, "foo", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin1, "bar", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "baz", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "baz", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin1, "test:foo", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin1, "test:bar", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "test:baz", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "test:baz", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
|
||||
assertEquals(messenger.getIncomingChannels(), "foo", "bar", "baz");
|
||||
assertEquals(messenger.getIncomingChannels(), "test:foo", "test:bar", "test:baz");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,13 +221,13 @@ public class StandardMessengerTest {
|
||||
TestPlugin plugin2 = getPlugin();
|
||||
TestPlugin plugin3 = getPlugin();
|
||||
|
||||
messenger.registerIncomingPluginChannel(plugin1, "foo", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin1, "bar", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "baz", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "qux", new TestMessageListener("foo", "bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin1, "test:foo", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin1, "test:bar", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "test:baz", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
messenger.registerIncomingPluginChannel(plugin2, "test:qux", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
|
||||
assertEquals(messenger.getIncomingChannels(plugin1), "foo", "bar");
|
||||
assertEquals(messenger.getIncomingChannels(plugin2), "baz", "qux");
|
||||
assertEquals(messenger.getIncomingChannels(plugin1), "test:foo", "test:bar");
|
||||
assertEquals(messenger.getIncomingChannels(plugin2), "test:baz", "test:qux");
|
||||
assertEquals(messenger.getIncomingChannels(plugin3));
|
||||
}
|
||||
|
||||
@@ -236,10 +237,10 @@ public class StandardMessengerTest {
|
||||
TestPlugin plugin1 = getPlugin();
|
||||
TestPlugin plugin2 = getPlugin();
|
||||
TestPlugin plugin3 = getPlugin();
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin1, "foo", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin1, "bar", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration3 = messenger.registerIncomingPluginChannel(plugin2, "baz", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration4 = messenger.registerIncomingPluginChannel(plugin2, "qux", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin1, "test:foo", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin1, "test:bar", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration3 = messenger.registerIncomingPluginChannel(plugin2, "test:baz", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration4 = messenger.registerIncomingPluginChannel(plugin2, "test:qux", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin1), registration1, registration2);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin2), registration3, registration4);
|
||||
@@ -251,14 +252,14 @@ public class StandardMessengerTest {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin1 = getPlugin();
|
||||
TestPlugin plugin2 = getPlugin();
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin1, "foo", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin1, "bar", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration3 = messenger.registerIncomingPluginChannel(plugin2, "foo", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration4 = messenger.registerIncomingPluginChannel(plugin2, "bar", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin1, "test:foo", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin1, "test:bar", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration3 = messenger.registerIncomingPluginChannel(plugin2, "test:foo", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration4 = messenger.registerIncomingPluginChannel(plugin2, "test:bar", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
|
||||
assertEquals(messenger.getIncomingChannelRegistrations("foo"), registration1, registration3);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations("bar"), registration2, registration4);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations("baz"));
|
||||
assertEquals(messenger.getIncomingChannelRegistrations("test:foo"), registration1, registration3);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations("test:bar"), registration2, registration4);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations("test:baz"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -267,19 +268,33 @@ public class StandardMessengerTest {
|
||||
TestPlugin plugin1 = getPlugin();
|
||||
TestPlugin plugin2 = getPlugin();
|
||||
TestPlugin plugin3 = getPlugin();
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin1, "foo", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin1, "foo", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration3 = messenger.registerIncomingPluginChannel(plugin1, "bar", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration4 = messenger.registerIncomingPluginChannel(plugin2, "bar", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration5 = messenger.registerIncomingPluginChannel(plugin2, "baz", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration6 = messenger.registerIncomingPluginChannel(plugin2, "baz", new TestMessageListener("foo", "bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration1 = messenger.registerIncomingPluginChannel(plugin1, "test:foo", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration2 = messenger.registerIncomingPluginChannel(plugin1, "test:foo", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration3 = messenger.registerIncomingPluginChannel(plugin1, "test:bar", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration4 = messenger.registerIncomingPluginChannel(plugin2, "test:bar", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration5 = messenger.registerIncomingPluginChannel(plugin2, "test:baz", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
PluginMessageListenerRegistration registration6 = messenger.registerIncomingPluginChannel(plugin2, "test:baz", new TestMessageListener("test:foo", "test:bar".getBytes()));
|
||||
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin1, "foo"), registration1, registration2);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin1, "bar"), registration3);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin2, "bar"), registration4);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin2, "baz"), registration5, registration6);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin1, "baz"));
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin3, "qux"));
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin1, "test:foo"), registration1, registration2);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin1, "test:bar"), registration3);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin2, "test:bar"), registration4);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin2, "test:baz"), registration5, registration6);
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin1, "test:baz"));
|
||||
assertEquals(messenger.getIncomingChannelRegistrations(plugin3, "test:qux"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidChannel() {
|
||||
Messenger messenger = getMessenger();
|
||||
TestPlugin plugin = getPlugin();
|
||||
|
||||
messenger.registerOutgoingPluginChannel(plugin, "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidateAndCorrectChannel() {
|
||||
Assert.assertEquals("bungeecord:main", StandardMessenger.validateAndCorrectChannel("BungeeCord"));
|
||||
Assert.assertEquals("BungeeCord", StandardMessenger.validateAndCorrectChannel("bungeecord:main"));
|
||||
}
|
||||
|
||||
private static <T> void assertEquals(Collection<T> actual, T... expected) {
|
||||
|
||||
Reference in New Issue
Block a user