Search in sources :

Example 76 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class GraphConfigurationControllerTest method shouldSerialiseAndDeserialiseGetStoreTraits.

@Test
public void shouldSerialiseAndDeserialiseGetStoreTraits() throws SerialisationException {
    // Given
    Store store = mock(Store.class);
    Schema schema = new Schema();
    StoreProperties props = new StoreProperties();
    Set<StoreTrait> storeTraits = Sets.newHashSet(INGEST_AGGREGATION, PRE_AGGREGATION_FILTERING, POST_AGGREGATION_FILTERING);
    when(store.getSchema()).thenReturn(schema);
    when(store.getProperties()).thenReturn(props);
    when(store.getTraits()).thenReturn(storeTraits);
    Graph graph = new Graph.Builder().config(new GraphConfig("id")).addSchema(new Schema()).store(store).build();
    when(graphFactory.getGraph()).thenReturn(graph);
    GraphConfigurationController controller = new GraphConfigurationController(graphFactory);
    // When
    byte[] bytes = JSONSerialiser.serialise(controller.getStoreTraits());
    final Set<String> traits = JSONSerialiser.deserialise(bytes, Set.class);
    // Then
    assertEquals(Sets.newHashSet(INGEST_AGGREGATION.name(), PRE_AGGREGATION_FILTERING.name(), POST_AGGREGATION_FILTERING.name()), traits);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) StoreTrait(uk.gov.gchq.gaffer.store.StoreTrait) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStore(uk.gov.gchq.gaffer.mapstore.MapStore) Store(uk.gov.gchq.gaffer.store.Store) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) Test(org.junit.jupiter.api.Test)

Example 77 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class GraphConfigurationControllerIT method shouldReturn500WhenANonExistentClassIsProvidedForGetFilterFunctions.

@Test
public void shouldReturn500WhenANonExistentClassIsProvidedForGetFilterFunctions() {
    // Given
    Graph emptyGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
    when(graphFactory.getGraph()).thenReturn(emptyGraph);
    // When
    ResponseEntity<Error> response = get("/graph/config/filterFunctions/a.random.thing", Error.class);
    // Then
    checkResponse(response, 500);
    assertThat(response.getBody().getSimpleMessage()).isEqualTo("Could not find input class: a.random.thing");
}
Also used : Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Error(uk.gov.gchq.gaffer.core.exception.Error) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.Test)

Example 78 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class GraphConfigurationControllerIT method shouldReturn200WhenReturningGraphId.

@Test
public void shouldReturn200WhenReturningGraphId() {
    // Given
    Graph emptyGraph = new Graph.Builder().config(new GraphConfig.Builder().graphId("id").description("test description").build()).storeProperties(new MapStoreProperties()).addSchema(new Schema()).build();
    when(graphFactory.getGraph()).thenReturn(emptyGraph);
    // When
    ResponseEntity<String> response = get("/graph/config/graphId", String.class);
    // Then
    checkResponse(response, 200);
    assertThat(response.getBody()).isEqualTo("id");
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.Test)

Example 79 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class FederatedAddGraphHandlerTest method shouldAddGraphIDOnlyWithAuths.

@Test
public void shouldAddGraphIDOnlyWithAuths() throws Exception {
    federatedStoreProperties.setCustomPropertyAuths("auth1,auth2");
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    Schema expectedSchema = new Schema.Builder().build();
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    FederatedAddGraphHandler federatedAddGraphHandler = new FederatedAddGraphHandler();
    try {
        federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).build(), new Context(testUser), store);
        fail(EXCEPTION_EXPECTED);
    } catch (OperationException e) {
        assertTrue(e.getMessage().contains(String.format(FederatedAddGraphHandler.USER_IS_LIMITED_TO_ONLY_USING_PARENT_PROPERTIES_ID_FROM_GRAPHLIBRARY_BUT_FOUND_STORE_PROPERTIES_S, "")));
    }
    federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).build(), new Context(authUser), store);
    final Collection<Graph> graphs = store.getGraphs(authUser, null, ignore);
    assertThat(graphs).hasSize(1);
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    assertEquals(EXPECTED_GRAPH_ID, graphs.iterator().next().getGraphId());
}
Also used : AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Context(uk.gov.gchq.gaffer.store.Context) Graph(uk.gov.gchq.gaffer.graph.Graph) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) OperationException(uk.gov.gchq.gaffer.operation.OperationException) Test(org.junit.jupiter.api.Test)

Example 80 with Graph

use of uk.gov.gchq.gaffer.graph.Graph in project Gaffer by gchq.

the class FederatedAddGraphHandlerTest method shouldAddDisabledByDefaultGraph.

@Test
public void shouldAddDisabledByDefaultGraph() throws Exception {
    store.initialise(FEDERATEDSTORE_GRAPH_ID, null, federatedStoreProperties);
    Schema expectedSchema = new Schema.Builder().build();
    assertEquals(0, store.getGraphs(testUser, null, ignore).size());
    FederatedAddGraphHandler federatedAddGraphHandler = new FederatedAddGraphHandler();
    federatedAddGraphHandler.doOperation(new AddGraph.Builder().graphId(EXPECTED_GRAPH_ID).schema(expectedSchema).storeProperties(PROPERTIES).disabledByDefault(true).build(), new Context(testUser), store);
    Collection<Graph> enabledGraphs = store.getGraphs(testUser, null, ignore);
    assertThat(enabledGraphs).isEmpty();
    Collection<Graph> expectedGraphs = store.getGraphs(testUser, EXPECTED_GRAPH_ID, ignore);
    assertThat(expectedGraphs).hasSize(1);
    assertEquals(EXPECTED_GRAPH_ID, expectedGraphs.iterator().next().getGraphId());
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Graph(uk.gov.gchq.gaffer.graph.Graph) AddGraph(uk.gov.gchq.gaffer.federatedstore.operation.AddGraph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Test(org.junit.jupiter.api.Test)

Aggregations

Graph (uk.gov.gchq.gaffer.graph.Graph)311 Test (org.junit.jupiter.api.Test)172 User (uk.gov.gchq.gaffer.user.User)155 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)146 Element (uk.gov.gchq.gaffer.data.element.Element)116 Schema (uk.gov.gchq.gaffer.store.schema.Schema)84 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)83 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)76 Edge (uk.gov.gchq.gaffer.data.element.Edge)75 HashSet (java.util.HashSet)71 Entity (uk.gov.gchq.gaffer.data.element.Entity)68 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)60 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)58 ArrayList (java.util.ArrayList)56 OperationException (uk.gov.gchq.gaffer.operation.OperationException)55 Test (org.junit.Test)49 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)49 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)44 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)44 Set (java.util.Set)38