DashboardItemDeletionHandler extends DeletionHandler { @Override public void deleteEventReport( EventReport eventReport ) { for ( DashboardItem item : dashboardService.getEventReportDashboardItems( eventReport ) ) { dashboardService.deleteDashboardItem( item ); } } DashboardItemDeletionHandler( DashboardService dashboardService ); @Override void deleteVisualization( Visualization visualization ); @Override void deleteReportTable( ReportTable reportTable ); @Override void deleteChart( Chart chart ); @Override void deleteEventChart( EventChart eventChart ); @Override void deleteMap( Map map ); @Override void deleteEventReport( EventReport eventReport ); @Override void deleteUser( User user ); @Override void deleteReport( Report report ); @Override void deleteDocument( Document document );  }
@Test public void testDeleteEventReport() { programService.addProgram( program ); EventReport eventReport = new EventReport( "A" ); eventReport.setProgram( program ); eventReportService.saveEventReport( eventReport ); dashboardItem.setEventReport( eventReport ); dashboardService.saveDashboard( dashboard ); assertEquals(1, dashboardService.getEventReportDashboardItems( eventReport ).size() ); assertEquals( 1, dashboard.getItemCount() ); eventReportService.deleteEventReport( eventReport ); assertEquals(0, dashboardService.getEventReportDashboardItems( eventReport ).size() ); assertEquals( 0, dashboard.getItemCount() ); }