use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.
the class HyperwalletTest method testUploadUserDocuments_successful.
@Test
public void testUploadUserDocuments_successful() throws Exception {
Hyperwallet client = new Hyperwallet("test-username", "test-password");
HyperwalletUser hyperwalletUser = new HyperwalletUser();
HyperwalletVerificationDocument hyperwalletDocument = new HyperwalletVerificationDocument();
hyperwalletDocument.category("IDENTIFICATION");
hyperwalletDocument.type("DRIVERS_LICENSE");
hyperwalletDocument.country("US");
List<HyperwalletVerificationDocument> hyperwalletDocumentList = new ArrayList<>();
hyperwalletDocumentList.add(hyperwalletDocument);
hyperwalletUser.setDocuments(hyperwalletDocumentList);
JSONObject jsonObject = new JSONObject();
jsonObject.put("type", "DRIVERS_LICENSE");
jsonObject.put("country", "AL");
jsonObject.put("category", "IDENTIFICATION");
List<JSONObject> jsonObjectList = new ArrayList<>();
jsonObjectList.add(jsonObject);
JSONObject jsonObject1 = new JSONObject();
jsonObject1.put("documents", jsonObjectList);
Map<String, String> multipartUploadData = new HashMap<String, String>();
multipartUploadData.put("data", jsonObject1.toString());
HyperwalletVerificationDocument uploadData = new HyperwalletVerificationDocument();
Map<String, String> uploadFiles = new HashMap<String, String>();
uploadFiles.put("drivers_license_front", "/integration/test.png");
uploadData.uploadFiles(uploadFiles);
List<HyperwalletVerificationDocument> docList = new ArrayList<HyperwalletVerificationDocument>();
docList.add(uploadData);
HyperwalletApiClient mockApiClient = createAndInjectHyperwalletApiClientMock(client);
Mockito.when(mockApiClient.put(ArgumentMatchers.anyString(), ArgumentMatchers.any(HyperwalletUser.class), ArgumentMatchers.any(Class.class))).thenReturn(hyperwalletUser);
HyperwalletUser hyperwalletUserResponse = client.uploadUserDocuments("test-token", docList);
assertThat(hyperwalletUserResponse, isOneOf(null, hyperwalletUser));
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.
the class HyperwalletTest method testUpdateUserVerificationStatus_Successful.
@Test
public void testUpdateUserVerificationStatus_Successful() throws Exception {
HyperwalletUser user = new HyperwalletUser();
user.setToken("test-user-token");
user.verificationStatus(VerificationStatus.REQUESTED);
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());
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.
the class HyperwalletTest method testUploadUserDocument_Error.
@Test
public void testUploadUserDocument_Error() throws Exception {
HyperwalletUser hyperwalletUserresponse;
try {
Hyperwallet client = new Hyperwallet("test-username", "test-username");
HyperwalletUser hyperwalletUser = new HyperwalletUser();
HyperwalletVerificationDocument hyperwalletDocument = new HyperwalletVerificationDocument();
hyperwalletDocument.category("IDENTIFICATION").type("DRIVERS_LICENSE").country("US");
Map<String, String> uploadFiles = new HashMap<String, String>();
ClassLoader classLoader = getClass().getClassLoader();
uploadFiles.put("drivers_license_front", new File(classLoader.getResource("integration/test.png").toURI()).getAbsolutePath());
uploadFiles.put("drivers_license_back", new File(classLoader.getResource("integration/test.png").toURI()).getAbsolutePath());
hyperwalletDocument.setUploadFiles(uploadFiles);
List<HyperwalletVerificationDocument> hyperwalletDocumentList = new ArrayList<>();
hyperwalletDocumentList.add(hyperwalletDocument);
hyperwalletUser.setDocuments(hyperwalletDocumentList);
HashMap<String, String> multiPartUploadData = new HashMap<String, String>();
hyperwalletUserresponse = client.uploadUserDocuments("usr-9aff8645-4bc3-4f12-9f95-f85652806472", hyperwalletDocumentList);
fail("Expect HyperwalletException");
} catch (HyperwalletException e) {
assertThat(e.getErrorCode(), is(equalTo("INCORRECT_LOGIN_CREDENTIALS")));
assertThat(e.getResponse(), is(notNullValue()));
assertThat(e.getErrorMessage(), is(equalTo("The information entered does not match our records. Please try again.")));
assertThat(e.getMessage(), is(equalTo("The information entered does not match our records. Please try again.")));
assertThat(e.getHyperwalletErrors(), is(notNullValue()));
assertThat(e.getRelatedResources(), is(nullValue()));
}
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.
the class HyperwalletTest method testCreateUser_withProgramTokenInUserObject.
@Test
public void testCreateUser_withProgramTokenInUserObject() 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");
user.setProgramToken("test-program-token2");
user.setProfileType(HyperwalletUser.ProfileType.BUSINESS);
user.setLetterOfAuthorizationStatus(LetterOfAuthorizationStatus.VERIFIED);
user.setTaxVerificationStatus(TaxVerificationStatus.REQUIRED);
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.getTaxVerificationStatus(), is(equalTo(TaxVerificationStatus.REQUIRED)));
assertThat(apiClientUser.getVerificationStatus(), is(nullValue()));
assertThat(apiClientUser.getBusinessStakeholderVerificationStatus(), is(nullValue()));
assertThat(apiClientUser.getLetterOfAuthorizationStatus(), is(equalTo(LetterOfAuthorizationStatus.VERIFIED)));
assertThat(apiClientUser.getGovernmentIdType(), is(nullValue()));
assertThat(apiClientUser.getCreatedOn(), is(nullValue()));
assertThat(apiClientUser.getProgramToken(), is(equalTo("test-program-token2")));
assertThat(apiClientUser.getLinks(), is(nullValue()));
}
use of com.hyperwallet.clientsdk.model.HyperwalletUser in project java-sdk by hyperwallet.
the class HyperwalletTest method testListUsers_noParameters.
@Test
public void testListUsers_noParameters() throws Exception {
HyperwalletList<HyperwalletUser> response = new HyperwalletList<HyperwalletUser>();
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<HyperwalletUser> resp = client.listUsers();
assertThat(resp, is(equalTo(response)));
Mockito.verify(mockApiClient).get(ArgumentMatchers.eq("https://api.sandbox.hyperwallet.com/rest/v4/users"), ArgumentMatchers.any(TypeReference.class));
}
Aggregations