Skip to content
Permalink
Browse files
fix transformation of values which are Sets
fixing test failure introduced, and expand test coverage;
the problem was not introduced here, but i think it was hidden
because we weren't transforming values in some cases.
presumably now we are transforming better+more,
and with this we're also transforming Set instances correctly.
  • Loading branch information
ahgittin committed Jan 14, 2016
1 parent a8644cd commit 50b3c22c00f0741b01ec720961308105df89d337
Showing 3 changed files with 20 additions and 11 deletions.
@@ -333,7 +333,7 @@ public Object apply(Object input) {
if (input instanceof Map)
return transformSpecialFlags((Map<?, ?>)input);
else if (input instanceof Set<?>)
return MutableSet.of(transformSpecialFlags((Iterable<?>)input));
return MutableSet.copyOf(transformSpecialFlags((Iterable<?>)input));
else if (input instanceof List<?>)
return MutableList.copyOf(transformSpecialFlags((Iterable<?>)input));
else if (input instanceof Iterable<?>)
@@ -102,7 +102,6 @@ public void testSingleEntity() throws Exception {
setupAndCheckTestEntityInBasicYamlWith();
}

@SuppressWarnings("unchecked")
@Test
public void testBrooklynConfig() throws Exception {
Entity testEntity = setupAndCheckTestEntityInBasicYamlWith(
@@ -115,21 +114,31 @@ public void testBrooklynConfig() throws Exception {
" - dogs",
" - cats",
" - badgers",
" test.confSetPlain: !!set",
" ? square",
" ? circle",
" ? triangle",
" test.confMapThing:",
" foo: bar",
" baz: qux",
" test.confListThing:",
" - dogs",
" - cats",
" - badgers",
" test.confSetThing: !!set",
" ? square",
" ? circle",
" ? triangle",
" test.confObject: 5");

Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_NAME), "Test Entity Name");
List<String> list = testEntity.getConfig(TestEntity.CONF_LIST_PLAIN);
Assert.assertEquals(list, ImmutableList.of("dogs", "cats", "badgers"));
Map<String, String> map = testEntity.getConfig(TestEntity.CONF_MAP_PLAIN);
Assert.assertEquals(map, ImmutableMap.of("foo", "bar", "baz", "qux"));
Set<String> set = (Set<String>)testEntity.getConfig(TestEntity.CONF_SET_THING);
Assert.assertEquals(set, ImmutableSet.of("square", "circle", "triangle"));
Object object = testEntity.getConfig(TestEntity.CONF_OBJECT);
Assert.assertEquals(object, 5);
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_OBJECT), 5);
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_LIST_PLAIN), ImmutableList.of("dogs", "cats", "badgers"));
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_MAP_PLAIN), ImmutableMap.of("foo", "bar", "baz", "qux"));
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_SET_PLAIN), ImmutableSet.of("square", "circle", "triangle"));
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("dogs", "cats", "badgers"));
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_MAP_THING), ImmutableMap.of("foo", "bar", "baz", "qux"));
Assert.assertEquals(testEntity.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("square", "circle", "triangle"));
}

@Test
@@ -258,7 +258,7 @@ private static void mergeWrapperParentSpecToChildEntity(EntitySpec<? extends App
wrappedChild.catalogItemId(wrapperParent.getCatalogItemId());
}

// NB: this clobber's child config; might prefer to deeply merge maps etc
// NB: this clobber's child config wherever they conflict; might prefer to deeply merge maps etc
// (or maybe even prevent the merge in these cases;
// not sure there is a compelling reason to have config on a pure-wrapper parent)
Map<ConfigKey<?>, Object> configWithoutWrapperMarker = Maps.filterKeys(wrapperParent.getConfig(), Predicates.not(Predicates.<ConfigKey<?>>equalTo(EntityManagementUtils.WRAPPER_APP_MARKER)));

0 comments on commit 50b3c22

Please sign in to comment.