summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2013-01-05 16:22:34 -0600
committerWesley Wolfe <weswolf@aol.com>2013-01-05 17:20:39 -0600
commit1c32f297606b89d663d664b74951575ba9eb7e1b (patch)
tree54ee8bcda583045b01999c33545335cf96aa607d /src/test
parent87e41b0d13fcaece914c58a9e3321403b5db9290 (diff)
downloadbukkit-1c32f297606b89d663d664b74951575ba9eb7e1b.tar
bukkit-1c32f297606b89d663d664b74951575ba9eb7e1b.tar.gz
bukkit-1c32f297606b89d663d664b74951575ba9eb7e1b.tar.lz
bukkit-1c32f297606b89d663d664b74951575ba9eb7e1b.tar.xz
bukkit-1c32f297606b89d663d664b74951575ba9eb7e1b.zip
Clarify dye and wool color datas in DyeColor. Addresses BUKKIT-2786
DyeColor used the wool data for getData(), which is very misleading based on class name. The old method has been deprecated and replaced with getWoolData() and getDyeData() for the appropriate types of data values. The MaterialData classes Dye and Wool were updated appropriately, especially Dye innapropriately using a DyeColor data value compensation. Unit tests were added for the new methods, as well as the getColor on Dye and Wool.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/bukkit/DyeColorTest.java65
1 files changed, 60 insertions, 5 deletions
diff --git a/src/test/java/org/bukkit/DyeColorTest.java b/src/test/java/org/bukkit/DyeColorTest.java
index 70049d7f..9e30fbfc 100644
--- a/src/test/java/org/bukkit/DyeColorTest.java
+++ b/src/test/java/org/bukkit/DyeColorTest.java
@@ -1,15 +1,70 @@
package org.bukkit;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.bukkit.material.Colorable;
+import org.bukkit.material.Dye;
+import org.bukkit.material.Wool;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+@RunWith(Parameterized.class)
public class DyeColorTest {
+
+ @Parameters(name= "{index}: {0}")
+ public static List<Object[]> data() {
+ List<Object[]> list = new ArrayList<Object[]>();
+ for (DyeColor dye : DyeColor.values()) {
+ list.add(new Object[] {dye});
+ }
+ return list;
+ }
+
+ @Parameter public DyeColor dye;
+
@Test
+ @SuppressWarnings("deprecation")
public void getByData() {
- for (DyeColor dyeColor : DyeColor.values()) {
- assertThat(DyeColor.getByData(dyeColor.getData()), is(dyeColor));
- }
+ byte data = dye.getData();
+
+ DyeColor byData = DyeColor.getByData(data);
+ assertThat(byData, is(dye));
+ }
+
+ @Test
+ public void getByWoolData() {
+ byte data = dye.getWoolData();
+
+ DyeColor byData = DyeColor.getByWoolData(data);
+ assertThat(byData, is(dye));
+ }
+
+ @Test
+ public void getByDyeData() {
+ byte data = dye.getDyeData();
+
+ DyeColor byData = DyeColor.getByDyeData(data);
+ assertThat(byData, is(dye));
+ }
+
+ @Test
+ public void getDyeDyeColor() {
+ testColorable(new Dye(Material.INK_SACK, dye.getDyeData()));
+ }
+
+ @Test
+ public void getWoolDyeColor() {
+ testColorable(new Wool(Material.WOOL, dye.getWoolData()));
+ }
+
+ private void testColorable(final Colorable colorable) {
+ assertThat(colorable.getColor(), is(this.dye));
}
}