DataGapDetector { public List<DataGap> getDataGaps() { return dataService.findDataGaps(); } DataGapDetector();  DataGapDetector(IDataService dataService, IParameterService parameterService,
            ISymmetricDialect symmetricDialect, IRouterService routerService, IStatisticManager statisticManager, INodeService nodeService); void beforeRouting(); void afterRouting(); List<DataGap> getDataGaps(); DataGap getLastDataGap(); void addDataIds(List<Long> dataIds); void setIsAllDataRead(boolean isAllDataRead); void setFullGapAnalysis(boolean isFullGapAnalysis); void setFullGapAnalysis(ISqlTransaction sqlTransaction, boolean b);  }
@Test public void testGapsFailedToDelete() throws Exception { when(parameterService.getLong(ParameterConstants.ROUTING_LARGEST_GAP_SIZE)).thenReturn(10L); when(parameterService.getInt(ParameterConstants.ROUTING_MAX_GAP_CHANGES)).thenReturn(2); List<Long> dataIds = new ArrayList<Long>(); dataIds.add(4L); List<DataGap> dataGaps = new ArrayList<DataGap>(); dataGaps.add(new DataGap(1, 1)); dataGaps.add(new DataGap(2, 2)); dataGaps.add(new DataGap(3, 13)); runGapDetector(dataGaps, dataIds, false); verify(dataService).findDataGaps(); verify(dataService).deleteAllDataGaps(sqlTransaction); verify(dataService).insertDataGap(sqlTransaction, new DataGap(1, 14)); verifyNoMoreInteractions(dataService); Mockito.reset(dataService); dataIds = new ArrayList<Long>(); dataIds.add(3L); dataGaps = detector.getDataGaps(); runGapDetector(dataGaps, dataIds, false); List<DataGap> inserted = new ArrayList<DataGap>(); inserted.add(new DataGap(1, 1)); inserted.add(new DataGap(2, 2)); inserted.add(new DataGap(5, 14)); verify(dataService).deleteAllDataGaps(sqlTransaction); verify(dataService).insertDataGaps(sqlTransaction, inserted); verifyNoMoreInteractions(dataService); }