use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListReceiptsForProgramAccount_withSomeParameters.
@Test
public void testListReceiptsForProgramAccount_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.listReceiptsForProgramAccount("test-program-token", "test-account-token", options);
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" + "?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 testCreateTransfer_successful.
@Test
public void testCreateTransfer_successful() throws Exception {
ForeignExchange foreignExchange = new ForeignExchange();
foreignExchange.setSourceAmount(200.0);
foreignExchange.setSourceCurrency("USD");
foreignExchange.setDestinationAmount(100.0);
foreignExchange.setDestinationCurrency("CAD");
foreignExchange.setRate(2.3);
HyperwalletTransfer transfer = new HyperwalletTransfer();
transfer.setSourceToken("test-source-token");
transfer.setDestinationToken("test-destination-token");
transfer.setStatus(HyperwalletTransfer.Status.QUOTED);
transfer.setCreatedOn(new Date());
transfer.setClientTransferId("test-client-transfer-id");
transfer.setSourceCurrency("USD");
transfer.setForeignExchanges(Collections.singletonList(foreignExchange));
HyperwalletTransfer transferResponse = new HyperwalletTransfer();
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(transferResponse);
HyperwalletTransfer resp = client.createTransfer(transfer);
assertThat(resp, is(equalTo(transferResponse)));
ArgumentCaptor<HyperwalletTransfer> argument = ArgumentCaptor.forClass(HyperwalletTransfer.class);
Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/transfers"), argument.capture(), ArgumentMatchers.eq(transfer.getClass()));
HyperwalletTransfer apiTransfer = argument.getValue();
assertThat(apiTransfer, is(notNullValue()));
assertThat(apiTransfer.getSourceToken(), is(equalTo("test-source-token")));
assertThat(apiTransfer.getClientTransferId(), is(equalTo("test-client-transfer-id")));
assertThat(apiTransfer.getSourceCurrency(), is(equalTo("USD")));
assertThat(apiTransfer.getStatus(), is(nullValue()));
assertThat(apiTransfer.getCreatedOn(), is(nullValue()));
assertThat(apiTransfer.getExpiresOn(), is(nullValue()));
ForeignExchange foreignExchangeResponse = apiTransfer.getForeignExchanges().get(0);
assertThat(foreignExchange.getSourceAmount(), is(equalTo(200.0)));
assertThat(foreignExchange.getSourceCurrency(), is(equalTo("USD")));
assertThat(foreignExchange.getDestinationAmount(), is(equalTo(100.0)));
assertThat(foreignExchange.getDestinationCurrency(), is(equalTo("CAD")));
assertThat(foreignExchange.getRate(), is(equalTo(2.3)));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListBalancesForUser_withSomeParameters.
@Test
public void testListBalancesForUser_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.listBalancesForUser("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/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 testListPayPalAccount_withParameters.
@Test
public void testListPayPalAccount_withParameters() throws Exception {
HyperwalletList<HyperwalletPayPalAccount> response = new HyperwalletList<HyperwalletPayPalAccount>();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletPayPalAccountListPaginationOptions options = new HyperwalletPayPalAccountListPaginationOptions();
options.status(HyperwalletPayPalAccount.Status.ACTIVATED).sortBy("test-sort-by").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);
HyperwalletList<HyperwalletPayPalAccount> resp = client.listPayPalAccounts("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/paypal-accounts?createdAfter=2016-06-29T17:58:26Z" + "&createdBefore=2016-06-29T17:58:26Z&sortBy=test-sort-by&limit=10&status=ACTIVATED"), ArgumentMatchers.any(TypeReference.class));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testDeactivatePaperCheckStatusTransition_withNotes_successful.
@Test
public void testDeactivatePaperCheckStatusTransition_withNotes_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.deactivatePaperCheck("test-user-token", "test-bank-card-token", "test-notes");
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/paper-checks/test-bank-card-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)));
assertThat(apiClientStatusTransition.getNotes(), is(equalTo("test-notes")));
}
Aggregations