Search in sources :

Example 31 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedTransformHandlerTest method shouldDelegateToHandler.

@Test
public void shouldDelegateToHandler() throws OperationException {
    // Given
    final FederatedStore store = mock(FederatedStore.class);
    final TransformHandler handler = mock(TransformHandler.class);
    final Transform op = mock(Transform.class);
    final Context context = mock(Context.class);
    final Iterable expectedResult = mock(Iterable.class);
    final Schema schema = mock(Schema.class);
    given(store.getSchema(op, context)).willReturn(schema);
    given(handler.doOperation(op, schema)).willReturn(expectedResult);
    final FederatedTransformHandler federatedHandler = new FederatedTransformHandler(handler);
    // When
    final Object result = federatedHandler.doOperation(op, context, store);
    // Then
    assertSame(expectedResult, result);
    verify(handler).doOperation(op, schema);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) TransformHandler(uk.gov.gchq.gaffer.store.operation.handler.function.TransformHandler) Schema(uk.gov.gchq.gaffer.store.schema.Schema) Transform(uk.gov.gchq.gaffer.operation.impl.function.Transform) FederatedTransformHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedTransformHandler) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Example 32 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedOperationOutputHandlerTest method shouldMergeResultsFromFieldObjects.

@Test
public void shouldMergeResultsFromFieldObjects() throws Exception {
    // Given
    final OP op = getExampleOperation();
    Schema unusedSchema = new Schema.Builder().build();
    StoreProperties storeProperties = new StoreProperties();
    Store mockStore1 = getMockStore(unusedSchema, storeProperties, o1);
    Store mockStore2 = getMockStore(unusedSchema, storeProperties, o2);
    Store mockStore3 = getMockStore(unusedSchema, storeProperties, o3);
    Store mockStore4 = getMockStore(unusedSchema, storeProperties, o4);
    FederatedStore mockStore = Mockito.mock(FederatedStore.class);
    LinkedHashSet<Graph> linkedGraphs = Sets.newLinkedHashSet();
    linkedGraphs.add(getGraphWithMockStore(mockStore1));
    linkedGraphs.add(getGraphWithMockStore(mockStore2));
    linkedGraphs.add(getGraphWithMockStore(mockStore3));
    linkedGraphs.add(getGraphWithMockStore(mockStore4));
    Mockito.when(mockStore.getGraphs(user, null, op)).thenReturn(linkedGraphs);
    // When
    O theMergedResultsOfOperation = getFederatedHandler().doOperation(op, context, mockStore);
    // Then
    validateMergeResultsFromFieldObjects(theMergedResultsOfOperation, o1, o2, o3, o4);
    verify(mockStore1).execute(any(OperationChain.class), any(Context.class));
    verify(mockStore2).execute(any(OperationChain.class), any(Context.class));
    verify(mockStore3).execute(any(OperationChain.class), any(Context.class));
    verify(mockStore4).execute(any(OperationChain.class), any(Context.class));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Store(uk.gov.gchq.gaffer.store.Store) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Example 33 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedOperationOutputHandlerTest method shouldMergeResultsFromFieldObjectsWithGivenGraphIds.

@Test
public void shouldMergeResultsFromFieldObjectsWithGivenGraphIds() throws Exception {
    // Given
    final OP op = getExampleOperation();
    op.addOption(KEY_OPERATION_OPTIONS_GRAPH_IDS, "1,3");
    Schema unusedSchema = new Schema.Builder().build();
    StoreProperties storeProperties = new StoreProperties();
    Store mockStore1 = getMockStore(unusedSchema, storeProperties, o1);
    Store mockStore2 = getMockStore(unusedSchema, storeProperties, o2);
    Store mockStore3 = getMockStore(unusedSchema, storeProperties, o3);
    Store mockStore4 = getMockStore(unusedSchema, storeProperties, o4);
    FederatedStore mockStore = Mockito.mock(FederatedStore.class);
    LinkedHashSet<Graph> filteredGraphs = Sets.newLinkedHashSet();
    filteredGraphs.add(getGraphWithMockStore(mockStore1));
    filteredGraphs.add(getGraphWithMockStore(mockStore3));
    Mockito.when(mockStore.getGraphs(user, "1,3", op)).thenReturn(filteredGraphs);
    // When
    O theMergedResultsOfOperation = getFederatedHandler().doOperation(op, context, mockStore);
    // Then
    validateMergeResultsFromFieldObjects(theMergedResultsOfOperation, o1, o3);
    verify(mockStore1).execute(any(OperationChain.class), any(Context.class));
    verify(mockStore2, never()).execute(any(OperationChain.class), any(Context.class));
    verify(mockStore3).execute(any(OperationChain.class), any(Context.class));
    verify(mockStore4, never()).execute(any(OperationChain.class), any(Context.class));
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Graph(uk.gov.gchq.gaffer.graph.Graph) Schema(uk.gov.gchq.gaffer.store.schema.Schema) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Store(uk.gov.gchq.gaffer.store.Store) StoreProperties(uk.gov.gchq.gaffer.store.StoreProperties) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Example 34 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedAddGraphWithHooksHandlerTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    CacheServiceLoader.shutdown();
    this.store = new FederatedStore();
    federatedStoreProperties = new FederatedStoreProperties();
    federatedStoreProperties.setCacheProperties(CACHE_SERVICE_CLASS_STRING);
    testUser = testUser();
    authUser = authUser();
    blankUser = blankUser();
    ignore = new IgnoreOptions();
}
Also used : FederatedStoreProperties(uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 35 with FederatedStore

use of uk.gov.gchq.gaffer.federatedstore.FederatedStore in project Gaffer by gchq.

the class FederatedFilterHandlerTest method shouldDelegateToHandler.

@Test
public void shouldDelegateToHandler() throws OperationException {
    // Given
    final FederatedStore store = mock(FederatedStore.class);
    final FilterHandler handler = mock(FilterHandler.class);
    final Filter op = mock(Filter.class);
    final Context context = mock(Context.class);
    final Iterable expectedResult = mock(Iterable.class);
    final Schema schema = mock(Schema.class);
    given(store.getSchema(op, context)).willReturn(schema);
    given(handler.doOperation(op, schema)).willReturn(expectedResult);
    final FederatedFilterHandler federatedHandler = new FederatedFilterHandler(handler);
    // When
    final Object result = federatedHandler.doOperation(op, context, store);
    // Then
    assertSame(expectedResult, result);
    verify(handler).doOperation(op, schema);
}
Also used : Context(uk.gov.gchq.gaffer.store.Context) Filter(uk.gov.gchq.gaffer.operation.impl.function.Filter) Schema(uk.gov.gchq.gaffer.store.schema.Schema) FederatedFilterHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedFilterHandler) FederatedFilterHandler(uk.gov.gchq.gaffer.federatedstore.operation.handler.FederatedFilterHandler) FilterHandler(uk.gov.gchq.gaffer.store.operation.handler.function.FilterHandler) FederatedStore(uk.gov.gchq.gaffer.federatedstore.FederatedStore) Test(org.junit.jupiter.api.Test)

Aggregations

FederatedStore (uk.gov.gchq.gaffer.federatedstore.FederatedStore)38 Test (org.junit.jupiter.api.Test)25 Context (uk.gov.gchq.gaffer.store.Context)25 Schema (uk.gov.gchq.gaffer.store.schema.Schema)19 Graph (uk.gov.gchq.gaffer.graph.Graph)16 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)12 OperationException (uk.gov.gchq.gaffer.operation.OperationException)12 StoreProperties (uk.gov.gchq.gaffer.store.StoreProperties)11 Store (uk.gov.gchq.gaffer.store.Store)10 FederatedOperationChain (uk.gov.gchq.gaffer.federatedstore.operation.FederatedOperationChain)8 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)7 FederatedStoreProperties (uk.gov.gchq.gaffer.federatedstore.FederatedStoreProperties)7 PredefinedFederatedStore (uk.gov.gchq.gaffer.federatedstore.PredefinedFederatedStore)7 Operation (uk.gov.gchq.gaffer.operation.Operation)7 GetAllElements (uk.gov.gchq.gaffer.operation.impl.get.GetAllElements)6 User (uk.gov.gchq.gaffer.user.User)6 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Element (uk.gov.gchq.gaffer.data.element.Element)4 GraphConfig (uk.gov.gchq.gaffer.graph.GraphConfig)4 GraphSerialisable (uk.gov.gchq.gaffer.graph.GraphSerialisable)4