Search in sources :

Example 1 with RecompactionCombineCondition

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);
}
Also used : RecompactionCondition(org.apache.gobblin.compaction.conditions.RecompactionCondition) RecompactionCombineCondition(org.apache.gobblin.compaction.conditions.RecompactionCombineCondition) DatasetHelper(org.apache.gobblin.compaction.dataset.DatasetHelper) Test(org.testng.annotations.Test)

Aggregations

RecompactionCombineCondition (org.apache.gobblin.compaction.conditions.RecompactionCombineCondition)1 RecompactionCondition (org.apache.gobblin.compaction.conditions.RecompactionCondition)1 DatasetHelper (org.apache.gobblin.compaction.dataset.DatasetHelper)1 Test (org.testng.annotations.Test)1