|
| 1 | +/* |
| 2 | + * ###### |
| 3 | + * ###### |
| 4 | + * ############ ####( ###### #####. ###### ############ ############ |
| 5 | + * ############# #####( ###### #####. ###### ############# ############# |
| 6 | + * ###### #####( ###### #####. ###### ##### ###### ##### ###### |
| 7 | + * ###### ###### #####( ###### #####. ###### ##### ##### ##### ###### |
| 8 | + * ###### ###### #####( ###### #####. ###### ##### ##### ###### |
| 9 | + * ############# ############# ############# ############# ##### ###### |
| 10 | + * ############ ############ ############# ############ ##### ###### |
| 11 | + * ###### |
| 12 | + * ############# |
| 13 | + * ############ |
| 14 | + * |
| 15 | + * Adyen Java API Library |
| 16 | + * |
| 17 | + * Copyright (c) 2026 Adyen B.V. |
| 18 | + * This file is open source and available under the MIT license. |
| 19 | + * See the LICENSE file for more info. |
| 20 | + */ |
| 21 | +package com.adyen.service.capital; |
| 22 | + |
| 23 | +import static org.mockito.Mockito.verify; |
| 24 | + |
| 25 | +import com.adyen.BaseTest; |
| 26 | +import com.adyen.Client; |
| 27 | +import com.adyen.constants.ApiConstants; |
| 28 | +import com.adyen.model.capital.Amount; |
| 29 | +import com.adyen.model.capital.GrantOffer; |
| 30 | +import com.adyen.model.capital.GrantOffers; |
| 31 | +import java.util.Map; |
| 32 | +import org.junit.jupiter.api.Assertions; |
| 33 | +import org.junit.jupiter.api.Test; |
| 34 | + |
| 35 | +public class GrantOffersApiTest extends BaseTest { |
| 36 | + |
| 37 | + @Test |
| 38 | + void testGetAllGrantOffers() throws Exception { |
| 39 | + Client client = createMockClientFromFile("mocks/capital/grant-offers-success.json"); |
| 40 | + GrantOffersApi grantOffersApi = new GrantOffersApi(client); |
| 41 | + GrantOffers response = grantOffersApi.getAllGrantOffers("AH00000000000000000000001", null); |
| 42 | + |
| 43 | + Assertions.assertNotNull(response); |
| 44 | + Assertions.assertEquals(1, response.getGrantOffers().size()); |
| 45 | + Assertions.assertEquals("GO00000000000000000000001", response.getGrantOffers().get(0).getId()); |
| 46 | + |
| 47 | + verify(client.getHttpClient()) |
| 48 | + .request( |
| 49 | + "https://balanceplatform-api-test.adyen.com/capital/v1/grantOffers", |
| 50 | + null, |
| 51 | + client.getConfig(), |
| 52 | + false, |
| 53 | + null, |
| 54 | + ApiConstants.HttpMethod.GET, |
| 55 | + Map.of("accountHolderId", "AH00000000000000000000001")); |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + void testGetAllGrantOffers2() throws Exception { |
| 60 | + Client client = createMockClientFromFile("mocks/capital/grant-offers-success.json"); |
| 61 | + GrantOffersApi grantOffersApi = new GrantOffersApi(client); |
| 62 | + GrantOffers response = grantOffersApi.getAllGrantOffers(); |
| 63 | + |
| 64 | + Assertions.assertNotNull(response); |
| 65 | + Assertions.assertEquals(1, response.getGrantOffers().size()); |
| 66 | + Assertions.assertEquals("GO00000000000000000000001", response.getGrantOffers().get(0).getId()); |
| 67 | + |
| 68 | + verify(client.getHttpClient()) |
| 69 | + .request( |
| 70 | + "https://balanceplatform-api-test.adyen.com/capital/v1/grantOffers", |
| 71 | + null, |
| 72 | + client.getConfig(), |
| 73 | + false, |
| 74 | + null, |
| 75 | + ApiConstants.HttpMethod.GET, |
| 76 | + Map.of()); |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + void testGetGrantOffer() throws Exception { |
| 81 | + Client client = createMockClientFromFile("mocks/capital/get-grant-offer-success.json"); |
| 82 | + GrantOffersApi grantOffersApi = new GrantOffersApi(client); |
| 83 | + GrantOffer response = grantOffersApi.getGrantOffer("GO00000000000000000000001"); |
| 84 | + |
| 85 | + Assertions.assertNotNull(response); |
| 86 | + Assertions.assertEquals("GO00000000000000000000001", response.getId()); |
| 87 | + Assertions.assertEquals("AH00000000000000000000001", response.getAccountHolderId()); |
| 88 | + Assertions.assertEquals(new Amount().currency("EUR").value(10000L), response.getAmount()); |
| 89 | + |
| 90 | + verify(client.getHttpClient()) |
| 91 | + .request( |
| 92 | + "https://balanceplatform-api-test.adyen.com/capital/v1/grantOffers/GO00000000000000000000001", |
| 93 | + null, |
| 94 | + client.getConfig(), |
| 95 | + false, |
| 96 | + null, |
| 97 | + ApiConstants.HttpMethod.GET, |
| 98 | + null); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + void testGetGrantOfferParams() { |
| 103 | + Client client = createMockClientFromFile("mocks/capital/get-grant-offer-success.json"); |
| 104 | + GrantOffersApi grantOffersApi = new GrantOffersApi(client); |
| 105 | + Assertions.assertThrows( |
| 106 | + IllegalArgumentException.class, () -> grantOffersApi.getGrantOffer(null)); |
| 107 | + } |
| 108 | +} |
0 commit comments