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) {
}
}
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;
}
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()));
}
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()));
}
}
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());
}
Aggregations