Search in sources :

Example 36 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.

the class AbstractCoreKeyIteratorSettingsFactoryTest method shouldReturnIteratorValidatorIterator.

@Test
public void shouldReturnIteratorValidatorIterator() throws Exception {
    // Given
    final AccumuloStore store = mock(AccumuloStore.class);
    final Schema schema = new Schema.Builder().merge(createSchema()).type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()).build();
    final AccumuloKeyPackage keyPackage = mock(AccumuloKeyPackage.class);
    final AccumuloElementConverter converter = mock(AccumuloElementConverter.class);
    given(store.getSchema()).willReturn(schema);
    given(store.getKeyPackage()).willReturn(keyPackage);
    given(keyPackage.getKeyConverter()).willReturn(converter);
    // When
    final IteratorSetting iterator = factory.getValidatorIteratorSetting(store);
    // Then
    assertEquals(AccumuloStoreConstants.VALIDATOR_ITERATOR_NAME, iterator.getName());
    assertEquals(AccumuloStoreConstants.VALIDATOR_ITERATOR_PRIORITY, iterator.getPriority());
    assertEquals(ValidatorFilter.class.getName(), iterator.getIteratorClass());
    JsonAssert.assertEquals(schema.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.SCHEMA).getBytes());
    assertEquals(converter.getClass().getName(), iterator.getOptions().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
}
Also used : AccumuloKeyPackage(uk.gov.gchq.gaffer.accumulostore.key.AccumuloKeyPackage) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Schema(uk.gov.gchq.gaffer.store.schema.Schema) AccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter) AccumuloStore(uk.gov.gchq.gaffer.accumulostore.AccumuloStore) ValidatorFilter(uk.gov.gchq.gaffer.accumulostore.key.impl.ValidatorFilter) Test(org.junit.jupiter.api.Test)

Example 37 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.

the class AbstractCoreKeyIteratorSettingsFactoryTest method shouldReturnPreAggFilterIterator.

@Test
public void shouldReturnPreAggFilterIterator() throws Exception {
    // Given
    final AccumuloStore store = mock(AccumuloStore.class);
    final Schema schema = createSchema();
    final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).build()).build();
    final AccumuloKeyPackage keyPackage = mock(AccumuloKeyPackage.class);
    final AccumuloElementConverter converter = mock(AccumuloElementConverter.class);
    given(store.getSchema()).willReturn(schema);
    given(store.getKeyPackage()).willReturn(keyPackage);
    given(keyPackage.getKeyConverter()).willReturn(converter);
    // When
    final IteratorSetting iterator = factory.getElementPreAggregationFilterIteratorSetting(view, store);
    // Then
    assertEquals(AccumuloStoreConstants.ELEMENT_PRE_AGGREGATION_FILTER_ITERATOR_NAME, iterator.getName());
    assertEquals(AccumuloStoreConstants.ELEMENT_PRE_AGGREGATION_FILTER_ITERATOR_PRIORITY, iterator.getPriority());
    assertEquals(ElementPreAggregationFilter.class.getName(), iterator.getIteratorClass());
    JsonAssert.assertEquals(schema.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.SCHEMA).getBytes());
    JsonAssert.assertEquals(view.toCompactJson(), iterator.getOptions().get(AccumuloStoreConstants.VIEW).getBytes());
    assertEquals(converter.getClass().getName(), iterator.getOptions().get(AccumuloStoreConstants.ACCUMULO_ELEMENT_CONVERTER_CLASS));
}
Also used : AccumuloKeyPackage(uk.gov.gchq.gaffer.accumulostore.key.AccumuloKeyPackage) IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Schema(uk.gov.gchq.gaffer.store.schema.Schema) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) AccumuloElementConverter(uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter) AccumuloStore(uk.gov.gchq.gaffer.accumulostore.AccumuloStore) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ElementPreAggregationFilter(uk.gov.gchq.gaffer.accumulostore.key.impl.ElementPreAggregationFilter) Test(org.junit.jupiter.api.Test)

Example 38 with Exists

use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.

the class AbstractCoreKeyIteratorSettingsFactoryTest method shouldReturnNullPreAggFilterIfNoPreAggFilters.

@Test
public void shouldReturnNullPreAggFilterIfNoPreAggFilters() throws Exception {
    // Given
    final AccumuloStore store = mock(AccumuloStore.class);
    final Schema schema = createSchema();
    final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).build()).build();
    given(store.getSchema()).willReturn(schema);
    // When
    final IteratorSetting iterator = factory.getElementPreAggregationFilterIteratorSetting(view, store);
    // Then
    assertNull(iterator);
}
Also used : IteratorSetting(org.apache.accumulo.core.client.IteratorSetting) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Schema(uk.gov.gchq.gaffer.store.schema.Schema) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) AccumuloStore(uk.gov.gchq.gaffer.accumulostore.AccumuloStore) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Test(org.junit.jupiter.api.Test)

Aggregations

Exists (uk.gov.gchq.koryphe.impl.predicate.Exists)38 Test (org.junit.jupiter.api.Test)31 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)12 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)9 Schema (uk.gov.gchq.gaffer.store.schema.Schema)9 AccumuloStore (uk.gov.gchq.gaffer.accumulostore.AccumuloStore)8 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)6 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)6 HashMap (java.util.HashMap)5 Map (java.util.Map)3 MiniAccumuloStore (uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore)3 SingleUseMiniAccumuloStore (uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore)3 AccumuloElementConverter (uk.gov.gchq.gaffer.accumulostore.key.AccumuloElementConverter)3 AccumuloKeyPackage (uk.gov.gchq.gaffer.accumulostore.key.AccumuloKeyPackage)3 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)3 ExampleFilterFunction (uk.gov.gchq.gaffer.function.ExampleFilterFunction)3 Operation (uk.gov.gchq.gaffer.operation.Operation)3 StringConcat (uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat)3 Date (java.util.Date)2 List (java.util.List)2