summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/bukkit/potion/PotionTest.java
blob: f6c23ebba439894f76b5d15461e6a8a4bb220e4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package org.bukkit.potion;

import static org.junit.Assert.*;

import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import net.minecraft.server.IRegistry;

import net.minecraft.server.MobEffect;
import net.minecraft.server.MobEffectList;
import net.minecraft.server.PotionRegistry;
import org.bukkit.support.AbstractTestingBase;
import org.junit.Test;

public class PotionTest extends AbstractTestingBase {
    @Test
    public void testEffectCompleteness() throws Throwable {
        Map<PotionType, String> effects = new EnumMap(PotionType.class);
        for (Object reg : IRegistry.POTION) {
            List<MobEffect> eff = ((PotionRegistry)reg).a();
            if (eff.size() != 1) continue;
            int id = MobEffectList.getId(eff.get(0).getMobEffect());
            PotionEffectType type = PotionEffectType.getById(id);
            assertNotNull(String.valueOf(id), PotionEffectType.getById(id));

            PotionType enumType = PotionType.getByEffect(type);
            assertNotNull(type.getName(), enumType);

            effects.put(enumType, enumType.name());
        }

        assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no/shared Effects */ 6);
    }
}