Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve deserialization unit testing #1421

Merged
merged 4 commits into from
Jan 24, 2025
Merged

Conversation

gcatanese
Copy link
Contributor

PR to:

  • add deserialization unit test for scheme
  • rename method to be more specific (TestDeserializePaymentRequestIdeal)

@gcatanese gcatanese requested a review from a team as a code owner January 24, 2025 11:23
Copy link
Member

@Kwok-he-Chu Kwok-he-Chu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work


PaymentRequest parsedCheckoutPaymentRequest = PaymentRequest.fromJson(paymentRequestJson);
assertNotNull(parsedCheckoutPaymentRequest.getPaymentMethod());
assertEquals(CardDetails.TypeEnum.SCHEME, parsedCheckoutPaymentRequest.getPaymentMethod().getCardDetails().getType());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement: Let's assert that all properties are populated correctly after deserialization, not just SCHEME but also encryptedExpiryMonth etc. (see paymentRequestScheme.json mock)

paymentRequest.setReturnUrl("http://return.com");
paymentRequest.setPaymentMethod(new CheckoutPaymentMethod(idealDetails));
public void TestDeserializePaymentRequestIdeal() throws Exception {
String paymentRequestJson = getFileContents("mocks/checkout/paymentRequestIdeal.json");

PaymentRequest parsedCheckoutPaymentRequest = PaymentRequest.fromJson(paymentRequestJson);
assertEquals(IdealDetails.TypeEnum.IDEAL, parsedCheckoutPaymentRequest.getPaymentMethod().getIdealDetails().getType());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement: idem. see comment below

@gcatanese gcatanese merged commit b49b20f into main Jan 24, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants