Search in sources :

Example 1 with ExportToOtherAuthorisedGraph

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

the class ExportToOtherAuthorisedGraphHandlerTest method shouldThrowExceptionWithParentSchemaIdWithNoParentStorePropertiesIdAndAuths.

@Test
public void shouldThrowExceptionWithParentSchemaIdWithNoParentStorePropertiesIdAndAuths(@TempDir Path tmpPath) {
    GraphLibrary graphLibrary = new FileGraphLibrary(tmpPath.toString());
    // 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);
    given(store.getGraphLibrary()).willReturn(graphLibrary);
    List<String> opAuths = Lists.newArrayList("auth1");
    idAuths.put(GRAPH_ID + 2, opAuths);
    idAuths.put(SCHEMA_ID_1, opAuths);
    final ExportToOtherAuthorisedGraph export = new ExportToOtherAuthorisedGraph.Builder().graphId(GRAPH_ID + 2).parentSchemaIds(SCHEMA_ID_1).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining("parentStorePropertiesId must be specified with parentSchemaId");
}
Also used : ExportToOtherAuthorisedGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 2 with ExportToOtherAuthorisedGraph

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

the class ExportToOtherAuthorisedGraphHandlerTest method shouldCreateGraphWithGraphIdInLibraryAndAuths.

@Test
public void shouldCreateGraphWithGraphIdInLibraryAndAuths(@TempDir Path tmpPath) {
    // Given
    GraphLibrary graphLibrary = new FileGraphLibrary(tmpPath.toString());
    graphLibrary.addOrUpdate(GRAPH_ID + 1, schema, storeProperties);
    given(store.getGraphLibrary()).willReturn(graphLibrary);
    List<String> graphIdAuths = new ArrayList<>();
    graphIdAuths.add("auth1");
    idAuths.put(GRAPH_ID + 1, graphIdAuths);
    final ExportToOtherAuthorisedGraph export = new ExportToOtherAuthorisedGraph.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());
}
Also used : ExportToOtherAuthorisedGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph) Graph(uk.gov.gchq.gaffer.graph.Graph) ExportToOtherAuthorisedGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 3 with ExportToOtherAuthorisedGraph

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

the class ExportToOtherAuthorisedGraphHandlerTest method shouldThrowExceptionWithParentSchemaIdAndStorePropertiesIdAndNoSchemaAuths.

@Test
public void shouldThrowExceptionWithParentSchemaIdAndStorePropertiesIdAndNoSchemaAuths(@TempDir Path tmpPath) {
    GraphLibrary graphLibrary = new FileGraphLibrary(tmpPath.toString());
    // 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);
    given(store.getGraphLibrary()).willReturn(graphLibrary);
    List<String> opAuths = Lists.newArrayList("auth1");
    idAuths.put(GRAPH_ID + 2, opAuths);
    idAuths.put(STORE_PROPS_ID, opAuths);
    final ExportToOtherAuthorisedGraph export = new ExportToOtherAuthorisedGraph.Builder().graphId(GRAPH_ID + 2).parentSchemaIds(SCHEMA_ID_1).parentStorePropertiesId(STORE_PROPS_ID).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining("User is not authorised to export using schemaId");
}
Also used : ExportToOtherAuthorisedGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 4 with ExportToOtherAuthorisedGraph

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

the class ExportToOtherAuthorisedGraphHandlerTest method shouldThrowExceptionWithParentStorePropertiesIdWithNoParentSchemaIdAndAuths.

@Test
public void shouldThrowExceptionWithParentStorePropertiesIdWithNoParentSchemaIdAndAuths(@TempDir Path tmpPath) {
    GraphLibrary graphLibrary = new FileGraphLibrary(tmpPath.toString());
    // Given
    Schema schema1 = new Schema.Builder().build();
    graphLibrary.addOrUpdate(GRAPH_ID + 1, schema, storeProperties);
    graphLibrary.addSchema(SCHEMA_ID_1, schema1);
    given(store.getGraphLibrary()).willReturn(graphLibrary);
    List<String> opAuths = Lists.newArrayList("auth1");
    idAuths.put(GRAPH_ID + 2, opAuths);
    idAuths.put(SCHEMA_ID_1, opAuths);
    idAuths.put(STORE_PROPS_ID, opAuths);
    final ExportToOtherAuthorisedGraph export = new ExportToOtherAuthorisedGraph.Builder().graphId(GRAPH_ID + 2).parentStorePropertiesId(STORE_PROPS_ID).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining("parentSchemaIds must be specified with parentStorePropertiesId");
}
Also used : ExportToOtherAuthorisedGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph) GraphLibrary(uk.gov.gchq.gaffer.store.library.GraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) FileGraphLibrary(uk.gov.gchq.gaffer.store.library.FileGraphLibrary) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 5 with ExportToOtherAuthorisedGraph

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

the class ExportToOtherAuthorisedGraphHandlerTest method shouldThrowExceptionWithNullGraphLibrary.

@Test
public void shouldThrowExceptionWithNullGraphLibrary() {
    // Given
    final ExportToOtherAuthorisedGraph export = new ExportToOtherAuthorisedGraph.Builder().graphId(GRAPH_ID).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining("Store GraphLibrary is null");
}
Also used : ExportToOtherAuthorisedGraph(uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)10 ExportToOtherAuthorisedGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph)10 FileGraphLibrary (uk.gov.gchq.gaffer.store.library.FileGraphLibrary)9 GraphLibrary (uk.gov.gchq.gaffer.store.library.GraphLibrary)9 Schema (uk.gov.gchq.gaffer.store.schema.Schema)6 ArrayList (java.util.ArrayList)2 Graph (uk.gov.gchq.gaffer.graph.Graph)2