Search in sources :

Example 1 with MapStore

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

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

Test (org.junit.jupiter.api.Test)2 MapStore (uk.gov.gchq.gaffer.mapstore.MapStore)2 MapStoreProperties (uk.gov.gchq.gaffer.mapstore.MapStoreProperties)2 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Pair (uk.gov.gchq.gaffer.commonutil.pair.Pair)1 Streams (uk.gov.gchq.gaffer.commonutil.stream.Streams)1 Edge (uk.gov.gchq.gaffer.data.element.Edge)1 SingleUseMapStore (uk.gov.gchq.gaffer.mapstore.SingleUseMapStore)1 GetAllElementsHandlerTest (uk.gov.gchq.gaffer.mapstore.impl.GetAllElementsHandlerTest)1 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)1 Context (uk.gov.gchq.gaffer.store.Context)1 StoreException (uk.gov.gchq.gaffer.store.StoreException)1 Schema (uk.gov.gchq.gaffer.store.schema.Schema)1