use of uk.gov.gchq.gaffer.store.Store in project Gaffer by gchq.
the class CoreOperationChainOptimiserTest method shouldAddValidateOperationForValidatableOperation.
@Test
public void shouldAddValidateOperationForValidatableOperation() throws Exception {
// Given
final Store store = mock(Store.class);
final CoreOperationChainOptimiser optimiser = new CoreOperationChainOptimiser(store);
final Validatable<Integer> validatable1 = mock(Validatable.class);
final boolean skipInvalidElements = true;
final CloseableIterable<Element> elements = mock(CloseableIterable.class);
final OperationChain<Integer> opChain = new OperationChain<>(validatable1);
final Map<String, String> options = mock(HashMap.class);
given(validatable1.getOptions()).willReturn(options);
given(validatable1.isSkipInvalidElements()).willReturn(skipInvalidElements);
given(validatable1.isValidate()).willReturn(true);
given(validatable1.getElements()).willReturn(elements);
// When
final OperationChain<Integer> optimisedOpChain = optimiser.optimise(opChain);
// Then
assertEquals(2, optimisedOpChain.getOperations().size());
assertSame(elements, ((Validate) optimisedOpChain.getOperations().get(0)).getElements());
assertSame(options, optimisedOpChain.getOperations().get(0).getOptions());
assertSame(validatable1, optimisedOpChain.getOperations().get(1));
verify(validatable1).setElements(null);
}
use of uk.gov.gchq.gaffer.store.Store in project Gaffer by gchq.
the class CoreOperationChainOptimiserTest method shouldNotAddDeduplicateOperationForGetOperationsWithoutFlag.
@Test
public void shouldNotAddDeduplicateOperationForGetOperationsWithoutFlag() throws Exception {
// Given
final Store store = mock(Store.class);
final CoreOperationChainOptimiser optimiser = new CoreOperationChainOptimiser(store);
final GetIterableOperation getOperation = mock(GetIterableOperation.class);
final OperationChain<Integer> opChain = new OperationChain<>(getOperation);
given(getOperation.getResultLimit()).willReturn(null);
given(getOperation.isDeduplicate()).willReturn(false);
// When
final OperationChain<Integer> optimisedOpChain = optimiser.optimise(opChain);
// Then
assertEquals(1, optimisedOpChain.getOperations().size());
assertSame(getOperation, optimisedOpChain.getOperations().get(0));
}
Aggregations