use of uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter in project Gaffer by gchq.
the class ElementPreAggregationFilterTest method shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithNoView.
@Test
public void shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithNoView() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPreAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
// When / Then
try {
filter.validateOptions(options);
fail("Expected IllegalArgumentException to be thrown on method invocation");
} catch (final IllegalArgumentException e) {
assertTrue(e.getMessage().contains(AccumuloStoreConstants.VIEW));
}
}
use of uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter in project Gaffer by gchq.
the class ElementPreAggregationFilterTest method shouldNotAcceptElementWhenViewValidatorDoesNotAcceptElement.
@Test
public void shouldNotAcceptElementWhenViewValidatorDoesNotAcceptElement() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPreAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.VIEW, getEmptyViewJson());
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
filter.validateOptions(options);
final ByteEntityAccumuloElementConverter converter = new ByteEntityAccumuloElementConverter(getSchema());
final Element element = new Edge(TestGroups.EDGE, "source", "dest", true);
final Pair<Key> key = converter.getKeysFromElement(element);
final Value value = converter.getValueFromElement(element);
// When
final boolean accept = filter.accept(key.getFirst(), value);
// Then
assertFalse(accept);
}
Aggregations