Search in sources :

Example 6 with ExportToOtherGraph

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

the class ExportToOtherGraphHandlerTest method shouldThrowExceptionPropertiesCannotBeUsedIfNotDefinedOrFound.

@Test
public void shouldThrowExceptionPropertiesCannotBeUsedIfNotDefinedOrFound() {
    // Given
    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_ID_S_CANNOT_BE_CREATED_WITHOUT_DEFINED_KNOWN_S, GRAPH_ID + 1, "StoreProperties");
    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 7 with ExportToOtherGraph

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

the class ExportToOtherGraphHandlerTest method shouldThrowExceptionSchemaIdCannotBeFound.

@Test
public void shouldThrowExceptionSchemaIdCannotBeFound() {
    // Given
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).parentSchemaIds(SCHEMA_ID).storeProperties(new StoreProperties()).build();
    // When / Then
    final String expectedMessage = getErrorMessage(SCHEMA_COULD_NOT_BE_FOUND_IN_THE_GRAPH_LIBRARY_WITH_ID_S, "[schemaId]");
    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)

Example 8 with ExportToOtherGraph

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

the class ExportToOtherGraphHandlerTest method shouldValidatePropsCannotBeUsedWhenGraphIdAlreadyExists.

@Test
public void shouldValidatePropsCannotBeUsedWhenGraphIdAlreadyExists() {
    // 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(new StoreProperties()).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", STORE_PROPERTIES_STRING, STORE_PROPERTIES_STRING);
    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)

Example 9 with ExportToOtherGraph

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

the class ExportToOtherGraphHandlerTest method shouldCreateNewGraphWithStoresSchema.

@Test
public void shouldCreateNewGraphWithStoresSchema() {
    // Given
    given(store.getSchema()).willReturn(schema);
    given(store.getGraphLibrary()).willReturn(null);
    final StoreProperties storeProperties1 = StoreProperties.loadStoreProperties(StreamUtil.storeProps(getClass()));
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).storeProperties(storeProperties1).build();
    // When
    Graph graph = createGraph(export);
    // Then
    assertEquals(GRAPH_ID + 1, graph.getGraphId());
    assertEquals(schema, graph.getSchema());
    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 10 with ExportToOtherGraph

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

the class ExportToOtherGraphHandlerTest method shouldValidateParentSchemaIdCannotBeUsedWithoutGraphLibrary.

@Test
public void shouldValidateParentSchemaIdCannotBeUsedWithoutGraphLibrary() {
    // Given
    given(store.getGraphLibrary()).willReturn(null);
    final ExportToOtherGraph export = new ExportToOtherGraph.Builder().graphId(GRAPH_ID + 1).parentSchemaIds(SCHEMA_ID).parentStorePropertiesId(SCHEMA_ID).build();
    // When / Then
    final String expectedMessage = "Validation errors: \n" + String.format(S_CANNOT_BE_USED_WITHOUT_A_GRAPH_LIBRARY, "parentSchemaIds") + '\n' + String.format(S_CANNOT_BE_USED_WITHOUT_A_GRAPH_LIBRARY, PARENT_STORE_PROPERTIES_ID);
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining(expectedMessage);
}
Also used : ExportToOtherGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph) 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