use of org.eclipse.che.api.machine.server.event.RecipePersistedEvent in project che by eclipse.
the class JpaRecipeDao method doCreate.
@Transactional(rollbackOn = { RuntimeException.class, ApiException.class })
protected void doCreate(RecipeImpl recipe) throws ConflictException, ServerException {
EntityManager manage = managerProvider.get();
manage.persist(recipe);
manage.flush();
eventService.publish(new RecipePersistedEvent(recipe)).propagateException();
}
use of org.eclipse.che.api.machine.server.event.RecipePersistedEvent in project che by eclipse.
the class RecipeDaoTest method shouldNotCreateRecipeWhenSubscriberThrowsExceptionOnRecipeStoring.
@Test(dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingRecipe", expectedExceptions = NotFoundException.class)
public void shouldNotCreateRecipeWhenSubscriberThrowsExceptionOnRecipeStoring() throws Exception {
final RecipeImpl recipe = createRecipe(0);
CascadeEventSubscriber<RecipePersistedEvent> subscriber = mockCascadeEventSubscriber();
doThrow(new ConflictException("error")).when(subscriber).onCascadeEvent(any());
eventService.subscribe(subscriber, RecipePersistedEvent.class);
try {
recipeDao.create(recipe);
fail("RecipeDao#create had to throw conflict exception");
} catch (ConflictException ignored) {
}
eventService.unsubscribe(subscriber, RecipePersistedEvent.class);
recipeDao.getById(recipe.getId());
}
Aggregations