package cz.jzitnik.game.logic;

import cz.jzitnik.game.annotations.CustomLogic;
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 CustomLogicProviderTest {
    @Test
    @DisplayName("All classes annotated with @CustomLogic must implement CustomLogicInterface")
    void allClassesLogicImplementLogic() {
        Reflections reflections = new Reflections("cz.jzitnik.game.logic.services");
        Set<Class<?>> handlerClasses = reflections.getTypesAnnotatedWith(CustomLogic.class);

        for (Class<?> clazz : handlerClasses) {
            boolean implementsClass = CustomLogicInterface.class.isAssignableFrom(clazz);
            assertTrue(implementsClass, "Class " + clazz.getName() + " annotated with @CustomLogic does not implement CustomLogicInterface.");
        }
    }

}
