Skip to content

Commit cc74379

Browse files
committed
Adding test for transfer webhook creation
1 parent 60f7ed3 commit cc74379

2 files changed

Lines changed: 110 additions & 0 deletions

File tree

src/test/java/com/adyen/webhooks/BalancePlatformWebhooksTest.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
import com.adyen.model.reportwebhooks.ReportWebhooksHandler;
1919
import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4;
2020
import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler;
21+
import com.adyen.model.transferwebhooks.BalanceMutation;
2122
import com.adyen.model.transferwebhooks.InterchangeData;
2223
import com.adyen.model.transferwebhooks.PlatformPayment;
24+
import com.adyen.model.transferwebhooks.TransferData;
25+
import com.adyen.model.transferwebhooks.TransferEvent;
2326
import com.adyen.model.transferwebhooks.TransferNotificationRequest;
2427
import com.adyen.model.transferwebhooks.TransferWebhooksHandler;
2528
import com.adyen.util.HMACValidator;
@@ -445,6 +448,61 @@ public void testTransferNotificationRequest() {
445448
.getActualInstance());
446449
}
447450

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+
448506
@Test
449507
public void testGetDisputeNotificationRequestSuccess() {
450508

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"data": {
3+
"id": "2WT1N05XXY7P9XH9",
4+
"type": "internalTransfer",
5+
"accountHolder": {
6+
"description": "Your description of the account holder of the target balance account",
7+
"id": "AH00000000000000000000002",
8+
"reference": "Your reference of the account holder"
9+
},
10+
"amount": {
11+
"currency": "EUR",
12+
"value": 1000
13+
},
14+
"balanceAccount": {
15+
"description": "Your description of the target balance account",
16+
"id": "BA00000000000000000000002"
17+
},
18+
"balancePlatform": "YOUR_BALANCE_PLATFORM",
19+
"balances": [
20+
{
21+
"currency": "EUR",
22+
"received": 1000
23+
}
24+
],
25+
"category": "internal",
26+
"creationDate": "2023-02-28T13:30:05+02:00",
27+
"description": "Your description of the transfer",
28+
"direction": "incoming",
29+
"events": [
30+
{
31+
"bookingDate": "2023-02-28T13:30:18+02:00",
32+
"id": "JDRF00000000000000000000000001",
33+
"mutations": [
34+
{
35+
"currency": "EUR",
36+
"received": 1000
37+
}
38+
],
39+
"status": "received",
40+
"type": "accounting"
41+
}
42+
],
43+
"reason": "approved",
44+
"reference": "Your reference of the transfer",
45+
"referenceForBeneficiary": "Your-reference-for-the-recipient-of-the-transfer-request",
46+
"sequenceNumber": 1,
47+
"status": "received"
48+
},
49+
"environment": "test",
50+
"timestamp": "2023-02-28T13:27:05+02:00",
51+
"type": "balancePlatform.transfer.created"
52+
}

0 commit comments

Comments
 (0)