use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListTransferRefunds_withAllParameters.
@Test
public void testListTransferRefunds_withAllParameters() throws Exception {
HyperwalletList<HyperwalletTransferRefund> response = new HyperwalletList<>();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletTransferRefundListOptions options = new HyperwalletTransferRefundListOptions();
options.clientRefundId("clientRefundId").sourceToken("sourceToken").status("COMPLETED").sortBy("sortByField").limit(10).createdAfter(convertStringToDate("2016-06-29T17:58:26Z")).createdBefore(convertStringToDate("2016-06-29T17:58:26Z"));
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
String transferToken = "transferToken";
HyperwalletList<HyperwalletTransferRefund> resp = client.listTransferRefunds(transferToken, options);
assertThat(resp, is(equalTo(response)));
Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/transfers/" + transferToken + "/refunds?createdAfter=2016-06-29T17:58:26Z&createdBefore=2016-06-29T17:58:26Z&sortBy=sortByField&limit=10" + "&clientRefundId=clientRefundId&sourceToken=sourceToken&status=COMPLETED"), ArgumentMatchers.any(TypeReference.class));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testGetUser_successful.
@Test
public void testGetUser_successful() throws Exception {
HyperwalletUser userResponse = new HyperwalletUser();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(Class.class))).thenReturn(userResponse);
HyperwalletUser resp = client.getUser("test-user-token");
assertThat(resp, is(equalTo(userResponse)));
Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token", userResponse.getClass());
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListReceiptsForUser_withSomeParameters.
@Test
public void testListReceiptsForUser_withSomeParameters() throws Exception {
HyperwalletList<HyperwalletReceipt> response = new HyperwalletList<HyperwalletReceipt>();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletReceiptPaginationOptions options = new HyperwalletReceiptPaginationOptions();
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<HyperwalletReceipt> resp = client.listReceiptsForUser("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/receipts?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 testListWebhookEvents_withParameters.
@Test
public void testListWebhookEvents_withParameters() throws Exception {
HyperwalletList<HyperwalletWebhookNotification> response = new HyperwalletList<HyperwalletWebhookNotification>();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletWebhookNotificationPaginationOptions options = new HyperwalletWebhookNotificationPaginationOptions();
options.programToken("program-token").type(HyperwalletWebhookNotification.Type.PREPAID_CARD_CREATED.toString()).sortBy("test-sort-by").limit(10).createdAfter(convertStringToDate("2016-08-24T13:56:26Z")).createdBefore(convertStringToDate("2016-08-24T13:56:26Z"));
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
HyperwalletList<HyperwalletWebhookNotification> resp = client.listWebhookEvents(options);
assertThat(resp, is(equalTo(response)));
Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/webhook-notifications?createdAfter=2016-08-24T13:56:26Z&createdBefore=2016" + "-08-24T13:56:26Z&sortBy=test-sort-by&limit=10&type=USERS.PREPAID_CARDS.CREATED&programToken=program-token"), ArgumentMatchers.any(TypeReference.class));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testUpdatePrepaidCardt_successful.
@Test
public void testUpdatePrepaidCardt_successful() throws Exception {
HyperwalletPrepaidCard prepaidCard = new HyperwalletPrepaidCard();
prepaidCard.setToken("test-prepaid-card-token");
prepaidCard.setUserToken("test-user-token");
prepaidCard.setTransferMethodCountry("UK");
prepaidCard.setTransferMethodCurrency("GBR");
HyperwalletPrepaidCard prepaidCardResponse = new HyperwalletPrepaidCard();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
Mockito.when(mockApiClient.put(ArgumentMatchers.anyString(), ArgumentMatchers.anyObject(), ArgumentMatchers.any(Class.class))).thenReturn(prepaidCardResponse);
HyperwalletPrepaidCard resp = client.updatePrepaidCard(prepaidCard);
assertThat(resp, is(equalTo(prepaidCardResponse)));
ArgumentCaptor<HyperwalletPrepaidCard> argument = ArgumentCaptor.forClass(HyperwalletPrepaidCard.class);
Mockito.verify(mockApiClient).put(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/prepaid-cards/test-prepaid-card-token"), argument.capture(), ArgumentMatchers.eq(prepaidCard.getClass()));
HyperwalletPrepaidCard apiClientBankAccount = argument.getValue();
assertThat(apiClientBankAccount, is(notNullValue()));
assertThat(apiClientBankAccount.getTransferMethodCountry(), is(equalTo("UK")));
assertThat(apiClientBankAccount.getTransferMethodCurrency(), is(equalTo("GBR")));
}
Aggregations