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;
|
2018-07-15 02:00:00 +02:00
|
|
|
import java.util.HashMap;
|
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
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
import net.minecraft.server.IRegistry;
|
2018-07-15 02:00:00 +02:00
|
|
|
import net.minecraft.server.MinecraftKey;
|
|
|
|
import net.minecraft.server.Paintings;
|
2012-01-29 11:22:11 +01:00
|
|
|
|
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;
|
2018-08-26 04:00:00 +02:00
|
|
|
import org.bukkit.support.AbstractTestingBase;
|
2012-01-29 11:22:11 +01:00
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
public class ArtTest extends AbstractTestingBase {
|
2012-01-29 11:22:11 +01:00
|
|
|
private static final int UNIT_MULTIPLIER = 16;
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void verifyMapping() {
|
|
|
|
List<Art> arts = Lists.newArrayList(Art.values());
|
|
|
|
|
2018-08-26 04:00:00 +02:00
|
|
|
for (MinecraftKey key : IRegistry.MOTIVE.keySet()) {
|
|
|
|
Paintings enumArt = IRegistry.MOTIVE.get(key);
|
2018-07-15 02:00:00 +02:00
|
|
|
String name = key.getKey();
|
2019-04-23 04:00:00 +02:00
|
|
|
int width = enumArt.getWidth() / UNIT_MULTIPLIER;
|
|
|
|
int height = enumArt.getHeight() / UNIT_MULTIPLIER;
|
2012-01-29 11:22:11 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
Art subject = CraftArt.NotchToBukkit(enumArt);
|
2012-01-29 11:22:11 +01:00
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
String message = String.format("org.bukkit.Art is missing '%s'", name);
|
2012-01-29 11:22:11 +01:00
|
|
|
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() {
|
2018-07-15 02:00:00 +02:00
|
|
|
Map<Paintings, Art> cache = new HashMap<>();
|
2012-11-01 09:06:47 +01:00
|
|
|
for (Art art : Art.values()) {
|
2018-07-15 02:00:00 +02:00
|
|
|
Paintings enumArt = CraftArt.BukkitToNotch(art);
|
2012-11-01 09:06:47 +01:00
|
|
|
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() {
|
2018-07-15 02:00:00 +02:00
|
|
|
Map<Art, Paintings> cache = new EnumMap(Art.class);
|
2019-04-23 04:00:00 +02:00
|
|
|
for (Paintings enumArt : IRegistry.MOTIVE) {
|
2012-11-01 09:06:47 +01:00
|
|
|
Art art = CraftArt.NotchToBukkit(enumArt);
|
2018-07-15 02:00:00 +02:00
|
|
|
assertNotNull("Could not CraftArt.NotchToBukkit " + enumArt, art);
|
|
|
|
assertThat("Duplicate artwork " + enumArt, cache.put(art, enumArt), is(nullValue()));
|
2012-11-01 09:06:47 +01:00
|
|
|
}
|
|
|
|
}
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|