use of org.apache.gobblin.compaction.conditions.RecompactionCombineCondition in project incubator-gobblin by apache.
the class RecompactionConditionTest method testRecompactionCombineCondition.
@Test
public void testRecompactionCombineCondition() {
DatasetHelper helper = mock(DatasetHelper.class);
RecompactionCondition cond1 = mock(RecompactionConditionBasedOnRatio.class);
RecompactionCondition cond2 = mock(RecompactionConditionBasedOnFileCount.class);
RecompactionCondition cond3 = mock(RecompactionConditionBasedOnDuration.class);
RecompactionCombineCondition combineConditionOr = new RecompactionCombineCondition(Arrays.asList(cond1, cond2, cond3), RecompactionCombineCondition.CombineOperation.OR);
when(cond1.isRecompactionNeeded(helper)).thenReturn(false);
when(cond2.isRecompactionNeeded(helper)).thenReturn(false);
when(cond3.isRecompactionNeeded(helper)).thenReturn(false);
Assert.assertEquals(combineConditionOr.isRecompactionNeeded(helper), false);
when(cond1.isRecompactionNeeded(helper)).thenReturn(false);
when(cond2.isRecompactionNeeded(helper)).thenReturn(true);
when(cond3.isRecompactionNeeded(helper)).thenReturn(false);
Assert.assertEquals(combineConditionOr.isRecompactionNeeded(helper), true);
RecompactionCombineCondition combineConditionAnd = new RecompactionCombineCondition(Arrays.asList(cond1, cond2, cond3), RecompactionCombineCondition.CombineOperation.AND);
when(cond1.isRecompactionNeeded(helper)).thenReturn(true);
when(cond2.isRecompactionNeeded(helper)).thenReturn(true);
when(cond3.isRecompactionNeeded(helper)).thenReturn(false);
Assert.assertEquals(combineConditionAnd.isRecompactionNeeded(helper), false);
when(cond1.isRecompactionNeeded(helper)).thenReturn(true);
when(cond2.isRecompactionNeeded(helper)).thenReturn(true);
when(cond3.isRecompactionNeeded(helper)).thenReturn(true);
Assert.assertEquals(combineConditionAnd.isRecompactionNeeded(helper), true);
}
Aggregations