<commit_before>package xyz.upperlevel.uppercore.config;

import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
import org.junit.Test;
import xyz.upperlevel.uppercore.FakePlaceholderManager;
import xyz.upperlevel.uppercore.config.parser.ConfigParserRegistry;
import xyz.upperlevel.uppercore.gui.GuiSize;
import xyz.upperlevel.uppercore.placeholder.PlaceholderUtil;
import xyz.upperlevel.uppercore.placeholder.managers.CustomPlaceholderManager;
import xyz.upperlevel.uppercore.sound.PlaySound;

import java.io.StringReader;

import static org.junit.Assert.assertEquals;
import static xyz.upperlevel.uppercore.placeholder.PlaceholderValue.fake;

public class BukkitTypesConfigTest {
    public static final ConfigParserRegistry registry = ConfigParserRegistry.getStandard();
    private static final Plugin plugin = null;

    public static class ConfigLoaderExample {
        @ConfigConstructor
        public ConfigLoaderExample(@ConfigProperty("pos") Vector position,
                                   @ConfigProperty("color1")   Color color1,
                                   @ConfigProperty("color2")   Color color2,
                                   @ConfigProperty("color3")   Color color3,
                                   //@ConfigProperty("sound")    Sound sound,
                                   @ConfigProperty("mat1")     Material mat1,
                                   @ConfigProperty("mat2")     Material mat2,
                                   //@ConfigProperty("loc")      Location loc,// TODO: mock
                                   //@ConfigProperty("ench1")    Enchantment ench1,
                                   //@ConfigProperty("ench2")    Enchantment ench2,
                                   @ConfigProperty("guisize1") GuiSize guiSize1,
                                   @ConfigProperty("guisize2") GuiSize guiSize2,
                                   @ConfigProperty("patterni") PatternType patternTypeId,
                                   @ConfigProperty("patternt") PatternType patternTypeName,
                                   @ConfigProperty("pattern") Pattern pattern,
                                   @ConfigProperty("firework") FireworkEffect fireworkEffect
                                   //@ConfigProperty("playsound") PlaySound playSound
                                   //@ConfigProperty("potiont")  PotionEffectType potionEffectType,
                                   //@ConfigProperty("potione")  PotionEffect potionEffect
        ) {

            assertEquals(new Vector(31, 24, 56), position);
            assertEquals(Color.GREEN, color1);
            assertEquals(Color.WHITE, color2);
            assertEquals(Color.RED, color3);
            //assertEquals(Sound.ENTITY_RABBIT_ATTACK, sound);
            assertEquals(Material.LAPIS_BLOCK, mat1);
            assertEquals(Material.BONE, mat2);// I am the bone of my api
            // location
            //assertEquals(Enchantment.OXYGEN, ench1);
            //assertEquals(Enchantment.THORNS, ench2);
            assertEquals(GuiSize.NORMAL, guiSize1);
            assertEquals(GuiSize.DOUBLE, guiSize2);
            assertEquals(PatternType.RHOMBUS_MIDDLE, patternTypeId);
            assertEquals(PatternType.MOJANG, patternTypeName);
            assertEquals(new Pattern(DyeColor.CYAN, PatternType.FLOWER), pattern);
            assertEquals(
                    FireworkEffect.builder()
                            .flicker(true)
                            .trail(true)
                            .withColor(Color.GREEN, Color.WHITE, Color.RED)
                            .withFade(Color.AQUA)
                            .with(FireworkEffect.Type.CREEPER)
                            .build(),
                    fireworkEffect
            );
            //assertEquals(new PlaySound(fake(Sound.AMBIENT_CAVE), null, null), playSound); // TODO: Cannot mock CompatibleSound
            /*assertEquals(
                    PotionEffectType.JUMP,
                    potionEffectType
            );
            assertEquals(
                    new PotionEffect(
                            PotionEffectType.FAST_DIGGING,
                            100,
                            50,
                            true,
                            true,
                            Color.AQUA
                    ),
                    potionEffect
            );*/
        }
    }

