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 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;
|
2018-08-26 12:00:00 +10:00
|
|
|
import net.minecraft.server.IRegistry;
|
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);
|
2018-08-26 12:00:00 +10:00
|
|
|
for (Object reg : IRegistry.POTION) {
|
2016-06-09 11:43:49 +10:00
|
|
|
List<MobEffect> eff = ((PotionRegistry)reg).a();
|
2016-03-01 08:32:46 +11:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-07-15 10:00:00 +10:00
|
|
|
assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no/shared Effects */ 6);
|
2012-11-01 03:38:25 -05:00
|
|
|
}
|
2012-01-09 15:51:32 +08:00
|
|
|
}
|