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));
}
}
Aggregations