package cz.jzitnik.game.logic.services.saplings;

import cz.jzitnik.game.annotations.BlockRegistry;
import cz.jzitnik.game.annotations.Sapling;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.reflections.Reflections;

import java.util.Set;
import static org.junit.jupiter.api.Assertions.*;

class SaplingLogicTest {
    @Test
    @DisplayName("All blocks annoteted with @Sapling must be annotated with @BlockRegistry")
    void allBlocksMustExist() {
        Reflections reflections = new Reflections("cz.jzitnik.game.entities.items.registry.blocks");
        Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(Sapling.class);

        for (Class<?> clazz : handlerClasses) {
            var hasClass = clazz.isAnnotationPresent(BlockRegistry.class);
            assertTrue(hasClass, "Class " + clazz.getName() + " annotated with @Sapling is not annotated with @BlockRegistry.");
        }
    }
}