use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithMergedParentSchemaIdAndProvidedSchema.
@Test
public void shouldCreateNewGraphWithMergedParentSchemaIdAndProvidedSchema() {
// Given
Schema schema1 = new Schema.Builder().entity("entity", new SchemaEntityDefinition.Builder().vertex("vertex").build()).type("vertex", String.class).build();
Schema schema2 = new Schema.Builder().edge("edge", new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed(DIRECTED_EITHER).build()).type("vertex", String.class).type(DIRECTED_EITHER, Boolean.class).build();
graphLibrary.addOrUpdate(GRAPH_ID + 1, schema, storeProperties);
graphLibrary.addSchema(SCHEMA_ID_1, schema1);
graphLibrary.addSchema(SCHEMA_ID_2, schema2);
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 2).parentSchemaIds(SCHEMA_ID_1, SCHEMA_ID_2).schema(schema).storeProperties(storeProperties).build();
// When
Graph graph = createGraph(export);
// Then
assertEquals(GRAPH_ID + 2, graph.getGraphId());
JsonAssert.assertEquals(new Schema.Builder().entity("entity", new SchemaEntityDefinition.Builder().vertex("vertex").build()).edge("edge", new SchemaEdgeDefinition.Builder().source("vertex").destination("vertex").directed(DIRECTED_EITHER).build()).type("vertex", String.class).type(DIRECTED_EITHER, Boolean.class).build().toJson(false), graph.getSchema().toJson(false));
assertEquals(storeProperties, graph.getStoreProperties());
}
use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldValidateParentSchemaIdCanBeUsedWhenGraphIdAlreadyExistsAndIsSame.
@Test
public void shouldValidateParentSchemaIdCanBeUsedWhenGraphIdAlreadyExistsAndIsSame() {
// Given
graphLibrary.add(GRAPH_ID + 1, SCHEMA_ID, new Schema.Builder().build(), STORE_PROPS_ID, new StoreProperties());
graphLibrary.addSchema(SCHEMA_ID, new Schema.Builder().build());
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).parentSchemaIds(SCHEMA_ID).build();
// When / Then`
validate(export);
}
use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithStoreGraphLibrary.
@Test
public void shouldCreateNewGraphWithStoreGraphLibrary() {
// Given
graphLibrary.add(GRAPH_ID + 1, schema, storeProperties);
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).build();
// When
Graph graph = createGraph(export);
// Then
assertEquals(GRAPH_ID + 1, graph.getGraphId());
assertEquals(schema, graph.getSchema());
assertEquals(storeProperties, graph.getStoreProperties());
}
use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldValidateSchemaCannotBeUsedWhenGraphIdAlreadyExists.
@Test
public void shouldValidateSchemaCannotBeUsedWhenGraphIdAlreadyExists() {
// Given
graphLibrary.add(GRAPH_ID + 1, SCHEMA_ID, new Schema.Builder().edge("testEdge", new SchemaEdgeDefinition()).build(), STORE_PROPS_ID, new StoreProperties());
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).schema(new Schema()).build();
// When / Then
final String expectedMessage = "Validation errors: \n" + String.format(GRAPH_S_ALREADY_EXISTS_SO_YOU_CANNOT_USE_A_DIFFERENT_S_DO_NOT_SET_THE_S_FIELD, "graphId1", SCHEMA_STRING, SCHEMA_STRING);
assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessage(expectedMessage);
}
use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldValidatePropsCanBeUsedWhenGraphIdAlreadyExistsAndIsSame.
@Test
public void shouldValidatePropsCanBeUsedWhenGraphIdAlreadyExistsAndIsSame() {
// Given
StoreProperties storeProperties1 = new StoreProperties();
storeProperties1.set("testKey", "testValue");
graphLibrary.add(GRAPH_ID + 1, SCHEMA_ID, new Schema.Builder().build(), STORE_PROPS_ID, storeProperties1);
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).storeProperties(storeProperties1).build();
// When / Then
validate(export);
}
Aggregations