@Test
public void testGapsBeforeAndAfterFull() throws Exception {

    detector.setFullGapAnalysis(true);
    when(contextService.is(ContextConstants.ROUTING_FULL_GAP_ANALYSIS)).thenReturn(true);
    List<Long> dataIds = new ArrayList<Long>();
    dataIds.add(843L);
    dataIds.add(844L);
    String sql = ArgumentMatchers.anyString();
    @SuppressWarnings("unchecked")
    ISqlRowMapper<Long> mapper = (ISqlRowMapper<Long>) ArgumentMatchers.any();
    when(sqlTemplate.query(sql, mapper, ArgumentMatchers.eq(841L), ArgumentMatchers.eq(50000840L))).thenReturn(dataIds);
    List<DataGap> dataGaps1 = new ArrayList<DataGap>();
    dataGaps1.add(new DataGap(841, 50000840));
    List<DataGap> dataGaps2 = new ArrayList<DataGap>();
    dataGaps2.add(new DataGap(841, 842));
    dataGaps2.add(new DataGap(845, 50000844));
    dataIds = new ArrayList<Long>();
    dataIds.add(845L);
    
    runGapDetector(dataGaps1, dataGaps2, dataIds, true);
    Set<DataGap> deleted = new HashSet<DataGap>();
    deleted.add(new DataGap(841, 50000840));
    
    Set<DataGap> deleted2 = new HashSet<DataGap>();
    deleted2.add(new DataGap(845, 50000844));
    Set<DataGap> inserted = new HashSet<DataGap>();
    inserted.add(new DataGap(841, 842));
    inserted.add(new DataGap(845, 50000844));
    
    Set<DataGap> inserted2 = new HashSet<DataGap>();
    inserted2.add(new DataGap(846, 50000845));
    
    verify(dataService).findDataGaps();
    verify(dataService).deleteDataGaps(sqlTransaction, deleted);
    verify(dataService).insertDataGaps(sqlTransaction, inserted);
    verify(dataService).deleteDataGaps(sqlTransaction, deleted2);
    verify(dataService).insertDataGaps(sqlTransaction, inserted2);
    verifyNoMoreInteractions(dataService);
}