diff options
Diffstat (limited to 'src/test/java/org/bukkit')
-rw-r--r-- | src/test/java/org/bukkit/AchievementTest.java | 37 | ||||
-rw-r--r-- | src/test/java/org/bukkit/ArtTest.java | 2 | ||||
-rw-r--r-- | src/test/java/org/bukkit/StatisticsAndAchievementsTest.java | 61 |
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))); + } + } +} |