forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qute: fix handling of missing properties in strict mode
- fixes quarkusio#44674
- Loading branch information
Showing
3 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
independent-projects/qute/core/src/test/java/io/quarkus/qute/LetTimeoutTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package io.quarkus.qute; | ||
|
||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Tests based on the description from | ||
* <a href="https://github.com/quarkusio/quarkus/issues/44674">https://github.com/quarkusio/quarkus/issues/44674</a>. | ||
*/ | ||
public class LetTimeoutTest { | ||
|
||
Engine engine = Engine.builder().addDefaults().build(); | ||
|
||
private static final Map<String, Object> DATA = Map.of( | ||
"a", Map.of("b", Map.of())); | ||
|
||
@Test | ||
void withDataFactoryMethod() { | ||
TemplateInstance instance = engine.parse(""" | ||
{#let b = a.b} | ||
{c} | ||
{/let} | ||
""").data(DATA); | ||
|
||
assertThatThrownBy(instance::render) | ||
.isInstanceOf(TemplateException.class) | ||
.hasRootCauseMessage("Rendering error: Key \"c\" not found in the map with keys [a] in expression {c}"); | ||
} | ||
|
||
@Test | ||
void withInstanceThenDataForEachEntry() { | ||
TemplateInstance instance = engine.parse(""" | ||
{#let b=a.b} | ||
{c} | ||
{/let} | ||
""").instance(); | ||
for (var e : DATA.entrySet()) { | ||
instance.data(e.getKey(), e.getValue()); | ||
} | ||
assertThatThrownBy(instance::render) | ||
.isInstanceOf(TemplateException.class) | ||
.hasRootCauseMessage( | ||
"Rendering error: Key \"c\" not found in the template data map with keys [a] in expression {c}"); | ||
} | ||
|
||
@Test | ||
void withSet_withInstanceThenDataForEachEntry() { | ||
TemplateInstance instance = engine.parse(""" | ||
{#set b = a.b} | ||
{c} | ||
{/set} | ||
""").instance(); | ||
for (var e : DATA.entrySet()) { | ||
instance.data(e.getKey(), e.getValue()); | ||
} | ||
assertThatThrownBy(instance::render) | ||
.isInstanceOf(TemplateException.class) | ||
.hasRootCauseMessage( | ||
"Rendering error: Key \"c\" not found in the template data map with keys [a] in expression {c}"); | ||
} | ||
|
||
@Test | ||
void withLetWithoutEndTagwithInstanceThenDataForEachEntry() { | ||
TemplateInstance instance = engine.parse(""" | ||
{#let b = a.b} | ||
{c} | ||
""").instance(); | ||
for (var e : DATA.entrySet()) { | ||
instance.data(e.getKey(), e.getValue()); | ||
} | ||
assertThatThrownBy(instance::render) | ||
.isInstanceOf(TemplateException.class) | ||
.hasRootCauseMessage( | ||
"Rendering error: Key \"c\" not found in the template data map with keys [a] in expression {c}"); | ||
} | ||
} |