Search in sources :

Example 31 with GraphConfig

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

the class ProxyStoreIT method setUpGraph.

@Before
public void setUpGraph() {
    delegateRestApiGraph = new Graph.Builder().storeProperties(new MapStoreProperties()).config(new GraphConfig("myGraph")).addSchema(Schema.fromJson(StreamUtil.openStream(getClass(), "/schema/schema.json"))).build();
    when(graphFactory.getGraph()).thenReturn(delegateRestApiGraph);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Graph(uk.gov.gchq.gaffer.graph.Graph) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Before(org.junit.Before)

Example 32 with GraphConfig

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

the class OperationControllerTest method setUpController.

@BeforeEach
public void setUpController() {
    store = mock(Store.class);
    graphFactory = mock(GraphFactory.class);
    userFactory = mock(UserFactory.class);
    examplesFactory = mock(ExamplesFactory.class);
    operationController = new OperationController(graphFactory, userFactory, examplesFactory);
    when(store.getSchema()).thenReturn(new Schema());
    when(store.getProperties()).thenReturn(new StoreProperties());
    Graph graph = new Graph.Builder().config(new GraphConfig("id")).store(store).addSchema(new Schema()).build();
    when(graphFactory.getGraph()).thenReturn(graph);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) GraphFactory(uk.gov.gchq.gaffer.rest.factory.GraphFactory) Graph(uk.gov.gchq.gaffer.graph.Graph) ExamplesFactory(uk.gov.gchq.gaffer.rest.factory.ExamplesFactory) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Store(uk.gov.gchq.gaffer.store.Store) UserFactory(uk.gov.gchq.gaffer.rest.factory.UserFactory) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 33 with GraphConfig

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

the class GraphConfigurationControllerTest method shouldGetStoreTraits.

@Test
public void shouldGetStoreTraits() {
    // Given
    when(graphFactory.getGraph()).thenReturn(new Graph.Builder().config(new GraphConfig("id")).addSchema(new Schema()).storeProperties(// Will be a map store
    new MapStoreProperties()).build());
    GraphConfigurationController controller = new GraphConfigurationController(graphFactory);
    // When
    final Set<StoreTrait> traits = controller.getStoreTraits();
    // Then
    assertEquals(MapStore.TRAITS, 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) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 34 with GraphConfig

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

the class GraphConfigurationControllerTest method shouldReturnDescription.

@Test
public void shouldReturnDescription() {
    // Given
    when(graphFactory.getGraph()).thenReturn(new Graph.Builder().config(new GraphConfig("id")).addSchema(new Schema()).storeProperties(new MapStoreProperties()).description("test graph").build());
    // When
    GraphConfigurationController controller = new GraphConfigurationController(graphFactory);
    final String description = controller.getDescription();
    // Then
    assertEquals("test graph", description);
}
Also used : GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 35 with GraphConfig

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

the class GetWalksIT method shouldGetPathsWithSimpleGraphHook_2.

@Test
public void shouldGetPathsWithSimpleGraphHook_2() throws Exception {
    // Given
    final AddOperationsToChain graphHook = new AddOperationsToChain();
    final java.util.Map<String, List<Operation>> graphHookConfig = new HashMap<>();
    graphHookConfig.put(GetElements.class.getName(), Lists.newArrayList(new Limit.Builder<>().resultLimit(1).build()));
    graphHook.setAfter(graphHookConfig);
    final GraphConfig config = new GraphConfig.Builder().addHook(graphHook).graphId("integrationTest").build();
    createGraph(config);
    addDefaultElements();
    final GetElements operation = new GetElements.Builder().directedType(DirectedType.DIRECTED).view(new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().properties(TestPropertyNames.COUNT).build()).build()).inOutType(SeededGraphFilters.IncludeIncomingOutgoingType.OUTGOING).build();
    final GetWalks op = new GetWalks.Builder().input(seedA).operations(operation, operation).build();
    // When
    final Iterable<Walk> results = graph.execute(op, getUser());
    // Then
    assertThat(getPaths(results)).isEqualTo("ABC");
}
Also used : Walk(uk.gov.gchq.gaffer.data.graph.Walk) HashMap(java.util.HashMap) GetWalks(uk.gov.gchq.gaffer.operation.impl.GetWalks) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) ViewElementDefinition(uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) GraphConfig(uk.gov.gchq.gaffer.graph.GraphConfig) Builder(uk.gov.gchq.gaffer.operation.impl.GetWalks.Builder) List(java.util.List) AddOperationsToChain(uk.gov.gchq.gaffer.graph.hook.AddOperationsToChain) Test(org.junit.Test)

Aggregations

GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)37 Graph (uk.gov.gchq.gaffer.graph.Graph)19 Schema (uk.gov.gchq.gaffer.store.schema.Schema)19 GraphSerialisable (uk.gov.gchq.gaffer.graph.GraphSerialisable)18 Test (org.junit.jupiter.api.Test)15 Context (uk.gov.gchq.gaffer.store.Context)8 MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)7 BeforeEach (org.junit.jupiter.api.BeforeEach)6 StoreTrait (uk.gov.gchq.gaffer.store.StoreTrait)6 Test (org.junit.Test)5 AddGraph (uk.gov.gchq.gaffer.federatedstore.operation.AddGraph)5 FederatedGetTraitsHandlerTest (uk.gov.gchq.gaffer.federatedstore.operation.handler.impl.FederatedGetTraitsHandlerTest)5 NoAccessPredicate (uk.gov.gchq.gaffer.access.predicate.NoAccessPredicate)4 FederatedStore (uk.gov.gchq.gaffer.federatedstore.FederatedStore)4 FederatedStoreProperties (uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties)4 RemoveGraph (uk.gov.gchq.gaffer.federatedstore.operation.RemoveGraph)4 ProxyProperties (uk.gov.gchq.gaffer.proxystore.ProxyProperties)4 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)4 SchemaEdgeDefinition (uk.gov.gchq.gaffer.store.schema.SchemaEdgeDefinition)4 ArrayList (java.util.ArrayList)3