### Question:
PasswordReader { Optional<String> readPassword(final DBeamPipelineOptions options) throws IOException { FileSystems.setDefaultPipelineOptions(options); if (options.getPasswordFileKmsEncrypted() != null) { LOGGER.info("Decrypting password using KMS..."); return Optional.of( kmsDecrypter .decrypt(BeamHelper.readFromFile(options.getPasswordFileKmsEncrypted())) .trim()); } else if (options.getPasswordFile() != null) { LOGGER.info("Reading password from file: {}", options.getPasswordFile()); return Optional.of(BeamHelper.readFromFile(options.getPasswordFile())); } else { return Optional.ofNullable(options.getPassword()); } } PasswordReader(KmsDecrypter kmsDecrypter);   }### Answer:
@Test public void shouldDecryptPasswordOnpasswordFileKmsEncryptedParameter() throws IOException { MockHttpTransport mockHttpTransport = new MockHttpTransport.Builder() .setLowLevelHttpResponse( new MockLowLevelHttpResponse() .setStatusCode(200) .setContentType(Json.MEDIA_TYPE) .setContent( JacksonFactory.getDefaultInstance() .toByteArray( new DecryptResponse() .encodePlaintext("something_decrypted".getBytes())))) .build(); PasswordReader passwordReader = new PasswordReader( KmsDecrypter.decrypter() .project(Optional.of("fake_project")) .credentials(NoopCredentialFactory.fromOptions(null).getCredential()) .transport(mockHttpTransport) .build()); DBeamPipelineOptions options = PipelineOptionsFactory.create().as(DBeamPipelineOptions.class); options.setPasswordFileKmsEncrypted(passwordFile.getPath()); final Optional<String> actualPassword = passwordReader.readPassword(options); Assert.assertEquals(Optional.of("something_decrypted"), actualPassword); }