Search in sources :

Example 16 with ExportToOtherGraph

use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.

the class ExportToOtherGraphHandlerTest method shouldThrowExceptionPropsIdCannotBeFound.

@Test
public void shouldThrowExceptionPropsIdCannotBeFound() {
    // Given
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).schema(new Schema()).parentStorePropertiesId(STORE_PROPS_ID).build();
    // When / Then
    final String expectedMessage = getErrorMessage(STORE_PROPERTIES_COULD_NOT_BE_FOUND_IN_THE_GRAPH_LIBRARY_WITH_ID_S, STORE_PROPS_ID);
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessage(expectedMessage);
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 17 with ExportToOtherGraph

use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.

the class ExportToOtherGraphHandlerTest method shouldThrowExceptionWhenExportingToSameGraph.

@Test
public void shouldThrowExceptionWhenExportingToSameGraph() {
    // Given
    graphLibrary.add(GRAPH_ID, SCHEMA_ID, schema, STORE_PROPS_ID, storeProperties);
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessage(getErrorMessage(CANNOT_EXPORT_TO_THE_SAME_GRAPH_S, GRAPH_ID));
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Test(org.junit.jupiter.api.Test)

Example 18 with ExportToOtherGraph

use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.

the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithMergedParentStorePropertiesIdAndProvidedStoreProperties.

@Test
public void shouldCreateNewGraphWithMergedParentStorePropertiesIdAndProvidedStoreProperties() {
    // Given
    StoreProperties storeProperties1 = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
    graphLibrary.addOrUpdate(GRAPH_ID + 1, SCHEMA_ID, schema, STORE_PROPS_ID, storeProperties);
    graphLibrary.addProperties(STORE_PROPS_ID_1, storeProperties1);
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 2).schema(schema).parentStorePropertiesId(STORE_PROPS_ID_1).storeProperties(storeProperties).build();
    // When
    Graph graph = createGraph(export);
    // Then
    assertEquals(GRAPH_ID + 2, graph.getGraphId());
    assertEquals(schema, graph.getSchema());
    storeProperties1.merge(storeProperties);
    assertEquals(storeProperties1, graph.getStoreProperties());
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 19 with ExportToOtherGraph

use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.

the class ExportToOtherGraphHandlerTest method shouldValidateWithSchemaAndStorePropertiesSpecified.

@Test
public void shouldValidateWithSchemaAndStorePropertiesSpecified() {
    // Given
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).schema(new Schema()).storeProperties(new StoreProperties()).build();
    // When
    validate(export);
// Then - no exceptions
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 20 with ExportToOtherGraph

use of uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph in project Gaffer by gchq.

the class ExportToOtherGraphHandlerTest method shouldValidateParentPropsIdCannotBeUsedWhenGraphIdAlreadyExists.

@Test
public void shouldValidateParentPropsIdCannotBeUsedWhenGraphIdAlreadyExists() {
    // 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).parentStorePropertiesId(STORE_PROPS_ID + 1).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", "StoreProperties", "parentStorePropertiesId");
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessage(expectedMessage);
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)25 ExportToOtherGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph)25 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)14 Schema (uk.gov.gchq.gaffer.store.schema.Schema)10 Graph (uk.gov.gchq.gaffer.graph.Graph)7 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)3 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)1 Operation (uk.gov.gchq.gaffer.operation.Operation)1 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)1 OtherGraphExporter (uk.gov.gchq.gaffer.operation.export.graph.OtherGraphExporter)1 Context (uk.gov.gchq.gaffer.store.Context)1 Store (uk.gov.gchq.gaffer.store.Store)1 SchemaEntityDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEntityDefinition)1 User (uk.gov.gchq.gaffer.user.User)1