Search in sources :

Example 51 with HyperwalletApiClient

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

the class HyperwalletTest method testCreateUserStatusTransition_successful.

@Test
public void testCreateUserStatusTransition_successful() throws Exception {
    HyperwalletStatusTransition transition = new HyperwalletStatusTransition();
    transition.setFromStatus(HyperwalletStatusTransition.Status.ACTIVATED);
    transition.setToStatus(HyperwalletStatusTransition.Status.DE_ACTIVATED);
    transition.setCreatedOn(new Date());
    transition.setTransition(HyperwalletStatusTransition.Status.DE_ACTIVATED);
    HyperwalletStatusTransition transitionResponse = 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(transitionResponse);
    HyperwalletStatusTransition resp = client.createUserStatusTransition("test-user-token", transition);
    assertThat(resp, is(equalTo(transitionResponse)));
    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(transition.getClass()));
    HyperwalletStatusTransition apiClientTransition = argument.getValue();
    assertThat(apiClientTransition, is(notNullValue()));
    assertThat(apiClientTransition.getTransition(), is(equalTo(HyperwalletStatusTransition.Status.DE_ACTIVATED)));
    assertThat(apiClientTransition.getFromStatus(), is(nullValue()));
    assertThat(apiClientTransition.getToStatus(), is(nullValue()));
    assertThat(apiClientTransition.getCreatedOn(), is(nullValue()));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 52 with HyperwalletApiClient

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

the class HyperwalletTest method testGetBankCard_successful.

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

Example 53 with HyperwalletApiClient

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

the class HyperwalletTest method testUploadStakeholderDocuments_Successful.

@Test
public void testUploadStakeholderDocuments_Successful() throws Exception {
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    String userToken = "user-token";
    String businessStakeholderToken = "business-token";
    HyperwalletBusinessStakeholder hyperwalletBusinessStakeholder = new HyperwalletBusinessStakeholder();
    List<HyperwalletVerificationDocument> hyperwalletVerificationDocumentList = new ArrayList<>();
    HyperwalletVerificationDocument hyperWalletVerificationDocument = new HyperwalletVerificationDocument();
    hyperWalletVerificationDocument.category("IDENTIFICATION").type("DRIVERS_LICENSE").status("NEW").country("AL");
    Map<String, String> uploadFiles = new HashMap<String, String>();
    uploadFiles.put("drivers_license_front", "/integration/test.png");
    hyperWalletVerificationDocument.setUploadFiles(uploadFiles);
    hyperwalletVerificationDocumentList.add(hyperWalletVerificationDocument);
    hyperwalletBusinessStakeholder.setDocuments(hyperwalletVerificationDocumentList);
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.put(ArgumentMatchers.anyString(), ArgumentMatchers.any(HyperwalletBusinessStakeholder.class), ArgumentMatchers.any(Class.class))).thenReturn(hyperwalletBusinessStakeholder);
    HashMap<String, String> multipartUploadData = new HashMap<String, String>();
    HyperwalletBusinessStakeholder hyperwalletBusinessStakeholderResponse = client.uploadStakeholderDocuments(userToken, businessStakeholderToken, hyperwalletVerificationDocumentList);
    assertThat(hyperwalletBusinessStakeholderResponse, isOneOf(null, hyperwalletBusinessStakeholder));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 54 with HyperwalletApiClient

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

the class HyperwalletTest method testCreatePayment_withoutProgramToken.

@Test
public void testCreatePayment_withoutProgramToken() throws Exception {
    HyperwalletPayment payment = new HyperwalletPayment();
    payment.setCreatedOn(new Date());
    payment.setCurrency("test-currency");
    HyperwalletPayment paymentResponse = new HyperwalletPayment();
    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(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(nullValue()));
    assertThat(apiClientPayment.getCurrency(), is(equalTo("test-currency")));
    assertThat(apiClientPayment.getCreatedOn(), is(nullValue()));
    assertThat(apiClientPayment.getProgramToken(), is(nullValue()));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 55 with HyperwalletApiClient

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

the class HyperwalletTest method testListTransferMethods.

@Test
public void testListTransferMethods() throws Exception {
    String userToken = "user-token";
    HyperwalletList<HyperwalletTransferMethod> response = new HyperwalletList<HyperwalletTransferMethod>();
    List<HyperwalletTransferMethod> hyperwalletTransferMethodsList = new ArrayList<>();
    HyperwalletTransferMethod bankTransferMethod = new HyperwalletTransferMethod();
    bankTransferMethod.setToken("bank-token");
    bankTransferMethod.setType(Type.BANK_ACCOUNT);
    HyperwalletTransferMethod cardTransferMethod = new HyperwalletTransferMethod();
    cardTransferMethod.setToken("card-token");
    cardTransferMethod.setType(Type.PREPAID_CARD);
    hyperwalletTransferMethodsList.add(bankTransferMethod);
    hyperwalletTransferMethodsList.add(cardTransferMethod);
    response.setData(hyperwalletTransferMethodsList);
    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<HyperwalletTransferMethod> resp = client.listTransferMethods(userToken, null);
    assertThat(resp, is(equalTo(response)));
    HyperwalletTransferMethod response1 = response.getData().get(0);
    HyperwalletTransferMethod response2 = response.getData().get(1);
    assertThat(response1.getToken(), is(equalTo("bank-token")));
    assertThat(response1.getType(), is(equalTo(Type.BANK_ACCOUNT)));
    assertThat(response2.getToken(), is(equalTo("card-token")));
    assertThat(response2.getType(), is(equalTo(Type.PREPAID_CARD)));
}
Also used : HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) 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