Search in sources :

Example 6 with EmptyClosableIterable

use of uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable in project Gaffer by gchq.

the class AbstractOperationsTest method shouldThrowUnsupportedTraitExceptionWithPostAggregationFiltering.

@Test
public void shouldThrowUnsupportedTraitExceptionWithPostAggregationFiltering() throws OperationException {
    // Given
    final Graph graph = createGraph();
    final List<Element> elements = getInputDataForGetAllElementsTest();
    graph.execute(new AddElements.Builder().input(elements).build(), user);
    final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().postAggregationFilter(new ElementFilter.Builder().select("double").execute(new IsEqual(2.0)).build()).build()).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> graph.execute(new GetElements.Builder().input(new EmptyClosableIterable<>()).view(view).build(), user)).withMessageContaining("POST_AGGREGATION_FILTERING");
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) EmptyClosableIterable(uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.jupiter.api.Test)

Example 7 with EmptyClosableIterable

use of uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable in project Gaffer by gchq.

the class AbstractOperationsTest method shouldThrowUnsupportedTraitExceptionWithPostTransformFiltering.

@Test
public void shouldThrowUnsupportedTraitExceptionWithPostTransformFiltering() throws OperationException {
    // Given
    final Graph graph = createGraph();
    final List<Element> elements = getInputDataForGetAllElementsTest();
    graph.execute(new AddElements.Builder().input(elements).build(), user);
    final View view = new View.Builder().edge(TestGroups.EDGE, new ViewElementDefinition.Builder().postTransformFilter(new ElementFilter.Builder().select("double").execute(new IsEqual(2.0)).build()).build()).build();
    // When / Then
    assertThatIllegalArgumentException().isThrownBy(() -> graph.execute(new GetElements.Builder().input(new EmptyClosableIterable<>()).view(view).build(), user)).withMessageContaining("POST_TRANSFORMATION_FILTERING");
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) EmptyClosableIterable(uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) View(uk.gov.gchq.gaffer.data.elementdefinition.view.View) IsEqual(uk.gov.gchq.koryphe.impl.predicate.IsEqual) Test(org.junit.jupiter.api.Test)

Example 8 with EmptyClosableIterable

use of uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable in project Gaffer by gchq.

the class GetElementsHandlerTest method testGetElementsWhenNoEntityIdsProvided.

@Test
public void testGetElementsWhenNoEntityIdsProvided() throws OperationException {
    // Given
    final Graph graph = GetAllElementsHandlerTest.getGraph();
    final AddElements addElements = new AddElements.Builder().input(getElements()).build();
    graph.execute(addElements, new User());
    // When
    final GetElements getElements = new GetElements.Builder().input(new EmptyClosableIterable<>()).build();
    final CloseableIterable<? extends Element> results = graph.execute(getElements, new User());
    // Then
    final Set<Element> resultsSet = new HashSet<>();
    Streams.toStream(results).forEach(resultsSet::add);
    assertEquals(Collections.emptySet(), resultsSet);
}
Also used : AddElements(uk.gov.gchq.gaffer.operation.impl.add.AddElements) Graph(uk.gov.gchq.gaffer.graph.Graph) User(uk.gov.gchq.gaffer.user.User) EmptyClosableIterable(uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable) Element(uk.gov.gchq.gaffer.data.element.Element) GetElements(uk.gov.gchq.gaffer.operation.impl.get.GetElements) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Aggregations

EmptyClosableIterable (uk.gov.gchq.gaffer.commonutil.iterable.EmptyClosableIterable)8 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)5 Test (org.junit.jupiter.api.Test)4 Element (uk.gov.gchq.gaffer.data.element.Element)4 Graph (uk.gov.gchq.gaffer.graph.Graph)4 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)4 Test (org.junit.Test)3 HashSet (java.util.HashSet)2 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)2 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)2 User (uk.gov.gchq.gaffer.user.User)2 IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)2 LimitedCloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.LimitedCloseableIterable)1 UnwrapEntityId (uk.gov.gchq.gaffer.data.element.function.UnwrapEntityId)1 EntityId (uk.gov.gchq.gaffer.data.element.id.EntityId)1 Builder (uk.gov.gchq.gaffer.data.elementdefinition.view.View.Builder)1 GraphWindow (uk.gov.gchq.gaffer.data.graph.GraphWindow)1 Walk (uk.gov.gchq.gaffer.data.graph.Walk)1 AdjacencyMaps (uk.gov.gchq.gaffer.data.graph.adjacency.AdjacencyMaps)1 PrunedAdjacencyMaps (uk.gov.gchq.gaffer.data.graph.adjacency.PrunedAdjacencyMaps)1