diff --git a/src/test/java/cz/jzitnik/game/core/autotransient/AutoTransientSupportTest.java b/src/test/java/cz/jzitnik/game/core/autotransient/AutoTransientSupportTest.java new file mode 100644 index 0000000..3d0bf3d --- /dev/null +++ b/src/test/java/cz/jzitnik/game/core/autotransient/AutoTransientSupportTest.java @@ -0,0 +1,34 @@ +package cz.jzitnik.game.core.autotransient; + +import cz.jzitnik.game.annotations.AutoTransient; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.reflections.Reflections; +import org.reflections.scanners.Scanners; +import org.reflections.util.ConfigurationBuilder; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Set; + +import static org.junit.jupiter.api.Assertions.*; + +class AutoTransientSupportTest { + @Test + @DisplayName("All fields annotated with @AutoTransient must be transient.") + void checkAutoTransientAnnotation() { + Reflections reflections = new Reflections( + new ConfigurationBuilder() + .forPackages("cz.jzitnik.game") + .addScanners(Scanners.FieldsAnnotated) // Explicitly add the scanner for fields + ); + Set fields = reflections.getFieldsAnnotatedWith(AutoTransient.class); + + for (Field field : fields) { + if (!Modifier.isTransient(field.getModifiers())) { + fail("Field '" + field.getName() + "' in class " + field.getClass().getName() + + " is annotated with @AutoTransient but is not transient."); + } + } + } +} \ No newline at end of file diff --git a/src/test/java/cz/jzitnik/game/threads/ThreadProviderTest.java b/src/test/java/cz/jzitnik/game/threads/ThreadProviderTest.java new file mode 100644 index 0000000..5af6f5b --- /dev/null +++ b/src/test/java/cz/jzitnik/game/threads/ThreadProviderTest.java @@ -0,0 +1,25 @@ +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> 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."); + } + } + } +} \ No newline at end of file