Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/test/java/com/adyen/TransfersTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void TransactionsRetrieveTest() throws Exception {

@Test
public void TestGetCapitalAccounts() throws Exception {
Client client = createMockClientFromFile("mocks/capital/get-capital-account.json");
Client client = createMockClientFromFile("mocks/transfers/get-capital-account.json");
CapitalApi capital = new CapitalApi(client);
CapitalGrants response = capital.getCapitalAccount();
assertEquals(response.getGrants().get(0).getGrantOfferId(), "string");
Expand All @@ -66,7 +66,7 @@ public void TestGetCapitalAccounts() throws Exception {

@Test
public void TestRequestGrant() throws Exception {
Client client = createMockClientFromFile("mocks/capital/request-grant.json");
Client client = createMockClientFromFile("mocks/transfers/request-grant.json");
CapitalApi capital = new CapitalApi(client);
CapitalGrant response = capital.requestGrantPayout(new CapitalGrantInfo());
assertEquals(response.getGrantAccountId(), "CG00000000000000000000001");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Java API Library
*
* Copyright (c) 2026 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
package com.adyen.service.capital;

import static org.mockito.Mockito.verify;

import com.adyen.BaseTest;
import com.adyen.Client;
import com.adyen.constants.ApiConstants;
import com.adyen.model.capital.GrantAccount;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class GrantAccountsApiTest extends BaseTest {

@Test
void testGetGrantAccount() throws Exception {
Client client = createMockClientFromFile("mocks/capital/get-grant-account-success.json");
GrantAccountsApi grantAccountsApi = new GrantAccountsApi(client);
GrantAccount response =
grantAccountsApi.getGrantAccountInformation("CG00000000000000000000001");

Assertions.assertNotNull(response);
Assertions.assertEquals("CG00000000000000000000001", response.getId());
Assertions.assertEquals("BA00000000000000000000001", response.getFundingBalanceAccountId());
Assertions.assertEquals(1, response.getLimits().size());
Assertions.assertEquals(1, response.getBalances().size());

verify(client.getHttpClient())
.request(
"https://balanceplatform-api-test.adyen.com/capital/v1/grantAccounts/CG00000000000000000000001",
null,
client.getConfig(),
false,
null,
ApiConstants.HttpMethod.GET,
null);
}

@Test
void testGetGrantAccountRequiredParams() {
Client client = createMockClientFromFile("mocks/capital/get-grant-account-success.json");
GrantAccountsApi grantAccountsApi = new GrantAccountsApi(client);
Assertions.assertThrows(
IllegalArgumentException.class, () -> grantAccountsApi.getGrantAccountInformation(null));
}
}
108 changes: 108 additions & 0 deletions src/test/java/com/adyen/service/capital/GrantOffersApiTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Java API Library
*
* Copyright (c) 2026 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*/
package com.adyen.service.capital;

import static org.mockito.Mockito.verify;

import com.adyen.BaseTest;
import com.adyen.Client;
import com.adyen.constants.ApiConstants;
import com.adyen.model.capital.Amount;
import com.adyen.model.capital.GrantOffer;
import com.adyen.model.capital.GrantOffers;
import java.util.Map;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class GrantOffersApiTest extends BaseTest {

@Test
void testGetAllGrantOffersWithQueryParam() throws Exception {
Client client = createMockClientFromFile("mocks/capital/grant-offers-success.json");
GrantOffersApi grantOffersApi = new GrantOffersApi(client);
GrantOffers response = grantOffersApi.getAllGrantOffers("AH00000000000000000000001", null);

Assertions.assertNotNull(response);
Assertions.assertEquals(1, response.getGrantOffers().size());
Assertions.assertEquals("GO00000000000000000000001", response.getGrantOffers().get(0).getId());

verify(client.getHttpClient())
.request(
"https://balanceplatform-api-test.adyen.com/capital/v1/grantOffers",
null,
client.getConfig(),
false,
null,
ApiConstants.HttpMethod.GET,
Map.of("accountHolderId", "AH00000000000000000000001"));
}

@Test
void testGetAllGrantOffers() throws Exception {
Client client = createMockClientFromFile("mocks/capital/grant-offers-success.json");
GrantOffersApi grantOffersApi = new GrantOffersApi(client);
GrantOffers response = grantOffersApi.getAllGrantOffers();

Assertions.assertNotNull(response);
Assertions.assertEquals(1, response.getGrantOffers().size());
Assertions.assertEquals("GO00000000000000000000001", response.getGrantOffers().get(0).getId());

verify(client.getHttpClient())
.request(
"https://balanceplatform-api-test.adyen.com/capital/v1/grantOffers",
null,
client.getConfig(),
false,
null,
ApiConstants.HttpMethod.GET,
Map.of());
}

@Test
void testGetGrantOffer() throws Exception {
Client client = createMockClientFromFile("mocks/capital/get-grant-offer-success.json");
GrantOffersApi grantOffersApi = new GrantOffersApi(client);
GrantOffer response = grantOffersApi.getGrantOffer("GO00000000000000000000001");

Assertions.assertNotNull(response);
Assertions.assertEquals("GO00000000000000000000001", response.getId());
Assertions.assertEquals("AH00000000000000000000001", response.getAccountHolderId());
Assertions.assertEquals(new Amount().currency("EUR").value(10000L), response.getAmount());

verify(client.getHttpClient())
.request(
"https://balanceplatform-api-test.adyen.com/capital/v1/grantOffers/GO00000000000000000000001",
null,
client.getConfig(),
false,
null,
ApiConstants.HttpMethod.GET,
null);
}

@Test
void testGetGrantOfferParams() {
Client client = createMockClientFromFile("mocks/capital/get-grant-offer-success.json");
GrantOffersApi grantOffersApi = new GrantOffersApi(client);
Assertions.assertThrows(
IllegalArgumentException.class, () -> grantOffersApi.getGrantOffer(null));
}
}
Loading