Skip to content

Commit

Permalink
Improve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gcatanese committed Jan 24, 2025
1 parent 3775d76 commit 3de65f2
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/test/java/com/adyen/CheckoutTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,19 @@ public void TestDeserializePaymentRequestIdeal() throws Exception {
String paymentRequestJson = getFileContents("mocks/checkout/paymentRequestIdeal.json");

PaymentRequest parsedCheckoutPaymentRequest = PaymentRequest.fromJson(paymentRequestJson);

// paymentMethod
assertEquals(IdealDetails.TypeEnum.IDEAL, parsedCheckoutPaymentRequest.getPaymentMethod().getIdealDetails().getType());
assertEquals("issuerName", parsedCheckoutPaymentRequest.getPaymentMethod().getIdealDetails().getIssuer());
// amount
assertEquals(1000L, parsedCheckoutPaymentRequest.getAmount().getValue().longValue());
assertEquals("EUR", parsedCheckoutPaymentRequest.getAmount().getCurrency());
// merchant account
assertEquals("myMerchantAccount", parsedCheckoutPaymentRequest.getMerchantAccount());
// reference
assertEquals("merchantReference", parsedCheckoutPaymentRequest.getReference());
// return url
assertEquals("http://return.com", parsedCheckoutPaymentRequest.getReturnUrl());
}

/**
Expand All @@ -105,7 +116,18 @@ public void TestDeserializePaymentRequestScheme() throws Exception {
PaymentRequest parsedCheckoutPaymentRequest = PaymentRequest.fromJson(paymentRequestJson);
assertNotNull(parsedCheckoutPaymentRequest.getPaymentMethod());
assertEquals(CardDetails.TypeEnum.SCHEME, parsedCheckoutPaymentRequest.getPaymentMethod().getCardDetails().getType());
assertEquals("2.4.2", parsedCheckoutPaymentRequest.getPaymentMethod().getCardDetails().getThreeDS2SdkVersion());
// verify un-encrypted fields are empty
assertNull(parsedCheckoutPaymentRequest.getPaymentMethod().getCardDetails().getNumber());
assertNull(parsedCheckoutPaymentRequest.getPaymentMethod().getCardDetails().getCvc());
// verify encrypted fields are correct
assertNotNull(parsedCheckoutPaymentRequest.getPaymentMethod().getCardDetails().getEncryptedCardNumber());
assertEquals("eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwidmVyc2lvbiI6IjEifQ.DXQDEl3M" +
"dyyW_ZrJoF2Kt3P1H2wWaP1z-FgI6SuDv96lN7e_0ki0mUkI8AL2USS_iiMbG5W4NtD4Ut5TqCBPlgOZfN6vDyM8O6Df-" +
"qNbX7rnW9iQQUue_21oo6U9K2tpFEQ9rYgUVIFhfLdFmLZ4q8ejmXFSGuTh-iC06APs2zWdUn0v-S4q4ltAzhee_5yOvff" +
"oSCWOWiGltUqViVOnrllheH-POp4qfL9GbaIkjixPyLNLRizQTrOO_j3m0gczeiORcrjXI2NSouSkPP9M1K9nwUWX-jpVTf" +
"1PkqLTYRzGQwZCoL9JU9HabRXYdM_eLMtNaIfiBo_4wPq5Iocmww",
parsedCheckoutPaymentRequest.getPaymentMethod().getCardDetails().getEncryptedCardNumber());
}
/**
* Should make paymentMethods call
Expand Down

0 comments on commit 3de65f2

Please sign in to comment.