use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListVenmoAccountStatusTransitions_withParameters.
@Test
public void testListVenmoAccountStatusTransitions_withParameters() throws Exception {
HyperwalletList<HyperwalletStatusTransition> response = new HyperwalletList<HyperwalletStatusTransition>();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletStatusTransitionListPaginationOptions options = new HyperwalletStatusTransitionListPaginationOptions();
options.sortBy("test-sort-by").limit(10).createdAfter(convertStringToDate("2020-08-20T23:14:26Z")).createdBefore(convertStringToDate("2020-08-20T23:14:26Z"));
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
HyperwalletList<HyperwalletStatusTransition> resp = client.listVenmoAccountStatusTransitions("test-user-token", "test-venmo-account-token", options);
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?createdAfter=2020-08-20T23:14:26Z&createdBefore=2020-08-20T23:14:26Z&sortBy=test-sort-by&limit=10"), ArgumentMatchers.any(TypeReference.class));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListUserStatusTransitions_withSomeParameters.
@Test
public void testListUserStatusTransitions_withSomeParameters() throws Exception {
HyperwalletList<HyperwalletStatusTransition> response = new HyperwalletList<HyperwalletStatusTransition>();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletPaginationOptions options = new HyperwalletPaginationOptions();
options.sortBy("test-sort-by").createdBefore(convertStringToDate("2016-06-29T17:58:26Z"));
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
HyperwalletList<HyperwalletStatusTransition> resp = client.listUserStatusTransitions("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/status-transitions?createdBefore=2016-06-29T17:58" + ":26Z&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 testCreateVenmoAccountStatusTransition_successful.
@Test
public void testCreateVenmoAccountStatusTransition_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.createVenmoAccountStatusTransition("test-user-token", "test-venmo-account-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/venmo-accounts/test-venmo-account-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()));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListTransfer_noParameters.
@Test
public void testListTransfer_noParameters() throws Exception {
HyperwalletList<HyperwalletTransfer> response = new HyperwalletList<HyperwalletTransfer>();
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<HyperwalletTransfer> resp = client.listTransfers();
assertThat(resp, is(equalTo(response)));
Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/transfers"), ArgumentMatchers.any(TypeReference.class));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testPrepaidCardStatusTransitionMethods_successful.
@Test(dataProvider = "prepaidCardStatusTransitions")
public void testPrepaidCardStatusTransitionMethods_successful(String methodName, HyperwalletStatusTransition.Status expectedTransition) 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);
Method method = client.getClass().getMethod(methodName + "PrepaidCard", String.class, String.class);
HyperwalletStatusTransition resp = (HyperwalletStatusTransition) method.invoke(client, "test-user-token", "test-prepaid-card-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/prepaid-cards/test-prepaid-card-token/status" + "-transitions"), argument.capture(), ArgumentMatchers.eq(statusTransitionResponse.getClass()));
HyperwalletStatusTransition apiClientStatusTransition = argument.getValue();
assertThat(apiClientStatusTransition, is(notNullValue()));
assertThat(apiClientStatusTransition.getTransition(), is(equalTo(expectedTransition)));
}
Aggregations