Search in sources :

Example 21 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.

the class HyperwalletApiClientTest method testPutMultipart_WithSucess.

@Test
public void testPutMultipart_WithSucess() {
    try {
        HyperwalletUser response = hyperwalletApiClient.put("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token", new Multipart(), HyperwalletUser.class);
        assertThat(response, is(notNullValue()));
        assertThat(response.getToken(), is(equalTo("test-user-token")));
        assertThat(response.getDocuments(), is(notNullValue()));
    } catch (Exception exception) {
    }
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) JOSEException(com.nimbusds.jose.JOSEException) JSONException(org.json.JSONException) ParseException(java.text.ParseException) HyperwalletException(com.hyperwallet.clientsdk.HyperwalletException) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 22 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.

the class HyperwalletTest method getHyperwalletUser.

private HyperwalletUser getHyperwalletUser() {
    HyperwalletUser user = new HyperwalletUser();
    user.token("test-userToken").verificationStatus(VerificationStatus.FAILED);
    HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
    hyperwalletVerificationDocument.setType("test_DRIVERS_LICENSE");
    hyperwalletVerificationDocument.setCategory("test_IDENTIFICATION");
    hyperwalletVerificationDocument.setCountry("test_US");
    Map<String, String> fileList = new HashMap<>();
    fileList.put("fileName", "fileData");
    hyperwalletVerificationDocument.setStatus("INVALID");
    hyperwalletVerificationDocument.setCreatedOn(new Date());
    HyperwalletVerificationDocumentReason documentRejectReason = new HyperwalletVerificationDocumentReason();
    documentRejectReason.setName(RejectReason.DOCUMENT_EXPIRED);
    documentRejectReason.setDescription("Document has expired");
    hyperwalletVerificationDocument.reasons(Arrays.asList(documentRejectReason));
    user.documents(Arrays.asList(hyperwalletVerificationDocument));
    return user;
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser)

Example 23 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.

the class HyperwalletTest method testCreateUser_withoutProgramToken.

