Search in sources :

Example 6 with AbstractElementFilter

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));
    }
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 7 with AbstractElementFilter

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);
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) Element(uk.gov.gchq.gaffer.data.element.Element) Value(org.apache.accumulo.core.data.Value) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Edge(uk.gov.gchq.gaffer.data.element.Edge) Key(org.apache.accumulo.core.data.Key) Test(org.junit.Test)

Example 8 with AbstractElementFilter

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);
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Test(org.junit.Test)

Example 9 with AbstractElementFilter

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));
    }
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Test(org.junit.Test)

Example 10 with AbstractElementFilter

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));
    }
}
Also used : AbstractElementFilter(uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter) HashMap(java.util.HashMap) ByteEntityAccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)12 Test (org.junit.Test)12 AbstractElementFilter (uk.gov.gchq.gaffer.accumulostore.key.AbstractElementFilter)12 ByteEntityAccumuloElementConverter (uk.gov.gchq.gaffer.accumulostore.key.core.impl.byteEntity.ByteEntityAccumuloElementConverter)10 Key (org.apache.accumulo.core.data.Key)4 Value (org.apache.accumulo.core.data.Value)4 Edge (uk.gov.gchq.gaffer.data.element.Edge)4 Element (uk.gov.gchq.gaffer.data.element.Element)4