Search in sources :

Example 31 with ElementFilter

use of uk.gov.gchq.gaffer.data.element.function.ElementFilter in project Gaffer by gchq.

the class ViewTest method shouldAddGlobalPreAggFiltersToGroup.

@Test
public void shouldAddGlobalPreAggFiltersToGroup() {
    // Given
    final ElementFilter filter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build();
    final View view = new View.Builder().globalEntities(new GlobalViewElementDefinition.Builder().groups(TestGroups.ENTITY).preAggregationFilter(filter).build()).entity(TestGroups.ENTITY).build();
    // When
    view.expandGlobalDefinitions();
    // Then
    assertTrue(view.hasPreAggregationFilters());
    assertEquals(Exists.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPreAggregationFilter().getComponents().get(0).getPredicate().getClass().getSimpleName());
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 32 with ElementFilter

use of uk.gov.gchq.gaffer.data.element.function.ElementFilter in project Gaffer by gchq.

the class ViewTest method shouldConcatGlobalPostTransformFiltersWhenSpecificGroupPostTransformFiltersSet.

@Test
public void shouldConcatGlobalPostTransformFiltersWhenSpecificGroupPostTransformFiltersSet() {
    // Given
    final ElementFilter globalFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build();
    final ElementFilter groupFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new ExampleFilterFunction()).build();
    final View view = new View.Builder().globalEntities(new GlobalViewElementDefinition.Builder().groups(TestGroups.ENTITY).postTransformFilter(globalFilter).build()).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().postTransformFilter(groupFilter).build()).build();
    // When
    view.expandGlobalDefinitions();
    // Then
    assertTrue(view.hasPostTransformFilters());
    assertEquals(Exists.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPostTransformFilter().getComponents().get(0).getPredicate().getClass().getSimpleName());
    assertEquals(ExampleFilterFunction.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPostTransformFilter().getComponents().get(1).getPredicate().getClass().getSimpleName());
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ExampleFilterFunction(uk.gov.gchq.gaffer.function.ExampleFilterFunction) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 33 with ElementFilter

use of uk.gov.gchq.gaffer.data.element.function.ElementFilter in project Gaffer by gchq.

the class ViewTest method shouldConcatGlobalPostAggFiltersWhenSpecificGroupPostAggFiltersSet.

@Test
public void shouldConcatGlobalPostAggFiltersWhenSpecificGroupPostAggFiltersSet() {
    // Given
    final ElementFilter globalFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build();
    final ElementFilter groupFilter = new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new ExampleFilterFunction()).build();
    final View view = new View.Builder().globalEntities(new GlobalViewElementDefinition.Builder().groups(TestGroups.ENTITY).postAggregationFilter(globalFilter).build()).entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().postAggregationFilter(groupFilter).build()).build();
    // When
    view.expandGlobalDefinitions();
    // Then
    assertTrue(view.hasPostAggregationFilters());
    assertEquals(Exists.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPostAggregationFilter().getComponents().get(0).getPredicate().getClass().getSimpleName());
    assertEquals(ExampleFilterFunction.class.getSimpleName(), view.getEntity(TestGroups.ENTITY).getPostAggregationFilter().getComponents().get(1).getPredicate().getClass().getSimpleName());
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ExampleFilterFunction(uk.gov.gchq.gaffer.function.ExampleFilterFunction) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest) Test(org.junit.jupiter.api.Test)

Example 34 with ElementFilter

use of uk.gov.gchq.gaffer.data.element.function.ElementFilter in project Gaffer by gchq.

the class ViewElementDefinitionTest method shouldFailToBuildElementDefinitionWhenPostTransformFilterSpecifiedTwice.

@Test
public void shouldFailToBuildElementDefinitionWhenPostTransformFilterSpecifiedTwice() {
    final ElementTransformer transformer = mock(ElementTransformer.class);
    final ElementFilter postFilter = mock(ElementFilter.class);
    assertThatIllegalArgumentException().isThrownBy(() -> new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_1, String.class).transientProperty(TestPropertyNames.PROP_2, String.class).transformer(transformer).postTransformFilter(postFilter).postTransformFilter(postFilter).build());
}
Also used : ElementTransformer(uk.gov.gchq.gaffer.data.element.function.ElementTransformer) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Test(org.junit.jupiter.api.Test)

Example 35 with ElementFilter

use of uk.gov.gchq.gaffer.data.element.function.ElementFilter in project Gaffer by gchq.

the class ViewElementDefinitionTest method shouldFailToBuildElementDefinitionWhenPreAggregationFilterSpecifiedTwice.

@Test
public void shouldFailToBuildElementDefinitionWhenPreAggregationFilterSpecifiedTwice() {
    final ElementTransformer transformer = mock(ElementTransformer.class);
    final ElementFilter filter = mock(ElementFilter.class);
    assertThatIllegalArgumentException().isThrownBy(() -> new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_1, String.class).transientProperty(TestPropertyNames.PROP_2, String.class).transformer(transformer).preAggregationFilter(filter).preAggregationFilter(filter).build());
}
Also used : ElementTransformer(uk.gov.gchq.gaffer.data.element.function.ElementTransformer) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Test(org.junit.jupiter.api.Test)

Aggregations

ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)43 Test (org.junit.jupiter.api.Test)35 Schema (uk.gov.gchq.gaffer.store.schema.Schema)11 Element (uk.gov.gchq.gaffer.data.element.Element)10 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)10 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)8 JSONSerialisationTest (uk.gov.gchq.gaffer.JSONSerialisationTest)6 Context (uk.gov.gchq.gaffer.store.Context)6 Store (uk.gov.gchq.gaffer.store.Store)6 Exists (uk.gov.gchq.koryphe.impl.predicate.Exists)6 ElementAggregator (uk.gov.gchq.gaffer.data.element.function.ElementAggregator)5 ElementTransformer (uk.gov.gchq.gaffer.data.element.function.ElementTransformer)5 GlobalViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.GlobalViewElementDefinition)5 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)5 ExampleFilterFunction (uk.gov.gchq.gaffer.function.ExampleFilterFunction)5 SchemaElementDefinition (uk.gov.gchq.gaffer.store.schema.SchemaElementDefinition)5 HashMap (java.util.HashMap)4 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)4 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)4 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)4