2012-01-29 11:22:11 +01:00
|
|
|
package org.bukkit;
|
|
|
|
|
2012-12-14 09:02:02 +01:00
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import static org.hamcrest.Matchers.*;
|
2012-01-29 11:22:11 +01:00
|
|
|
|
2012-12-14 09:02:02 +01:00
|
|
|
import java.util.Collections;
|
2012-11-01 09:06:47 +01:00
|
|
|
import java.util.EnumMap;
|
2012-01-29 11:22:11 +01:00
|
|
|
import java.util.List;
|
2012-11-01 09:06:47 +01:00
|
|
|
import java.util.Map;
|
2012-01-29 11:22:11 +01:00
|
|
|
|
|
|
|
import net.minecraft.server.EnumArt;
|
|
|
|
|
2012-11-01 09:06:47 +01:00
|
|
|
import org.bukkit.craftbukkit.CraftArt;
|
2012-01-29 11:22:11 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
public class ArtTest {
|
|
|
|
private static final int UNIT_MULTIPLIER = 16;
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void verifyMapping() {
|
|
|
|
List<Art> arts = Lists.newArrayList(Art.values());
|
|
|
|
|
|
|
|
for (EnumArt enumArt : EnumArt.values()) {
|
|
|
|
int id = enumArt.ordinal();
|
2012-10-25 05:53:23 +02:00
|
|
|
String name = enumArt.B;
|
|
|
|
int width = enumArt.C / UNIT_MULTIPLIER;
|
|
|
|
int height = enumArt.D / UNIT_MULTIPLIER;
|
2012-01-29 11:22:11 +01:00
|
|
|
|
|
|
|
Art subject = Art.getById(id);
|
|
|
|
|
|
|
|
String message = String.format("org.bukkit.Art is missing id: %d named: '%s'", id - Achievement.STATISTIC_OFFSET, name);
|
|
|
|
assertNotNull(message, subject);
|
|
|
|
|
|
|
|
assertThat(Art.getByName(name), is(subject));
|
|
|
|
assertThat("Art." + subject + "'s width", subject.getBlockWidth(), is(width));
|
|
|
|
assertThat("Art." + subject + "'s height", subject.getBlockHeight(), is(height));
|
|
|
|
|
|
|
|
arts.remove(subject);
|
|
|
|
}
|
|
|
|
|
2012-12-14 09:02:02 +01:00
|
|
|
assertThat("org.bukkit.Art has too many arts", arts, is(Collections.EMPTY_LIST));
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|
2012-11-01 09:06:47 +01:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCraftArtToNotch() {
|
|
|
|
Map<EnumArt, Art> cache = new EnumMap(EnumArt.class);
|
|
|
|
for (Art art : Art.values()) {
|
|
|
|
EnumArt enumArt = CraftArt.BukkitToNotch(art);
|
|
|
|
assertNotNull(art.name(), enumArt);
|
2012-12-14 09:02:02 +01:00
|
|
|
assertThat(art.name(), cache.put(enumArt, art), is(nullValue()));
|
2012-11-01 09:06:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCraftArtToBukkit() {
|
|
|
|
Map<Art, EnumArt> cache = new EnumMap(Art.class);
|
|
|
|
for (EnumArt enumArt : EnumArt.values()) {
|
|
|
|
Art art = CraftArt.NotchToBukkit(enumArt);
|
|
|
|
assertNotNull(enumArt.name(), art);
|
2012-12-14 09:02:02 +01:00
|
|
|
assertThat(enumArt.name(), cache.put(art, enumArt), is(nullValue()));
|
2012-11-01 09:06:47 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|