use of org.eclipse.che.api.workspace.server.event.StackPersistedEvent in project che by eclipse.
the class JpaStackDao method doCreate.
@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
protected void doCreate(StackImpl stack) throws ConflictException, ServerException {
if (stack.getWorkspaceConfig() != null) {
stack.getWorkspaceConfig().getProjects().forEach(ProjectConfigImpl::prePersistAttributes);
}
EntityManager manager = managerProvider.get();
manager.persist(stack);
manager.flush();
eventService.publish(new StackPersistedEvent(stack)).propagateException();
}
use of org.eclipse.che.api.workspace.server.event.StackPersistedEvent in project che by eclipse.
the class StackDaoTest method shouldNotCreateStackWhenSubscriberThrowsExceptionOnStackStoring.
@Test(dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingStack", expectedExceptions = NotFoundException.class)
public void shouldNotCreateStackWhenSubscriberThrowsExceptionOnStackStoring() throws Exception {
final StackImpl stack = createStack("new-stack", "new-stack-name");
CascadeEventSubscriber<StackPersistedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ConflictException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, StackPersistedEvent.class);
try {
stackDao.create(stack);
fail("StackDao#create had to throw conflict exception");
} catch (ConflictException ignored) {
}
eventService.unsubscribe(subscriber, StackPersistedEvent.class);
stackDao.getById(stack.getId());
}
Aggregations