Search in sources :

Example 66 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testListBankCards_withParameters.

@Test
public void testListBankCards_withParameters() throws Exception {
    HyperwalletList<HyperwalletBankCard> response = new HyperwalletList<HyperwalletBankCard>();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    HyperwalletBankCardListPaginationOptions options = new HyperwalletBankCardListPaginationOptions();
    options.status(HyperwalletBankCard.Status.ACTIVATED).sortBy("test-sort-by").limit(10).createdAfter(convertStringToDate("2016-06-29T17:58:26Z")).createdBefore(convertStringToDate("2019-06-29T17:58:26Z"));
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
    HyperwalletList<HyperwalletBankCard> resp = client.listBankCards("test-user-token", options);
    assertThat(resp, is(equalTo(response)));
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/bank-cards?createdAfter=2016-06-29T17:58:26Z" + "&createdBefore=2019-06-29T17:58:26Z&sortBy=test-sort-by&limit=10&status=ACTIVATED"), ArgumentMatchers.any(TypeReference.class));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.testng.annotations.Test)

Example 67 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testDeactivateBusinessStakeholderStatusTransition_successful.

@Test
public void testDeactivateBusinessStakeholderStatusTransition_successful() throws Exception {
    HyperwalletStatusTransition statusTransitionResponse = new HyperwalletStatusTransition();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyObject(), ArgumentMatchers.any(Class.class))).thenReturn(statusTransitionResponse);
    HyperwalletStatusTransition resp = client.deactivateBusinessStakeholder("test-user-token", "test-stk-token");
    assertThat(resp, is(equalTo(statusTransitionResponse)));
    ArgumentCaptor<HyperwalletStatusTransition> argument = ArgumentCaptor.forClass(HyperwalletStatusTransition.class);
    Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/business-stakeholders/test-stk-token/status" + "-transitions"), argument.capture(), ArgumentMatchers.eq(statusTransitionResponse.getClass()));
    HyperwalletStatusTransition apiClientStatusTransition = argument.getValue();
    assertThat(apiClientStatusTransition, is(notNullValue()));
    assertThat(apiClientStatusTransition.getTransition(), is(equalTo(HyperwalletStatusTransition.Status.DE_ACTIVATED)));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 68 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testGetWebhookEvent_Successful.

@Test
public void testGetWebhookEvent_Successful() throws Exception {
    HyperwalletWebhookNotification event = new HyperwalletWebhookNotification();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(Class.class))).thenReturn(event);
    HyperwalletWebhookNotification resp = client.getWebhookEvent("test-webhook-token");
    assertThat(resp, is(equalTo(event)));
    Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/webhook-notifications/test-webhook-token", event.getClass());
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 69 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testListReceiptsForProgramAccount_noParameters.

@Test
public void testListReceiptsForProgramAccount_noParameters() throws Exception {
    HyperwalletList<HyperwalletReceipt> response = new HyperwalletList<HyperwalletReceipt>();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
    HyperwalletList<HyperwalletReceipt> resp = client.listReceiptsForProgramAccount("test-program-token", "test-account-token");
    assertThat(resp, is(equalTo(response)));
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/programs/test-program-token/accounts/test-account-token/receipts"), ArgumentMatchers.any(TypeReference.class));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.testng.annotations.Test)

Example 70 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testListVenmoAccountStatusTransitions_noParameters.

@Test
public void testListVenmoAccountStatusTransitions_noParameters() throws Exception {
    HyperwalletList<HyperwalletStatusTransition> response = new HyperwalletList<HyperwalletStatusTransition>();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
    HyperwalletList<HyperwalletStatusTransition> resp = client.listVenmoAccountStatusTransitions("test-user-token", "test-venmo-account-token");
    assertThat(resp, is(equalTo(response)));
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/venmo-accounts/test-venmo-account-token/status" + "-transitions"), ArgumentMatchers.any(TypeReference.class));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.testng.annotations.Test)

Aggregations

HyperwalletApiClient (com.hyperwallet.clientsdk.util.HyperwalletApiClient)170 Test (org.testng.annotations.Test)168 TypeReference (com.fasterxml.jackson.core.type.TypeReference)85 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)11 ForeignExchange (com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange)3 Field (java.lang.reflect.Field)2 Method (java.lang.reflect.Method)1 JSONObject (net.minidev.json.JSONObject)1