Search in sources :

Example 36 with Store

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);
}
Also used : Element(uk.gov.gchq.gaffer.data.element.Element) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Store(uk.gov.gchq.gaffer.store.Store) Test(org.junit.Test)

Example 37 with Store

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));
}
Also used : GetIterableOperation(uk.gov.gchq.gaffer.operation.GetIterableOperation) OperationChain(uk.gov.gchq.gaffer.operation.OperationChain) Store(uk.gov.gchq.gaffer.store.Store) Test(org.junit.Test)

Aggregations

Store (uk.gov.gchq.gaffer.store.Store)37 Test (org.junit.Test)35 Context (uk.gov.gchq.gaffer.store.Context)17 OperationChain (uk.gov.gchq.gaffer.operation.OperationChain)13 User (uk.gov.gchq.gaffer.user.User)11 Element (uk.gov.gchq.gaffer.data.element.Element)10 Schema (uk.gov.gchq.gaffer.store.schema.Schema)9 TestStore (uk.gov.gchq.gaffer.integration.store.TestStore)6 GetIterableOperation (uk.gov.gchq.gaffer.operation.GetIterableOperation)5 GroupCounts (uk.gov.gchq.gaffer.data.GroupCounts)4 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)4 Graph (uk.gov.gchq.gaffer.graph.Graph)4 JobDetail (uk.gov.gchq.gaffer.jobtracker.JobDetail)4 JSONSerialiser (uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser)4 GafferResultCacheExporter (uk.gov.gchq.gaffer.operation.export.resultcache.GafferResultCacheExporter)4 CountGroups (uk.gov.gchq.gaffer.operation.impl.CountGroups)4 CountGroupsHandler (uk.gov.gchq.gaffer.store.operation.handler.CountGroupsHandler)4 HashSet (java.util.HashSet)3 InOrder (org.mockito.InOrder)3 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)3