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-01-29 11:22:11 +01:00
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import net.minecraft.server.Item;
|
|
|
|
|
|
|
|
import org.bukkit.support.AbstractTestingBase;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
2013-11-04 14:07:38 +01:00
|
|
|
import java.util.Iterator;
|
|
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
2012-01-29 11:22:11 +01:00
|
|
|
|
|
|
|
public class MaterialTest extends AbstractTestingBase {
|
2012-12-14 09:02:02 +01:00
|
|
|
|
2012-01-29 11:22:11 +01:00
|
|
|
@Test
|
|
|
|
public void verifyMapping() {
|
|
|
|
Map<Integer, Material> materials = Maps.newHashMap();
|
|
|
|
for (Material material : Material.values()) {
|
2013-11-04 14:07:38 +01:00
|
|
|
if (INVALIDATED_MATERIALS.contains(material)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-01-29 11:22:11 +01:00
|
|
|
materials.put(material.getId(), material);
|
|
|
|
}
|
|
|
|
materials.remove(0); // Purge air.
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
Iterator<Item> items = Item.REGISTRY.iterator();
|
|
|
|
|
|
|
|
while (items.hasNext()) {
|
|
|
|
Item item = items.next();
|
2012-01-29 11:22:11 +01:00
|
|
|
if (item == null) continue;
|
|
|
|
|
2013-11-04 14:07:38 +01:00
|
|
|
int id = CraftMagicNumbers.getId(item);
|
2012-01-29 11:22:11 +01:00
|
|
|
String name = item.getName();
|
|
|
|
|
|
|
|
Material material = materials.remove(id);
|
|
|
|
|
2012-12-14 09:02:02 +01:00
|
|
|
assertThat("Missing " + name + "(" + id + ")", material, is(not(nullValue())));
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-14 09:02:02 +01:00
|
|
|
assertThat(materials, is(Collections.EMPTY_MAP));
|
2012-01-29 11:22:11 +01:00
|
|
|
}
|
|
|
|
}
|