PropertyBag { public Iterator<Map.Entry<String, String>> getPropertiesIterator() { return Optional.ofNullable(properties) .map(props -> props.entrySet().stream() .map(entry -> (Map.Entry<String, String>) new AbstractMap.SimpleEntry<>(entry.getKey(), entry.getValue() != null ? entry.getValue().get(0) : null)) .iterator()) .orElse(Collections.emptyIterator()); } private  PropertyBag(final String topicWithoutPropertyBag, final Map<String, List<String>> properties); static PropertyBag fromTopic(final String topic); String getProperty(final String name); Iterator<Map.Entry<String, String>> getPropertiesIterator(); String topicWithoutPropertyBag();  }
@Test public void testGetPropertiesIterator() { final PropertyBag propertyBag = PropertyBag.fromTopic("event/tenant/device/?param1=30&param2=value2"); assertNotNull(propertyBag); final Iterator<Map.Entry<String, String>> propertiesIterator = propertyBag.getPropertiesIterator(); final Map<String, String> tmpMap = new HashMap<>(); propertiesIterator.forEachRemaining((entry) -> tmpMap.put(entry.getKey(), entry.getValue())); assertEquals(2, tmpMap.size()); assertEquals("30", tmpMap.get("param1")); assertEquals("value2", tmpMap.get("param2")); }