Search in sources :

Example 6 with StringConcat

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

the class ViewValidatorTest method shouldValidateAndReturnTrueWhenAggregatorSelectionUnknownProperty.

@Test
public void shouldValidateAndReturnTrueWhenAggregatorSelectionUnknownProperty() {
    // Given
    final ViewValidator validator = new ViewValidator();
    final View view = new View.Builder().entity(TestGroups.ENTITY, new ViewElementDefinition.Builder().aggregator(new ElementAggregator.Builder().select(TestPropertyNames.PROP_1).execute(new StringConcat()).build()).build()).build();
    final Schema schema = new Schema.Builder().entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().build()).build();
    // When
    final ValidationResult result = validator.validate(view, schema, ALL_STORE_TRAITS);
    // Then
    assertTrue(result.isValid());
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) ElementAggregator(uk.gov.gchq.gaffer.data.element.function.ElementAggregator) Test(org.junit.jupiter.api.Test)

Example 7 with StringConcat

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

the class OperationControllerIT method shouldCorrectlyStreamExecuteChunked.

@Test
public void shouldCorrectlyStreamExecuteChunked() throws Exception {
    // Given
    final Schema schema = new Schema.Builder().entity("g1", new SchemaEntityDefinition.Builder().vertex("string").build()).type("string", new TypeDefinition.Builder().clazz(String.class).aggregateFunction(new StringConcat()).build()).build();
    Graph graph = new Graph.Builder().config(new GraphConfig("id")).storeProperties(new MapStoreProperties()).addSchema(schema).build();
    when(getGraphFactory().getGraph()).thenReturn(graph);
    Entity ent1 = new Entity.Builder().group("g1").vertex("v1").build();
    Entity ent2 = new Entity.Builder().group("g1").vertex("v2").build();
    final ObjectMapper mapper = createDefaultMapper();
    graph.execute(new AddElements.Builder().input(ent1).build(), new Context());
    graph.execute(new AddElements.Builder().input(ent2).build(), new Context());
    // When
    final ResponseEntity<String> response = post("/graph/operations/execute/chunked", new GetAllElements.Builder().build(), String.class);
    // Then
    String expected = mapper.writeValueAsString(ent1) + "\r\n" + mapper.writeValueAsString(ent2) + "\r\n";
    assertEquals(expected, response.getBody());
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Context(uk.gov.gchq.gaffer.store.Context) Entity(uk.gov.gchq.gaffer.data.element.Entity) HttpEntity(org.springframework.http.HttpEntity) ResponseEntity(org.springframework.http.ResponseEntity) StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) Schema(uk.gov.gchq.gaffer.store.schema.Schema) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 8 with StringConcat

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

the class AccumuloStoreTest method shouldFindInconsistentVertexSerialiser.

@Test
public void shouldFindInconsistentVertexSerialiser() throws StoreException {
    final Schema inconsistentSchema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("false").property(TestPropertyNames.INT, "int").groupBy(TestPropertyNames.INT).build()).type("string", new TypeDefinition.Builder().clazz(String.class).serialiser(new JavaSerialiser()).aggregateFunction(new StringConcat()).build()).type("int", new TypeDefinition.Builder().clazz(Integer.class).serialiser(new JavaSerialiser()).aggregateFunction(new Sum()).build()).type("false", Boolean.class).vertexSerialiser(new JavaSerialiser()).build();
    final AccumuloStore store = new AccumuloStore();
    // When & Then
    assertThatExceptionOfType(SchemaException.class).isThrownBy(() -> store.preInitialise("graphId", inconsistentSchema, PROPERTIES)).withMessage("Vertex serialiser is inconsistent. This store requires vertices to be serialised in a consistent way.");
    // When & Then
    assertThatExceptionOfType(SchemaException.class).isThrownBy(() -> store.validateSchemas()).withMessage("Vertex serialiser is inconsistent. This store requires vertices to be serialised in a consistent way.");
}
Also used : StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) JavaSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.JavaSerialiser) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Sum(uk.gov.gchq.koryphe.impl.binaryoperator.Sum) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) Test(org.junit.jupiter.api.Test)

Example 9 with StringConcat

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

the class StoreTest method setup.

