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