Search in sources :

Example 11 with StringConcat

use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat 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());
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) ElementTransformer(uk.gov.gchq.gaffer.data.element.function.ElementTransformer) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ExampleTransformFunction(uk.gov.gchq.gaffer.function.ExampleTransformFunction) Test(org.junit.jupiter.api.Test)

Example 12 with StringConcat

use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.

the class GetSchemaHandlerTest method setup.

@BeforeEach
public void setup() {
    handler = new GetSchemaHandler();
    store = mock(Store.class);
    context = mock(Context.class);
    user = mock(User.class);
    properties = new StoreProperties();
    schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("string").destination("string").description("anEdge").directed("true").property(TestPropertyNames.PROP_1, "string").build()).edge(TestGroups.EDGE_2, new SchemaEdgeDefinition.Builder().source("string").destination("string").description("anotherEdge").directed("true").property(TestPropertyNames.PROP_1, "string").build()).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("string").property(TestPropertyNames.PROP_1, "string").description("anEntity").build()).type("string", new TypeDefinition.Builder().clazz(String.class).serialiser(new StringSerialiser()).aggregateFunction(new StringConcat()).build()).type("true", Boolean.class).build();
    compactSchemaBytes = schema.toCompactJson();
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) User(uk.gov.gchq.gaffer.user.User) Schema(uk.gov.gchq.gaffer.store.schema.Schema) GetSchema(uk.gov.gchq.gaffer.store.operation.GetSchema) Store(uk.gov.gchq.gaffer.store.Store) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with StringConcat

use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.

the class TableUtilsTest method shouldCreateTableWithAllRequiredIterators.

@Test
public void shouldCreateTableWithAllRequiredIterators() throws Exception {
    // Given
    final AccumuloStore store = new SingleUseMiniAccumuloStore();
    final Schema schema = new Schema.Builder().type(TestTypes.ID_STRING, new TypeDefinition.Builder().aggregateFunction(new StringConcat()).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);
    // When
    TableUtils.createTable(store);
    // Then - this call will check the table is configured properly
    TableUtils.ensureTableExists(store);
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) 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) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) Test(org.junit.jupiter.api.Test)

Example 14 with StringConcat

use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.

the class TableUtilsTest method shouldFailTableValidationWhenMissingValidatorIterator.

@Test
public void shouldFailTableValidationWhenMissingValidatorIterator() 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.VALIDATOR_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 15 with StringConcat

use of uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat in project Gaffer by gchq.

the class TableUtilsTest method shouldFailTableValidationWhenTableInvalid.

public void shouldFailTableValidationWhenTableInvalid(final AccumuloStore store, final Runnable invalidateTable) throws Exception {
    // Given
    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();
    final AccumuloProperties props = AccumuloProperties.loadStoreProperties(StreamUtil.storeProps(TableUtilsTest.class));
    store.initialise(GRAPH_ID, schema, props);
    invalidateTable.run();
    // When / Then
    assertThatExceptionOfType(StoreException.class).isThrownBy(() -> TableUtils.ensureTableExists(store)).extracting("message").isNotNull();
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) AccumuloProperties(uk.gov.gchq.gaffer.accumulostore.AccumuloProperties) Exists(uk.gov.gchq.koryphe.impl.predicate.Exists) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreException(uk.gov.gchq.gaffer.store.StoreException)

Aggregations

StringConcat (uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat)16 Test (org.junit.jupiter.api.Test)11 Schema (uk.gov.gchq.gaffer.store.schema.Schema)10 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)6 StoreException (uk.gov.gchq.gaffer.store.StoreException)4 AccumuloStore (uk.gov.gchq.gaffer.accumulostore.AccumuloStore)3 MiniAccumuloStore (uk.gov.gchq.gaffer.accumulostore.MiniAccumuloStore)3 SingleUseMiniAccumuloStore (uk.gov.gchq.gaffer.accumulostore.SingleUseMiniAccumuloStore)3 ElementAggregator (uk.gov.gchq.gaffer.data.element.function.ElementAggregator)3 SchemaEntityDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition)3 ValidationResult (uk.gov.gchq.koryphe.ValidationResult)3 Exists (uk.gov.gchq.koryphe.impl.predicate.Exists)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 AccumuloRuntimeException (uk.gov.gchq.gaffer.accumulostore.key.AccumuloRuntimeException)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 ExampleAggregateFunction (uk.gov.gchq.gaffer.function.ExampleAggregateFunction)2 ExampleTuple2BinaryOperator (uk.gov.gchq.gaffer.function.ExampleTuple2BinaryOperator)2 HBaseProperties (uk.gov.gchq.gaffer.hbasestore.HBaseProperties)2 SingleUseMiniHBaseStore (uk.gov.gchq.gaffer.hbasestore.SingleUseMiniHBaseStore)2 StringSerialiser (uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser)2