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-01-09 15:51:32 +08:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void getEffects() {
|
|
|
|
for (PotionType type : PotionType.values()) {
|
|
|
|
for (PotionEffect effect : new Potion(type).getEffects()) {
|
2012-11-01 03:38:25 -05:00
|
|
|
PotionEffectType potionType = effect.getType();
|
|
|
|
assertThat(effect.getType(), is(sameInstance(PotionEffectType.getById(potionType.getId()))));
|
|
|
|
|
|
|
|
assertNotNull(potionType.getName(), PotionType.getByEffect(potionType));
|
2012-01-09 15:51:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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-01 08:32:46 +11:00
|
|
|
assertEquals(effects.entrySet().size(), PotionType.values().length - /* WATER */ 1);
|
2012-11-01 03:38:25 -05:00
|
|
|
}
|
2012-01-09 15:51:32 +08:00
|
|
|
}
|