RepositoryUtils { public static List<String> cleanUpCredentialsFromEnvMap(final Map<String, Object> envMap) { return KEYS_TO_SEARCH .stream() .filter(key -> envMap.remove(key) != null) .collect(Collectors.toList()); } private  RepositoryUtils(); static List<String> cleanUpCredentialsFromEnvMap(final Map<String, Object> envMap);  }
@Test public void cleanUpCredentialsFromEnvMapWhenNotNeededTest() { final Map<String, Object> envMap = createEnvMap(false); final List<String> result = RepositoryUtils.cleanUpCredentialsFromEnvMap(envMap); assertThat(result).isEmpty(); }
@Test public void cleanUpCredentialsFromEnvMapWhenNeededTest() { final Map<String, Object> envMap = createEnvMap(true); final List<String> result = RepositoryUtils.cleanUpCredentialsFromEnvMap(envMap); assertThat(result).isNotEmpty(); assertThat(result).contains(EnvironmentParameters.USER_NAME, EnvironmentParameters.PASSWORD, EnvironmentParameters.SECURE_PREFIX + EnvironmentParameters.PASSWORD); assertThat(envMap).doesNotContainKeys(EnvironmentParameters.USER_NAME, EnvironmentParameters.PASSWORD, EnvironmentParameters.SECURE_PREFIX + EnvironmentParameters.PASSWORD); }