2012-01-09 15:51:32 +08:00
|
|
|
package org.bukkit.potion;
|
|
|
|
|
|
|
|
import static org.junit.Assert.*;
|
2012-11-01 03:38:25 -05:00
|
|
|
import static org.hamcrest.Matchers.*;
|
|
|
|
|
|
|
|
import java.util.EnumMap;
|
2016-03-01 08:32:46 +11:00
|
|
|
import java.util.List;
|
2012-11-01 03:38:25 -05:00
|
|
|
import java.util.Map;
|
2012-01-09 15:51:32 +08:00
|
|
|
|
2016-03-01 08:32:46 +11:00
|
|
|
import net.minecraft.server.MobEffect;
|
|
|
|
import net.minecraft.server.MobEffectList;
|
|
|
|
import net.minecraft.server.PotionRegistry;
|
2012-12-17 01:31:41 -06:00
|
|
|
import org.bukkit.support.AbstractTestingBase;
|
2012-01-09 15:51:32 +08:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2012-12-17 01:31:41 -06:00
|
|
|
public class PotionTest extends AbstractTestingBase {
|
2012-11-01 03:38:25 -05:00
|
|
|
@Test
|
2012-12-17 01:31:41 -06:00
|
|
|
public void testEffectCompleteness() throws Throwable {
|
2012-11-01 03:38:25 -05:00
|
|
|
Map<PotionType, String> effects = new EnumMap(PotionType.class);
|
2016-03-01 08:32:46 +11:00
|
|
|
for (PotionRegistry reg : PotionRegistry.a) {
|
|
|
|
List<MobEffect> eff = reg.a();
|
|
|
|
if (eff.size() != 1) continue;
|
|
|
|
int id = MobEffectList.getId(eff.get(0).getMobEffect());
|
2012-11-01 03:38:25 -05:00
|
|
|
PotionEffectType type = PotionEffectType.getById(id);
|
|
|
|
assertNotNull(String.valueOf(id), PotionEffectType.getById(id));
|
|
|
|
|
|
|
|
PotionType enumType = PotionType.getByEffect(type);
|
|
|
|
assertNotNull(type.getName(), enumType);
|
|
|
|
|
2016-03-01 08:32:46 +11:00
|
|
|
effects.put(enumType, enumType.name());
|
2012-11-01 03:38:25 -05:00
|
|
|
}
|
|
|
|
|
2016-03-02 20:43:58 -05:00
|
|
|
assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no Effects */ 5);
|
2012-11-01 03:38:25 -05:00
|
|
|
}
|
2012-01-09 15:51:32 +08:00
|
|
|
}
|