Search in sources :

Example 11 with HyperwalletUser

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

the class HyperwalletTest method testGetUser_successful.

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

Example 12 with HyperwalletUser

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

the class HyperwalletTest method testListUsers_withParameters.

@Test
public void testListUsers_withParameters() throws Exception {
    HyperwalletList<HyperwalletUser> response = new HyperwalletList<HyperwalletUser>();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
    options.clientUserId("CSLAJQt7bD").email("john@company.com").programToken("prg-83836cdf-2ce2-4696-8bc5-f1b86077238c").status(HyperwalletUser.Status.ACTIVATED).verificationStatus(HyperwalletUser.VerificationStatus.NOT_REQUIRED).taxVerificationStatus(TaxVerificationStatus.REQUIRED).sortBy("test-sort-by").limit(10).createdAfter(convertStringToDate("2016-06-29T17:58:26Z")).createdBefore(convertStringToDate("2016-06-29T17:58:26Z"));
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
    HyperwalletList<HyperwalletUser> resp = client.listUsers(options);
    assertThat(resp, is(equalTo(response)));
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users?createdAfter=2016-06-29T17:58:26Z&createdBefore=2016-06-29T17:58:26Z" + "&sortBy=test-sort-by&limit=10&clientUserId=CSLAJQt7bD&email=john@company" + ".com&programToken=prg-83836cdf-2ce2-4696-8bc5-f1b86077238c&status=ACTIVATED&verificationStatus=NOT_REQUIRED" + "&taxVerificationStatus=REQUIRED"), ArgumentMatchers.any(TypeReference.class));
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.testng.annotations.Test)

Example 13 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser 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 14 with HyperwalletUser

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

the class HyperwalletTest method testListUsers_withSomeParameters.

@Test
public void testListUsers_withSomeParameters() throws Exception {
    HyperwalletList<HyperwalletUser> response = new HyperwalletList<HyperwalletUser>();
    Hyperwallet client = new Hyperwallet("test-username", "test-password");
    HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
    HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
    options.sortBy("test-sort-by").createdBefore(convertStringToDate("2016-06-29T17:58:26Z"));
    Mockito.when(mockApiClient.get(ArgumentMatchers.anyString(), ArgumentMatchers.any(TypeReference.class))).thenReturn(response);
    HyperwalletList<HyperwalletUser> resp = client.listUsers(options);
    assertThat(resp, is(equalTo(response)));
    Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users?createdBefore=2016-06-29T17:58:26Z&sortBy=test-sort-by"), ArgumentMatchers.any(TypeReference.class));
}
Also used : HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) HyperwalletApiClient(com.hyperwallet.clientsdk.util.HyperwalletApiClient) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.testng.annotations.Test)

Example 15 with HyperwalletUser

use of com.hyperwallet.clientsdk.model.HyperwalletUser in project mirakl-hyperwallet-connector by paypal.

the class KYCReadyForReviewServiceImplTest method notifyBstkReadyForReview_shouldRunNotifyBusinessStakeholderToHW.

@Test
void notifyBstkReadyForReview_shouldRunNotifyBusinessStakeholderToHW() {
    // @formatter:off
    final KYCDocumentBusinessStakeHolderInfoModel kycDocumentOne = KYCDocumentBusinessStakeHolderInfoModel.builder().hyperwalletProgram(HYPERWALLET_PROGRAM).userToken(List.of(new MiraklAdditionalFieldValue.MiraklStringAdditionalFieldValue(KYCConstants.HYPERWALLET_USER_TOKEN_FIELD, USER_TOKEN_1))).build();
    // @formatter:on
    when(hyperwalletApiClientMock.updateUser(Mockito.any(HyperwalletUser.class))).thenReturn(hyperwalletUserMock);
    when(hyperwalletUserMock.getClientUserId()).thenReturn(SHOP_ID);
    when(hyperwalletSDKServiceMock.getHyperwalletInstance(HYPERWALLET_PROGRAM)).thenReturn(hyperwalletApiClientMock);
    testObj.notifyBstkReadyForReview(Map.entry(USER_TOKEN_1, List.of(kycDocumentOne)));
    verify(hyperwalletApiClientMock).updateUser(hyperwalletUserCaptor.capture());
    final HyperwalletUser hyperwalletUser = hyperwalletUserCaptor.getValue();
    assertThat(hyperwalletUser.getToken()).isEqualTo(USER_TOKEN_1);
    assertThat(hyperwalletUser.getBusinessStakeholderVerificationStatus()).isEqualTo(HyperwalletUser.BusinessStakeholderVerificationStatus.READY_FOR_REVIEW);
}
Also used : MiraklAdditionalFieldValue(com.mirakl.client.mmp.domain.common.MiraklAdditionalFieldValue) HyperwalletUser(com.hyperwallet.clientsdk.model.HyperwalletUser) KYCDocumentBusinessStakeHolderInfoModel(com.paypal.kyc.model.KYCDocumentBusinessStakeHolderInfoModel) Test(org.junit.jupiter.api.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