Search in sources :

Example 31 with HyperwalletUser

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

the class HyperwalletTest method testCreateUser_withProgramTokenAddedByDefault.

@Test
public void testCreateUser_withProgramTokenAddedByDefault() throws Exception {
    HyperwalletUser user = new HyperwalletUser();
    user.setStatus(HyperwalletUser.Status.ACTIVATED);
    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", "test-program-token");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    Mockito.when(mockApiClient.post(ArgumentMatchers.anyString(), ArgumentMatchers.anyObject(), ArgumentMatchers.any(Class.class))).thenReturn(userResponse);
    HyperwalletUser resp = client.createUser(user);
    assertThat(resp, is(equalTo(userResponse)));
    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.getVerificationStatus(), is(nullValue()));
    assertThat(apiClientUser.getBusinessStakeholderVerificationStatus(), is(nullValue()));
    assertThat(apiClientUser.getLetterOfAuthorizationStatus(), is(nullValue()));
    assertThat(apiClientUser.getGovernmentIdType(), is(nullValue()));
    assertThat(apiClientUser.getCreatedOn(), is(nullValue()));
    assertThat(apiClientUser.getProgramToken(), is(equalTo("test-program-token")));
    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 32 with HyperwalletUser

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

the class HyperwalletTest method testCreateUser_userTokenSpecified.

@Test
public void testCreateUser_userTokenSpecified() {
    HyperwalletUser user = new HyperwalletUser();
    user.setToken("test-token");
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    try {
        client.createUser(user);
        fail("Expect HyperwalletException");
    } catch (HyperwalletException e) {
        assertThat(e.getErrorCode(), is(nullValue()));
        assertThat(e.getResponse(), is(nullValue()));
        assertThat(e.getErrorMessage(), is(equalTo("User token may not be present")));
        assertThat(e.getMessage(), is(equalTo("User token may not be present")));
        assertThat(e.getHyperwalletErrors(), is(nullValue()));
        assertThat(e.getRelatedResources(), is(nullValue()));
    }
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) 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