Search in sources :

Example 31 with UserImpl

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

the class FactoryServiceTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    factoryBuilderSpy = spy(new FactoryBuilder(new SourceStorageParametersValidator()));
    factoryParametersResolvers = new HashSet<>();
    doNothing().when(factoryBuilderSpy).checkValid(any(FactoryDto.class));
    doNothing().when(factoryBuilderSpy).checkValid(any(FactoryDto.class), anyBoolean());
    when(factoryParametersResolverHolder.getFactoryParametersResolvers()).thenReturn(factoryParametersResolvers);
    user = new UserImpl(USER_ID, USER_EMAIL, ADMIN_USER_NAME);
    when(userManager.getById(anyString())).thenReturn(user);
    when(preferenceManager.find(USER_ID)).thenReturn(ImmutableMap.of("preference", "value"));
    service = new FactoryService(factoryManager, userManager, preferenceManager, createValidator, acceptValidator, editValidator, factoryBuilderSpy, workspaceManager, factoryParametersResolverHolder);
}
Also used : FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) SourceStorageParametersValidator(org.eclipse.che.api.factory.server.impl.SourceStorageParametersValidator) FactoryBuilder(org.eclipse.che.api.factory.server.builder.FactoryBuilder) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 32 with UserImpl

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

the class FactoryBaseValidatorTest method setUp.

@BeforeMethod
public void setUp() throws ParseException, NotFoundException, ServerException {
    factory = newDto(FactoryDto.class).withV("4.0").withCreator(newDto(AuthorDto.class).withUserId("userid"));
    final UserImpl user = new UserImpl("userid", "email", "name");
    when(userDao.getById("userid")).thenReturn(user);
    validator = new TesterFactoryBaseValidator();
}
Also used : AuthorDto(org.eclipse.che.api.factory.shared.dto.AuthorDto) FactoryDto(org.eclipse.che.api.factory.shared.dto.FactoryDto) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 33 with UserImpl

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

the class PreferenceDaoTest method setUp.

@BeforeMethod
private void setUp() throws Exception {
    userPreferences = new ArrayList<>(ENTRY_COUNT);
    UserImpl[] users = new UserImpl[ENTRY_COUNT];
    for (int index = 0; index < ENTRY_COUNT; index++) {
        String userId = "userId_" + index;
        users[index] = new UserImpl(userId, "email_" + userId, "name_" + userId, "password", emptyList());
        final Map<String, String> prefs = new HashMap<>();
        prefs.put("preference1", "value");
        prefs.put("preference2", "value");
        prefs.put("preference3", "value");
        userPreferences.add(Pair.of(userId, prefs));
    }
    userTckRepository.createAll(Arrays.asList(users));
    preferenceTckRepository.createAll(userPreferences);
}
Also used : HashMap(java.util.HashMap) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 34 with UserImpl

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

the class UserDaoTest method shouldUpdateUser.

@Test(dependsOnMethods = "shouldGetUserById")
public void shouldUpdateUser() throws Exception {
    final UserImpl user = users[0];
    userDao.update(new UserImpl(user.getId(), "new-email", "new-name", null, asList("google:new-alias", "github:new-alias")));
    final UserImpl updated = userDao.getById(user.getId());
    assertEquals(updated.getId(), user.getId());
    assertEquals(updated.getEmail(), "new-email");
    assertEquals(updated.getName(), "new-name");
    assertEquals(new HashSet<>(updated.getAliases()), new HashSet<>(asList("google:new-alias", "github:new-alias")));
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 35 with UserImpl

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

the class UserDaoTest method shouldThrowConflictExceptionWhenUpdatingUserWithReservedName.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenUpdatingUserWithReservedName() throws Exception {
    final UserImpl user = users[0];
    user.setName(users[1].getName());
    userDao.update(user);
}
Also used : 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