Search in sources :

Example 11 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.

the class GraphConfigurationControllerTest method shouldReturnGraphId.

@Test
public void shouldReturnGraphId() {
    // 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 graphId = controller.getGraphId();
    // Then
    assertEquals("id", graphId);
}
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 12 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties 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 13 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties 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 14 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.

the class AddElementsHandlerTest method shouldAddWithNoGroupByProperties.

@Test
public void shouldAddWithNoGroupByProperties() throws OperationException, StoreException {
    // Given
    final AddElements addElements = mock(AddElements.class);
    given(addElements.getInput()).willReturn((Iterable) Arrays.asList(new Edge("group1")));
    final Context context = mock(Context.class);
    final MapStore store = new SingleUseMapStore();
    store.initialise("graphId1", new Schema(), new MapStoreProperties());
    final AddElementsHandler handler = new AddElementsHandler();
    // When / Then - should not throw NPE
    handler.doOperation(addElements, context, store);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Context(uk.gov.gchq.gaffer.store.Context) SingleUseMapStore(uk.gov.gchq.gaffer.mapstore.SingleUseMapStore) Schema(uk.gov.gchq.gaffer.store.schema.Schema) MapStore(uk.gov.gchq.gaffer.mapstore.MapStore) SingleUseMapStore(uk.gov.gchq.gaffer.mapstore.SingleUseMapStore) Edge(uk.gov.gchq.gaffer.data.element.Edge) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Test(org.junit.jupiter.api.Test)

Example 15 with MapStoreProperties

use of uk.gov.gchq.gaffer.mapstore.MapStoreProperties in project Gaffer by gchq.

the class ElementClonerTest method testElementCloner.

@Test
public void testElementCloner() throws StoreException {
    // Given
    final ElementCloner cloner = new ElementCloner();
    final MapStore mapStore = new MapStore();
    mapStore.initialise("graphId", GetAllElementsHandlerTest.getSchema(), new MapStoreProperties());
    // Then
    Streams.toStream(GetAllElementsHandlerTest.getElements()).map(element -> new Pair<>(element, cloner.cloneElement(element, mapStore.getSchema()))).forEach(pair -> assertEquals(pair.getFirst(), pair.getSecond()));
}
Also used : Test(org.junit.jupiter.api.Test) StoreException(uk.gov.gchq.gaffer.store.StoreException) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) MapStore(uk.gov.gchq.gaffer.mapstore.MapStore) GetAllElementsHandlerTest(uk.gov.gchq.gaffer.mapstore.impl.GetAllElementsHandlerTest) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Streams(uk.gov.gchq.gaffer.commonutil.stream.Streams) MapStore(uk.gov.gchq.gaffer.mapstore.MapStore) MapStoreProperties(uk.gov.gchq.gaffer.mapstore.MapStoreProperties) Pair(uk.gov.gchq.gaffer.commonutil.pair.Pair) Test(org.junit.jupiter.api.Test) GetAllElementsHandlerTest(uk.gov.gchq.gaffer.mapstore.impl.GetAllElementsHandlerTest)

Aggregations

MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)42 Schema (uk.gov.gchq.gaffer.store.schema.Schema)34 Graph (uk.gov.gchq.gaffer.graph.Graph)28 Test (org.junit.Test)19 Test (org.junit.jupiter.api.Test)15 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)10 Set (java.util.Set)7 Error (uk.gov.gchq.gaffer.core.exception.Error)7 HashSet (java.util.HashSet)6 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)5 LinkedHashMap (java.util.LinkedHashMap)4 Element (uk.gov.gchq.gaffer.data.element.Element)4 TypeDefinition (uk.gov.gchq.gaffer.store.schema.TypeDefinition)4 Map (java.util.Map)3 HashMapCacheService (uk.gov.gchq.gaffer.cache.impl.HashMapCacheService)3 Edge (uk.gov.gchq.gaffer.data.element.Edge)3 Entity (uk.gov.gchq.gaffer.data.element.Entity)3 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)3 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)3 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)3