Search in sources :

Example 16 with HyperwalletApiClient

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

the class HyperwalletTest method testGetTransferRefund_successful.

@Test
public void testGetTransferRefund_successful() throws Exception {
    HyperwalletTransferRefund transferRefund = new HyperwalletTransferRefund();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(Class.class))).thenReturn(transferRefund);
    HyperwalletTransferRefund resp = client.getTransferRefund("transferToken", "transferRefundToken");
    assertThat(resp, is(equalTo(transferRefund)));
    Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/transfers/transferToken/refunds/transferRefundToken", transferRefund.getClass());
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 17 with HyperwalletApiClient

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

the class HyperwalletTest method testListBalancesForPrepaidCard_withSomeParameters.

@Test
public void testListBalancesForPrepaidCard_withSomeParameters() throws Exception {
    HyperwalletList<HyperwalletBalance> response = new HyperwalletList<HyperwalletBalance>();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    HyperwalletBalanceListOptions options = new HyperwalletBalanceListOptions();
    options.sortBy("test-sort-by");
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
    HyperwalletList<HyperwalletBalance> resp = client.listBalancesForPrepaidCard("test-user-token", "test-prepaid-card-token", options);
    assertThat(resp, is(equalTo(response)));
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/prepaid-cards/test-prepaid-card-token/balances" + "?sortBy=test-sort-by"), 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 18 with HyperwalletApiClient

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

the class HyperwalletTest method listBusinessStakeholders_withVerificationDocumentAndRejectReasons.

@Test
public void listBusinessStakeholders_withVerificationDocumentAndRejectReasons() throws Exception {
    String token = "test-token";
    HyperwalletBusinessStakeholder hyperwalletBusinessStakeholder = getHyperwalletBusinessStakeholder();
    HyperwalletList<HyperwalletBusinessStakeholder> response = new HyperwalletList<>();
    response.setData(Arrays.asList(hyperwalletBusinessStakeholder));
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    final String url = "https://api.sandbox.hyperwallet.com/rest/v4/users/" + token + "/business-stakeholders";
    Mockito.when(mockApiClient.get(ArgumentMatchers.eq(url), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
    HyperwalletList<HyperwalletBusinessStakeholder> resp = client.listBusinessStakeholders(token);
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq(url), ArgumentMatchers.any(TypeReference.class));
    assertThat(resp.getData().size(), is(1));
    assertThat(resp.getData().get(0).getToken(), is(hyperwalletBusinessStakeholder.getToken()));
    assertThat(resp.getData().get(0).getDocuments().size(), is(1));
    assertThat(resp.getData().get(0).getDocuments().get(0).getReasons().get(0).getName(), is(RejectReason.DOCUMENT_EXPIRED));
    assertThat(resp.getData().get(0).getDocuments().get(0).getReasons().get(0).getDescription(), is("Document has expired"));
    assertThat(resp.getData().get(0).getDocuments().get(0).getCreatedOn(), is(hyperwalletBusinessStakeholder.getDocuments().get(0).getCreatedOn()));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.testng.annotations.Test)

Example 19 with HyperwalletApiClient

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

the class HyperwalletTest method testGetPrepaidCard_successful.

@Test
public void testGetPrepaidCard_successful() throws Exception {
    HyperwalletPrepaidCard prepaidCardResponse = new HyperwalletPrepaidCard();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(Class.class))).thenReturn(prepaidCardResponse);
    HyperwalletPrepaidCard resp = client.getPrepaidCard("test-user-token", "test-prepaid-card-token");
    assertThat(resp, is(equalTo(prepaidCardResponse)));
    Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/prepaid-cards/test-prepaid-card-token", prepaidCardResponse.getClass());
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 20 with HyperwalletApiClient

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

the class HyperwalletTest method testCreatePaperCheckStatusTransition_successful.

@Test
public void testCreatePaperCheckStatusTransition_successful() throws Exception {
    HyperwalletStatusTransition transition = new HyperwalletStatusTransition();
    transition.setFromStatus(HyperwalletStatusTransition.Status.ACTIVATED);
    transition.setToStatus(HyperwalletStatusTransition.Status.DE_ACTIVATED);
    transition.setCreatedOn(new Date());
    transition.setTransition(HyperwalletStatusTransition.Status.DE_ACTIVATED);
    HyperwalletStatusTransition transitionResponse = 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(transitionResponse);
    HyperwalletStatusTransition resp = client.createPaperCheckStatusTransition("test-user-token", "test-bank-card-token", transition);
    assertThat(resp, is(equalTo(transitionResponse)));
    ArgumentCaptor<HyperwalletStatusTransition> argument = ArgumentCaptor.forClass(HyperwalletStatusTransition.class);
    Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/paper-checks/test-bank-card-token/status-transitions"), argument.capture(), ArgumentMatchers.eq(transition.getClass()));
    HyperwalletStatusTransition apiClientTransition = argument.getValue();
    assertThat(apiClientTransition, is(notNullValue()));
    assertThat(apiClientTransition.getTransition(), is(equalTo(HyperwalletStatusTransition.Status.DE_ACTIVATED)));
    assertThat(apiClientTransition.getFromStatus(), is(nullValue()));
    assertThat(apiClientTransition.getToStatus(), is(nullValue()));
    assertThat(apiClientTransition.getCreatedOn(), is(nullValue()));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) 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