PropertiesEncryption { public void decryptAndSave(String input, Set<String> mustBeDecrypted) { modifyAndSave(input, mustBeDecrypted, this::decryptIfNot); }  void encryptAndSave(String input, Set<String> mustBeEncrypted); void decryptAndSave(String input, Set<String> mustBeDecrypted);  }
@Test public void decryptAndSave() throws Exception { String propertyKey = "admin.password"; String propertyEncodedValue = "JP6lC6hVeu3wRZA1Tzigyg=="; String propertyValue = "5ecr3t"; Path tempFile = Files.createTempFile("dataprep-PropertiesEncryptionTest.", ".properties"); try (BufferedWriter bufferedWriter = Files.newBufferedWriter(tempFile, Charsets.UTF_8)) { for (int i = 0; i < 5; i++) { bufferedWriter.write(propertyKey + "=" + propertyEncodedValue); bufferedWriter.newLine(); } } new PropertiesEncryption().decryptAndSave(tempFile.toString(), Sets.newHashSet(propertyKey)); final String expectedLine = propertyKey + "=" + propertyValue; verifyContent(expectedLine, tempFile); }