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());
}
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));
}
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()));
}
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());
}
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()));
}
Aggregations