|
14 | 14 | import com.adyen.model.reportwebhooks.ReportWebhooksHandler;
|
15 | 15 | import com.adyen.model.transactionwebhooks.TransactionNotificationRequestV4;
|
16 | 16 | import com.adyen.model.transactionwebhooks.TransactionWebhooksHandler;
|
| 17 | +import com.adyen.model.transferwebhooks.PlatformPayment; |
| 18 | +import com.adyen.model.transferwebhooks.TransferNotificationRequest; |
| 19 | +import com.adyen.model.transferwebhooks.TransferWebhooksHandler; |
17 | 20 | import com.adyen.util.HMACValidator;
|
18 | 21 | import java.security.SignatureException;
|
19 | 22 | import java.util.Optional;
|
20 | 23 | import org.junit.Assert;
|
21 | 24 | import org.junit.Test;
|
22 | 25 |
|
| 26 | + |
23 | 27 | /** Unit testing for all AfP/Bank related webhooks */
|
24 | 28 | public class BalancePlatformWebhooksTest extends BaseTest {
|
25 | 29 |
|
@@ -352,4 +356,31 @@ public void testNetworkTokenUpdatedNotificationRequest() throws Exception {
|
352 | 356 | assertEquals(
|
353 | 357 | "YOUR_BALANCE_PLATFORM", networkTokenNotificationRequest.getData().getBalancePlatform());
|
354 | 358 | }
|
| 359 | + |
| 360 | + @Test |
| 361 | + public void testTransferNotificationRequest() throws Exception { |
| 362 | + String json = |
| 363 | + getFileContents( |
| 364 | + "mocks/balancePlatform-webhooks/transfer-updated.json"); |
| 365 | + |
| 366 | + Optional<TransferNotificationRequest> optionalTransferNotificationRequest = |
| 367 | + new TransferWebhooksHandler(json).getTransferNotificationRequest(); |
| 368 | + assertTrue(optionalTransferNotificationRequest.isPresent()); |
| 369 | + |
| 370 | + TransferNotificationRequest transferNotificationRequest = |
| 371 | + optionalTransferNotificationRequest.get(); |
| 372 | + assertEquals( |
| 373 | + TransferNotificationRequest.TypeEnum.BALANCEPLATFORM_TRANSFER_UPDATED, |
| 374 | + transferNotificationRequest.getType()); |
| 375 | + assertNotNull(transferNotificationRequest.getData()); |
| 376 | + assertEquals("YOUR_BALANCE_PLATFORM", transferNotificationRequest.getData().getBalancePlatform()); |
| 377 | + |
| 378 | + assertNotNull(transferNotificationRequest.getData().getCategoryData().getPlatformPayment()); |
| 379 | + assertEquals(PlatformPayment.PlatformPaymentTypeEnum.REMAINDER, |
| 380 | + transferNotificationRequest.getData().getCategoryData().getPlatformPayment().getPlatformPaymentType()); |
| 381 | + |
| 382 | + assertNotNull(transferNotificationRequest.getData().getBalances()); |
| 383 | + assertEquals(1, transferNotificationRequest.getData().getBalances().size()); |
| 384 | + } |
| 385 | + |
355 | 386 | }
|
0 commit comments