3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00
Paper/src/test/java/org/bukkit/MaterialTest.java

49 Zeilen
1.3 KiB
Java

2012-01-29 11:22:11 +01:00
package org.bukkit;
import static org.junit.Assert.*;
import static org.hamcrest.Matchers.*;
2012-01-29 11:22:11 +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-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);
assertThat("Missing " + name + "(" + id + ")", material, is(not(nullValue())));
2012-01-29 11:22:11 +01:00
}
assertThat(materials, is(Collections.EMPTY_MAP));
2012-01-29 11:22:11 +01:00
}
}