Skip to content

Commit

Permalink
Be less strict about datetime of created payments, due to mismatch te…
Browse files Browse the repository at this point in the history
…st machine and mollie instance
  • Loading branch information
Mats Stijlaart committed Oct 25, 2016
1 parent 06cbd3d commit 6186552
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/test/java/nl/stil4m/mollie/ClientIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testCreatePayment() throws IOException, InterruptedException {
Date beforeTest = new Date();
ResponseOrError<CreatedPayment> payment = client.payments().create(new CreatePayment(Optional.empty(), 1.00, "Some description", "http://example.com", Optional.empty(), null));

DynamicClientIntegrationTest.assertWithin(beforeTest, payment.getData().getCreatedDatetime(), new Date());
DynamicClientIntegrationTest.assertWithin(beforeTest, payment.getData().getCreatedDatetime(), new Date(), 5000L);
}

@Test
Expand All @@ -58,7 +58,7 @@ public void testCreateIdealPayment() throws IOException, URISyntaxException, Int
ResponseOrError<CreatedPayment> payment = client.payments().create(new CreateIdealPayment(1.00, "Some description", "http://example.com", Optional.empty(), null, new IdealPaymentOptions(issuer.getId())));

assertThat(payment.getSuccess(), is(true));
DynamicClientIntegrationTest.assertWithin(beforeTest, payment.getData().getCreatedDatetime(), new Date());
DynamicClientIntegrationTest.assertWithin(beforeTest, payment.getData().getCreatedDatetime(), new Date(), 5000L);
}

@Test
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/nl/stil4m/mollie/DynamicClientIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testCreatePayment() throws IOException {
ResponseOrError<CreatedPayment> payment = client.payments(VALID_API_KEY).create(new CreatePayment(Optional.empty(), 1.00, "Some description", "http://example.com", Optional.empty(), meta));

CreatedPayment createdPayment = payment.getData();
assertWithin(beforeTest, createdPayment.getCreatedDatetime(), new Date());
assertWithin(beforeTest, createdPayment.getCreatedDatetime(), new Date(), 5000L);

assertThat(createdPayment.getMethod(), is(nullValue()));
assertThat(createdPayment.getAmount(), is(1.00));
Expand All @@ -78,7 +78,7 @@ public void testCreatePaymentWithMethod() throws IOException {
ResponseOrError<CreatedPayment> payment = client.payments(VALID_API_KEY).create(new CreatePayment(Optional.of("ideal"), 1.00, "Some description", "http://example.com", Optional.empty(), meta));

CreatedPayment createdPayment = payment.getData();
assertWithin(beforeTest, createdPayment.getCreatedDatetime(), new Date());
assertWithin(beforeTest, createdPayment.getCreatedDatetime(), new Date(), 5000L);

assertThat(createdPayment.getMethod(), is("ideal"));
assertThat(createdPayment.getAmount(), is(1.00));
Expand Down Expand Up @@ -144,9 +144,9 @@ public void testCreateAndGetCreditCardPayment() throws IOException {
}


public static void assertWithin(Date before, Date target, Date after) {
long beforeTime = before.getTime() - (before.getTime() % 1000) - 1000; //Subtract another 1000 just to be safe
long afterTime = after.getTime() - (after.getTime() % 1000) + 1000;
public static void assertWithin(Date before, Date target, Date after, Long additionalSpan) {
long beforeTime = before.getTime() - (before.getTime() % 1000) - additionalSpan;
long afterTime = after.getTime() - (after.getTime() % 1000) + additionalSpan;
assertThat(beforeTime <= target.getTime(), is(true));
assertThat(target.getTime() <= afterTime, is(true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class CreateIdealPaymentTest {
public void before() throws InterruptedException {
Thread.sleep(TEST_TIMEOUT);
}

@Test
public void testSerialize() throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
Expand Down

0 comments on commit 6186552

Please sign in to comment.