use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class SchemaTest method shouldReturnTrueWhenSchemaHasValidatorEntityPropertyFilters.
@Test
public void shouldReturnTrueWhenSchemaHasValidatorEntityPropertyFilters() {
// Given
final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "str").build()).type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()).edge(TestGroups.EDGE, new SchemaEdgeDefinition()).build();
// When
final boolean result = schema.hasValidation();
// Then
assertTrue(result);
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class ViewValidatorTest method shouldValidateAndReturnFalseWhenMissingTraits.
@Test
public void shouldValidateAndReturnFalseWhenMissingTraits() {
// Given
final ViewValidator validator = new ViewValidator();
final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().transientProperty(TestPropertyNames.PROP_3, String.class).preAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).aggregator(new ElementAggregator.Builder().select(TestPropertyNames.PROP_1).execute(new StringConcat()).build()).postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_2).execute(new Exists()).build()).transformer(new ElementTransformer.Builder().select(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2).execute(new ExampleTransformFunction()).project(TestPropertyNames.PROP_3).build()).postTransformFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_3).execute(new Exists()).build()).build()).build();
final Schema schema = new Schema.Builder().type("obj", String.class).type("string", String.class).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().property(TestPropertyNames.PROP_1, "obj").property(TestPropertyNames.PROP_2, "string").build()).build();
// When
final ValidationResult result = validator.validate(view, schema, NO_STORE_TRAITS);
// Then
final String errPrefix = "This store does not currently support ";
assertFalse(result.isValid());
assertEquals(Sets.newHashSet(errPrefix + StoreTrait.PRE_AGGREGATION_FILTERING.name(), errPrefix + StoreTrait.QUERY_AGGREGATION.name(), errPrefix + StoreTrait.POST_AGGREGATION_FILTERING.name(), errPrefix + StoreTrait.TRANSFORMATION.name(), errPrefix + StoreTrait.POST_TRANSFORMATION_FILTERING.name()), result.getErrors());
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class WhileTest method shouldShallowCloneOperation.
@Test
@Override
public void shouldShallowCloneOperation() {
// Given
final EntitySeed input = new EntitySeed("E");
final Predicate predicate = new Exists();
final Operation delegate = new GetAdjacentIds();
final int maxRepeats = 5;
final While operation = new While.Builder<>().input(input).maxRepeats(maxRepeats).conditional(predicate).operation(delegate).build();
// When
final While clone = operation.shallowClone();
// Then
assertNotSame(operation, clone);
assertEquals(input, clone.getInput());
assertEquals(maxRepeats, clone.getMaxRepeats());
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class UpdateViewHookTest method shouldMergeAndApplyWhiteList.
@Test
public void shouldMergeAndApplyWhiteList() throws Exception {
updateViewHook.setViewToMerge(viewToMerge);
updateViewHook.setWithOpAuth(Sets.newHashSet("opA"));
updateViewHook.setWhiteListElementGroups(Sets.newHashSet("white2", "white1", "testGroup"));
opChain = new OperationChain.Builder().first(new GetAllElements.Builder().view(new View.Builder().entity("wrong1").entity("white1").entity("white2").edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new Exists()).build()).build()).build()).build()).build();
updateViewHook.preExecute(opChain, new Context(new User.Builder().opAuth("opA").build()));
GetAllElements op = (GetAllElements) opChain.getOperations().get(0);
JsonAssert.assertEquals(new View.Builder().entity("white1", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new IsIn("value1", "value2")).build()).build()).entity("white2").edge("testGroup", new ViewElementDefinition.Builder().preAggregationFilter(new ElementFilter.Builder().select("prop1").execute(new Exists()).select("count").execute(new IsMoreThan(10)).build()).build()).build().toJson(true), op.getView().toJson(true));
assertTrue(op.getView().getGroups().contains("testGroup"));
}
use of uk.gov.gchq.koryphe.impl.predicate.Exists in project Gaffer by gchq.
the class ViewTest method shouldReturnTrueWhenViewHasPostAggEdgeFilters.
@Test
public void shouldReturnTrueWhenViewHasPostAggEdgeFilters() {
// Given
final View view = new View.Builder().entity(TestGroups.ENTITY).edge(TestGroups.EDGE, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).build()).edge(TestGroups.EDGE_2, null).build();
// When
final boolean result = view.hasPostAggregationFilters();
// Then
assertTrue(result);
}
Aggregations