use of org.eclipse.che.api.workspace.server.event.BeforeStackRemovedEvent in project che by eclipse.
the class JpaStackDao method doRemove.
@Transactional(rollbackOn = { RuntimeException.class, ServerException.class })
protected void doRemove(String id) throws ServerException {
final EntityManager manager = managerProvider.get();
final StackImpl stack = manager.find(StackImpl.class, id);
if (stack != null) {
eventService.publish(new BeforeStackRemovedEvent(new StackImpl(stack))).propagateException();
manager.remove(stack);
manager.flush();
}
}
use of org.eclipse.che.api.workspace.server.event.BeforeStackRemovedEvent in project che by eclipse.
the class StackDaoTest method shouldNotRemoveStackWhenSubscriberThrowsExceptionOnStackRemoving.
@Test(dependsOnMethods = "shouldGetById")
public void shouldNotRemoveStackWhenSubscriberThrowsExceptionOnStackRemoving() throws Exception {
final StackImpl stack = stacks[0];
CascadeEventSubscriber<BeforeStackRemovedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ServerException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, BeforeStackRemovedEvent.class);
try {
stackDao.remove(stack.getId());
fail("StackDao#remove had to throw server exception");
} catch (ServerException ignored) {
}
assertEquals(stackDao.getById(stack.getId()), stack);
eventService.unsubscribe(subscriber, BeforeStackRemovedEvent.class);
}
Aggregations