use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListPayments_noParameters.
@Test
public void testListPayments_noParameters() throws Exception {
HyperwalletList<HyperwalletPayment> response = new HyperwalletList<HyperwalletPayment>();
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<HyperwalletPayment> resp = client.listPayments();
assertThat(resp, is(equalTo(response)));
Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/payments"), ArgumentMatchers.any(TypeReference.class));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testGetProgram_successful.
@Test
public void testGetProgram_successful() throws Exception {
HyperwalletProgram programResponse = new HyperwalletProgram();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(Class.class))).thenReturn(programResponse);
HyperwalletProgram resp = client.getProgram("test-program-token");
assertThat(resp, is(equalTo(programResponse)));
Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/programs/test-program-token", programResponse.getClass());
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testCreatePrepaidCard_withType.
@Test
public void testCreatePrepaidCard_withType() throws Exception {
HyperwalletPrepaidCard prepaidCard = new HyperwalletPrepaidCard();
prepaidCard.setUserToken("test-user-token");
prepaidCard.setType(HyperwalletPrepaidCard.Type.PREPAID_CARD);
prepaidCard.setStatus(HyperwalletPrepaidCard.Status.ACTIVATED);
prepaidCard.setCreatedOn(new Date());
prepaidCard.setCardType(HyperwalletPrepaidCard.CardType.VIRTUAL);
prepaidCard.setTransferMethodCountry("test-transfer-method-country");
prepaidCard.setTransferMethodCurrency("test-transfer-method-currency");
prepaidCard.setCardNumber("test-card-number");
prepaidCard.setCardBrand(HyperwalletPrepaidCard.Brand.VISA);
prepaidCard.setDateOfExpiry(new Date());
prepaidCard.setCardPackage("test-card-package");
HyperwalletPrepaidCard prepaidCardResponse = new HyperwalletPrepaidCard();
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(prepaidCardResponse);
HyperwalletPrepaidCard resp = client.createOrReplacePrepaidCard(prepaidCard);
assertThat(resp, is(equalTo(prepaidCardResponse)));
ArgumentCaptor<HyperwalletPrepaidCard> argument = ArgumentCaptor.forClass(HyperwalletPrepaidCard.class);
Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/prepaid-cards"), argument.capture(), ArgumentMatchers.eq(prepaidCard.getClass()));
HyperwalletPrepaidCard apiClientPrepaidCard = argument.getValue();
assertThat(apiClientPrepaidCard, is(notNullValue()));
assertThat(apiClientPrepaidCard.getType(), is(equalTo(HyperwalletPrepaidCard.Type.PREPAID_CARD)));
assertThat(apiClientPrepaidCard.getCardPackage(), is(equalTo("test-card-package")));
assertThat(apiClientPrepaidCard.getStatus(), is(nullValue()));
assertThat(apiClientPrepaidCard.getCreatedOn(), is(nullValue()));
assertThat(apiClientPrepaidCard.getCardType(), is(nullValue()));
assertThat(apiClientPrepaidCard.getCardBrand(), is(nullValue()));
assertThat(apiClientPrepaidCard.getTransferMethodCountry(), is(nullValue()));
assertThat(apiClientPrepaidCard.getTransferMethodCurrency(), is(nullValue()));
assertThat(apiClientPrepaidCard.getDateOfExpiry(), is(nullValue()));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method createAndInjectHyperwalletApiClientMock.
// --------------------------------------
// Internal utils
// --------------------------------------
private HyperwalletApiClient createAndInjectHyperwalletApiClientMock(Hyperwallet client) throws Exception {
HyperwalletApiClient mock = Mockito.mock(HyperwalletApiClient.class);
Field apiClientField = client.getClass().getDeclaredField("apiClient");
apiClientField.setAccessible(true);
apiClientField.set(client, mock);
return mock;
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testListBankAccounts_withSomeParameters.
@Test
public void testListBankAccounts_withSomeParameters() throws Exception {
HyperwalletList<HyperwalletBankAccount> response = new HyperwalletList<HyperwalletBankAccount>();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
HyperwalletBankAccountsListPaginationOptions options = new HyperwalletBankAccountsListPaginationOptions();
options.status(HyperwalletBankAccount.Status.ACTIVATED).sortBy("test-sort-by").createdBefore(convertStringToDate("2019-06-29T17:58:26Z"));
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
HyperwalletList<HyperwalletBankAccount> resp = client.listBankAccounts("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/bank-accounts?createdBefore=2019-06-29T17:58:26Z" + "&sortBy=test-sort-by&status=ACTIVATED"), ArgumentMatchers.any(TypeReference.class));
}
Aggregations