Search in sources :

Example 56 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testGetBankCardStatusTransition_successful.

@Test
public void testGetBankCardStatusTransition_successful() throws Exception {
    HyperwalletStatusTransition transitionResponse = new HyperwalletStatusTransition();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(Class.class))).thenReturn(transitionResponse);
    HyperwalletStatusTransition resp = client.getBankCardStatusTransition("test-user-token", "test-bank-card-token", "test-status-transition-token");
    assertThat(resp, is(equalTo(transitionResponse)));
    Mockito.verify(mockApiClient).get("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/bank-cards/test-bank-card-token/status-transitions/test" + "-status-transition-token", transitionResponse.getClass());
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 57 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method getUser_withVerificationDocumentAndRejectReasons.

@Test
public void getUser_withVerificationDocumentAndRejectReasons() throws Exception {
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    HyperwalletUser hyperwalletUser = getHyperwalletUser();
    final String url = "https://api.sandbox.hyperwallet.com/rest/v4/users/" + "test-userToken";
    Mockito.when(mockApiClient.get(ArgumentMatchers.eq(url), ArgumentMatchers.eq(HyperwalletUser.class))).thenReturn(hyperwalletUser);
    HyperwalletUser user = client.getUser("test-userToken");
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq(url), ArgumentMatchers.eq(HyperwalletUser.class));
    assertThat(user.getToken(), is(hyperwalletUser.getToken()));
    assertThat(user.getDocuments().size(), is(1));
    assertThat(user.getDocuments().get(0).getStatus(), is("INVALID"));
    assertThat(user.getDocuments().get(0).getCreatedOn(), is(hyperwalletUser.getDocuments().get(0).getCreatedOn()));
    assertThat(user.getDocuments().get(0).getReasons().size(), is(1));
    assertThat(user.getDocuments().get(0).getReasons().get(0).getName(), is(RejectReason.DOCUMENT_EXPIRED));
    assertThat(user.getDocuments().get(0).getReasons().get(0).getDescription(), is("Document has expired"));
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 58 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testCreatePayPalAccount_noType.

@Test
public void testCreatePayPalAccount_noType() throws Exception {
    HyperwalletPayPalAccount payPalAccount = new HyperwalletPayPalAccount();
    payPalAccount.setUserToken("test-user-token");
    payPalAccount.setTransferMethodCountry("test-transfer-method-country");
    payPalAccount.setTransferMethodCurrency("test-transfer-method-currency");
    payPalAccount.setEmail("test-email");
    payPalAccount.setStatus(HyperwalletPayPalAccount.Status.ACTIVATED);
    payPalAccount.setCreatedOn(new Date());
    HyperwalletPayPalAccount payPalAccountResponse = new HyperwalletPayPalAccount();
    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(payPalAccountResponse);
    HyperwalletPayPalAccount resp = client.createPayPalAccount(payPalAccount);
    assertThat(resp, is(equalTo(payPalAccountResponse)));
    ArgumentCaptor<HyperwalletPayPalAccount> argument = ArgumentCaptor.forClass(HyperwalletPayPalAccount.class);
    Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/paypal-accounts"), argument.capture(), ArgumentMatchers.eq(payPalAccount.getClass()));
    HyperwalletPayPalAccount apiPayPalAccount = argument.getValue();
    assertThat(apiPayPalAccount, is(notNullValue()));
    assertThat(apiPayPalAccount.getUserToken(), is(equalTo("test-user-token")));
    assertThat(apiPayPalAccount.getTransferMethodCountry(), is(equalTo("test-transfer-method-country")));
    assertThat(apiPayPalAccount.getTransferMethodCurrency(), is(equalTo("test-transfer-method-currency")));
    assertThat(apiPayPalAccount.getStatus(), is(nullValue()));
    assertThat(apiPayPalAccount.getCreatedOn(), is(nullValue()));
    assertThat(apiPayPalAccount.getType(), is(HyperwalletPayPalAccount.Type.PAYPAL_ACCOUNT));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 59 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testDeactivateVenmoAccountStatusTransition_withNotes_successful.

@Test
public void testDeactivateVenmoAccountStatusTransition_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.deactivateVenmoAccount("test-user-token", "test-venmo-account-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/venmo-accounts/test-venmo-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)));
    assertThat(apiClientStatusTransition.getNotes(), is(equalTo("test-notes")));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 60 with HyperwalletApiClient

use of com.hyperwallet.clientsdk.util.HyperwalletApiClient in project java-sdk by hyperwallet.

the class HyperwalletTest method testCreateBankCard_withType.

@Test
public void testCreateBankCard_withType() throws Exception {
    HyperwalletBankCard bankCard = new HyperwalletBankCard();
    bankCard.setUserToken("test-user-token");
    bankCard.setType(HyperwalletBankCard.Type.BANK_CARD);
    bankCard.setStatus(HyperwalletBankCard.Status.ACTIVATED);
    bankCard.setCreatedOn(new Date());
    bankCard.setCardType(HyperwalletBankCard.CardType.DEBIT);
    bankCard.setTransferMethodCountry("test-transfer-method-country");
    bankCard.setTransferMethodCurrency("test-transfer-method-currency");
    bankCard.setCardNumber("test-card-number");
    bankCard.setCardBrand(HyperwalletBankCard.Brand.VISA);
    bankCard.setDateOfExpiry(new Date());
    bankCard.setCvv("cvv");
    HyperwalletBankCard bankCardResponse = new HyperwalletBankCard();
    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(bankCardResponse);
    HyperwalletBankCard resp = client.createBankCard(bankCard);
    assertThat(resp, is(equalTo(bankCardResponse)));
    ArgumentCaptor<HyperwalletBankCard> argument = ArgumentCaptor.forClass(HyperwalletBankCard.class);
    Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token/bank-cards"), argument.capture(), ArgumentMatchers.eq(bankCard.getClass()));
    HyperwalletBankCard apiClienBankCard = argument.getValue();
    assertThat(apiClienBankCard, is(notNullValue()));
    assertThat(apiClienBankCard.getType(), is(equalTo(HyperwalletBankCard.Type.BANK_CARD)));
    assertThat(apiClienBankCard.getStatus(), is(nullValue()));
    assertThat(apiClienBankCard.getCreatedOn(), is(nullValue()));
    assertThat(apiClienBankCard.getCardType(), is(nullValue()));
    assertThat(apiClienBankCard.getCardBrand(), is(nullValue()));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Aggregations

HyperwalletApiClient (com.hyperwallet.clientsdk.util.HyperwalletApiClient)170 Test (org.testng.annotations.Test)168 TypeReference (com.fasterxml.jackson.core.type.TypeReference)85 HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)11 ForeignExchange (com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange)3 Field (java.lang.reflect.Field)2 Method (java.lang.reflect.Method)1 JSONObject (net.minidev.json.JSONObject)1