use of org.eclipse.che.api.machine.server.event.BeforeRecipeRemovedEvent in project che by eclipse.
the class JpaRecipeDao method doRemove.
@Transactional(rollbackOn = { RuntimeException.class, ServerException.class })
protected void doRemove(String id) throws ServerException {
final EntityManager manager = managerProvider.get();
final RecipeImpl recipe = manager.find(RecipeImpl.class, id);
if (recipe != null) {
eventService.publish(new BeforeRecipeRemovedEvent(new RecipeImpl(recipe))).propagateException();
manager.remove(recipe);
manager.flush();
}
}
use of org.eclipse.che.api.machine.server.event.BeforeRecipeRemovedEvent in project che by eclipse.
the class RecipeDaoTest method shouldNotRemoveRecipeWhenSubscriberThrowsExceptionOnRecipeRemoving.
@Test(dependsOnMethods = "shouldGetRecipeById")
public void shouldNotRemoveRecipeWhenSubscriberThrowsExceptionOnRecipeRemoving() throws Exception {
final RecipeImpl recipe = recipes.get(0);
CascadeEventSubscriber<BeforeRecipeRemovedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ServerException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, BeforeRecipeRemovedEvent.class);
try {
recipeDao.remove(recipe.getId());
fail("RecipeDao#remove had to throw server exception");
} catch (ServerException ignored) {
}
assertEquals(recipeDao.getById(recipe.getId()), recipe);
eventService.unsubscribe(subscriber, BeforeRecipeRemovedEvent.class);
}
Aggregations