Search in sources :

Example 1 with ReferenceException

use of com.ingenico.connect.gateway.sdk.java.ReferenceException in project connect-sdk-java by Ingenico-ePayments.

the class PaymentsClientTest method testCreateReferenceError.

/**
 * Tests that a 409 failure response with a duplicate request code but without an idempotence key will throw a
 * {@link ReferenceException}.
 */
@Test
@SuppressWarnings("resource")
public void testCreateReferenceError() {
    Client client = Factory.createClient(session);
    String responseBody = getResource("duplicate_request.json");
    whenPost().thenReturn(new Response(409, responseBody, null));
    CreatePaymentRequest body = createRequest();
    try {
        client.merchant("merchantId").payments().create(body);
        Assert.fail("Expected ApiException");
    } catch (ReferenceException e) {
        Assert.assertTrue(e.toString().contains(responseBody));
    }
}
Also used : Response(com.ingenico.connect.gateway.sdk.java.Response) CreatePaymentResponse(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentResponse) ReferenceException(com.ingenico.connect.gateway.sdk.java.ReferenceException) CreatePaymentRequest(com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest) Client(com.ingenico.connect.gateway.sdk.java.Client) Test(org.junit.Test)

Aggregations

Client (com.ingenico.connect.gateway.sdk.java.Client)1 ReferenceException (com.ingenico.connect.gateway.sdk.java.ReferenceException)1 Response (com.ingenico.connect.gateway.sdk.java.Response)1 CreatePaymentRequest (com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentRequest)1 CreatePaymentResponse (com.ingenico.connect.gateway.sdk.java.domain.payment.CreatePaymentResponse)1 Test (org.junit.Test)1