### Question:
PaymentProtocolService extends AbstractService { public Optional<Protos.PaymentRequest> newSignedPaymentRequest(SignedPaymentRequestSummary signedPaymentRequestSummary) throws NoSuchAlgorithmException { KeyStore keyStore = signedPaymentRequestSummary.getKeyStore(); String keyAlias = signedPaymentRequestSummary.getKeyAlias(); char[] keyStorePassword = signedPaymentRequestSummary.getKeyStorePassword(); Protos.PaymentRequest.Builder paymentRequest; try { paymentRequest = PaymentProtocol.createPaymentRequest( networkParameters, signedPaymentRequestSummary.getAmount(), signedPaymentRequestSummary.getPaymentAddress(), signedPaymentRequestSummary.getMemo(), signedPaymentRequestSummary.getPaymentUrl().toString(), signedPaymentRequestSummary.getMerchantData() ); final java.security.cert.Certificate[] certificateChain = keyStore.getCertificateChain(keyAlias); X509Certificate[] x509CertificateChain = new X509Certificate[certificateChain.length]; for (int i = 0; i < certificateChain.length; i++) { if (certificateChain[i] instanceof X509Certificate) { x509CertificateChain[i] = (X509Certificate) certificateChain[i]; } else { log.error("Key store has an inconsistent chain of certificates (expected X509 throughout)"); return Optional.absent(); } } PrivateKey privateKey = (PrivateKey) keyStore.getKey(keyAlias, keyStorePassword); PaymentProtocol.signPaymentRequest( paymentRequest, x509CertificateChain, privateKey ); return Optional.of(paymentRequest.build()); } catch (KeyStoreException | UnrecoverableKeyException e) { log.error("Unexpected error in payment request", e); } return Optional.absent(); } PaymentProtocolService(NetworkParameters networkParameters); PaymentSessionSummary probeForPaymentSession(URI paymentRequestUri, boolean checkPKI, TrustStoreLoader trustStoreLoader); Optional<Protos.PaymentRequest> newSignedPaymentRequest(SignedPaymentRequestSummary signedPaymentRequestSummary); Optional<Protos.Payment> newPayment(byte[] merchantData, List<Transaction> transactions, Coin refundAmount, Address refundAddress, String paymentMemo); Optional<Protos.PaymentACK> newPaymentACK(Protos.Payment payment, String paymentACKMemo);  }### Answer:
@Test public void testNewSignedPaymentRequest() throws Exception { KeyStore keyStore = KeyStore.getInstance("JKS"); InputStream keyStream = PaymentProtocolService.class.getResourceAsStream("/localhost.jks"); keyStore.load(keyStream, HttpsManager.PASSPHRASE.toCharArray()); SignedPaymentRequestSummary signedPaymentRequestSummary = new SignedPaymentRequestSummary( new Address(networkParameters, "1AhN6rPdrMuKBGFDKR1k9A8SCLYaNgXhty"), Coin.CENT, "Please donate to MultiBit", new URL("https: "Donation 0001".getBytes(Charsets.UTF_8), keyStore, "serverkey", HttpsManager.PASSPHRASE.toCharArray() ); final Optional<Protos.PaymentRequest> paymentRequest = testObject.newSignedPaymentRequest(signedPaymentRequestSummary); assertThat(paymentRequest.isPresent()).isTrue(); KeyStore trustStore = KeyStore.getInstance("JKS"); InputStream certStream = PaymentProtocolService.class.getResourceAsStream("/mbhd-cacerts-with-localhost"); trustStore.load(certStream, HttpsManager.PASSPHRASE.toCharArray()); PaymentProtocol.PkiVerificationData pkiVerificationData = PaymentProtocol.verifyPaymentRequestPki( paymentRequest.get(), trustStore ); if (pkiVerificationData == null) { fail(); return; } assertThat(pkiVerificationData).isNotNull(); assertThat(pkiVerificationData.displayName).isEqualTo("Test, Test, US"); }