use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldCreateUserFromEntity.
@Test
public void shouldCreateUserFromEntity() throws Exception {
final UserDto newUser = newDto(UserDto.class).withName("test").withEmail("test@codenvy.com").withPassword("password12345");
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().body(newUser).contentType("application/json").post(SECURE_PATH + "/user");
assertEquals(response.statusCode(), 201);
verify(userManager).create(userCaptor.capture(), anyBoolean());
final User user = userCaptor.getValue();
assertEquals(user.getEmail(), "test@codenvy.com");
assertEquals(user.getName(), "test");
assertEquals(user.getPassword(), "password12345");
}
use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldBeAbleToGetUserById.
@Test
public void shouldBeAbleToGetUserById() throws Exception {
final UserImpl testUser = copySubject();
when(userManager.getById(SUBJECT.getUserId())).thenReturn(testUser);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/user/" + SUBJECT.getUserId());
assertEquals(response.getStatusCode(), 200);
final UserDto fetchedUser = unwrapDto(response, UserDto.class);
assertEquals(fetchedUser.getId(), testUser.getId());
assertEquals(fetchedUser.getName(), testUser.getName());
assertEquals(fetchedUser.getEmail(), testUser.getEmail());
}
use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldBeAbleToFindUserByName.
@Test
public void shouldBeAbleToFindUserByName() throws Exception {
final UserImpl testUser = copySubject();
when(userManager.getByName(testUser.getName())).thenReturn(testUser);
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/user/find?name=" + testUser.getName());
assertEquals(response.getStatusCode(), 200);
final UserDto fetchedUser = unwrapDto(response, UserDto.class);
assertEquals(fetchedUser.getId(), testUser.getId());
assertEquals(fetchedUser.getName(), testUser.getName());
assertEquals(fetchedUser.getEmail(), testUser.getEmail());
}
use of org.eclipse.che.api.user.shared.dto.UserDto in project che by eclipse.
the class UserServiceTest method shouldNotCreateUserFromEntityWhenPasswordIsNotValid.
@Test
public void shouldNotCreateUserFromEntityWhenPasswordIsNotValid() throws Exception {
final UserDto newUser = newDto(UserDto.class).withName("test").withEmail("test@codenvy.com").withPassword("1");
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().body(newUser).contentType("application/json").post(SECURE_PATH + "/user");
assertEquals(response.statusCode(), 400);
assertEquals(unwrapError(response), "Password should contain at least 8 characters");
}
Aggregations