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);
}
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));
}
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));
}
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();
}
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);
}
Aggregations