### Question:
SecretsDirConfigSource extends PayaraConfigSource implements ConfigSource { @Override public String getValue(String property) { String result = properties.get(property); if (result != null) { try { FileTime ft = storedModifiedTimes.get(property); Path path = Paths.get(secretsDir.toString(), property); if (Files.exists(path) && Files.getLastModifiedTime(path).compareTo(ft) > 0) { result = readFile(property); storedModifiedTimes.put(property, Files.getLastModifiedTime(path)); properties.put(property, result); } } catch (IOException ex) { Logger.getLogger(SecretsDirConfigSource.class.getName()).log(Level.SEVERE, null, ex); } } else { Path path = Paths.get(secretsDir.toString(), property); if (Files.exists(path) && Files.isRegularFile(path) && Files.isReadable(path)) { try { result = readFile(property); storedModifiedTimes.put(property, Files.getLastModifiedTime(path)); properties.put(property, result); } catch (IOException ex) { Logger.getLogger(SecretsDirConfigSource.class.getName()).log(Level.SEVERE, null, ex); } } } return result; } SecretsDirConfigSource();   SecretsDirConfigSource(Path directory); @Override Map<String, String> getProperties(); @Override Set<String> getPropertyNames(); @Override int getOrdinal(); @Override String getValue(String property); @Override String getName();  }### Answer:
@Test public void testGetValue() { assertEquals("value1", source.getValue("property1")); assertEquals("value2", source.getValue("property2")); }
@Test public void testChangeProperty() throws IOException { assertEquals("value1", source.getValue("property1")); Path file1 = Paths.get(testDirectory.toString(), "property1"); Files.write(file1, "value-changed".getBytes()); try { FileTime nowplus1sec = FileTime.fromMillis(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(1)); Files.setLastModifiedTime(file1, nowplus1sec); assertEquals("value-changed", source.getValue("property1")); } finally { Files.write(file1, "value1".getBytes()); } }
@Test public void testNewFile() throws IOException { assertNull(source.getValue("property-new")); Path file1 = Paths.get(testDirectory.toString(), "property-new"); Files.write(file1, "newValue".getBytes()); try { assertEquals("newValue", source.getValue("property-new")); } finally { Files.delete(file1); } }
@Test public void testBadDirectoryNoBlowUp() { assertNull(new SecretsDirConfigSource(Paths.get(testDirectory.toString(), "FOOBLE")).getValue("BILLY")); }