Search in sources :

Example 1 with ConditionComparator

use of org.apache.accumulo.core.client.impl.ConditionalWriterImpl.ConditionComparator in project accumulo by apache.

the class ConditionalComparatorTest method testComparator.

@Test
public void testComparator() {
    Condition c1 = new Condition("a", "b");
    Condition c2 = new Condition("a", "c");
    Condition c3 = new Condition("b", "c");
    Condition c4 = new Condition("a", "b").setTimestamp(5);
    Condition c5 = new Condition("a", "b").setTimestamp(6);
    Condition c6 = new Condition("a", "b").setVisibility(new ColumnVisibility("A&B"));
    Condition c7 = new Condition("a", "b").setVisibility(new ColumnVisibility("A&C"));
    ConditionComparator comparator = new ConditionComparator();
    Assert.assertTrue(comparator.compare(c1, c1) == 0);
    Assert.assertTrue(comparator.compare(c1, c2) < 0);
    Assert.assertTrue(comparator.compare(c2, c1) > 0);
    Assert.assertTrue(comparator.compare(c1, c3) < 0);
    Assert.assertTrue(comparator.compare(c3, c1) > 0);
    Assert.assertTrue(comparator.compare(c1, c4) < 0);
    Assert.assertTrue(comparator.compare(c4, c1) > 0);
    Assert.assertTrue(comparator.compare(c5, c4) < 0);
    Assert.assertTrue(comparator.compare(c4, c5) > 0);
    Assert.assertTrue(comparator.compare(c1, c7) < 0);
    Assert.assertTrue(comparator.compare(c7, c1) > 0);
    Assert.assertTrue(comparator.compare(c6, c7) < 0);
    Assert.assertTrue(comparator.compare(c7, c6) > 0);
}
Also used : Condition(org.apache.accumulo.core.data.Condition) ConditionComparator(org.apache.accumulo.core.client.impl.ConditionalWriterImpl.ConditionComparator) ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Test(org.junit.Test)

Aggregations

ConditionComparator (org.apache.accumulo.core.client.impl.ConditionalWriterImpl.ConditionComparator)1 Condition (org.apache.accumulo.core.data.Condition)1 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)1 Test (org.junit.Test)1