[
https://issues.apache.org/jira/browse/BROOKLYN-542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16194572#comment-16194572
]
ASF GitHub Bot commented on BROOKLYN-542:
-----------------------------------------
Github user aledsage commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/855#discussion_r143186317
--- Diff:
core/src/test/java/org/apache/brooklyn/util/core/text/TemplateProcessorTest.java
---
@@ -247,4 +251,40 @@ public void testDotSeparatedKeyCollisionFailure() {
}
}
+ @Test
+ public void testBuiltInsForLists() {
+ AttributeSensor<List> sensor1 = Sensors.newSensor(List.class,
"list");
+ TestEntity entity =
app.createAndManageChild(EntitySpec.create(TestEntity.class));
+ entity.sensors().set(sensor1, ImmutableList.of("first", "second"));
+ String templateContents = Joiner.on("\n").join(
+ "<#list attribute['list'] as l>",
+ "${l}",
+ "</#list>");
+ String result =
TemplateProcessor.processTemplateContents(templateContents, entity,
ImmutableMap.<String,Object>of());
+ assertEquals(result.trim(), "first\nsecond");
+ }
+
+ /**
+ * Based on http://freemarker.org/docs/ref_builtins_hash.html
+ */
+ @Test
+ public void testBuiltInsForHashes() {
+ AttributeSensor<Map> sensor1 = Sensors.newSensor(Map.class, "map");
+ TestEntity entity =
app.createAndManageChild(EntitySpec.create(TestEntity.class));
+ entity.sensors().set(sensor1, ImmutableMap.of("name", "mouse",
"price", 50));
+ String keys = Joiner.on("\n").join(
+ "<#list attribute['map']?keys as k>",
+ "${k}",
+ "</#list>");
+ String resultForKeys =
TemplateProcessor.processTemplateContents(keys, entity, ImmutableMap.of());
+ assertEquals(resultForKeys.trim(), "name\nprice");
+
+ String values = Joiner.on("\n").join(
+ "<#list attribute['map']?keys as k>",
--- End diff --
I think this should say `?values...`
> Can't use a Freemarker template hashes in a blueprint
> -----------------------------------------------------
>
> Key: BROOKLYN-542
> URL: https://issues.apache.org/jira/browse/BROOKLYN-542
> Project: Brooklyn
> Issue Type: Bug
> Affects Versions: 0.12.0
> Reporter: Andrea Turli
> Assignee: Andrea Turli
>
> It is not possible to use http://freemarker.org/docs/ref_builtins_hash.html
> in a brooklyn blueprint
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)