package cz.jzitnik.game.threads;

import cz.jzitnik.game.annotations.ThreadRegistry;
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 ThreadProviderTest {
    @Test
    @DisplayName("All classes annotated with @ThreadRegistry must extend Thread")
    void threadRegistryTest() {
        Reflections reflections = new Reflections("cz.jzitnik.game.threads.list");
        Set<Class<?>> classes = reflections.getTypesAnnotatedWith(ThreadRegistry.class);

        for (Class<?> clazz : classes) {
            if (!Thread.class.isAssignableFrom(clazz)) {
                fail("Class " + clazz.getName() + " is annotated with @ThreadRegistry but does not extend Thread.");
            }
        }
    }
}