-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve: double brackets to handle non string values in object templates
Signed-off-by: Attila Mészáros <[email protected]>
- Loading branch information
Showing
5 changed files
with
55 additions
and
8 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
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
26 changes: 25 additions & 1 deletion
26
src/test/java/io/javaoperatorsdk/operator/glue/templating/GenericTemplateHandlerTest.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 |
---|---|---|
@@ -1,14 +1,38 @@ | ||
package io.javaoperatorsdk.operator.glue.templating; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.fabric8.kubernetes.client.utils.Serialization; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class GenericTemplateHandlerTest { | ||
|
||
GenericTemplateHandler templateHandler = new GenericTemplateHandler(); | ||
|
||
@Test | ||
void testDoubleCurlyBrackets() { | ||
fail(); | ||
var template = """ | ||
intValue: "{{spec.intvalue}}" | ||
stringValue: "{spec.stringvalue}" | ||
"""; | ||
|
||
Map<String, Map<?, ?>> data = new HashMap<>(); | ||
|
||
Map values = new HashMap(); | ||
values.put("intvalue", 1); | ||
values.put("stringvalue", "value1"); | ||
data.put("spec", values); | ||
|
||
var result = templateHandler.processTemplate(data, template, true); | ||
|
||
Map mapResult = Serialization.unmarshal(result, Map.class); | ||
|
||
assertEquals(1, mapResult.get("intValue")); | ||
assertEquals("value1", mapResult.get("stringValue")); | ||
} | ||
|
||
} |
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