Search in sources :

Example 56 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl 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));
}
Also used : User(org.eclipse.che.api.core.model.user.User) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 57 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl 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);
}
Also used : User(org.eclipse.che.api.core.model.user.User) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 58 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.

the class UserManagerTest method shouldGenerateIdentifierWhenCreatingUserWithNullId.

@Test
public void shouldGenerateIdentifierWhenCreatingUserWithNullId() throws Exception {
    final User user = new UserImpl(null, "test@email.com", "testName", null, null);
    manager.create(user, false);
    final ArgumentCaptor<UserImpl> userCaptor = ArgumentCaptor.forClass(UserImpl.class);
    verify(userDao).create(userCaptor.capture());
    final String id = userCaptor.getValue().getId();
    assertNotNull(id);
}
Also used : User(org.eclipse.che.api.core.model.user.User) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 59 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl in project che by eclipse.

the class UserServiceTest method shouldBeAbleToFindUserByEmail.

@Test
public void shouldBeAbleToFindUserByEmail() throws Exception {
    final UserImpl testUser = copySubject();
    when(userManager.getByEmail(testUser.getEmail())).thenReturn(testUser);
    final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).when().get(SECURE_PATH + "/user/find?email=" + testUser.getEmail());
    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());
}
Also used : Response(com.jayway.restassured.response.Response) UserDto(org.eclipse.che.api.user.shared.dto.UserDto) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 60 with UserImpl

use of org.eclipse.che.api.user.server.model.impl.UserImpl 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());
}
Also used : Response(com.jayway.restassured.response.Response) UserDto(org.eclipse.che.api.user.shared.dto.UserDto) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Aggregations

UserImpl (org.eclipse.che.api.user.server.model.impl.UserImpl)65 Test (org.testng.annotations.Test)45 User (org.eclipse.che.api.core.model.user.User)13 Response (com.jayway.restassured.response.Response)10 BeforeMethod (org.testng.annotations.BeforeMethod)9 ServerException (org.eclipse.che.api.core.ServerException)8 Transactional (com.google.inject.persist.Transactional)6 ConflictException (org.eclipse.che.api.core.ConflictException)5 BeforeUserRemovedEvent (org.eclipse.che.api.user.server.event.BeforeUserRemovedEvent)5 EntityManager (javax.persistence.EntityManager)4 NotFoundException (org.eclipse.che.api.core.NotFoundException)4 Page (org.eclipse.che.api.core.Page)4 PostUserPersistedEvent (org.eclipse.che.api.user.server.event.PostUserPersistedEvent)4 ProfileImpl (org.eclipse.che.api.user.server.model.impl.ProfileImpl)4 UserDao (org.eclipse.che.api.user.server.spi.UserDao)4 ArrayList (java.util.ArrayList)3 Inject (javax.inject.Inject)3 UserRemovedEvent (org.eclipse.che.api.user.server.event.UserRemovedEvent)3 UserDto (org.eclipse.che.api.user.shared.dto.UserDto)3 TckRepository (org.eclipse.che.commons.test.tck.repository.TckRepository)3