Search in sources :

Example 36 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) ISqlRowMapper(org.jumpmind.db.sql.ISqlRowMapper) Test(org.junit.Test)

Example 37 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 38 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) ISqlRowMapper(org.jumpmind.db.sql.ISqlRowMapper) Test(org.junit.Test)

Example 39 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 40 with DataGap

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);
}
Also used : DataGap(org.jumpmind.symmetric.model.DataGap) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

DataGap (org.jumpmind.symmetric.model.DataGap)49 ArrayList (java.util.ArrayList)32 Test (org.junit.Test)28 Data (org.jumpmind.symmetric.model.Data)7 Date (java.util.Date)6 ISqlRowMapper (org.jumpmind.db.sql.ISqlRowMapper)6 TransformedData (org.jumpmind.symmetric.io.data.transform.TransformedData)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 ISqlTemplate (org.jumpmind.db.sql.ISqlTemplate)5 HashSet (java.util.HashSet)3 List (java.util.List)3 ISqlTransaction (org.jumpmind.db.sql.ISqlTransaction)3 Row (org.jumpmind.db.sql.Row)2 ProcessInfo (org.jumpmind.symmetric.model.ProcessInfo)2 ProcessInfoKey (org.jumpmind.symmetric.model.ProcessInfoKey)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1 MemoryUsage (java.lang.management.MemoryUsage)1