test_class.file: dataprep-backend-service/src/test/java/org/talend/dataprep/encrypt/PropertiesEncryptionTest.java
test_class.identifier: PropertiesEncryptionTest
test_case.body: @Test
      public void shouldEncryptAndSaveAllOccurrences() throws Exception {
          // given
          String propertyKey = "admin.password";
          String propertyValue = "5ecr3t";
          String propertyEncodedValue = "JP6lC6hVeu3wRZA1Tzigyg==";
  
          String mongoPropName = "mongodb.uri";
          String mongoPropValue = "mongodb://userName:5ecr3t@dataprep-server.org:27017/dataprep?toto=tata";
          String mongoPropValueEncrypted =
                  "mongodb://userName:JP6lC6hVeu3wRZA1Tzigyg==@dataprep-server.org:27017/dataprep?toto=tata";
  
          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();
              }
              bufferedWriter.write(mongoPropName + "=" + mongoPropValue);
          }
  
          // when
          new PropertiesEncryption().encryptAndSave(tempFile.toString(), Sets.newHashSet(propertyKey, mongoPropName));
  
          // then
          Properties properties = new Properties();
          properties.load(new FileInputStream(tempFile.toFile()));
          assertEquals(propertyEncodedValue, properties.getProperty(propertyKey));
          assertEquals(mongoPropValueEncrypted, properties.getProperty(mongoPropName));
      }
test_case.class_method_signature: PropertiesEncryptionTest.shouldEncryptAndSaveAllOccurrences()
test_case.full_signature: @Test public void shouldEncryptAndSaveAllOccurrences()
test_case.identifier: shouldEncryptAndSaveAllOccurrences
test_case.invocations: createTempFile newBufferedWriter write newLine write encryptAndSave toString newHashSet load toFile assertEquals getProperty assertEquals getProperty
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldEncryptAndSaveAllOccurrences()
focal_class.declarator: LOGGER = LoggerFactory.getLogger(PropertiesEncryption.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = LoggerFactory.getLogger(PropertiesEncryption.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.file: dataprep-backend-service/src/main/java/org/talend/dataprep/encrypt/PropertiesEncryption.java
focal_class.identifier: PropertiesEncryption
focal_class.class_method_signature: PropertiesEncryption.encryptAndSave(String input, Set<String> mustBeEncrypted)
focal_class.full_signature: public void encryptAndSave(String input, Set<String> mustBeEncrypted)
focal_class.identifier: encryptAndSave
focal_class.modifiers: public
focal_class.parameters: (String input, Set<String> mustBeEncrypted)
focal_class.return: void
focal_class.signature: void encryptAndSave(String input, Set<String> mustBeEncrypted)
focal_class.class_method_signature: PropertiesEncryption.decryptAndSave(String input, Set<String> mustBeDecrypted)
focal_class.full_signature: public void decryptAndSave(String input, Set<String> mustBeDecrypted)
focal_class.identifier: decryptAndSave
focal_class.modifiers: public
focal_class.parameters: (String input, Set<String> mustBeDecrypted)
focal_class.return: void
focal_class.signature: void decryptAndSave(String input, Set<String> mustBeDecrypted)
focal_class.class_method_signature: PropertiesEncryption.modifyAndSave(String input, Set<String> mustBeModified, Function<String, String> function)
focal_class.full_signature: private void modifyAndSave(String input, Set<String> mustBeModified, Function<String, String> function)
focal_class.identifier: modifyAndSave
focal_class.modifiers: private
focal_class.parameters: (String input, Set<String> mustBeModified, Function<String, String> function)
focal_class.return: void
focal_class.signature: void modifyAndSave(String input, Set<String> mustBeModified, Function<String, String> function)
focal_class.class_method_signature: PropertiesEncryption.encryptIfNot(String input)
focal_class.full_signature: private String encryptIfNot(String input)
focal_class.identifier: encryptIfNot
focal_class.modifiers: private
focal_class.parameters: (String input)
focal_class.return: String
focal_class.signature: String encryptIfNot(String input)
focal_class.class_method_signature: PropertiesEncryption.decryptIfNot(String input)
focal_class.full_signature: private String decryptIfNot(String input)
focal_class.identifier: decryptIfNot
focal_class.modifiers: private
focal_class.parameters: (String input)
focal_class.return: String
focal_class.signature: String decryptIfNot(String input)
focal_class.class_method_signature: PropertiesEncryption.isUrl(String field)
focal_class.full_signature: private static boolean isUrl(String field)
focal_class.identifier: isUrl
focal_class.modifiers: private static
focal_class.parameters: (String field)
focal_class.return: boolean
focal_class.signature: boolean isUrl(String field)
focal_method.body: public void encryptAndSave(String input, Set<String> mustBeEncrypted) {
          modifyAndSave(input, mustBeEncrypted, this::encryptIfNot);
      }
focal_method.class_method_signature: PropertiesEncryption.encryptAndSave(String input, Set<String> mustBeEncrypted)
focal_method.full_signature: public void encryptAndSave(String input, Set<String> mustBeEncrypted)
focal_method.identifier: encryptAndSave
focal_method.invocations: modifyAndSave
focal_method.modifiers: public
focal_method.parameters: (String input, Set<String> mustBeEncrypted)
focal_method.return: void
focal_method.signature: void encryptAndSave(String input, Set<String> mustBeEncrypted)