|
18 | 18 | import com.adyen.model.reportwebhooks.ReportWebhooksHandler; |
19 | 19 | import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4; |
20 | 20 | import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler; |
| 21 | +import com.adyen.model.transferwebhooks.BalanceMutation; |
21 | 22 | import com.adyen.model.transferwebhooks.InterchangeData; |
22 | 23 | import com.adyen.model.transferwebhooks.PlatformPayment; |
| 24 | +import com.adyen.model.transferwebhooks.TransferData; |
| 25 | +import com.adyen.model.transferwebhooks.TransferEvent; |
23 | 26 | import com.adyen.model.transferwebhooks.TransferNotificationRequest; |
24 | 27 | import com.adyen.model.transferwebhooks.TransferWebhooksHandler; |
25 | 28 | import com.adyen.util.HMACValidator; |
@@ -445,6 +448,61 @@ public void testTransferNotificationRequest() { |
445 | 448 | .getActualInstance()); |
446 | 449 | } |
447 | 450 |
|
| 451 | + @Test |
| 452 | + public void testTransferCreatedNotificationRequest() { |
| 453 | + String json = getFileContents("mocks/balancePlatform-webhooks/transfer-created.json"); |
| 454 | + |
| 455 | + Optional<TransferNotificationRequest> optionalTransferNotificationRequest = |
| 456 | + new TransferWebhooksHandler(json).getTransferNotificationRequest(); |
| 457 | + assertTrue(optionalTransferNotificationRequest.isPresent()); |
| 458 | + |
| 459 | + TransferNotificationRequest transferNotificationRequest = |
| 460 | + optionalTransferNotificationRequest.get(); |
| 461 | + assertEquals( |
| 462 | + TransferNotificationRequest.TypeEnum.BALANCEPLATFORM_TRANSFER_CREATED, |
| 463 | + transferNotificationRequest.getType()); |
| 464 | + assertEquals("test", transferNotificationRequest.getEnvironment()); |
| 465 | + assertNotNull(transferNotificationRequest.getTimestamp()); |
| 466 | + |
| 467 | + TransferData data = transferNotificationRequest.getData(); |
| 468 | + assertNotNull(data); |
| 469 | + assertEquals("2WT1N05XXY7P9XH9", data.getId()); |
| 470 | + assertEquals(TransferData.TypeEnum.INTERNALTRANSFER, data.getType()); |
| 471 | + assertEquals("YOUR_BALANCE_PLATFORM", data.getBalancePlatform()); |
| 472 | + assertEquals(TransferData.CategoryEnum.INTERNAL, data.getCategory()); |
| 473 | + assertEquals("2023-02-28T13:30:05+02:00", data.getCreationDate().toString()); |
| 474 | + assertEquals(TransferData.DirectionEnum.INCOMING, data.getDirection()); |
| 475 | + assertEquals(TransferData.ReasonEnum.APPROVED, data.getReason()); |
| 476 | + assertEquals(TransferData.StatusEnum.RECEIVED, data.getStatus()); |
| 477 | + assertEquals(Integer.valueOf(1), data.getSequenceNumber()); |
| 478 | + |
| 479 | + assertNotNull(data.getAccountHolder()); |
| 480 | + assertEquals("AH00000000000000000000002", data.getAccountHolder().getId()); |
| 481 | + assertEquals("Your reference of the account holder", data.getAccountHolder().getReference()); |
| 482 | + assertNotNull(data.getAmount()); |
| 483 | + assertEquals("EUR", data.getAmount().getCurrency()); |
| 484 | + assertEquals(Long.valueOf(1000), data.getAmount().getValue()); |
| 485 | + assertNotNull(data.getBalanceAccount()); |
| 486 | + assertEquals("BA00000000000000000000002", data.getBalanceAccount().getId()); |
| 487 | + |
| 488 | + assertNotNull(data.getBalances()); |
| 489 | + assertEquals(1, data.getBalances().size()); |
| 490 | + BalanceMutation balance = data.getBalances().get(0); |
| 491 | + assertEquals("EUR", balance.getCurrency()); |
| 492 | + assertEquals(Long.valueOf(1000), balance.getReceived()); |
| 493 | + |
| 494 | + assertNotNull(data.getEvents()); |
| 495 | + assertEquals(1, data.getEvents().size()); |
| 496 | + TransferEvent event = data.getEvents().get(0); |
| 497 | + assertEquals("JDRF00000000000000000000000001", event.getId()); |
| 498 | + assertEquals("2023-02-28T13:30:18+02:00", event.getBookingDate().toString()); |
| 499 | + assertEquals(TransferEvent.StatusEnum.RECEIVED, event.getStatus()); |
| 500 | + assertEquals(TransferEvent.TypeEnum.ACCOUNTING, event.getType()); |
| 501 | + assertNotNull(event.getMutations()); |
| 502 | + assertEquals(1, event.getMutations().size()); |
| 503 | + assertEquals(Long.valueOf(1000), event.getMutations().get(0).getReceived()); |
| 504 | + } |
| 505 | + |
448 | 506 | @Test |
449 | 507 | public void testGetDisputeNotificationRequestSuccess() { |
450 | 508 |
|
|
0 commit comments