@Test public void testJoinerUnquoted() { entity.sensors().set(LIST_SENSOR, MutableList.<String>of("a", "\"b", "ccc").append(null)); entity.enrichers().add(Enrichers.builder() .joining(LIST_SENSOR) .publishing(TestEntity.NAME) .minimum(1) .maximum(2) .separator(":") .quote(false) .build()); // in this case, it should be immediately available upon adding the enricher EntityAsserts.assertAttributeEquals(entity, TestEntity.NAME, "a:\"b"); // empty list causes null here, because below the minimum entity.sensors().set(LIST_SENSOR, MutableList.<String>of().append(null)); EntityAsserts.assertAttributeEqualsEventually(entity, TestEntity.NAME, null); }
@Test public void testJoinerMinMax() { entity.enrichers().add(Enrichers.builder() .joining(LIST_SENSOR) .publishing(TestEntity.NAME) .minimum(2) .maximum(4) .quote(false) .build()); // null values ignored, and it quotes entity.sensors().set(LIST_SENSOR, MutableList.<String>of("a", "b")); EntityAsserts.assertAttributeEqualsEventually(entity, TestEntity.NAME, "a,b"); // empty list causes "" entity.sensors().set(LIST_SENSOR, MutableList.<String>of("x")); EntityAsserts.assertAttributeEqualsEventually(entity, TestEntity.NAME, null); // null causes null entity.sensors().set(LIST_SENSOR, MutableList.<String>of("a", "b", "c", "d", "e")); EntityAsserts.assertAttributeEqualsEventually(entity, TestEntity.NAME, "a,b,c,d"); }
@Override protected void initEnrichers() { super.initEnrichers(); EnricherSpec<?> zks = Enrichers.builder() .aggregating(ZooKeeperNode.ZOOKEEPER_ENDPOINT) .publishing(ZOOKEEPER_SERVERS) .fromMembers() .build(); EnricherSpec<?> zke = Enrichers.builder() .joining(ZOOKEEPER_SERVERS) .publishing(ZOOKEEPER_ENDPOINTS) .quote(false) .separator(",") .build(); enrichers().add(zks); enrichers().add(zke); }