Source:
public void paymentCreatedSuccessfully() throws JsonProcessingException { final Account account = new Account("test", TokenPaymentType.DIRECT_DEBIT); final String paymentId = "abc123"; final String createdDate = "2018-01-01T11:12:13Z"; final String referenceText = "a reference"; final String descriptionText = "a description"; final String paymentProviderText = "a payment provider"; final String status = "created"; final boolean finished = false; DirectDebitConnectorCreatePaymentResponse connectorResponse = aDirectDebitConnectorCreatePaymentResponse() .withPaymentExternalId(paymentId) .withAmount(500L) .withPaymentProvider(paymentProviderText) .withCreatedDate(createdDate) .withDescription(descriptionText) .withState(new PaymentState(status, finished)) .withReference(referenceText) .build(); publicAuthMockClient.mapBearerTokenToAccountId(API_KEY, account.getAccountId()); connectorDDMockClient.respondWithPaymentCreated(connectorResponse, account.getAccountId()); var createDirectDebitPaymentRequest = (CreateDirectDebitPaymentRequest) CreatePaymentRequestBuilder .builder() .amount(500) .description(descriptionText) .reference(referenceText) .agreementId("test") .build(); postPaymentResponse(createDirectDebitPaymentRequest) .statusCode(201) .body("payment_id", is(paymentId)) .body("amount", is(500)) .body("payment_provider", is(paymentProviderText)) .body("created_date", is(createdDate)) .body("description", is(descriptionText)) .body("reference", is(referenceText)) .body("state.status", is(status)) .body("state.finished", is(finished)) .body("_links.events.href", is(paymentEventsLocationFor(paymentId))) .body("_links.events.method", is("GET")) .body("_links.self.href", is(paymentLocationFor(paymentId))) .body("_links.self.method", is("GET")); }

Target:
public void paymentCreatedSuccessfully() throws JsonProcessingException { final Account account = new Account("test", TokenPaymentType.DIRECT_DEBIT); final String paymentId = "abc123"; final String createdDate = "2018-01-01T11:12:13Z"; final String referenceText = "a reference"; final String descriptionText = "a description"; final String paymentProviderText = "a payment provider"; final String status = "created"; final boolean finished = false; DirectDebitConnectorCreatePaymentResponse connectorResponse = aDirectDebitConnectorCreatePaymentResponse() .withPaymentExternalId(paymentId) .withAmount(500L) .withPaymentProvider(paymentProviderText) .withCreatedDate(createdDate) .withDescription(descriptionText) .withState(new PaymentState(status, finished)) .withReference(referenceText) .build(); publicAuthMockClient.mapBearerTokenToAccountId(API_KEY, account.getAccountId()); connectorDDMockClient.respondWithPaymentCreated(connectorResponse, account.getAccountId()); var createDirectDebitPaymentRequest = (CreateDirectDebitPaymentRequest) CreatePaymentRequestBuilder .builder() .amount(500) .description(descriptionText) .reference(referenceText) .mandateId("test") .build(); postPaymentResponse(createDirectDebitPaymentRequest) .statusCode(201) .body("payment_id", is(paymentId)) .body("amount", is(500)) .body("payment_provider", is(paymentProviderText)) .body("created_date", is(createdDate)) .body("description", is(descriptionText)) .body("reference", is(referenceText)) .body("state.status", is(status)) .body("state.finished", is(finished)) .body("_links.events.href", is(paymentEventsLocationFor(paymentId))) .body("_links.events.method", is("GET")) .body("_links.self.href", is(paymentLocationFor(paymentId))) .body("_links.self.method", is("GET")); }