use of org.eclipse.che.api.core.model.user.User in project che by eclipse.
the class UserService method create.
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@GenerateLink(rel = LINK_REL_USER)
@ApiOperation(value = "Create a new user", response = UserDto.class)
@ApiResponses({ @ApiResponse(code = 201, message = "User successfully created, response contains created entity"), @ApiResponse(code = 400, message = "Missed required parameters, parameters are not valid"), @ApiResponse(code = 401, message = "Missed token parameter"), @ApiResponse(code = 500, message = "Couldn't create user due to internal server error") })
public Response create(@ApiParam("New user") UserDto userDto, @ApiParam("Authentication token") @QueryParam("token") String token, @ApiParam("User type") @QueryParam("temporary") @DefaultValue("false") Boolean isTemporary) throws BadRequestException, UnauthorizedException, ConflictException, ServerException {
if (userDto != null) {
//should be generated by userManager
userDto.setId(null);
}
final User newUser = token == null ? userDto : tokenValidator.validateToken(token);
userValidator.checkUser(newUser);
return Response.status(CREATED).entity(linksInjector.injectLinks(asDto(userManager.create(newUser, isTemporary)), getServiceContext())).build();
}
use of org.eclipse.che.api.core.model.user.User in project che by eclipse.
the class UserManagerTest method shouldGetUserById.
@Test
public void shouldGetUserById() throws Exception {
final User user = new UserImpl("identifier", "test@email.com", "testName", "password", Collections.singletonList("alias"));
when(manager.getById(user.getId())).thenReturn(user);
assertEquals(manager.getById(user.getId()), user);
}
use of org.eclipse.che.api.core.model.user.User in project che by eclipse.
the class UserManagerTest method shouldThrowConflictExceptionOnCreationIfUserNameIsReserved.
@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionOnCreationIfUserNameIsReserved() throws Exception {
final User user = new UserImpl("id", "test@email.com", "reserved");
manager.create(user, false);
}
use of org.eclipse.che.api.core.model.user.User in project che by eclipse.
the class UserManagerTest method shouldUpdateUser.
@Test
public void shouldUpdateUser() throws Exception {
final User user = new UserImpl("identifier", "test@email.com", "testName", "password", Collections.emptyList());
manager.update(user);
verify(userDao).update(new UserImpl(user));
}
use of org.eclipse.che.api.core.model.user.User in project che by eclipse.
the class UserManagerTest method shouldGetUserByAlias.
@Test
public void shouldGetUserByAlias() throws Exception {
final User user = new UserImpl("identifier", "test@email.com", "testName", "password", Collections.singletonList("alias"));
when(manager.getByAlias("alias")).thenReturn(user);
assertEquals(manager.getByAlias("alias"), user);
}
Aggregations