### Question:
PasswordMasker { public Map<String, String> mask(Map<String, String> unmasked) { return Maps.transformEntries(unmasked, new Maps.EntryTransformer<String, String, String>() { @Override public String transformEntry(@Nonnull String key, @Nonnull String value) { return mask(key, value); } }); }  Map<String, String> mask(Map<String, String> unmasked); String mask(Map.Entry<String, String> unmasked); String maskPasswordsIfNecessary(String unmasked);  }### Answer:
@Test public void testWhenJavaSystemPropertiesAreAskedPasswordsAppearMasked() throws Exception { Map<String, String> masked = passwordMasker.mask(jsonToMap("/instrumentation-system-properties.json")); assertPasswordValueIsMasked(masked, "javax.net.ssl.trustStorePassword"); assertPasswordValueIsMasked(masked, "oozie.https.keystore.pass"); }
@Test public void testWhenOSEnvIsAskedPasswordsAppearMasked() throws Exception { Map<String, String> masked = passwordMasker.mask(jsonToMap("/instrumentation-os-env.json")); assertPasswordValueIsMasked(masked, "HADOOP_CREDSTORE_PASSWORD"); assertPasswordValueIsMasked(masked, "OOZIE_HTTPS_KEYSTORE_PASSWORD"); assertPasswordValueIsMasked(masked, "OOZIE_HTTPS_TRUSTSTORE_PASSWORD"); assertPasswordValueFragmentIsMasked(masked, "CATALINA_OPTS", "-Doozie.https.keystore.pass="); assertPasswordValueFragmentIsMasked(masked, "CATALINA_OPTS", "-Djavax.net.ssl.trustStorePassword="); assertValueFragmentIsPresent(masked, "CATALINA_OPTS", "-Xmx1024m"); assertValueFragmentIsPresent(masked, "CATALINA_OPTS", "-Doozie.https.keystore.file=/Users/forsage/.keystore"); assertValueFragmentIsPresent(masked, "CATALINA_OPTS", "-Djava.library.path="); }