use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapsOverlapThenDataFull.
@Test
public void testGapsOverlapThenDataFull() throws Exception {
detector.setFullGapAnalysis(true);
when(contextService.is(ContextConstants.ROUTING_FULL_GAP_ANALYSIS)).thenReturn(true);
List<Long> dataIds = new ArrayList<Long>();
dataIds.add(30953883L);
@SuppressWarnings("unchecked") ISqlRowMapper<Long> mapper = (ISqlRowMapper<Long>) Matchers.anyObject();
String sql = Matchers.anyString();
when(sqlTemplate.query(sql, mapper, Matchers.eq(30953883L), Matchers.eq(80953883L))).thenReturn(dataIds);
List<DataGap> dataGaps1 = new ArrayList<DataGap>();
dataGaps1.add(new DataGap(30953883, 80953883));
dataGaps1.add(new DataGap(30953884, 80953883));
List<DataGap> dataGaps2 = new ArrayList<DataGap>();
dataGaps2.add(new DataGap(30953884, 80953883));
dataIds = new ArrayList<Long>();
dataIds.add(30953883L);
runGapDetector(dataGaps1, dataGaps2, dataIds, true);
verify(dataService).findDataGaps();
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(30953884, 80953883));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(30953883, 80953883));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(30953884, 80953883));
verifyNoMoreInteractions(dataService);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapExpire.
@Test
public void testGapExpire() throws Exception {
List<DataGap> dataGaps = new ArrayList<DataGap>();
dataGaps.add(new DataGap(3, 3));
dataGaps.add(new DataGap(5, 6));
dataGaps.add(new DataGap(7, 50000006));
when(symmetricDialect.supportsTransactionViews()).thenReturn(true);
when(symmetricDialect.getDatabaseTime()).thenReturn(System.currentTimeMillis() + 60001L);
runGapDetector(dataGaps, new ArrayList<Long>(), true);
verify(dataService).findDataGaps();
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(3, 3));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(5, 6));
verifyNoMoreInteractions(dataService);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapsBeforeAndAfterFull.
@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);
@SuppressWarnings("unchecked") ISqlRowMapper<Long> mapper = (ISqlRowMapper<Long>) Matchers.anyObject();
String sql = Matchers.anyString();
when(sqlTemplate.query(sql, mapper, Matchers.eq(841L), Matchers.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);
verify(dataService).findDataGaps();
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(841, 50000840));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(841, 842));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(845, 50000844));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(845, 50000844));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(846, 50000845));
verifyNoMoreInteractions(dataService);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapsDuplicateDetection.
@Test
public void testGapsDuplicateDetection() throws Exception {
List<Long> dataIds = new ArrayList<Long>();
dataIds.add(31832439L);
List<DataGap> dataGaps = new ArrayList<DataGap>();
dataGaps.add(new DataGap(31832006, 31832438));
dataGaps.add(new DataGap(31832439, 81832439));
dataGaps.add(new DataGap(31832440, 81832439));
runGapDetector(dataGaps, dataIds, true);
verify(dataService).findDataGaps();
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(31832440, 81832439));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(31832439, 81832439));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(31832440, 81832439));
verifyNoMoreInteractions(dataService);
}
use of org.jumpmind.symmetric.model.DataGap in project symmetric-ds by JumpMind.
the class DataGapDetectorTest method testGapInGap.
@Test
public void testGapInGap() throws Exception {
List<DataGap> dataGaps = new ArrayList<DataGap>();
dataGaps.add(new DataGap(3, 3));
dataGaps.add(new DataGap(5, 10));
dataGaps.add(new DataGap(15, 20));
dataGaps.add(new DataGap(21, 50000020));
List<Long> dataIds = new ArrayList<Long>();
dataIds.add(6L);
dataIds.add(18L);
dataIds.add(23L);
runGapDetector(dataGaps, dataIds, true);
verify(dataService).findDataGaps();
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(5, 10));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(5, 5));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(7, 10));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(15, 20));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(15, 17));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(19, 20));
verify(dataService).deleteDataGap(sqlTransaction, new DataGap(21, 50000020));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(21, 22));
verify(dataService).insertDataGap(sqlTransaction, new DataGap(24, 50000023));
verifyNoMoreInteractions(dataService);
}
Aggregations