RepositoryAspect { @Around("execution(* org.bonitasoft.web.designer.repository.AbstractRepository.delete(String))") public void delete(JoinPoint joinPoint) { try { Object component = get(joinPoint); handler.delete(filePath(joinPoint)); getPersister(joinPoint).delete(resolvePathFolder(joinPoint), (Identifiable) component); } catch (ResourceNotFoundException | IOException e) { throw new RepositoryException("An error occured while proceeding delete action.", e); } } @Inject  RepositoryAspect(WorkspaceResourceHandler handler); @After("execution(* org.bonitasoft.web.designer.repository.Repository+.updateLastUpdateAndSave(..)) ") void postSaveAndUpdateDate(JoinPoint joinPoint); @After("execution(* org.bonitasoft.web.designer.repository.Repository+.save(..))") void postSave(JoinPoint joinPoint); @Around("execution(* org.bonitasoft.web.designer.repository.AbstractRepository.delete(String))") void delete(JoinPoint joinPoint); @After("execution(* org.bonitasoft.web.designer.repository.Repository+.delete(String))") void postDelete(JoinPoint joinPoint);  }
@Test public void should_trigger_delete_on_workspaceResourceHandler_when_deleting_a_widget() throws Exception { widgetRepository.save(aWidget().id("widgetId1").custom().build()); widgetRepository.delete("widgetId1"); verify(workspaceResourceHandler).delete(widgetRepository.resolvePath("widgetId1")); }
@Test public void should_trigger_delete_on_workspaceResourceHandler_when_deleting_a_form() throws Exception { formRepository.save(aPage().withId("aPageId").build()); formRepository.delete("aPageId"); verify(workspaceResourceHandler).delete(formRepository.resolvePath("aPageId")); }
@Test(expected = IllegalArgumentException.class) public void should_throw_an_IllegalArgumentException_when_deleting_a_form_with_a_null_id() throws Exception { formRepository.delete(null); }