@BeforeEach
public void setup() {
    System.clearProperty(JSONSerialiser.JSON_SERIALISER_CLASS_KEY);
    System.clearProperty(JSONSerialiser.JSON_SERIALISER_MODULES);
    JSONSerialiser.update();
    schemaOptimiser = mock(SchemaOptimiser.class);
    operationChainValidator = mock(OperationChainValidator.class);
    store = new StoreImpl();
    given(operationChainValidator.validate(any(OperationChain.class), any(User.class), any(Store.class))).willReturn(new ValidationResult());
    addElementsHandler = mock(OperationHandler.class);
    getElementsHandler = mock(OutputOperationHandler.class);
    getAllElementsHandler = mock(OutputOperationHandler.class);
    getAdjacentIdsHandler = mock(OutputOperationHandler.class);
    validateHandler = mock(OperationHandler.class);
    exportToGafferResultCacheHandler = mock(OperationHandler.class);
    getGafferResultCacheExportHandler = mock(OperationHandler.class);
    jobTracker = mock(JobTracker.class);
    schema = new Schema.Builder().edge(TestGroups.EDGE, new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("true").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).edge(TestGroups.EDGE_2, new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("true").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).entity(TestGroups.ENTITY, new SchemaEntityDefinition.Builder().vertex("string").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).entity(TestGroups.ENTITY_2, new SchemaEntityDefinition.Builder().vertex("string").property(TestPropertyNames.PROP_1, "string").property(TestPropertyNames.PROP_2, "string").build()).type("string", new TypeDefinition.Builder().clazz(String.class).serialiser(new StringSerialiser()).aggregateFunction(new StringConcat()).build()).type("true", Boolean.class).build();
}
Also used : StringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.StringSerialiser) StringToStringSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.tostring.StringToStringSerialiser) StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) User(uk.gov.gchq.gaffer.user.User) JobTracker(uk.gov.gchq.gaffer.jobtracker.JobTracker) OutputOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler) SchemaEntityDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition) OperationChainValidator(uk.gov.gchq.gaffer.store.operation.OperationChainValidator) ValidationResult(uk.gov.gchq.koryphe.ValidationResult) SchemaOptimiser(uk.gov.gchq.gaffer.store.schema.SchemaOptimiser) ValidateOperationChain(uk.gov.gchq.gaffer.operation.impl.ValidateOperationChain) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) SchemaEdgeDefinition(uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition) OutputOperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OutputOperationHandler) OperationHandler(uk.gov.gchq.gaffer.store.operation.handler.OperationHandler) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 10 with StringConcat

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

the class GraphTest method shouldThrowExceptionIfSchemaIsInvalid.

@Test
public void shouldThrowExceptionIfSchemaIsInvalid() throws OperationException {
    final StoreProperties storeProperties = new StoreProperties();
    storeProperties.setStoreClass(TestStoreImpl.class.getName());
    try {
        new Graph.Builder().config(new GraphConfig.Builder().graphId(GRAPH_ID).build()).addSchema(new Schema.Builder().type("int", new TypeDefinition.Builder().clazz(Integer.class).aggregateFunction(new Sum()).serialiser(new RawDoubleSerialiser()).build()).type("string", new TypeDefinition.Builder().clazz(String.class).aggregateFunction(new StringConcat()).build()).type("boolean", Boolean.class).edge("EDGE", new SchemaEdgeDefinition.Builder().source("string").destination("string").directed("boolean").build()).entity("ENTITY", new SchemaEntityDefinition.Builder().vertex("string").property("p2", "int").build()).build()).storeProperties(storeProperties).build();
        fail("exception expected");
    } catch (final SchemaException e) {
        assertNotNull(e.getMessage());
    }
}
Also used : SchemaException(uk.gov.gchq.gaffer.data.elementdefinition.exception.SchemaException) StringConcat(uk.gov.gchq.koryphe.impl.binaryoperator.StringConcat) RawDoubleSerialiser(uk.gov.gchq.gaffer.serialisation.implementation.raw.RawDoubleSerialiser) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Sum(uk.gov.gchq.koryphe.impl.binaryoperator.Sum) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) TypeDefinition(uk.gov.gchq.gaffer.store.schema.TypeDefinition) Test(org.junit.jupiter.api.Test)

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