Search in sources :

Example 11 with FileGraphLibrary

use of uk.gov.gchq.gaffer.store.library.FileGraphLibrary in project Gaffer by gchq.

the class ExportToOtherAuthorisedGraphHandlerTest method shouldCreateGraphWithParentSchemaIdAndStorePropertiesIdAndAuths.

@Test
public void shouldCreateGraphWithParentSchemaIdAndStorePropertiesIdAndAuths(@TempDir Path tmpPath) {
    // Given
    GraphLibrary graphLibrary = new FileGraphLibrary(tmpPath.toString());
    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);
    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
    Graph graph = createGraph(export);
    // Then
    assertEquals(GRAPH_ID + 2, graph.getGraphId());
    assertEquals(schema1, 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) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Example 12 with FileGraphLibrary

use of uk.gov.gchq.gaffer.store.library.FileGraphLibrary in project Gaffer by gchq.

the class ExportToOtherAuthorisedGraphHandlerTest method shouldThrowExceptionWhenExportingToSameGraph.

@Test
public void shouldThrowExceptionWhenExportingToSameGraph(@TempDir Path tmpPath) {
    GraphLibrary graphLibrary = new FileGraphLibrary(tmpPath.toString());
    // Given
    given(store.getGraphLibrary()).willReturn(graphLibrary);
    final ExportToOtherAuthorisedGraph export = new ExportToOtherAuthorisedGraph.Builder().graphId(GRAPH_ID).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining("Cannot export to the same Graph");
}
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) Test(org.junit.jupiter.api.Test)

Example 13 with FileGraphLibrary

use of uk.gov.gchq.gaffer.store.library.FileGraphLibrary in project Gaffer by gchq.

the class ExportToOtherAuthorisedGraphHandlerTest method shouldCreateGraphWithParentSchemaIdAndStorePropertiesIdAndNoStorePropsAuths.

@Test
public void shouldCreateGraphWithParentSchemaIdAndStorePropertiesIdAndNoStorePropsAuths(@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).parentStorePropertiesId(STORE_PROPS_ID).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining("User is not authorised to export using storePropertiesId");
}
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 14 with FileGraphLibrary

use of uk.gov.gchq.gaffer.store.library.FileGraphLibrary in project Gaffer by gchq.

the class ExportToOtherAuthorisedGraphHandlerTest method shouldThrowExceptionWithParentSchemaIdAndStorePropertiesIdAndNoGraphAuths.

@Test
public void shouldThrowExceptionWithParentSchemaIdAndStorePropertiesIdAndNoGraphAuths(@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(SCHEMA_ID_1, 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 graphId");
}
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 15 with FileGraphLibrary

use of uk.gov.gchq.gaffer.store.library.FileGraphLibrary in project Gaffer by gchq.

the class ExportToOtherAuthorisedGraphHandlerTest method shouldThrowExceptionWhenGraphIdCannotBeFound.

@Test
public void shouldThrowExceptionWhenGraphIdCannotBeFound(@TempDir Path tmpPath) {
    GraphLibrary graphLibrary = new FileGraphLibrary(tmpPath.toString());
    // Given
    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 / Then
    assertThatIllegalArgumentException().isThrownBy(() -> createGraph(export)).withMessageContaining("GraphLibrary cannot be found with graphId");
}
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) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

FileGraphLibrary (uk.gov.gchq.gaffer.store.library.FileGraphLibrary)20 Schema (uk.gov.gchq.gaffer.store.schema.Schema)16 Test (org.junit.jupiter.api.Test)15 GraphLibrary (uk.gov.gchq.gaffer.store.library.GraphLibrary)13 ExportToOtherAuthorisedGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph)9 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)6 Graph (uk.gov.gchq.gaffer.graph.Graph)4 AccumuloProperties (uk.gov.gchq.gaffer.accumulostore.AccumuloProperties)3 ArrayList (java.util.ArrayList)2 Element (uk.gov.gchq.gaffer.data.element.Element)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)2 ExportToOtherGraph (uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherGraph)2 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)2 NoGraphLibrary (uk.gov.gchq.gaffer.store.library.NoGraphLibrary)2 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)2 IsTrue (uk.gov.gchq.koryphe.impl.predicate.IsTrue)2 File (java.io.File)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 TableName (org.apache.hadoop.hbase.TableName)1