Search in sources :

Example 21 with UserImpl

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

the class UserDaoTest method shouldThrowConflictExceptionWhenCreatingUserWithExistingEmail.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenCreatingUserWithExistingEmail() throws Exception {
    final UserImpl newUser = new UserImpl("user123", users[0].getEmail(), "user_name", "password", asList("google:user123", "github:user123"));
    userDao.create(newUser);
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 22 with UserImpl

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

the class UserDaoTest method shouldThrowConflictExceptionWhenCreatingUserWithExistingName.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenCreatingUserWithExistingName() throws Exception {
    final UserImpl newUser = new UserImpl("user123", "user123@eclipse.org", users[0].getName(), "password", asList("google:user123", "github:user123"));
    userDao.create(newUser);
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 23 with UserImpl

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

the class UserDaoTest method shouldReturnUserWithNullPasswordWhenGetUserByAliasAndPassword.

@Test(dependsOnMethods = { "shouldGetUserByNameAndPassword", "shouldGetUserByEmailAndPassword" })
public void shouldReturnUserWithNullPasswordWhenGetUserByAliasAndPassword() throws Exception {
    final UserImpl user = users[0];
    assertEquals(userDao.getByAliasAndPassword(user.getName(), user.getPassword()).getPassword(), null);
    assertEquals(userDao.getByAliasAndPassword(user.getEmail(), user.getPassword()).getPassword(), null);
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 24 with UserImpl

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

the class UserDaoTest method shouldThrowConflictExceptionWhenUpdatingUserWithReservedAlias.

@Test(expectedExceptions = ConflictException.class)
public void shouldThrowConflictExceptionWhenUpdatingUserWithReservedAlias() throws Exception {
    final UserImpl user = users[0];
    user.setAliases(users[1].getAliases());
    userDao.update(user);
}
Also used : UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) Test(org.testng.annotations.Test)

Example 25 with UserImpl

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

the class UserDaoTest method shouldNotRemoveUserWhenSubscriberThrowsExceptionOnUserRemoving.

@Test(dependsOnMethods = "shouldGetUserById")
public void shouldNotRemoveUserWhenSubscriberThrowsExceptionOnUserRemoving() throws Exception {
    final UserImpl user = users[0];
    CascadeEventSubscriber<BeforeUserRemovedEvent> subscriber = mockCascadeEventSubscriber();
    doThrow(new ServerException("error")).when(subscriber).onCascadeEvent(any());
    eventService.subscribe(subscriber, BeforeUserRemovedEvent.class);
    try {
        userDao.remove(user.getId());
        fail("UserDao#remove had to throw server exception");
    } catch (ServerException ignored) {
    }
    assertEqualsNoPassword(userDao.getById(user.getId()), user);
    eventService.unsubscribe(subscriber, BeforeUserRemovedEvent.class);
}
Also used : ServerException(org.eclipse.che.api.core.ServerException) UserImpl(org.eclipse.che.api.user.server.model.impl.UserImpl) BeforeUserRemovedEvent(org.eclipse.che.api.user.server.event.BeforeUserRemovedEvent) 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