@Test public void shouldEncryptAllKeysButMissingOnes() throws Exception { String propertyKey = "admin.password"; String missingPropertyKeyOne = "missingOne"; String missingPropertyKeyTwo = "missingTwo"; String propertyValue = "5ecr3t"; String propertyEncodedValue = "JP6lC6hVeu3wRZA1Tzigyg=="; 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 + "=" + propertyValue); bufferedWriter.newLine(); } } new PropertiesEncryption().encryptAndSave(tempFile.toString(), Sets.newHashSet(propertyKey, missingPropertyKeyOne, missingPropertyKeyTwo)); final String expectedLine = propertyKey + "=" + propertyEncodedValue; verifyContent(expectedLine, tempFile); }
public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); } }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }  }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }  void encryptAndSave(String input, Set<String> mustBeEncrypted); void decryptAndSave(String input, Set<String> mustBeDecrypted); }
PropertiesEncryption { public void encryptAndSave(String input, Set<String> mustBeEncrypted) { modifyAndSave(input, mustBeEncrypted, this::encryptIfNot); }  void encryptAndSave(String input, Set<String> mustBeEncrypted); void decryptAndSave(String input, Set<String> mustBeDecrypted);  }