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