summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authort00thpick1 <t00thpick1dirko@gmail.com>2014-01-14 23:42:40 -0500
committerWesley Wolfe <weswolf@aol.com>2014-01-16 00:51:04 -0600
commit622a2976d97775df8650d92be44cdb67ca4012ca (patch)
tree4d5112db2b7ac21d729d0c86cf9746e61e8c45da /src/test
parentdd12820c58871c6e05b6a8cbe9197ac64c6a00a3 (diff)
downloadcraftbukkit-622a2976d97775df8650d92be44cdb67ca4012ca.tar
craftbukkit-622a2976d97775df8650d92be44cdb67ca4012ca.tar.gz
craftbukkit-622a2976d97775df8650d92be44cdb67ca4012ca.tar.lz
craftbukkit-622a2976d97775df8650d92be44cdb67ca4012ca.tar.xz
craftbukkit-622a2976d97775df8650d92be44cdb67ca4012ca.zip
[Bleeding] Fix Achievements and Statistics API. Fixes BUKKIT-5305
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/bukkit/AchievementTest.java37
-rw-r--r--src/test/java/org/bukkit/ArtTest.java2
-rw-r--r--src/test/java/org/bukkit/StatisticsAndAchievementsTest.java61
3 files changed, 62 insertions, 38 deletions
diff --git a/src/test/java/org/bukkit/AchievementTest.java b/src/test/java/org/bukkit/AchievementTest.java
deleted file mode 100644
index 813568e3..00000000
--- a/src/test/java/org/bukkit/AchievementTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.bukkit;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.Matchers.*;
-
-import java.util.Collections;
-import java.util.List;
-
-import net.minecraft.server.AchievementList;
-
-import org.bukkit.craftbukkit.CraftAchievement;
-import org.bukkit.support.AbstractTestingBase;
-import org.bukkit.support.Util;
-import org.junit.Test;
-
-import com.google.common.collect.Lists;
-
-public class AchievementTest extends AbstractTestingBase {
- @Test
- @SuppressWarnings("unchecked")
- public void verifyMapping() throws Throwable {
- List<Achievement> achievements = Lists.newArrayList(Achievement.values());
-
- for (net.minecraft.server.Achievement statistic : (List<net.minecraft.server.Achievement>) AchievementList.e) {
- String name = statistic.e;
-
- String message = String.format("org.bukkit.Achievement is missing: '%s'", name);
-
- Achievement subject = CraftAchievement.getAchievement(name);
- assertNotNull(message, subject);
-
- assertTrue(name, achievements.remove(subject));
- }
-
- assertThat("org.bukkit.Achievement has too many achievements", achievements, is(Collections.EMPTY_LIST));
- }
-}
diff --git a/src/test/java/org/bukkit/ArtTest.java b/src/test/java/org/bukkit/ArtTest.java
index 46804f7e..c8e11d86 100644
--- a/src/test/java/org/bukkit/ArtTest.java
+++ b/src/test/java/org/bukkit/ArtTest.java
@@ -30,7 +30,7 @@ public class ArtTest {
Art subject = Art.getById(id);
- String message = String.format("org.bukkit.Art is missing id: %d named: '%s'", id - Achievement.STATISTIC_OFFSET, name);
+ String message = String.format("org.bukkit.Art is missing id: %d named: '%s'", id, name);
assertNotNull(message, subject);
assertThat(Art.getByName(name), is(subject));
diff --git a/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java
new file mode 100644
index 00000000..306c2a41
--- /dev/null
+++ b/src/test/java/org/bukkit/StatisticsAndAchievementsTest.java
@@ -0,0 +1,61 @@
+package org.bukkit;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.Matchers.*;
+
+import java.util.Collections;
+import java.util.List;
+
+import net.minecraft.server.AchievementList;
+import net.minecraft.server.StatisticList;
+
+import org.bukkit.craftbukkit.CraftStatistic;
+import org.bukkit.support.AbstractTestingBase;
+import org.junit.Test;
+
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.Lists;
+
+public class StatisticsAndAchievementsTest extends AbstractTestingBase {
+ @Test
+ @SuppressWarnings("unchecked")
+ public void verifyAchievementMapping() throws Throwable {
+ List<Achievement> achievements = Lists.newArrayList(Achievement.values());
+ for (net.minecraft.server.Achievement achievement : (List<net.minecraft.server.Achievement>) AchievementList.e) {
+ String name = achievement.e;
+
+ String message = String.format("org.bukkit.Achievement is missing: '%s'", name);
+
+ Achievement subject = CraftStatistic.getBukkitAchievement(achievement);
+ assertThat(message, subject, is(not(nullValue())));
+
+ assertThat(name, achievements.remove(subject), is(true));
+ }
+
+ assertThat("org.bukkit.Achievement has too many achievements", achievements, is(empty()));
+ }
+
+ @Test
+ @SuppressWarnings("unchecked")
+ public void verifyStatisticMapping() throws Throwable {
+ HashMultiset<Statistic> statistics = HashMultiset.create();
+ for (net.minecraft.server.Statistic statistic : (List<net.minecraft.server.Statistic>) StatisticList.b) {
+ if (statistic instanceof net.minecraft.server.Achievement) {
+ continue;
+ }
+ String name = statistic.e;
+
+ String message = String.format("org.bukkit.Statistic is missing: '%s'", name);
+
+ Statistic subject = CraftStatistic.getBukkitStatistic(statistic);
+ assertThat(message, subject, is(not(nullValue())));
+
+ statistics.add(subject);
+ }
+
+ for (Statistic statistic : Statistic.values()) {
+ String message = String.format("org.bukkit.Statistic.%s does not have a corresponding minecraft statistic", statistic.name());
+ assertThat(message, statistics.remove(statistic, statistics.count(statistic)), is(greaterThan(0)));
+ }
+ }
+}