use of uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter in project Gaffer by gchq.
the class ElementPreAggregationFilterTest method shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithElementConverterClass.
@Test
public void shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithElementConverterClass() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPreAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.VIEW, getViewJson());
// When / Then
try {
filter.validateOptions(options);
fail("Expected IllegalArgumentException to be thrown on method invocation");
} catch (final IllegalArgumentException e) {
assertTrue(e.getMessage().contains(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
}
}
use of uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter in project Gaffer by gchq.
the class ElementPreAggregationFilterTest method shouldAcceptElementWhenViewValidatorAcceptsElement.
@Test
public void shouldAcceptElementWhenViewValidatorAcceptsElement() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPreAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.VIEW, getViewJson());
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
assertTrue(accept);
}
use of uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter in project Gaffer by gchq.
the class ElementPostAggregationFilterTest method shouldReturnTrueWhenValidOptions.
@Test
public void shouldReturnTrueWhenValidOptions() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPostAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.SCHEMA, getSchemaJson());
options.put(AccumuloStoreConstants.VIEW, getViewJson());
options.put(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS, ByteEntityAccumuloElementConverter.class.getName());
// When
final boolean isValid = filter.validateOptions(options);
// Then
assertTrue(isValid);
}
use of uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter in project Gaffer by gchq.
the class ElementPostAggregationFilterTest method shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithNoSchema.
@Test
public void shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithNoSchema() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPostAggregationFilter();
final Map<String, String> options = new HashMap<>();
options.put(AccumuloStoreConstants.VIEW, getViewJson());
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.SCHEMA));
}
}
use of uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter in project Gaffer by gchq.
the class ElementPostAggregationFilterTest method shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithNoView.
@Test
public void shouldThrowIllegalArgumentExceptionWhenValidateOptionsWithNoView() throws Exception {
// Given
final AbstractElementFilter filter = new ElementPostAggregationFilter();
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));
}
}
Aggregations