field.set(bsp, bssc);
int srcId = 101;
long sinceScn = 5;
long startScn = 10;
BootstrapDBMetaDataDAO bmdd = EasyMock.createMock(BootstrapDBMetaDataDAO.class);
EasyMock.expect(bmdd.getLogIdToCatchup(srcId, startScn)).andReturn(0).anyTimes();
EasyMock.expect(bmdd.getLogIdToCatchup(srcId, sinceScn)).andReturn(0).anyTimes();
EasyMock.replay(bmdd);
Field dbDaoField = bsp.getClass().getDeclaredField("_dbDao");
dbDaoField.setAccessible(true);
dbDaoField.set(bsp, bmdd);
List<SourceStatusInfo> srcList = new ArrayList<SourceStatusInfo>();
String name = "foo";
SourceStatusInfo ssi = new SourceStatusInfo(name, srcId, 4);
srcList.add(ssi);
// case 1. Single source, defaultRowsThresholdForSnapshotBypass set to Long.MAX_VALUE,
// individual overrides not set
boolean sbs = bsp.shouldBypassSnapshot(sinceScn, startScn, srcList);
Assert.assertEquals(true, sbs);
// case 2. Single source, defaultRowsThresholdForSnapshotBypass set to finite value,
// individual overrides set for the source
rowsThresholdForSnapshotBypass.put(name, Long.MAX_VALUE);
BootstrapServerStaticConfig bssc2 = new BootstrapServerStaticConfig(defaultRowsThresholdForSnapshotBypass,
rowsThresholdForSnapshotBypass,
disableSnapshotBypass,
predicatePushDown,
predicatePushDownBypass,
queryTimeoutInSec,
enableMinScnCheck,
db,
longestDbTxnTimeMins);
field.set(bsp, bssc2);
sbs = bsp.shouldBypassSnapshot(sinceScn, startScn, srcList);
Assert.assertEquals(true, sbs);
// Case 3: Detect case when the log is not available on log tables ( so it should NOT bypass snapshot )
BootstrapDBMetaDataDAO bmdd2 = EasyMock.createMock(BootstrapDBMetaDataDAO.class);
EasyMock.expect(bmdd2.getLogIdToCatchup(srcId, startScn)).andReturn(2).anyTimes();
EasyMock.expect(bmdd2.getLogIdToCatchup(srcId, sinceScn)).andThrow(new BootstrapProcessingException(""));
EasyMock.replay(bmdd2);
Field dbDaoField2 = bsp.getClass().getDeclaredField("_dbDao");
dbDaoField2.setAccessible(true);
dbDaoField2.set(bsp, bmdd2);