use of com.stripe.net.StripeResponse in project stripe-java by stripe.
the class StripeResponseTest method testResponseIncludedList.
@Test
public void testResponseIncludedList() throws AuthenticationException, InvalidRequestException, APIException, APIConnectionException, CardException {
CustomerCollection cusCollection = Customer.list(new HashMap<String, Object>());
StripeResponse resp = cusCollection.getLastResponse();
assertThat(resp, instanceOf(StripeResponse.class));
assertEquals(200, resp.code());
assertTrue(resp.requestId().startsWith("req_"));
assertTrue(resp.body().length() > 0);
}
use of com.stripe.net.StripeResponse in project stripe-java by stripe.
the class StripeResponseTest method testGetIdempotencyKey.
@Test
public void testGetIdempotencyKey() {
Map<String, List<String>> headerMap = generateHeaderMap();
StripeResponse stripeResponse = new StripeResponse(200, chargeBody, headerMap);
assertEquals("12345", stripeResponse.idempotencyKey());
}
use of com.stripe.net.StripeResponse in project stripe-java by stripe.
the class StripeResponseTest method testRequestId.
@Test
public void testRequestId() {
Map<String, List<String>> headerMap = generateHeaderMap();
StripeResponse stripeResponse = new StripeResponse(200, chargeBody, headerMap);
assertEquals(stripeResponse.requestId(), "req_12345");
}
use of com.stripe.net.StripeResponse in project stripe-java by stripe.
the class StripeResponseTest method testNoHeaders.
@Test
public void testNoHeaders() {
StripeResponse stripeResponse = new StripeResponse(200, chargeBody);
assertEquals(stripeResponse.headers(), null);
assertEquals(stripeResponse.idempotencyKey(), null);
assertEquals(stripeResponse.requestId(), null);
}
use of com.stripe.net.StripeResponse in project stripe-java by stripe.
the class StripeResponseTest method testResponseIncluded.
@Test
public void testResponseIncluded() throws AuthenticationException, InvalidRequestException, APIException, APIConnectionException, CardException {
String idempotencyKey = Long.toString(System.currentTimeMillis());
RequestOptions requestOptions = RequestOptions.builder().setStripeVersion(Stripe.apiVersion).setIdempotencyKey(idempotencyKey).build();
Customer cus = Customer.create(defaultCustomerParams, requestOptions);
cus = Customer.retrieve(cus.getId(), requestOptions);
StripeResponse resp = cus.getLastResponse();
assertThat(resp, instanceOf(StripeResponse.class));
assertEquals(200, resp.code());
assertEquals(idempotencyKey, resp.idempotencyKey());
assertTrue(resp.requestId().startsWith("req_"));
assertTrue(resp.body().length() > 0);
}
Aggregations