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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations