use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldValidateGraphIdMustBeDifferent.
@Test
public void shouldValidateGraphIdMustBeDifferent() {
// Given
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID).schema(schema).storeProperties(storeProperties).build();
// When / Then
assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessage(getErrorMessage(CANNOT_EXPORT_TO_THE_SAME_GRAPH_S, "graphId"));
}
use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldValidateSchemaUsedWhenGraphIdAlreadyExistsAndIsSame.
@Test
public void shouldValidateSchemaUsedWhenGraphIdAlreadyExistsAndIsSame() {
// Given
Schema schema1 = new Schema.Builder().edge("testEdge", new SchemaEdgeDefinition()).build();
graphLibrary.add(GRAPH_ID + 1, SCHEMA_ID + 1, schema1, STORE_PROPS_ID, new StoreProperties());
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).schema(schema1).build();
// When / Then
validate(export);
}
use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithParentSchemaId.
@Test
public void shouldCreateNewGraphWithParentSchemaId() {
// Given
Schema schema1 = new Schema.Builder().build();
graphLibrary.addOrUpdate(GRAPH_ID + 1, SCHEMA_ID, schema, STORE_PROPS_ID, storeProperties);
graphLibrary.addSchema(SCHEMA_ID_1, schema1);
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 2).parentSchemaIds(SCHEMA_ID_1).storeProperties(storeProperties).build();
// When
Graph graph = createGraph(export);
// Then
assertEquals(GRAPH_ID + 2, graph.getGraphId());
assertEquals(schema1, 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 shouldValidateParentPropsIdCanBeUsedWhenGraphIdAlreadyExistsAndIsSame.
@Test
public void shouldValidateParentPropsIdCanBeUsedWhenGraphIdAlreadyExistsAndIsSame() {
// Given
graphLibrary.add(GRAPH_ID + 1, SCHEMA_ID, new Schema(), STORE_PROPS_ID_1, new StoreProperties());
final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).parentStorePropertiesId(STORE_PROPS_ID_1).build();
// When / Then
validate(export);
}
use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.
the class ExportToOtherGraphHandlerTest method shouldValidateParentSchemaIdCannotBeUsedWhenGraphIdAlreadyExists.
@Test
public void shouldValidateParentSchemaIdCannotBeUsedWhenGraphIdAlreadyExists() {
// Given
graphLibrary.add(GRAPH_ID + 1, SCHEMA_ID_1, new Schema.Builder().edge("edge", new SchemaEdgeDefinition()).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
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, "parentSchemaIds");
assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessage(expectedMessage);
}
Aggregations