use of com.thoughtworks.go.presentation.UserSearchModel in project gocd by gocd.
the class UserServiceTest method shouldReturnErrorMessageWhenUserValidationsFail.
@Test
public void shouldReturnErrorMessageWhenUserValidationsFail() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
User invalidUser = new User("fooUser", "Foo User", "invalidEmail");
UserSearchModel searchModel = new UserSearchModel(invalidUser, UserSourceType.LDAP);
when(userDao.findUser("fooUser")).thenReturn(new NullUser());
when(userDao.enabledUserCount()).thenReturn(1);
userService.create(Arrays.asList(searchModel), result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(HttpServletResponse.SC_BAD_REQUEST));
}
use of com.thoughtworks.go.presentation.UserSearchModel in project gocd by gocd.
the class UserServiceTest method shouldReturnConflictWhenUserAlreadyExists.
@Test
public void shouldReturnConflictWhenUserAlreadyExists() {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
User existsingUser = new User("existingUser", "Existing User", "existing@user.com");
UserSearchModel searchModel = new UserSearchModel(existsingUser, UserSourceType.LDAP);
when(userDao.findUser("existingUser")).thenReturn(existsingUser);
userService.create(Arrays.asList(searchModel), result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(HttpServletResponse.SC_CONFLICT));
}
Aggregations