Source:
<code>public void testWithAppEnricher() throws Exception { Entity app = createAndStartApplication("test-app-with-enricher.yaml"); waitForApplicationTasks(app); <START> Assert.assertEquals(app.getDisplayName(), "test-app-with-enricher"); <END> log.info("App started:"); Entities.dumpInfo(app); Assert.assertEquals(app.getEnrichers().size(), 1); final Enricher enricher = app.getEnrichers().iterator().next(); Assert.assertTrue(enricher instanceof TestEnricher); Assert.assertEquals(enricher.getConfig(TestEnricher.CONF_NAME), "Name from YAML"); Assert.assertEquals(enricher.getConfig(TestEnricher.CONF_FROM_FUNCTION), "$brooklyn: is a fun place"); Entity target = ((EntityInternal)app).getExecutionContext().submit(MutableMap.of(), new Callable<Entity>() { public Entity call() { return enricher.getConfig(TestEnricher.TARGET_ENTITY); }}).get(); Assert.assertNotNull(target); Assert.assertEquals(target.getDisplayName(), "testentity"); Assert.assertEquals(target, app.getChildren().iterator().next()); Entity targetFromFlag = ((EntityInternal)app).getExecutionContext().submit(MutableMap.of(), new Callable<Entity>() { public Entity call() { return enricher.getConfig(TestEnricher.TARGET_ENTITY_FROM_FLAG); }}).get(); Assert.assertEquals(targetFromFlag, target); Map<?, ?> leftoverProperties = ((TestEnricher) enricher).getLeftoverProperties(); Assert.assertEquals(leftoverProperties.get("enricherLiteralValue1"), "Hello"); Assert.assertEquals(leftoverProperties.get("enricherLiteralValue2"), "World"); Assert.assertEquals(leftoverProperties.size(), 2); }</code><technical_language>Note for future: do this assertion in lots of tests - a single test app display name set suffice. Guessing apply for some other assertions in there. strong feelings</technical_language>

Target:
public void testWithAppEnricher() throws Exception { Entity app = createAndStartApplication("test-app-with-enricher.yaml"); waitForApplicationTasks(app); Assert.assertEquals(app.getDisplayName(), "test-app-with-enricher"); log.info("App started:"); Entities.dumpInfo(app); Assert.assertEquals(app.getEnrichers().size(), 1); final Enricher enricher = app.getEnrichers().iterator().next(); Assert.assertTrue(enricher instanceof TestEnricher, "enricher="+enricher); Assert.assertEquals(enricher.getConfig(TestEnricher.CONF_NAME), "Name from YAML"); Assert.assertEquals(enricher.getConfig(TestEnricher.CONF_FROM_FUNCTION), "$brooklyn: is a fun place"); Entity target = ((EntityInternal)app).getExecutionContext().submit(MutableMap.of(), new Callable<Entity>() { public Entity call() { return enricher.getConfig(TestEnricher.TARGET_ENTITY); }}).get(); Assert.assertNotNull(target); Assert.assertEquals(target.getDisplayName(), "testentity"); Assert.assertEquals(target, app.getChildren().iterator().next()); Entity targetFromFlag = ((EntityInternal)app).getExecutionContext().submit(MutableMap.of(), new Callable<Entity>() { public Entity call() { return enricher.getConfig(TestEnricher.TARGET_ENTITY_FROM_FLAG); }}).get(); Assert.assertEquals(targetFromFlag, target); Map<?, ?> leftoverProperties = ((TestEnricher) enricher).getLeftoverProperties(); Assert.assertEquals(leftoverProperties.get("enricherLiteralValue1"), "Hello"); Assert.assertEquals(leftoverProperties.get("enricherLiteralValue2"), "World"); Assert.assertEquals(leftoverProperties.size(), 2); }