GlobalMetadata { public void load(File propertiesFile, Logger logger) { if (propertiesFile == null) { return; } if (!propertiesFile.isFile()) { logger.warning(String.format("Metadata properties file '%s' not found", propertiesFile)); return; } logger.info(String.format("Reading metadata properties file '%s'...", propertiesFile)); try (FileReader reader = new FileReader(propertiesFile)) { final Properties properties = new Properties(); properties.load(reader); for (String name : properties.stringPropertyNames()) { metaProperties.put(name, properties.getProperty(name)); } } catch (IOException e) { final String msgPattern = "Failed to load metadata properties file '%s': %s"; logger.warning(String.format(msgPattern, propertiesFile, e.getMessage())); } } GlobalMetadata(); static GlobalMetadata create(BinningOp operator); static GlobalMetadata create(BinningConfig config); void processMetadataTemplates(File metadataTemplateDir, BinningOp operator, Product targetProduct, Logger logger); SortedMap<String, String> asSortedMap(); MetadataElement asMetadataElement(); void load(File propertiesFile, Logger logger);  }
@Test public void testLoad() throws IOException { final Logger logger = mock(Logger.class); final GlobalMetadata globalMetadata = new GlobalMetadata(); try { final File propertiesFile = writePropertiesFile(); globalMetadata.load(propertiesFile, logger); final SortedMap<String, String> metaProperties = globalMetadata.asSortedMap(); assertEquals("aaaaa", metaProperties.get("param_a")); assertEquals("bbbb", metaProperties.get("param_b")); assertEquals("CCCC", metaProperties.get("param_c")); verify(logger, times(1)).info(contains("Reading metadata properties file")); verifyNoMoreInteractions(logger); } finally { deletePropertiesFile(); } }