Search in sources :

Example 1 with UserImpl

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

the class FactoryDaoTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    factories = new FactoryImpl[ENTRY_COUNT];
    users = new UserImpl[ENTRY_COUNT];
    for (int i = 0; i < ENTRY_COUNT; i++) {
        users[i] = new UserImpl("userId_" + i, "email_" + i, "name" + i);
    }
    for (int i = 0; i < ENTRY_COUNT; i++) {
        factories[i] = createFactory(i, users[i].getId());
    }
    userTckRepository.createAll(Arrays.asList(users));
    factoryTckRepository.createAll(Stream.of(factories).map(FactoryImpl::new).collect(toList()));
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) FactoryImpl(org.eclipse.che.api.factory.server.model.impl.FactoryImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with UserImpl

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

the class UserManagerTest method shouldCreateProfileAndPreferencesOnUserCreation.

@Test
public void shouldCreateProfileAndPreferencesOnUserCreation() throws Exception {
    final UserImpl user = new UserImpl(null, "test@email.com", "testName", null, null);
    manager.create(user, false);
    verify(userDao).create(any(UserImpl.class));
    verify(profileDao).create(any(ProfileImpl.class));
    verify(preferencesDao).setPreferences(anyString(), anyMapOf(String.class, String.class));
}
Also used : ProfileImpl(org.eclipse.che.api.user.server.model.impl.ProfileImpl) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.testng.annotations.Test)

Example 3 with UserImpl

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

the class UserManagerTest method shouldGeneratePasswordWhenCreatingUserAndItIsMissing.

@Test
public void shouldGeneratePasswordWhenCreatingUserAndItIsMissing() 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());
    assertNotNull(userCaptor.getValue().getPassword());
}
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 4 with UserImpl

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

the class UserManagerTest method shouldGetUserByName.

@Test
public void shouldGetUserByName() throws Exception {
    final User user = new UserImpl("identifier", "test@email.com", "testName", "password", Collections.singletonList("alias"));
    when(manager.getByName(user.getName())).thenReturn(user);
    assertEquals(manager.getByName(user.getName()), 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 5 with UserImpl

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

the class UserManagerTest method shouldNotGenerateIdentifierWhenCreatingUserWithNotNullId.

@Test
public void shouldNotGenerateIdentifierWhenCreatingUserWithNotNullId() throws Exception {
    final User user = new UserImpl("identifier", "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);
    assertEquals(id, "identifier");
}
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)

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