    @Test
    public void basicTest() {
        PlaceholderUtil.setManager(new FakePlaceholderManager());

        registry.getFor(ConfigLoaderExample.class)
                .parse(
                        new StringReader(
                                "pos: [31, 24, 56]\n" +
                                        "color1: 0;128;0\n" +
                                        "color2: '#FFFFFF'\n" +
                                        "color3: red\n" +
                                        //"sound: entity rabbit attack\n" +
                                        "mat1: lapis block\n" +
                                        "mat2: bone\n" +
                                        //"loc: [main, 10, 12, 13]\n" +
                                        //"ench1: 5\n" +
                                        //"ench2: thorns\n" +
                                        "guisize1: 27\n" +<commit_msg>Fix class not found in test<commit_after>package xyz.upperlevel.uppercore.config;

import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.util.Vector;
import org.junit.Test;
import xyz.upperlevel.uppercore.config.parser.ConfigParserRegistry;
import xyz.upperlevel.uppercore.gui.GuiSize;

import java.io.StringReader;

import static org.junit.Assert.assertEquals;

public class BukkitTypesConfigTest {
    public static final ConfigParserRegistry registry = ConfigParserRegistry.getStandard();

    public static class ConfigLoaderExample {
        @ConfigConstructor
        public ConfigLoaderExample(@ConfigProperty("pos") Vector position,
                                   @ConfigProperty("color1")   Color color1,
                                   @ConfigProperty("color2")   Color color2,
                                   @ConfigProperty("color3")   Color color3,
                                   //@ConfigProperty("sound")    Sound sound,
                                   @ConfigProperty("mat1")     Material mat1,
                                   @ConfigProperty("mat2")     Material mat2,
                                   //@ConfigProperty("loc")      Location loc,// TODO: mock
                                   //@ConfigProperty("ench1")    Enchantment ench1,
                                   //@ConfigProperty("ench2")    Enchantment ench2,
                                   @ConfigProperty("guisize1") GuiSize guiSize1,
                                   @ConfigProperty("guisize2") GuiSize guiSize2,
                                   @ConfigProperty("patterni") PatternType patternTypeId,
                                   @ConfigProperty("patternt") PatternType patternTypeName,
                                   @ConfigProperty("pattern") Pattern pattern,
                                   @ConfigProperty("firework") FireworkEffect fireworkEffect
                                   //@ConfigProperty("playsound") PlaySound playSound
                                   //@ConfigProperty("potiont")  PotionEffectType potionEffectType,
                                   //@ConfigProperty("potione")  PotionEffect potionEffect
        ) {

            assertEquals(new Vector(31, 24, 56), position);
            assertEquals(Color.GREEN, color1);
            assertEquals(Color.WHITE, color2);
            assertEquals(Color.RED, color3);
            //assertEquals(Sound.ENTITY_RABBIT_ATTACK, sound);
            assertEquals(Material.LAPIS_BLOCK, mat1);
            assertEquals(Material.BONE, mat2);// I am the bone of my api
            // location
            //assertEquals(Enchantment.OXYGEN, ench1);
            //assertEquals(Enchantment.THORNS, ench2);
            assertEquals(GuiSize.NORMAL, guiSize1);
            assertEquals(GuiSize.DOUBLE, guiSize2);
            assertEquals(PatternType.RHOMBUS_MIDDLE, patternTypeId);
            assertEquals(PatternType.MOJANG, patternTypeName);
            assertEquals(new Pattern(DyeColor.CYAN, PatternType.FLOWER), pattern);
            assertEquals(
                    FireworkEffect.builder()
                            .flicker(true)
                            .trail(true)
                            .withColor(Color.GREEN, Color.WHITE, Color.RED)
                            .withFade(Color.AQUA)
                            .with(FireworkEffect.Type.CREEPER)
                            .build(),
                    fireworkEffect
            );
            //assertEquals(new PlaySound(fake(Sound.AMBIENT_CAVE), null, null), playSound); // TODO: Cannot mock CompatibleSound
            /*assertEquals(
                    PotionEffectType.JUMP,
                    potionEffectType
            );
            assertEquals(
                    new PotionEffect(
                            PotionEffectType.FAST_DIGGING,
                            100,
                            50,
                            true,
                            true,
                            Color.AQUA
                    ),
                    potionEffect
            );*/
        }
    }

    @Test
    public void basicTest() {
        registry.getFor(ConfigLoaderExample.class)
                .parse(
                        new StringReader(
                                "pos: [31, 24, 56]\n" +
                                        "color1: 0;128;0\n" +
                                        "color2: '#FFFFFF'\n" +
                                        "color3: red\n" +
                                        //"sound: entity rabbit attack\n" +
                                        "mat1: lapis block\n" +
                                        "mat2: bone\n" +
                                        //"loc: [main, 10, 12, 13]\n" +
                                        //"ench1: 5\n" +
                                        //"ench2: thorns\n" +
                                        "guisize1: 27\n" +
{'fraction_non_alphanumeric': 0.08654750705550329, 'fraction_numerical': 0.012417685794920037, 'mean_word_length': 1.278396913844835, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 56, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4742283', 'n_tokens_mistral': 2611, 'n_tokens_neox': 2459, 'n_words': 454}