From a0c128039ff689fbc967df4b2ec43317eac40189 Mon Sep 17 00:00:00 2001 From: Martin Kouba Date: Tue, 13 Jun 2023 15:09:46 +0200 Subject: [PATCH] Qute: add MapTemplateExtensionsTest --- .../extensions/MapTemplateExtensionsTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/MapTemplateExtensionsTest.java diff --git a/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/MapTemplateExtensionsTest.java b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/MapTemplateExtensionsTest.java new file mode 100644 index 0000000000000..d2fb6dff0e675 --- /dev/null +++ b/extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/extensions/MapTemplateExtensionsTest.java @@ -0,0 +1,36 @@ +package io.quarkus.qute.deployment.extensions; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Map; + +import org.jboss.shrinkwrap.api.asset.StringAsset; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.qute.CheckedTemplate; +import io.quarkus.qute.TemplateInstance; +import io.quarkus.test.QuarkusUnitTest; + +public class MapTemplateExtensionsTest { + + @RegisterExtension + static final QuarkusUnitTest config = new QuarkusUnitTest() + .withApplicationRoot(root -> root + .addClass(Templates.class) + .addAsResource(new StringAsset( + "{map.foo}::{map['bar']}::{map.keys}::{map.empty}::{map.get('foo')}"), + "templates/map.html")); + + @Test + public void testMap() { + assertEquals("1::5::[foo, bar]::false::1", Templates.map(Map.of("foo", 1, "bar", 5)).render()); + } + + @CheckedTemplate(basePath = "") + public static class Templates { + + static native TemplateInstance map(Map map); + } + +}