summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorryanbennitt <ryanbennitt@googlemail.com>2016-03-26 09:26:20 +1100
committermd_5 <git@md-5.net>2016-03-26 09:40:09 +1100
commit996146280e6e9fb4cc6f43235f22f4e568431597 (patch)
treeaa37967267234d24397b9451e109d07b00f385ce /src/test/java/org
parentccc245a7e6fd9406220d69d583b5e8eeeb0bfe3e (diff)
downloadbukkit-996146280e6e9fb4cc6f43235f22f4e568431597.tar
bukkit-996146280e6e9fb4cc6f43235f22f4e568431597.tar.gz
bukkit-996146280e6e9fb4cc6f43235f22f4e568431597.tar.lz
bukkit-996146280e6e9fb4cc6f43235f22f4e568431597.tar.xz
bukkit-996146280e6e9fb4cc6f43235f22f4e568431597.zip
SPIGOT-1682: Fixed block data for Beetroot
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/bukkit/materials/MaterialDataTest.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/test/java/org/bukkit/materials/MaterialDataTest.java b/src/test/java/org/bukkit/materials/MaterialDataTest.java
index 3eaede3c..2be3ddc9 100644
--- a/src/test/java/org/bukkit/materials/MaterialDataTest.java
+++ b/src/test/java/org/bukkit/materials/MaterialDataTest.java
@@ -3,12 +3,16 @@ package org.bukkit.materials;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
+import org.bukkit.CropState;
import org.bukkit.Material;
+import org.bukkit.NetherWartsState;
import org.bukkit.TreeSpecies;
import org.bukkit.block.BlockFace;
+import org.bukkit.material.Crops;
import org.bukkit.material.Door;
import org.bukkit.material.Leaves;
import org.bukkit.material.Mushroom;
+import org.bukkit.material.NetherWarts;
import org.bukkit.material.Sapling;
import org.bukkit.material.Tree;
import org.bukkit.material.Wood;
@@ -259,4 +263,62 @@ 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 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 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};
+ for (Material crop : allCrops) {
+ crops = new Crops(crop);
+ assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(crop));
+ assertThat("Constructed with default crop state", crops.getState(), equalTo(CropState.SEEDED));
+
+ for (CropState state : allStates) {
+ crops = new Crops(crop, state);
+ assertThat("Constructed with correct crops type", crops.getItemType(), equalTo(crop));
+ assertThat("Constructed with correct crop state", crops.getState(), equalTo(state));
+ }
+ }
+
+ // Beetroot are crops too, but they only have four states
+ // 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));
+ 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));
+ 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);
+ 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));
+ assertThat("Constructed with default wart state", warts.getState(), equalTo(NetherWartsState.SEEDED));
+ allStates = new CropState[] {CropState.SEEDED, CropState.SMALL, CropState.TALL, CropState.RIPE};
+ 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]);
+ 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]));
+ assertThat("Constructed with correct wart state", warts.getState(), equalTo(allWartStates[s]));
+ }
+ }
}