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