protected void addChildren(RebindContext rebindContext, EntityMemento memento) { for (String childId : memento.getChildren()) { Entity child = rebindContext.lookup().lookupEntity(childId); if (child != null) { entity.addChild(proxy(child)); } else { LOG.warn("Entity not found; discarding child {} of entity {}({})", new Object[] {childId, memento.getType(), memento.getId()}); } } }
@Test public void testMergesDeprecatedKeyFromRuntimeParent() throws Exception { EntityInternal entity = app.addChild(EntitySpec.create(TestEntity.class) .configure("oldConfMapDeepMerge", ImmutableMap.of("mykey", "myval"))); EntityInternal child = entity.addChild(EntitySpec.create(MyEntity.class) .configure("oldConfMapDeepMerge", ImmutableMap.of("mykey2", "myval2"))); assertEquals(child.config().get(MyEntity.CONF_MAP_DEEP_MERGE), ImmutableMap.of("mykey", "myval", "mykey2", "myval2")); }
@Test public void testMergesDeprecatedKeyFromRuntimeParentWithOwn() throws Exception { EntityInternal entity = app.addChild(EntitySpec.create(TestEntity.class) .configure("oldConfMapDeepMerge", ImmutableMap.of("mykey", "myval"))); EntityInternal child = entity.addChild(EntitySpec.create(MyEntity.class) .configure("confMapDeepMerge", ImmutableMap.of("mykey2", "myval2"))); assertEquals(child.config().get(MyEntity.CONF_MAP_DEEP_MERGE), ImmutableMap.of("mykey", "myval", "mykey2", "myval2")); }
@Test public void testMergesKeyFromRuntimeParentWithOwnDeprecated() throws Exception { EntityInternal entity = app.addChild(EntitySpec.create(TestEntity.class) .configure("confMapDeepMerge", ImmutableMap.of("mykey", "myval"))); EntityInternal child = entity.addChild(EntitySpec.create(MyEntity.class) .configure("oldConfMapDeepMerge", ImmutableMap.of("mykey2", "myval2"))); assertEquals(child.config().get(MyEntity.CONF_MAP_DEEP_MERGE), ImmutableMap.of("mykey", "myval", "mykey2", "myval2")); }
@Test public void testInheritsDeprecatedKeyFromRuntimeParent() throws Exception { EntityInternal entity = app.addChild(EntitySpec.create(TestEntity.class) .configure("oldConfMapDeepMerge", ImmutableMap.of("mykey", "myval")) .configure("oldConfMapNotReinherited", ImmutableMap.of("mykey", "myval"))); EntityInternal child = entity.addChild(EntitySpec.create(MyEntity.class)); assertEquals(child.config().get(MyEntity.CONF_MAP_DEEP_MERGE), ImmutableMap.of("mykey", "myval")); assertEquals(child.config().get(MyEntity.CONF_MAP_NOT_REINHERITED), ImmutableMap.of("mykey", "myval")); }
@Test public void testDeprecatedKeyNotReinheritedIfNotSupposedToBe() throws Exception { EntityInternal entity = app.addChild(EntitySpec.create(MyEntity.class) .configure("oldConfMapNotReinherited", ImmutableMap.of("mykey", "myval"))); EntityInternal child = entity.addChild(EntitySpec.create(MyEntity.class)); assertEquals(entity.config().get(MyEntity.CONF_MAP_NOT_REINHERITED), ImmutableMap.of("mykey", "myval")); assertEquals(child.config().get(MyEntity.CONF_MAP_NOT_REINHERITED), null); }
@Test public void testInheritsDeprecatedKeyFromRuntimeParent() throws Exception { EntityInternal entity = app.addChild(EntitySpec.create(TestEntity.class) .configure("oldSuperKey1", "myval")); EntityInternal child = entity.addChild(EntitySpec.create(MyBaseEntity.class)); assertEquals(child.config().get(MyBaseEntity.SUPER_KEY_1), "myval"); }
final Entity dryRunChild = entity().addChild(createDryRunSpec() .displayName("Upgraded Version Dry-Run Node")