use of org.eclipse.che.api.user.server.event.PostUserPersistedEvent in project che by eclipse.
the class UserDaoTest method shouldNotCreateUserWhenSubscriberThrowsExceptionOnUserStoring.
@Test(dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingUserById", expectedExceptions = NotFoundException.class)
public void shouldNotCreateUserWhenSubscriberThrowsExceptionOnUserStoring() throws Exception {
final UserImpl newUser = new UserImpl("user123", "user123@eclipse.org", "user_name", "password", asList("google:user123", "github:user123"));
CascadeEventSubscriber<PostUserPersistedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ConflictException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, PostUserPersistedEvent.class);
try {
userDao.create(newUser);
fail("UserDao#create had to throw conflict exception");
} catch (ConflictException ignored) {
}
eventService.unsubscribe(subscriber, PostUserPersistedEvent.class);
userDao.getById(newUser.getId());
}
use of org.eclipse.che.api.user.server.event.PostUserPersistedEvent in project che by eclipse.
the class JpaUserDao method doCreate.
@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
protected void doCreate(UserImpl user) throws ConflictException, ServerException {
EntityManager manage = managerProvider.get();
manage.persist(user);
manage.flush();
eventService.publish(new PostUserPersistedEvent(new UserImpl(user))).propagateException();
}
Aggregations