DocumentFieldPredicate implements Predicate<MultimapRecord> { @Override public boolean apply(MultimapRecord input) { Collection<RecordValue<?>> values = input.get(column); for (RecordValue<?> value : values) { if (value.value().equals(predicateValue.toString())) return true; } return false; } DocumentFieldPredicate(Field field, Literal value); @Override boolean apply(MultimapRecord input);  }
@Test public void testEmptyDocument() { Multimap<Column, RecordValue<?>> values = ArrayListMultimap.create(); MultimapRecord doc = new MultimapRecord(values,"abc",new ColumnVisibility("viz1")); DocumentFieldPredicate filter = new DocumentFieldPredicate(new Field("field1"),new Literal("Value1")); assertFalse( filter.apply(doc) ); }
@Test public void testFieldButNoValue() { Multimap<Column, RecordValue<?>> values = ArrayListMultimap.create(); values.put(new Column("field1"), RecordValue.create("Value2", new ColumnVisibility("viz1"))); MultimapRecord doc = new MultimapRecord(values,"abc",new ColumnVisibility("viz1")); DocumentFieldPredicate filter = new DocumentFieldPredicate(new Field("field1"),new Literal("Value1")); assertFalse( filter.apply(doc) ); }
@Test public void testFieldWithValue() { Multimap<Column, RecordValue<?>> values = ArrayListMultimap.create(); values.put(new Column("field1"), RecordValue.create("Value1", new ColumnVisibility("viz1"))); MultimapRecord doc = new MultimapRecord(values,"abc",new ColumnVisibility("viz1")); DocumentFieldPredicate filter = new DocumentFieldPredicate(new Field("field1"),new Literal("Value1")); assertTrue( filter.apply(doc) ); }