Search in sources :

Example 6 with Exists

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

the class SchemaTest method shouldReturnTrueWhenSchemaHasValidatorEdgePropertyFilters.

@Test
public void shouldReturnTrueWhenSchemaHasValidatorEdgePropertyFilters() {
    // Given
    final Schema schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().property(TestPropertyNames.PROP_1, "str").build()).type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()).edge(TestGroups.ENTITY, new SchemaEdgeDefinition()).build();
    // When
    final boolean result = schema.hasValidation();
    // Then
    assertTrue(result);
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Test(org.junit.jupiter.api.Test)

Example 7 with Exists

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

the class SchemaTest method shouldReturnTrueWhenSchemaHasValidatorEdgeIdentifierFilters.

@Test
public void shouldReturnTrueWhenSchemaHasValidatorEdgeIdentifierFilters() {
    // Given
    final Schema schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("str").destination("dest").build()).type("str", new TypeDefinition.Builder().validateFunctions(new Exists()).build()).edge(TestGroups.EDGE_2, new SchemaEdgeDefinition.Builder().source("src").destination("dest").build()).build();
    // When
    final boolean result = schema.hasValidation();
    // Then
    assertTrue(result);
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Test(org.junit.jupiter.api.Test)

Example 8 with Exists

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

the class SchemaTest method shouldReturnTrueWhenSchemaHasValidatorEdgeFilters.

@Test
public void shouldReturnTrueWhenSchemaHasValidatorEdgeFilters() {
    // Given
    final Schema schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().validator(new ElementFilter.Builder().select(TestPropertyNames.PROP_1).execute(new Exists()).build()).build()).edge(TestGroups.ENTITY, new SchemaEdgeDefinition()).build();
    // When
    final boolean result = schema.hasValidation();
    // Then
    assertTrue(result);
}
Also used : Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Test(org.junit.jupiter.api.Test)

Example 9 with Exists

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

the class TableUtilsTest method shouldFailTableValidationWhenMissingAggregatorIterator.

@Test
public void shouldFailTableValidationWhenMissingAggregatorIterator() throws Exception {
    final AccumuloStore store = new SingleUseMiniAccumuloStore();
    final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, new TypeDefinition.Builder().aggregateFunction(new StringConcat()).validateFunctions(new Exists()).clazz(String.class).build()).type(TestTypes.DIRECTED_TRUE, Boolean.class).edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source(TestTypes.ID_STRING).destination(TestTypes.ID_STRING).directed(TestTypes.DIRECTED_TRUE).build()).build();
    store.initialise(GRAPH_ID, schema, PROPERTIES);
    final Runnable invalidateTable = () -> {
        try {
            AddUpdateTableIterator.removeIterator(store, AccumuloStoreConstants.AGGREGATOR_ITERATOR_NAME);
        } catch (final StoreException e) {
            throw new RuntimeException(e);
        }
    };
    shouldFailTableValidationWhenTableInvalid(store, invalidateTable);
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) AccumuloRuntimeException(uk.gov.gchq.gaffer.accumulostore.key.AccumuloRuntimeException) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MiniAccumuloStore(uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore) SingleUseMiniAccumuloStore(uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore) AccumuloStore(uk.gov.gchq.gaffer.accumulostore.AccumuloStore) SingleUseMiniAccumuloStore(uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore) StoreException(uk.gov.gchq.gaffer.store.StoreException) Test(org.junit.jupiter.api.Test)

Example 10 with Exists

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

the class AddOperationsToChainTest method shouldHandleNestedOperationChain.

@Test
public void shouldHandleNestedOperationChain() throws SerialisationException {
    // Given
    AddOperationsToChain hook = fromJson(ADD_OPERATIONS_TO_CHAIN_RESOURCE_PATH);
    Operation discardOutput = new DiscardOutput();
    Operation splitStore = new SplitStoreFromFile();
    Operation validate = new Validate();
    Operation getAdjacentIds = new GetAdjacentIds();
    Operation count = new Count<>();
    Operation countGroups = new CountGroups();
    Operation getElements = new GetElements();
    If ifOp = new If.Builder<>().conditional(new Conditional(new Exists(), new GetElements())).then(new GetElements()).otherwise(new GetAllElements()).build();
    Operation getAllElements = new GetAllElements();
    Operation limit = new Limit<>();
    final OperationChain opChain = new OperationChain.Builder().first(getAdjacentIds).then(new OperationChain.Builder().first(getElements).then(getAllElements).build()).then(ifOp).build();
    // When
    hook.preExecute(opChain, new Context(new User()));
    // Then
    final OperationChain expectedOpChain = new OperationChain.Builder().first(discardOutput).then(splitStore).then(validate).then(getAdjacentIds).then(count).then(discardOutput).then((Operation) new OperationChain.Builder().first(countGroups).then(getElements).then(getAllElements).then(limit).then(validate).build()).then(new If.Builder<>().conditional(new Conditional(new Exists(), new OperationChain<>(new CountGroups(), new GetElements()))).then(new OperationChain<>(new CountGroups(), new GetElements())).otherwise(new OperationChain<>(new GetAllElements(), new Limit<>(), new Validate())).build()).then(new Count()).build();
    JsonAssert.assertEquals(JSONSerialiser.serialise(expectedOpChain), JSONSerialiser.serialise(opChain));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) GetAdjacentIds(uk.gov.gchq.gaffer.operation.impl.get.GetAdjacentIds) User(uk.gov.gchq.gaffer.user.User) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) Conditional(uk.gov.gchq.gaffer.operation.util.Conditional) Operation(uk.gov.gchq.gaffer.operation.Operation) Count(uk.gov.gchq.gaffer.operation.impl.Count) SplitStoreFromFile(uk.gov.gchq.gaffer.operation.impl.SplitStoreFromFile) CountGroups(uk.gov.gchq.gaffer.operation.impl.CountGroups) Validate(uk.gov.gchq.gaffer.operation.impl.Validate) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) GetAllElements(uk.gov.gchq.gaffer.operation.impl.get.GetAllElements) DiscardOutput(uk.gov.gchq.gaffer.operation.impl.DiscardOutput) Limit(uk.gov.gchq.gaffer.operation.impl.Limit) If(uk.gov.gchq.gaffer.operation.impl.If) 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