DashboardItemDeletionHandler extends DeletionHandler { @Override public void deleteEventChart( EventChart eventChart ) { for ( DashboardItem item : dashboardService.getEventChartDashboardItems( eventChart ) ) { 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 testDeleteEventChart() { programService.addProgram( program ); EventChart eventChart = new EventChart( "A" ); eventChart.setProgram( program ); eventChart.setType( ChartType.COLUMN ); eventChartService.saveEventChart( eventChart ); dashboardItem.setEventChart( eventChart ); dashboardService.saveDashboard( dashboard ); assertEquals(1, dashboardService.getEventChartDashboardItems( eventChart ).size() ); assertEquals( 1, dashboard.getItemCount() ); eventChartService.deleteEventChart( eventChart ); assertEquals(0, dashboardService.getEventChartDashboardItems( eventChart ).size() ); assertEquals( 0, dashboard.getItemCount() ); }