### Question:
ConfigurationFilesManager { Properties getAlsoCustomAndInternalPropertiesFromFilename(Map<String, Properties> propertiesByFilename, String propertiesFileName) { Properties properties = new Properties(); if (propertiesByFilename != null) { if (propertiesByFilename.containsKey(propertiesFileName)) { properties.putAll(propertiesByFilename.get(propertiesFileName)); } final String internalFilename = getSuffixedPropertyFilename(propertiesFileName, "-internal"); if (propertiesByFilename.containsKey(internalFilename)) { properties.putAll(propertiesByFilename.get(internalFilename)); } final String customFilename = getSuffixedPropertyFilename(propertiesFileName, "-custom"); if (propertiesByFilename.containsKey(customFilename)) { properties.putAll(propertiesByFilename.get(customFilename)); } } return properties; }  static ConfigurationFilesManager getInstance(); Properties getPlatformProperties(String propertiesFile); Properties getTenantProperties(String propertiesFileName, long tenantId); void setPlatformConfigurations(Map<String, byte[]> configurationFiles); void setTenantConfigurations(Map<String, byte[]> configurationFiles, long tenantId); void setTenantConfiguration(String fileName, byte[] content, long tenantId); void removeProperty(String propertiesFilename, long tenantId, String propertyName); void setProperty(String propertiesFilename, long tenantId, String propertyName, String propertyValue); void updateAggregatedProperties(String propertiesFilename, long tenantId, String propertyName, String propertyValue,
            Map<String, Properties> resources); File getPlatformConfigurationFile(String fileName); File getTenantConfigurationFile(String fileName, long tenantId); File getTenantAutoLoginConfiguration(long tenantId);  }### Answer:
@Test public void getAlsoCustomAndInternalPropertiesFromFilename_should_merge_custom_properties_if_exist() throws Exception { Map<String, Properties> propertiesMap = new HashMap<>(2); final Properties defaultProps = new Properties(); defaultProps.put("defaultKey", "defaultValue"); propertiesMap.put("toto.properties", defaultProps); final Properties customProps = new Properties(); customProps.put("customKey", "customValue"); propertiesMap.put("toto-custom.properties", customProps); final Properties properties = configurationFilesManager.getAlsoCustomAndInternalPropertiesFromFilename(propertiesMap, "toto.properties"); assertThat(properties).containsEntry("defaultKey", "defaultValue").containsEntry("customKey", "customValue"); }
@Test public void getAlsoCustomAndInternalPropertiesFromFilename_should_merge_internal_properties_if_exist() throws Exception { Map<String, Properties> propertiesMap = new HashMap<>(2); final Properties defaultProps = new Properties(); defaultProps.put("defaultKey", "defaultValue"); propertiesMap.put("toto.properties", defaultProps); final Properties internalProps = new Properties(); internalProps.put("internalKey", "internalValue"); propertiesMap.put("toto-internal.properties", internalProps); final Properties properties = configurationFilesManager.getAlsoCustomAndInternalPropertiesFromFilename(propertiesMap, "toto.properties"); assertThat(properties).containsEntry("defaultKey", "defaultValue").containsEntry("internalKey", "internalValue"); }
@Test public void custom_properties_should_overwrite_internal_properties() throws Exception { final Properties defaultProps = new Properties(); defaultProps.put("defaultKey", "defaultValue"); final Properties internalProps = new Properties(); internalProps.put("otherKey", "someInternallyManagedValue"); final Properties customProps = new Properties(); final String expectedOverwrittenValue = "custom_changed_value"; customProps.put("otherKey", expectedOverwrittenValue); Map<String, Properties> propertiesMap = new HashMap<>(3); propertiesMap.put("overwrite.properties", defaultProps); propertiesMap.put("overwrite-internal.properties", internalProps); propertiesMap.put("overwrite-custom.properties", customProps); final Properties properties = configurationFilesManager.getAlsoCustomAndInternalPropertiesFromFilename(propertiesMap, "overwrite.properties"); assertThat(properties).containsEntry("defaultKey", "defaultValue").containsEntry("otherKey", expectedOverwrittenValue); }