diff --git a/src/test/java/formflow/library/config/ThymeleafConfigurationTest.java b/src/test/java/formflow/library/config/ThymeleafConfigurationLoadedTest.java similarity index 72% rename from src/test/java/formflow/library/config/ThymeleafConfigurationTest.java rename to src/test/java/formflow/library/config/ThymeleafConfigurationLoadedTest.java index 6a631d8cd..6622f709f 100644 --- a/src/test/java/formflow/library/config/ThymeleafConfigurationTest.java +++ b/src/test/java/formflow/library/config/ThymeleafConfigurationLoadedTest.java @@ -2,30 +2,26 @@ import static org.assertj.core.api.Assertions.assertThat; +import java.util.Objects; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.thymeleaf.TemplateEngine; import org.junit.jupiter.api.Test; -import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; -@SpringBootTest(classes = {ThymeleafConfiguration.class}, properties = {"form-flow.design-system.name=cfa-uswds"}) @ImportAutoConfiguration(ThymeleafAutoConfiguration.class) -class ThymeleafConfigurationTest { - - @Autowired - private ThymeleafConfiguration thymeleafConfiguration; +@SpringBootTest(classes = {ThymeleafConfiguration.class}, properties = {"form-flow.design-system.name=cfa-uswds"}) +public class ThymeleafConfigurationLoadedTest { @Autowired private TemplateEngine templateEngine; @Test void checkThatUSWDSTemplateResolverIsLoaded() { - System.out.println(templateEngine.getTemplateResolvers()); assertThat(templateEngine.getTemplateResolvers().size()).isEqualTo(2); - - assertThat(thymeleafConfiguration).isEqualTo("test"); + var uswdsResolver = templateEngine.getTemplateResolvers().stream() + .filter(x -> Objects.equals(x.getName(), "org.thymeleaf.templateresolver.ClassLoaderTemplateResolver")).findFirst(); + assertThat(uswdsResolver).isPresent(); } - } diff --git a/src/test/java/formflow/library/config/ThymeleafConfigurationUnloadedTest.java b/src/test/java/formflow/library/config/ThymeleafConfigurationUnloadedTest.java new file mode 100644 index 000000000..caee8253e --- /dev/null +++ b/src/test/java/formflow/library/config/ThymeleafConfigurationUnloadedTest.java @@ -0,0 +1,27 @@ +package formflow.library.config; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Objects; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration; +import org.springframework.boot.test.context.SpringBootTest; +import org.thymeleaf.TemplateEngine; + +@ImportAutoConfiguration(ThymeleafAutoConfiguration.class) +@SpringBootTest(classes = {ThymeleafConfiguration.class}, properties = {"form-flow.design-system.name=honeycrisp"}) +public class ThymeleafConfigurationUnloadedTest { + + @Autowired + private TemplateEngine templateEngine; + + @Test + void checkThatUSWDSTemplateResolverIsLoaded() { + assertThat(templateEngine.getTemplateResolvers().size()).isEqualTo(1); + var uswdsResolver = templateEngine.getTemplateResolvers().stream() + .filter(x -> Objects.equals(x.getName(), "org.thymeleaf.templateresolver.ClassLoaderTemplateResolver")).findFirst(); + assertThat(uswdsResolver).isNotPresent(); + } +}