DefaultServiceResponseTransformerHelper implements ServiceResponseTransformerHelper { @Override public TokenReply buildTokenReply(final Token intToken) { final TokenReply tokenReply = new TokenReply(); tokenReply.setAuthenticatedShopperID(intToken.getAuthenticatedShopperID()); tokenReply.setTokenEventReference(intToken.getTokenEventReference()); final List<Object> tokenInformationFields = intToken.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); for (final Object tokenInformationField : tokenInformationFields) { if (tokenInformationField instanceof TokenReason) { tokenReply.setTokenReason(((TokenReason) tokenInformationField).getvalue()); } else if (tokenInformationField instanceof TokenDetails) { final com.worldpay.service.model.token.TokenDetails tokenDetails = transformTokenDetails((TokenDetails) tokenInformationField); tokenReply.setTokenDetails(tokenDetails); } else if (tokenInformationField instanceof PaymentInstrument) { final Object paymentInstrument = ((PaymentInstrument) tokenInformationField).getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().get(0); if (paymentInstrument instanceof CardDetails) { final com.worldpay.service.model.payment.Card card = transformCard((CardDetails) paymentInstrument); tokenReply.setPaymentInstrument(card); } else if (paymentInstrument instanceof Paypal) { tokenReply.setPaypalDetails(((Paypal) paymentInstrument).getvalue()); } } else if (tokenInformationField instanceof Error) { tokenReply.setError(buildErrorDetail((Error) tokenInformationField)); } } return tokenReply; }  @Override boolean checkForError(final ServiceResponse response, final Reply reply); @Override PaymentReply buildPaymentReply(final Payment intPayment); @Override UpdateTokenReply buildUpdateTokenReply(final UpdateTokenReceived intUpdateTokenReceived); @Override DeleteTokenReply buildDeleteTokenReply(final DeleteTokenReceived intDeleteTokenReceived); @Override TokenReply buildTokenReply(final Token intToken); @Override WebformRefundReply buildWebformRefundReply(final ShopperWebformRefundDetails intShopperWebformRefundDetails); @Override JournalReply buildJournalReply(final Journal intJournal);  }
@Test public void shouldBuildTokenReply() { final Token token = new Token(); token.setAuthenticatedShopperID(AUTHENTICATED_SHOPPER_ID); token.setTokenEventReference(TOKEN_EVENT_REFERENCE); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final TokenReason tokenReason = new TokenReason(); tokenReason.setvalue(TOKEN_REASON); tokenElements.add(tokenReason); final TokenDetails tokenDetail = new TokenDetails(); tokenDetail.setTokenReason(tokenReason); final PaymentTokenExpiry tokenExpiry = new PaymentTokenExpiry(); tokenExpiry.setDate(createDate()); tokenDetail.setPaymentTokenExpiry(tokenExpiry); final PaymentTokenID paymentTokenID = new PaymentTokenID(); paymentTokenID.setvalue(PAYMENT_TOKEN_ID); tokenDetail.setPaymentTokenID(paymentTokenID); tokenDetail.setReportingTokenID(REPORTING_TOKEN); tokenDetail.setTokenEventReference(TOKEN_EVENT_REFERENCE); tokenDetail.setTokenEvent(TOKEN_EVENT); final ReportingTokenExpiry reportingTokenExpiry = new ReportingTokenExpiry(); reportingTokenExpiry.setDate(createReportingTokenExpiryDate()); tokenDetail.setReportingTokenExpiry(reportingTokenExpiry); tokenElements.add(tokenDetail); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("VISA", null)); tokenElements.add(paymentInstrument); final Error error = new Error(); error.setCode(ERROR_CODE); error.setvalue(ERROR_MESSAGE); tokenElements.add(error); final TokenReply tokenReply = testObj.buildTokenReply(token); assertEquals(AUTHENTICATED_SHOPPER_ID, tokenReply.getAuthenticatedShopperID()); assertEquals(TOKEN_EVENT_REFERENCE, tokenReply.getTokenEventReference()); assertEquals(TOKEN_REASON, tokenReply.getTokenReason()); assertEquals(CARD_NUMBER, tokenReply.getPaymentInstrument().getCardNumber()); assertEquals(cardHolderName.getvalue(), tokenReply.getPaymentInstrument().getCardHolderName()); assertEquals(CVC, tokenReply.getPaymentInstrument().getCvc()); assertEquals(CITY, tokenReply.getPaymentInstrument().getCardAddress().getCity()); assertEquals(COUNTRY_CODE, tokenReply.getPaymentInstrument().getCardAddress().getCountryCode()); assertEquals(POSTAL_CODE, tokenReply.getPaymentInstrument().getCardAddress().getPostalCode()); assertEquals(LAST_NAME, tokenReply.getPaymentInstrument().getCardAddress().getLastName()); assertEquals(CARD_HOLDER_NAME, tokenReply.getPaymentInstrument().getCardAddress().getFirstName()); assertEquals(STATE, tokenReply.getPaymentInstrument().getCardAddress().getState()); assertEquals(TELEPHONE_NUMBER, tokenReply.getPaymentInstrument().getCardAddress().getTelephoneNumber()); assertEquals(STREET, tokenReply.getPaymentInstrument().getCardAddress().getStreet()); assertEquals(HOUSE_NAME, tokenReply.getPaymentInstrument().getCardAddress().getHouseName()); assertEquals(HOUSE_NUMBER, tokenReply.getPaymentInstrument().getCardAddress().getHouseNumber()); assertEquals(HOUSE_NUMBER_EXTENSION, tokenReply.getPaymentInstrument().getCardAddress().getHouseNumberExtension()); assertEquals(ADDRESS_1, tokenReply.getPaymentInstrument().getCardAddress().getAddress1()); assertEquals(ADDRESS_2, tokenReply.getPaymentInstrument().getCardAddress().getAddress2()); assertEquals(ADDRESS_3, tokenReply.getPaymentInstrument().getCardAddress().getAddress3()); assertEquals(BIN, tokenReply.getPaymentInstrument().getBin()); assertEquals(EXPIRY_YEAR, tokenReply.getPaymentInstrument().getExpiryDate().getYear()); assertEquals(EXPIRY_MONTH, tokenReply.getPaymentInstrument().getExpiryDate().getMonth()); assertEquals(DAY_OF_MONTH, tokenReply.getPaymentInstrument().getExpiryDate().getDayOfMonth()); assertEquals(HOUR, tokenReply.getPaymentInstrument().getExpiryDate().getHour()); assertEquals(MINUTE, tokenReply.getPaymentInstrument().getExpiryDate().getMinute()); assertEquals(SECOND, tokenReply.getPaymentInstrument().getExpiryDate().getSecond()); assertEquals(ERROR_CODE, tokenReply.getError().getCode()); assertEquals(ERROR_MESSAGE, tokenReply.getError().getMessage()); }
@Test public void shouldBuildTokenReplyWithCartebleueVisa() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("VISA", "CARTEBLEUE")); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.CARTE_BLEUE); }
@Test public void shouldBuildTokenReplyWithCarteBancaireMasterCard() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("ECMC", "CB")); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.CARTE_BANCAIRE); }
@Test public void shouldBuildTokenReplyWithVisa() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("VISA", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.VISA); }
@Test public void shouldBuildTokenReplyWithAirplus() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("AIRPLUS", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.AIRPLUS); }
@Test public void shouldBuildTokenReplyWithAMEX() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("AMEX", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.AMERICAN_EXPRESS); }
@Test public void shouldBuildTokenReplyWithDankort() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("DANKORT", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.DANKORT); }
@Test public void shouldBuildTokenReplyWithDiners() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("DINERS", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.DINERS); }
@Test public void shouldBuildTokenReplyWithDiscover() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("DISCOVER", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.DISCOVER); }
@Test public void shouldBuildTokenReplyWithJCB() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("JCB", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.JCB); }
@Test public void shouldBuildTokenReplyWithMaestro() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("MAESTRO", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.MAESTRO); }
@Test public void shouldBuildTokenReplyWithUATP() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("UATP", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.UATP); }
@Test public void shouldBuildTokenReplyWithUnknownBrand() { final Token token = new Token(); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetails("MONZO", null)); tokenElements.add(paymentInstrument); final TokenReply tokenReply = testObj.buildTokenReply(token); assertThat(tokenReply.getPaymentInstrument().getPaymentType()).isEqualTo(PaymentType.CARD_SSL); }
@Test public void shouldBuildTokenReplyWithoutCardHolderNameInPaymentInstrument() { final Token token = new Token(); token.setAuthenticatedShopperID(AUTHENTICATED_SHOPPER_ID); token.setTokenEventReference(TOKEN_EVENT_REFERENCE); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final TokenReason tokenReason = new TokenReason(); tokenReason.setvalue(TOKEN_REASON); tokenElements.add(tokenReason); final TokenDetails tokenDetail = new TokenDetails(); tokenDetail.setTokenReason(tokenReason); final PaymentTokenExpiry tokenExpiry = new PaymentTokenExpiry(); tokenExpiry.setDate(createDate()); tokenDetail.setPaymentTokenExpiry(tokenExpiry); final PaymentTokenID paymentTokenID = new PaymentTokenID(); paymentTokenID.setvalue(PAYMENT_TOKEN_ID); tokenDetail.setPaymentTokenID(paymentTokenID); tokenDetail.setReportingTokenID(REPORTING_TOKEN); tokenDetail.setTokenEventReference(TOKEN_EVENT_REFERENCE); tokenDetail.setTokenEvent(TOKEN_EVENT); final ReportingTokenExpiry reportingTokenExpiry = new ReportingTokenExpiry(); reportingTokenExpiry.setDate(createReportingTokenExpiryDate()); tokenDetail.setReportingTokenExpiry(reportingTokenExpiry); tokenElements.add(tokenDetail); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetailsWithoutCardHolderName()); tokenElements.add(paymentInstrument); final Error error = new Error(); error.setCode(ERROR_CODE); error.setvalue(ERROR_MESSAGE); tokenElements.add(error); final TokenReply tokenReply = testObj.buildTokenReply(token); assertEquals(AUTHENTICATED_SHOPPER_ID, tokenReply.getAuthenticatedShopperID()); assertEquals(TOKEN_EVENT_REFERENCE, tokenReply.getTokenEventReference()); assertEquals(TOKEN_REASON, tokenReply.getTokenReason()); assertEquals(CARD_NUMBER, tokenReply.getPaymentInstrument().getCardNumber()); assertNull(tokenReply.getPaymentInstrument().getCardHolderName()); assertEquals(CVC, tokenReply.getPaymentInstrument().getCvc()); assertEquals(CITY, tokenReply.getPaymentInstrument().getCardAddress().getCity()); assertEquals(COUNTRY_CODE, tokenReply.getPaymentInstrument().getCardAddress().getCountryCode()); assertEquals(POSTAL_CODE, tokenReply.getPaymentInstrument().getCardAddress().getPostalCode()); assertEquals(LAST_NAME, tokenReply.getPaymentInstrument().getCardAddress().getLastName()); assertEquals(CARD_HOLDER_NAME, tokenReply.getPaymentInstrument().getCardAddress().getFirstName()); assertEquals(STATE, tokenReply.getPaymentInstrument().getCardAddress().getState()); assertEquals(TELEPHONE_NUMBER, tokenReply.getPaymentInstrument().getCardAddress().getTelephoneNumber()); assertEquals(STREET, tokenReply.getPaymentInstrument().getCardAddress().getStreet()); assertEquals(HOUSE_NAME, tokenReply.getPaymentInstrument().getCardAddress().getHouseName()); assertEquals(HOUSE_NUMBER, tokenReply.getPaymentInstrument().getCardAddress().getHouseNumber()); assertEquals(HOUSE_NUMBER_EXTENSION, tokenReply.getPaymentInstrument().getCardAddress().getHouseNumberExtension()); assertEquals(ADDRESS_1, tokenReply.getPaymentInstrument().getCardAddress().getAddress1()); assertEquals(ADDRESS_2, tokenReply.getPaymentInstrument().getCardAddress().getAddress2()); assertEquals(ADDRESS_3, tokenReply.getPaymentInstrument().getCardAddress().getAddress3()); assertEquals(EXPIRY_YEAR, tokenReply.getPaymentInstrument().getExpiryDate().getYear()); assertEquals(EXPIRY_MONTH, tokenReply.getPaymentInstrument().getExpiryDate().getMonth()); assertEquals(DAY_OF_MONTH, tokenReply.getPaymentInstrument().getExpiryDate().getDayOfMonth()); assertEquals(HOUR, tokenReply.getPaymentInstrument().getExpiryDate().getHour()); assertEquals(MINUTE, tokenReply.getPaymentInstrument().getExpiryDate().getMinute()); assertEquals(SECOND, tokenReply.getPaymentInstrument().getExpiryDate().getSecond()); assertEquals(ERROR_CODE, tokenReply.getError().getCode()); assertEquals(ERROR_MESSAGE, tokenReply.getError().getMessage()); }
@Test public void shouldBuildTokenReplyWithoutCardAddress() { final Token token = new Token(); token.setAuthenticatedShopperID(AUTHENTICATED_SHOPPER_ID); token.setTokenEventReference(TOKEN_EVENT_REFERENCE); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final TokenReason tokenReason = new TokenReason(); tokenReason.setvalue(TOKEN_REASON); tokenElements.add(tokenReason); final TokenDetails tokenDetail = new TokenDetails(); tokenDetail.setTokenReason(tokenReason); final PaymentTokenExpiry tokenExpiry = new PaymentTokenExpiry(); tokenExpiry.setDate(createDate()); tokenDetail.setPaymentTokenExpiry(tokenExpiry); final PaymentTokenID paymentTokenID = new PaymentTokenID(); paymentTokenID.setvalue(PAYMENT_TOKEN_ID); tokenDetail.setPaymentTokenID(paymentTokenID); tokenDetail.setReportingTokenID(REPORTING_TOKEN); tokenDetail.setTokenEventReference(TOKEN_EVENT_REFERENCE); tokenDetail.setTokenEvent(TOKEN_EVENT); final ReportingTokenExpiry reportingTokenExpiry = new ReportingTokenExpiry(); reportingTokenExpiry.setDate(createReportingTokenExpiryDate()); tokenDetail.setReportingTokenExpiry(reportingTokenExpiry); tokenElements.add(tokenDetail); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetailsWithoutAddress()); tokenElements.add(paymentInstrument); final Error error = new Error(); error.setCode(ERROR_CODE); error.setvalue(ERROR_MESSAGE); tokenElements.add(error); final TokenReply tokenReply = testObj.buildTokenReply(token); assertEquals(AUTHENTICATED_SHOPPER_ID, tokenReply.getAuthenticatedShopperID()); assertEquals(TOKEN_EVENT_REFERENCE, tokenReply.getTokenEventReference()); assertEquals(TOKEN_REASON, tokenReply.getTokenReason()); assertEquals(CARD_NUMBER, tokenReply.getPaymentInstrument().getCardNumber()); assertEquals(cardHolderName.getvalue(), tokenReply.getPaymentInstrument().getCardHolderName()); assertEquals(CVC, tokenReply.getPaymentInstrument().getCvc()); assertNull(tokenReply.getPaymentInstrument().getCardAddress()); assertEquals(EXPIRY_YEAR, tokenReply.getPaymentInstrument().getExpiryDate().getYear()); assertEquals(EXPIRY_MONTH, tokenReply.getPaymentInstrument().getExpiryDate().getMonth()); assertEquals(DAY_OF_MONTH, tokenReply.getPaymentInstrument().getExpiryDate().getDayOfMonth()); assertEquals(HOUR, tokenReply.getPaymentInstrument().getExpiryDate().getHour()); assertEquals(MINUTE, tokenReply.getPaymentInstrument().getExpiryDate().getMinute()); assertEquals(SECOND, tokenReply.getPaymentInstrument().getExpiryDate().getSecond()); assertEquals(ERROR_CODE, tokenReply.getError().getCode()); assertEquals(ERROR_MESSAGE, tokenReply.getError().getMessage()); }
@Test public void shouldBuildTokenReplyWithoutExpiryDate() { final Token token = new Token(); token.setAuthenticatedShopperID(AUTHENTICATED_SHOPPER_ID); token.setTokenEventReference(TOKEN_EVENT_REFERENCE); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final TokenReason tokenReason = new TokenReason(); tokenReason.setvalue(TOKEN_REASON); tokenElements.add(tokenReason); final TokenDetails tokenDetail = new TokenDetails(); tokenDetail.setTokenReason(tokenReason); final PaymentTokenExpiry tokenExpiry = new PaymentTokenExpiry(); tokenExpiry.setDate(createDate()); tokenDetail.setPaymentTokenExpiry(tokenExpiry); final PaymentTokenID paymentTokenID = new PaymentTokenID(); paymentTokenID.setvalue(PAYMENT_TOKEN_ID); tokenDetail.setPaymentTokenID(paymentTokenID); tokenDetail.setReportingTokenID(REPORTING_TOKEN); tokenDetail.setTokenEventReference(TOKEN_EVENT_REFERENCE); tokenDetail.setTokenEvent(TOKEN_EVENT); final ReportingTokenExpiry reportingTokenExpiry = new ReportingTokenExpiry(); reportingTokenExpiry.setDate(createReportingTokenExpiryDate()); tokenDetail.setReportingTokenExpiry(reportingTokenExpiry); tokenElements.add(tokenDetail); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetailsWithoutExpiryDate()); tokenElements.add(paymentInstrument); final Error error = new Error(); error.setCode(ERROR_CODE); error.setvalue(ERROR_MESSAGE); tokenElements.add(error); final TokenReply tokenReply = testObj.buildTokenReply(token); assertEquals(AUTHENTICATED_SHOPPER_ID, tokenReply.getAuthenticatedShopperID()); assertEquals(TOKEN_EVENT_REFERENCE, tokenReply.getTokenEventReference()); assertEquals(TOKEN_REASON, tokenReply.getTokenReason()); assertEquals(CARD_NUMBER, tokenReply.getPaymentInstrument().getCardNumber()); assertEquals(cardHolderName.getvalue(), tokenReply.getPaymentInstrument().getCardHolderName()); assertEquals(CVC, tokenReply.getPaymentInstrument().getCvc()); assertEquals(CITY, tokenReply.getPaymentInstrument().getCardAddress().getCity()); assertEquals(COUNTRY_CODE, tokenReply.getPaymentInstrument().getCardAddress().getCountryCode()); assertEquals(POSTAL_CODE, tokenReply.getPaymentInstrument().getCardAddress().getPostalCode()); assertEquals(LAST_NAME, tokenReply.getPaymentInstrument().getCardAddress().getLastName()); assertEquals(CARD_HOLDER_NAME, tokenReply.getPaymentInstrument().getCardAddress().getFirstName()); assertEquals(STATE, tokenReply.getPaymentInstrument().getCardAddress().getState()); assertEquals(TELEPHONE_NUMBER, tokenReply.getPaymentInstrument().getCardAddress().getTelephoneNumber()); assertEquals(STREET, tokenReply.getPaymentInstrument().getCardAddress().getStreet()); assertEquals(HOUSE_NAME, tokenReply.getPaymentInstrument().getCardAddress().getHouseName()); assertEquals(HOUSE_NUMBER, tokenReply.getPaymentInstrument().getCardAddress().getHouseNumber()); assertEquals(HOUSE_NUMBER_EXTENSION, tokenReply.getPaymentInstrument().getCardAddress().getHouseNumberExtension()); assertEquals(ADDRESS_1, tokenReply.getPaymentInstrument().getCardAddress().getAddress1()); assertEquals(ADDRESS_2, tokenReply.getPaymentInstrument().getCardAddress().getAddress2()); assertEquals(ADDRESS_3, tokenReply.getPaymentInstrument().getCardAddress().getAddress3()); assertNull(tokenReply.getPaymentInstrument().getExpiryDate()); assertEquals(ERROR_CODE, tokenReply.getError().getCode()); assertEquals(ERROR_MESSAGE, tokenReply.getError().getMessage()); }
@Test public void shouldBuildTokenReplyWithoutDerived() { final Token token = new Token(); token.setAuthenticatedShopperID(AUTHENTICATED_SHOPPER_ID); token.setTokenEventReference(TOKEN_EVENT_REFERENCE); final List<Object> tokenElements = token.getTokenReasonOrTokenDetailsOrPaymentInstrumentOrSchemeResponseOrError(); final TokenReason tokenReason = new TokenReason(); tokenReason.setvalue(TOKEN_REASON); tokenElements.add(tokenReason); final TokenDetails tokenDetail = new TokenDetails(); tokenDetail.setTokenReason(tokenReason); final PaymentTokenExpiry tokenExpiry = new PaymentTokenExpiry(); tokenExpiry.setDate(createDate()); tokenDetail.setPaymentTokenExpiry(tokenExpiry); final PaymentTokenID paymentTokenID = new PaymentTokenID(); paymentTokenID.setvalue(PAYMENT_TOKEN_ID); tokenDetail.setPaymentTokenID(paymentTokenID); tokenDetail.setReportingTokenID(REPORTING_TOKEN); tokenDetail.setTokenEventReference(TOKEN_EVENT_REFERENCE); tokenDetail.setTokenEvent(TOKEN_EVENT); final ReportingTokenExpiry reportingTokenExpiry = new ReportingTokenExpiry(); reportingTokenExpiry.setDate(createReportingTokenExpiryDate()); tokenDetail.setReportingTokenExpiry(reportingTokenExpiry); tokenElements.add(tokenDetail); final PaymentInstrument paymentInstrument = new PaymentInstrument(); paymentInstrument.getCardDetailsOrPaypalOrSepaOrEmvcoTokenDetailsOrSAMSUNGPAYSSL().add(createCardDetailsWithoutDerived()); tokenElements.add(paymentInstrument); final Error error = new Error(); error.setCode(ERROR_CODE); error.setvalue(ERROR_MESSAGE); tokenElements.add(error); final TokenReply tokenReply = testObj.buildTokenReply(token); assertEquals(AUTHENTICATED_SHOPPER_ID, tokenReply.getAuthenticatedShopperID()); assertEquals(TOKEN_EVENT_REFERENCE, tokenReply.getTokenEventReference()); assertEquals(TOKEN_REASON, tokenReply.getTokenReason()); assertNull(tokenReply.getPaymentInstrument()); assertEquals(ERROR_CODE, tokenReply.getError().getCode()); assertEquals(ERROR_MESSAGE, tokenReply.getError().getMessage()); }