@Test
public void testCreateUser_withoutProgramToken() throws Exception {
    HyperwalletUser user = new HyperwalletUser();
    user.setStatus(HyperwalletUser.Status.ACTIVATED);
    user.setTaxVerificationStatus(TaxVerificationStatus.REQUIRED);
    user.setVerificationStatus(VerificationStatus.VERIFIED);
    user.setBusinessStakeholderVerificationStatus(BusinessStakeholderVerificationStatus.VERIFIED);
    user.setLetterOfAuthorizationStatus(LetterOfAuthorizationStatus.VERIFIED);
    user.setGovernmentIdType(GovernmentIdType.NATIONAL_ID_CARD);
    user.setCreatedOn(new Date());
    user.setFirstName("test-first-name");
    user.setBusinessOperatingName("test-business-operating-name");
    HyperwalletUser userResponse = new HyperwalletUser();
    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(user);
    HyperwalletUser resp = client.createUser(user);
    assertThat(resp, is(equalTo(user)));
    assertThat(resp.getTaxVerificationStatus(), is(equalTo(TaxVerificationStatus.REQUIRED)));
    assertThat(resp.getVerificationStatus(), is(equalTo(VerificationStatus.VERIFIED)));
    assertThat(resp.getLetterOfAuthorizationStatus(), is(equalTo(LetterOfAuthorizationStatus.VERIFIED)));
    assertThat(resp.getBusinessStakeholderVerificationStatus(), is(equalTo(BusinessStakeholderVerificationStatus.VERIFIED)));
    assertThat(resp.getLetterOfAuthorizationStatus(), is(equalTo(LetterOfAuthorizationStatus.VERIFIED)));
    assertThat(resp.getGovernmentIdType(), is(equalTo(GovernmentIdType.NATIONAL_ID_CARD)));
    ArgumentCaptor<HyperwalletUser> argument = ArgumentCaptor.forClass(HyperwalletUser.class);
    Mockito.verify(mockApiClient).post(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users"), argument.capture(), ArgumentMatchers.eq(user.getClass()));
    HyperwalletUser apiClientUser = argument.getValue();
    assertThat(apiClientUser, is(notNullValue()));
    assertThat(apiClientUser.getFirstName(), is(equalTo("test-first-name")));
    assertThat(apiClientUser.getBusinessOperatingName(), is(equalTo("test-business-operating-name")));
    assertThat(apiClientUser.getStatus(), is(nullValue()));
    assertThat(apiClientUser.getTaxVerificationStatus(), is(equalTo(TaxVerificationStatus.REQUIRED)));
    assertThat(apiClientUser.getVerificationStatus(), is(equalTo(VerificationStatus.VERIFIED)));
    assertThat(apiClientUser.getLetterOfAuthorizationStatus(), is(equalTo(LetterOfAuthorizationStatus.VERIFIED)));
    assertThat(apiClientUser.getBusinessStakeholderVerificationStatus(), is(equalTo(BusinessStakeholderVerificationStatus.VERIFIED)));
    assertThat(apiClientUser.getGovernmentIdType(), is(equalTo(GovernmentIdType.NATIONAL_ID_CARD)));
    assertThat(apiClientUser.getCreatedOn(), is(nullValue()));
    assertThat(apiClientUser.getProgramToken(), is(nullValue()));
    assertThat(apiClientUser.getLinks(), is(nullValue()));
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Example 24 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.

the class HyperwalletTest method testUpdateUser_noUserToken.

@Test
public void testUpdateUser_noUserToken() {
    HyperwalletUser user = new HyperwalletUser();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    try {
        client.updateUser(user);
        fail("Expect HyperwalletException");
    } catch (HyperwalletException e) {
        assertThat(e.getErrorCode(), is(nullValue()));
        assertThat(e.getResponse(), is(nullValue()));
        assertThat(e.getErrorMessage(), is(equalTo("User token is required")));
        assertThat(e.getMessage(), is(equalTo("User token is required")));
        assertThat(e.getHyperwalletErrors(), is(nullValue()));
        assertThat(e.getRelatedResources(), is(nullValue()));
    }
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) Test(org.testng.annotations.Test)

Example 25 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.

the class HyperwalletTest method testUpdateUser_successful.

@Test
public void testUpdateUser_successful() throws Exception {
    HyperwalletUser user = new HyperwalletUser();
    user.setToken("test-user-token");
    user.setFirstName("test-first-name");
    user.setBusinessStakeholderVerificationStatus(BusinessStakeholderVerificationStatus.UNDER_REVIEW);
    user.setGovernmentIdType(GovernmentIdType.NATIONAL_ID_CARD);
    HyperwalletUser userResponse = new HyperwalletUser();
    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(userResponse);
    HyperwalletUser resp = client.updateUser(user);
    assertThat(resp, is(equalTo(userResponse)));
    Mockito.verify(mockApiClient).put("https://api.sandbox.hyperwallet.com/rest/v4/users/test-user-token", user, user.getClass());
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) Test(org.testng.annotations.Test)

Aggregations

HyperwalletUser (com.hyperwallet.clientsdk.model.HyperwalletUser)32 Test (org.testng.annotations.Test)15 HyperwalletApiClient (com.hyperwallet.clientsdk.util.HyperwalletApiClient)11 Test (org.junit.jupiter.api.Test)9 HyperwalletException (com.hyperwallet.clientsdk.HyperwalletException)5 TypeReference (com.fasterxml.jackson.core.type.TypeReference)3 Hyperwallet (com.hyperwallet.clientsdk.Hyperwallet)3 MiraklAdditionalFieldValue (com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue)2 IOException (java.io.IOException)2 Gson (com.google.gson.Gson)1 JOSEException (com.nimbusds.jose.JOSEException)1 KYCDocumentBusinessStakeHolderInfoModel (com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel)1 KYCDocumentSellerInfoModel (com.paypal.kyc.model.KYCDocumentSellerInfoModel)1 File (java.io.File)1 ParseException (java.text.ParseException)1 JSONObject (net.minidev.json.JSONObject)1 JSONException (org.json.JSONException)1