use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testCreatePayment_withProgramTokenInPaymentObject.
@Test
public void testCreatePayment_withProgramTokenInPaymentObject() throws Exception {
HyperwalletPayment payment = new HyperwalletPayment();
payment.setCreatedOn(new Date());
payment.setCurrency("test-currency");
payment.setProgramToken("test-program-token2");
payment.setStatus("COMPLETED");
HyperwalletPayment paymentResponse = new HyperwalletPayment();
Hyperwallet client = new Hyperwallet("test-username", "test-password", "test-program-token");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
Mockito.when(mockApiClient.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyObject(), ArgumentMatchers.any(Class.class))).thenReturn(paymentResponse);
HyperwalletPayment resp = client.createPayment(payment);
assertThat(resp, is(equalTo(paymentResponse)));
ArgumentCaptor<HyperwalletPayment> argument = ArgumentCaptor.forClass(HyperwalletPayment.class);
Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/payments"), argument.capture(), ArgumentMatchers.eq(payment.getClass()));
HyperwalletPayment apiClientPayment = argument.getValue();
assertThat(apiClientPayment, is(notNullValue()));
assertThat(apiClientPayment.getStatus(), is(notNullValue()));
assertThat(apiClientPayment.getCurrency(), is(equalTo("test-currency")));
assertThat(apiClientPayment.getCreatedOn(), is(nullValue()));
assertThat(apiClientPayment.getProgramToken(), is(equalTo("test-program-token2")));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testDeactivateBankAccount_successful.
@Test
public void testDeactivateBankAccount_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.deactivateBankAccount("test-user-token", "test-bank-account-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/bank-accounts/test-bank-account-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)));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testGetPayPalAccount_successful.
@Test
public void testGetPayPalAccount_successful() throws Exception {
HyperwalletPayPalAccount payPalAccount = new HyperwalletPayPalAccount();
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(Class.class))).thenReturn(payPalAccount);
HyperwalletPayPalAccount resp = client.getPayPalAccount("test-user-token", "test-paypal-account-token");
assertThat(resp, is(equalTo(payPalAccount)));
Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/paypal-accounts/test-paypal-account-token", payPalAccount.getClass());
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testLockUserStatusTransition_successful.
@Test
public void testLockUserStatusTransition_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.lockUser("test-user-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/status-transitions"), argument.capture(), ArgumentMatchers.eq(statusTransitionResponse.getClass()));
HyperwalletStatusTransition apiClientStatusTransition = argument.getValue();
assertThat(apiClientStatusTransition, is(notNullValue()));
assertThat(apiClientStatusTransition.getTransition(), is(equalTo(Status.LOCKED)));
}
use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.
the class HyperwalletTest method testUpdatePaperCheck_successful.
@Test
public void testUpdatePaperCheck_successful() throws Exception {
HyperwalletPaperCheck paperCheck = new HyperwalletPaperCheck();
paperCheck.setToken("test-bank-card-token");
paperCheck.setUserToken("test-user-token");
paperCheck.setAddressLine1("test-address-line1");
paperCheck.setBusinessOperatingName("test-bank-operating-name");
HyperwalletPaperCheck paperCheckResponse = new HyperwalletPaperCheck();
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(paperCheckResponse);
HyperwalletPaperCheck resp = client.updatePaperCheck(paperCheck);
assertThat(resp, is(equalTo(paperCheckResponse)));
ArgumentCaptor<HyperwalletPaperCheck> argument = ArgumentCaptor.forClass(HyperwalletPaperCheck.class);
Mockito.verify(mockApiClient).put(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/paper-checks/test-bank-card-token"), argument.capture(), ArgumentMatchers.eq(paperCheck.getClass()));
HyperwalletPaperCheck apiClientBankAccount = argument.getValue();
assertThat(apiClientBankAccount, is(notNullValue()));
assertThat(apiClientBankAccount.getAddressLine1(), is(equalTo("test-address-line1")));
assertThat(apiClientBankAccount.getBusinessOperatingName(), is(equalTo("test-bank-operating-name")));
}
Aggregations