From 3d45c9b61e66391ed38b4b3586152d0ba93a1000 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Fri, 6 Sep 2024 21:08:30 +0200 Subject: [PATCH] Qute: fix unsatisfied exception when recording rendered results is off --- .../qute/deployment/test/RenderedResultsDisabledTest.java | 6 ++++++ .../main/java/io/quarkus/qute/runtime/TemplateProducer.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/test/RenderedResultsDisabledTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/test/RenderedResultsDisabledTest.java index 867778d4ee832..805586405f21a 100644 --- a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/test/RenderedResultsDisabledTest.java +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/test/RenderedResultsDisabledTest.java @@ -1,5 +1,6 @@ package io.quarkus.qute.deployment.test; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import jakarta.enterprise.inject.Instance; @@ -10,6 +11,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; import io.quarkus.qute.RenderedResults; +import io.quarkus.qute.Template; import io.quarkus.test.QuarkusUnitTest; public class RenderedResultsDisabledTest { @@ -25,9 +27,13 @@ public class RenderedResultsDisabledTest { @Inject Instance renderedResults; + @Inject + Template foo; + @Test public void testRenderedResultsNotRegistered() { assertTrue(renderedResults.isUnsatisfied()); + assertEquals("Morna", foo.data("name", "Morna").render()); } } diff --git a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java index 55cf3151aec9a..ae7d0519d5e94 100644 --- a/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java +++ b/extensions/qute/runtime/src/main/java/io/quarkus/qute/runtime/TemplateProducer.java @@ -68,7 +68,7 @@ public class TemplateProducer { templateVariants.put(entry.getKey(), var); } this.templateVariants = Collections.unmodifiableMap(templateVariants); - this.renderedResults = launchMode == LaunchMode.TEST ? renderedResults.get() : null; + this.renderedResults = launchMode == LaunchMode.TEST && renderedResults.isResolvable() ? renderedResults.get() : null; this.injectedTemplates = launchMode == LaunchMode.DEVELOPMENT ? Collections.synchronizedList(new ArrayList<>()) : null; LOGGER.debugf("Initializing Qute variant templates: %s", templateVariants); }