@Test public void paymentTokenCreateShouldNotContainTokenRequestIfNotProvided() throws WorldpayModelTransformationException { final CardTokenRequest cardTokenRequest = new CardTokenRequest(null, AUTHENTICATED_SHOPPER_ID, PAYMENT); final PaymentTokenCreate result = (PaymentTokenCreate) cardTokenRequest.transformToInternalModel(); assertNull(result.getCreateToken()); }
@Override public InternalModelObject transformToInternalModel() throws WorldpayModelTransformationException { final PaymentTokenCreate paymentTokenCreate = new PaymentTokenCreate(); Optional.ofNullable(authenticatedShopperId) .ifPresent(paymentTokenCreate::setAuthenticatedShopperID); Optional.ofNullable(tokenRequest) .map(TokenRequest::transformToInternalModel) .map(CreateToken.class::cast) .ifPresent(paymentTokenCreate::setCreateToken); Optional.ofNullable(storedCredentials) .map(StoredCredentials::transformToInternalModel) .ifPresent(paymentTokenCreate::setStoredCredentials); paymentTokenCreate.getPaymentInstrumentOrCSEDATA().add(payment.transformToInternalModel()); return paymentTokenCreate; }
CardTokenRequest implements InternalModelTransformer, Serializable { @Override public InternalModelObject transformToInternalModel() throws WorldpayModelTransformationException { final PaymentTokenCreate paymentTokenCreate = new PaymentTokenCreate(); Optional.ofNullable(authenticatedShopperId) .ifPresent(paymentTokenCreate::setAuthenticatedShopperID); Optional.ofNullable(tokenRequest) .map(TokenRequest::transformToInternalModel) .map(CreateToken.class::cast) .ifPresent(paymentTokenCreate::setCreateToken); Optional.ofNullable(storedCredentials) .map(StoredCredentials::transformToInternalModel) .ifPresent(paymentTokenCreate::setStoredCredentials); paymentTokenCreate.getPaymentInstrumentOrCSEDATA().add(payment.transformToInternalModel()); return paymentTokenCreate; } }
CardTokenRequest implements InternalModelTransformer, Serializable { @Override public InternalModelObject transformToInternalModel() throws WorldpayModelTransformationException { final PaymentTokenCreate paymentTokenCreate = new PaymentTokenCreate(); Optional.ofNullable(authenticatedShopperId) .ifPresent(paymentTokenCreate::setAuthenticatedShopperID); Optional.ofNullable(tokenRequest) .map(TokenRequest::transformToInternalModel) .map(CreateToken.class::cast) .ifPresent(paymentTokenCreate::setCreateToken); Optional.ofNullable(storedCredentials) .map(StoredCredentials::transformToInternalModel) .ifPresent(paymentTokenCreate::setStoredCredentials); paymentTokenCreate.getPaymentInstrumentOrCSEDATA().add(payment.transformToInternalModel()); return paymentTokenCreate; } CardTokenRequest(final TokenRequest tokenRequest, final String authenticatedShopperId, final Payment payment, final StoredCredentials storedCredentials);  CardTokenRequest(final TokenRequest tokenRequest, final String authenticatedShopperId, final Payment payment);  CardTokenRequest(final TokenRequest tokenRequest, final Payment payment); }
CardTokenRequest implements InternalModelTransformer, Serializable { @Override public InternalModelObject transformToInternalModel() throws WorldpayModelTransformationException { final PaymentTokenCreate paymentTokenCreate = new PaymentTokenCreate(); Optional.ofNullable(authenticatedShopperId) .ifPresent(paymentTokenCreate::setAuthenticatedShopperID); Optional.ofNullable(tokenRequest) .map(TokenRequest::transformToInternalModel) .map(CreateToken.class::cast) .ifPresent(paymentTokenCreate::setCreateToken); Optional.ofNullable(storedCredentials) .map(StoredCredentials::transformToInternalModel) .ifPresent(paymentTokenCreate::setStoredCredentials); paymentTokenCreate.getPaymentInstrumentOrCSEDATA().add(payment.transformToInternalModel()); return paymentTokenCreate; } CardTokenRequest(final TokenRequest tokenRequest, final String authenticatedShopperId, final Payment payment, final StoredCredentials storedCredentials);  CardTokenRequest(final TokenRequest tokenRequest, final String authenticatedShopperId, final Payment payment);  CardTokenRequest(final TokenRequest tokenRequest, final Payment payment); @Override InternalModelObject transformToInternalModel(); TokenRequest getTokenRequest(); String getAuthenticatedShopperId(); Payment getPayment(); void setTokenRequest(final TokenRequest tokenRequest); void setAuthenticatedShopperId(final String authenticatedShopperId); void setPayment(final Payment payment); StoredCredentials getStoredCredentials(); void setStoredCredentials(final StoredCredentials storedCredentials); @Override String toString(); }
CardTokenRequest implements InternalModelTransformer, Serializable { @Override public InternalModelObject transformToInternalModel() throws WorldpayModelTransformationException { final PaymentTokenCreate paymentTokenCreate = new PaymentTokenCreate(); Optional.ofNullable(authenticatedShopperId) .ifPresent(paymentTokenCreate::setAuthenticatedShopperID); Optional.ofNullable(tokenRequest) .map(TokenRequest::transformToInternalModel) .map(CreateToken.class::cast) .ifPresent(paymentTokenCreate::setCreateToken); Optional.ofNullable(storedCredentials) .map(StoredCredentials::transformToInternalModel) .ifPresent(paymentTokenCreate::setStoredCredentials); paymentTokenCreate.getPaymentInstrumentOrCSEDATA().add(payment.transformToInternalModel()); return paymentTokenCreate; } CardTokenRequest(final TokenRequest tokenRequest, final String authenticatedShopperId, final Payment payment, final StoredCredentials storedCredentials);  CardTokenRequest(final TokenRequest tokenRequest, final String authenticatedShopperId, final Payment payment);  CardTokenRequest(final TokenRequest tokenRequest, final Payment payment); @Override InternalModelObject transformToInternalModel(); TokenRequest getTokenRequest(); String getAuthenticatedShopperId(); Payment getPayment(); void setTokenRequest(final TokenRequest tokenRequest); void setAuthenticatedShopperId(final String authenticatedShopperId); void setPayment(final Payment payment); StoredCredentials getStoredCredentials(); void setStoredCredentials(final StoredCredentials storedCredentials); @Override String toString();  }