### Question:
StackAdvisorResourceProvider extends ReadOnlyResourceProvider { protected Map<String, Map<String, Map<String, String>>> calculateConfigurations(Request request) { Map<String, Map<String, Map<String, String>>> configurations = new HashMap<>(); Map<String, Object> properties = request.getProperties().iterator().next(); for (String property : properties.keySet()) { if (property.startsWith(CONFIGURATIONS_PROPERTY_ID)) { try { String propertyEnd = property.substring(CONFIGURATIONS_PROPERTY_ID.length()); String[] propertyPath = propertyEnd.split("/"); String siteName = propertyPath[0]; String propertiesProperty = propertyPath[1]; String propertyName = propertyPath[2]; Map<String, Map<String, String>> siteMap = configurations.get(siteName); if (siteMap == null) { siteMap = new HashMap<>(); configurations.put(siteName, siteMap); } Map<String, String> propertiesMap = siteMap.get(propertiesProperty); if (propertiesMap == null) { propertiesMap = new HashMap<>(); siteMap.put(propertiesProperty, propertiesMap); } Object propVal = properties.get(property); if (propVal != null) propertiesMap.put(propertyName, propVal.toString()); else LOG.info(String.format("No value specified for configuration property, name = %s ", property)); } catch (Exception e) { LOG.debug(String.format("Error handling configuration property, name = %s", property), e); } } } return configurations; } protected  StackAdvisorResourceProvider(Resource.Type type, Set<String> propertyIds, Map<Type, String> keyPropertyIds,
                                         AmbariManagementController managementController); @Inject static void init(StackAdvisorHelper instance, Configuration serverConfig);  }### Answer:
@Test public void testCalculateConfigurations() throws Exception { Request request = createMockRequest( CONFIGURATIONS_PROPERTY_ID + "site/properties/string_prop", "string", CONFIGURATIONS_PROPERTY_ID + "site/properties/array_prop", Lists.newArrayList("array1", "array2")); Map<String, Map<String, Map<String, String>>> calculatedConfigurations = provider.calculateConfigurations(request); assertNotNull(calculatedConfigurations); assertEquals(1, calculatedConfigurations.size()); Map<String, Map<String, String>> site = calculatedConfigurations.get("site"); assertNotNull(site); assertEquals(1, site.size()); Map<String, String> properties = site.get("properties"); assertNotNull(properties); assertEquals(2, properties.size()); assertEquals("string", properties.get("string_prop")); assertEquals("[array1, array2]", properties.get("array_prop")); }
@Test public void testCalculateConfigurationsWithNullPropertyValues() throws Exception { Request request = createMockRequest( CONFIGURATIONS_PROPERTY_ID + "site/properties/string_prop", null, CONFIGURATIONS_PROPERTY_ID + "site/properties/array_prop", Lists.newArrayList("array1", "array2")); Map<String, Map<String, Map<String, String>>> calculatedConfigurations = provider.calculateConfigurations(request); assertNotNull(calculatedConfigurations); assertEquals(1, calculatedConfigurations.size()); Map<String, Map<String, String>> site = calculatedConfigurations.get("site"); assertNotNull(site); assertEquals(1, site.size()); Map<String, String> properties = site.get("properties"); assertNotNull(properties); assertEquals("[array1, array2]", properties.get("array_prop")); assertFalse(properties.containsKey("string_prop")); }