From d694822761d0fcc96fa38ef3b3e24423a6adb005 Mon Sep 17 00:00:00 2001 From: Kamil Patryk Kozakowski Date: Sun, 20 Jul 2025 07:45:43 +0200 Subject: [PATCH] better tests style --- .../ast/in/AstFileFinderTest.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/test/java/click/kamil/springstatemachineexporter/ast/in/AstFileFinderTest.java b/src/test/java/click/kamil/springstatemachineexporter/ast/in/AstFileFinderTest.java index a916044..b3c930a 100644 --- a/src/test/java/click/kamil/springstatemachineexporter/ast/in/AstFileFinderTest.java +++ b/src/test/java/click/kamil/springstatemachineexporter/ast/in/AstFileFinderTest.java @@ -2,7 +2,6 @@ package click.kamil.springstatemachineexporter.ast.in; import org.junit.jupiter.api.Test; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -98,7 +97,7 @@ class AstFileFinderTest { @Test void shouldReturnTrue_whenClassHasMatchingAnnotation() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_ANNOTATION); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_ANNOTATION, annotationNames); @@ -108,7 +107,7 @@ class AstFileFinderTest { @Test void shouldReturnTrue_whenClassHasMultipleMatchingAnnotations() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_MULTIPLE_ANNOTATIONS); - List annotationNames = Arrays.asList("Service", "Component"); + List annotationNames = List.of("Service", "Component"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_MULTIPLE_ANNOTATIONS, annotationNames); @@ -118,7 +117,7 @@ class AstFileFinderTest { @Test void shouldReturnFalse_whenClassHasNoAnnotation() { AstFileFinder finder = new AstFileFinder(CLASS_WITHOUT_ANNOTATION); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(CLASS_WITHOUT_ANNOTATION, annotationNames); @@ -128,7 +127,7 @@ class AstFileFinderTest { @Test void shouldReturnFalse_whenClassHasDifferentAnnotation() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_DIFFERENT_ANNOTATION); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_DIFFERENT_ANNOTATION, annotationNames); @@ -138,7 +137,7 @@ class AstFileFinderTest { @Test void shouldReturnTrue_whenClassHasFullyQualifiedAnnotation() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_FULLY_QUALIFIED_ANNOTATION); - List annotationNames = Arrays.asList("org.springframework.stereotype.Service"); + List annotationNames = List.of("org.springframework.stereotype.Service"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_FULLY_QUALIFIED_ANNOTATION, annotationNames); @@ -148,7 +147,7 @@ class AstFileFinderTest { @Test void shouldReturnTrue_whenMultipleClassesAndOneHasAnnotation() { AstFileFinder finder = new AstFileFinder(MULTIPLE_CLASSES); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(MULTIPLE_CLASSES, annotationNames); @@ -158,7 +157,7 @@ class AstFileFinderTest { @Test void shouldReturnFalse_whenInterfaceHasAnnotation() { AstFileFinder finder = new AstFileFinder(INTERFACE_WITH_ANNOTATION); - List annotationNames = Arrays.asList("FunctionalInterface"); + List annotationNames = List.of("FunctionalInterface"); boolean result = finder.hasClassWithAnnotation(INTERFACE_WITH_ANNOTATION, annotationNames); @@ -178,7 +177,7 @@ class AstFileFinderTest { @Test void shouldReturnFalse_whenEmptySource() { AstFileFinder finder = new AstFileFinder(EMPTY_SOURCE); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(EMPTY_SOURCE, annotationNames); @@ -198,7 +197,7 @@ class AstFileFinderTest { @Test void shouldReturnTrue_whenClassHasAnnotationAndFields() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_ANNOTATION_AND_FIELDS); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_ANNOTATION_AND_FIELDS, annotationNames); @@ -208,7 +207,7 @@ class AstFileFinderTest { @Test void shouldHandleInvalidJavaSyntax() { AstFileFinder finder = new AstFileFinder(INVALID_JAVA_SYNTAX); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(INVALID_JAVA_SYNTAX, annotationNames); @@ -220,7 +219,7 @@ class AstFileFinderTest { @Test void shouldReturnTrue_whenAnnotationNameMatchesCaseInsensitive() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_ANNOTATION); - List annotationNames = Arrays.asList("service"); // lowercase + List annotationNames = List.of("service"); // lowercase boolean result = finder.hasClassWithAnnotation(CLASS_WITH_ANNOTATION, annotationNames); @@ -230,7 +229,7 @@ class AstFileFinderTest { @Test void shouldReturnTrue_whenMultipleAnnotationNamesProvided() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_ANNOTATION); - List annotationNames = Arrays.asList("Component", "Service", "Repository"); + List annotationNames = List.of("Component", "Service", "Repository"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_ANNOTATION, annotationNames); @@ -240,7 +239,7 @@ class AstFileFinderTest { @Test void shouldReturnFalse_whenNoMatchingAnnotationNames() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_ANNOTATION); - List annotationNames = Arrays.asList("Component", "Repository", "Controller"); + List annotationNames = List.of("Component", "Repository", "Controller"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_ANNOTATION, annotationNames); @@ -255,7 +254,7 @@ class AstFileFinderTest { /** JavaDoc comment */ """; AstFileFinder finder = new AstFileFinder(sourceWithComments); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(sourceWithComments, annotationNames); @@ -266,7 +265,7 @@ class AstFileFinderTest { void shouldReturnFalse_whenSourceContainsOnlyPackageDeclaration() { String sourceWithPackage = "package com.example;"; AstFileFinder finder = new AstFileFinder(sourceWithPackage); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(sourceWithPackage, annotationNames); @@ -284,7 +283,7 @@ class AstFileFinderTest { } """; AstFileFinder finder = new AstFileFinder(classWithAnnotatedParams); - List annotationNames = Arrays.asList("Service"); + List annotationNames = List.of("Service"); boolean result = finder.hasClassWithAnnotation(classWithAnnotatedParams, annotationNames); @@ -294,7 +293,7 @@ class AstFileFinderTest { @Test void shouldReturnFalse_whenAnnotationListContainsNull() { AstFileFinder finder = new AstFileFinder(CLASS_WITH_ANNOTATION); - List annotationNames = Arrays.asList("Service", null, "Component"); + List annotationNames = List.of("Service", null, "Component"); boolean result = finder.hasClassWithAnnotation(CLASS_WITH_ANNOTATION, annotationNames);