### Question:
ConfigurationFactory { public Configuration getConfiguration(Collection<Map<String, String>> configProperties) { Map<String, Map<String, String>> properties = new HashMap<>(); Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>(); Configuration configuration = new Configuration(properties, attributes); if (configProperties != null) { for (Map<String, String> typeMap : configProperties) { ConfigurationStrategy strategy = decidePopulationStrategy(typeMap); for (Map.Entry<String, String> entry : typeMap.entrySet()) { String[] propertyNameTokens = entry.getKey().split("/"); strategy.setConfiguration(configuration, propertyNameTokens, entry.getValue()); } } } return configuration; }  Configuration getConfiguration(Collection<Map<String, String>> configProperties);  }### Answer:
@Test public void testOldSyntax() throws Exception { ConfigurationFactory factory = new ConfigurationFactory(); Configuration configuration = factory.getConfiguration(getOldSyntaxConfigProps()); assertEquals(2, configuration.getProperties().size()); Map<String, String> configProperties1 = configuration.getProperties().get("foo-type"); assertEquals(2, configProperties1.size()); assertEquals("prop1Value", configProperties1.get("prop1")); assertEquals("prop2Value", configProperties1.get("prop2")); Map<String, String> configProperties2 = configuration.getProperties().get("bar-type"); assertEquals(1, configProperties2.size()); assertEquals("prop3Value", configProperties2.get("prop3")); assertTrue(configuration.getAttributes().isEmpty()); }
@Test public void testNewSyntax() throws Exception { ConfigurationFactory factory = new ConfigurationFactory(); Configuration configuration = factory.getConfiguration(getNewSyntaxConfigProps()); Map<String, Map<String, String>> properties = configuration.getProperties(); assertEquals(2, properties.size()); Map<String, String> configProperties1 = properties.get("foo-type"); assertEquals(2, configProperties1.size()); assertEquals("prop1Value", configProperties1.get("prop1")); assertEquals("prop2Value", configProperties1.get("prop2")); Map<String, String> configProperties2 = properties.get("bar-type"); assertEquals(1, configProperties2.size()); assertEquals("prop3Value", configProperties2.get("prop3")); Map<String, Map<String, Map<String, String>>> attributes = configuration.getAttributes(); assertEquals(2, attributes.size()); Map<String, Map<String, String>> configType1Attributes = attributes.get("foo-type"); assertEquals(2, configType1Attributes.size()); Map<String, String> configType1Prop1Attributes = configType1Attributes.get("attribute1"); assertEquals(3, configType1Prop1Attributes.size()); assertEquals("attribute1-prop1-value", configType1Prop1Attributes.get("prop1")); assertEquals("attribute1-prop2-value", configType1Prop1Attributes.get("prop2")); assertEquals("attribute1-prop3-value", configType1Prop1Attributes.get("prop3")); Map<String, String> configType1Prop2Attributes = configType1Attributes.get("attribute2"); assertEquals(1, configType1Prop2Attributes.size()); assertEquals("attribute2-prop1-value", configType1Prop2Attributes.get("prop1")); Map<String, Map<String, String>> configType2Attributes = attributes.get("foobar-type"); assertEquals(2, configType2Attributes.size()); Map<String, String> configType2Prop1Attributes = configType2Attributes.get("attribute1"); assertEquals(1, configType2Prop1Attributes.size()); assertEquals("attribute1-prop10-value", configType2Prop1Attributes.get("prop10")); Map<String, String> configType2Prop2Attributes = configType2Attributes.get("attribute10"); assertEquals(1, configType2Prop2Attributes.size()); assertEquals("attribute10-prop11-value", configType2Prop2Attributes.get("prop11")); }