Search in sources :

Example 51 with IsMoreThan

use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project gaffer-doc by gchq.

the class IsMoreThanExample method isMoreThanAString.

public void isMoreThanAString() {
    // ---------------------------------------------------------
    final IsMoreThan function = new IsMoreThan("B");
    // ---------------------------------------------------------
    runExample(function, null, 1, "A", "B", "C");
}
Also used : IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)

Example 52 with IsMoreThan

use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project gaffer-doc by gchq.

the class PredicateMapExample method freqMapIsMoreThan2.

public void freqMapIsMoreThan2() {
    // ---------------------------------------------------------
    final PredicateMap function = new PredicateMap("key1", new IsMoreThan(2L));
    // ---------------------------------------------------------
    final FreqMap map1 = new FreqMap();
    map1.put("key1", 1L);
    final FreqMap map2 = new FreqMap();
    map2.put("key1", 2L);
    final FreqMap map3 = new FreqMap();
    map3.put("key1", 3L);
    final FreqMap map4 = new FreqMap();
    map4.put("key1", 3L);
    map4.put("key2", 0L);
    final FreqMap map5 = new FreqMap();
    map5.put("key2", 3L);
    runExample(function, null, map1, map2, map3, map4, map5);
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) PredicateMap(uk.gov.gchq.koryphe.predicate.PredicateMap) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)

Example 53 with IsMoreThan

use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project Gaffer by gchq.

the class ConditionalTest method shouldCloneTransformInShallowClone.

@Test
public void shouldCloneTransformInShallowClone() {
    // Given
    final Operation transform = mock(Operation.class);
    final Operation transformClone = mock(Operation.class);
    given(transform.shallowClone()).willReturn(transformClone);
    final Conditional conditional = new Conditional(new IsMoreThan(1), transform);
    // When
    final Conditional clone = conditional.shallowClone();
    // Then
    assertNotSame(conditional, clone);
    assertSame(transformClone, clone.getTransform());
    verify(transform).shallowClone();
}
Also used : Operation(uk.gov.gchq.gaffer.operation.Operation) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Test(org.junit.jupiter.api.Test) JSONSerialisationTest(uk.gov.gchq.gaffer.JSONSerialisationTest)

Example 54 with IsMoreThan

use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project Gaffer by gchq.

the class FilterHandlerTest method shouldFilterEntitiesAndEdges.

@Test
public void shouldFilterEntitiesAndEdges() throws OperationException {
    // Given
    given(store.getSchema()).willReturn(SCHEMA);
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("junctionA").dest("junctionB").directed(true).property(TestPropertyNames.COUNT, 2L).build();
    final Edge edge1 = new Edge.Builder().group(TestGroups.EDGE_2).source("junctionA").dest("junctionB").directed(true).property(TestPropertyNames.COUNT, 1L).build();
    final Edge edge2 = new Edge.Builder().group(TestGroups.EDGE).source("junctionB").dest("junctionA").directed(true).property(TestPropertyNames.COUNT, 4L).build();
    final Entity entity = new Entity.Builder().group(TestGroups.ENTITY).property(TestPropertyNames.COUNT, 3L).build();
    final Entity entity1 = new Entity.Builder().group(TestGroups.ENTITY_2).property(TestPropertyNames.COUNT, 4L).build();
    input.add(edge);
    input.add(edge1);
    input.add(edge2);
    input.add(entity);
    input.add(entity1);
    expected.add(edge2);
    expected.add(entity);
    expected.add(entity1);
    final Filter filter = new Filter.Builder().input(input).globalElements(new ElementFilter.Builder().select(TestPropertyNames.COUNT).execute(new IsMoreThan(2L)).build()).build();
    // When
    final Iterable<? extends Element> results = handler.doOperation(filter, context, store);
    // Then
    final List<Element> resultsList = Lists.newArrayList(results);
    assertEquals(expected, resultsList);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Filter(uk.gov.gchq.gaffer.operation.impl.function.Filter) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Element(uk.gov.gchq.gaffer.data.element.Element) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Example 55 with IsMoreThan

use of uk.gov.gchq.koryphe.impl.predicate.IsMoreThan in project Gaffer by gchq.

the class FilterHandlerTest method shouldHandleComplexFiltering.

@Test
public void shouldHandleComplexFiltering() throws OperationException {
    // Given
    given(store.getSchema()).willReturn(SCHEMA);
    final Edge edge = new Edge.Builder().group(TestGroups.EDGE).source("junctionA").dest("junctionB").directed(true).property(TestPropertyNames.COUNT, 2L).build();
    final Edge edge1 = new Edge.Builder().group(TestGroups.EDGE_2).source("junctionA").dest("junctionB").directed(true).property(TestPropertyNames.COUNT, 1L).build();
    final Edge edge2 = new Edge.Builder().group(TestGroups.EDGE).source("junctionB").dest("junctionA").directed(true).property(TestPropertyNames.COUNT, 4L).build();
    final Entity entity = new Entity.Builder().group(TestGroups.ENTITY).property(TestPropertyNames.COUNT, 3L).build();
    final Entity entity1 = new Entity.Builder().group(TestGroups.ENTITY_2).property(TestPropertyNames.COUNT, 4L).build();
    final Entity entity2 = new Entity.Builder().group(TestGroups.ENTITY_3).property(TestPropertyNames.COUNT, 6L).build();
    final Filter filter = new Filter.Builder().input(input).globalElements(new ElementFilter.Builder().select(TestPropertyNames.COUNT).execute(new IsMoreThan(1L)).build()).edge(TestGroups.EDGE, new ElementFilter.Builder().select(TestPropertyNames.COUNT).execute(new IsMoreThan(2L)).build()).entity(TestGroups.ENTITY_2).build();
    input.add(edge);
    input.add(edge1);
    input.add(edge2);
    input.add(entity);
    input.add(entity1);
    input.add(entity2);
    expected.add(edge2);
    expected.add(entity1);
    // When
    final Iterable<? extends Element> results = handler.doOperation(filter, context, store);
    // Then
    final List<Element> resultsList = Lists.newArrayList(results);
    assertEquals(expected, resultsList);
}
Also used : Entity(uk.gov.gchq.gaffer.data.element.Entity) Filter(uk.gov.gchq.gaffer.operation.impl.function.Filter) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) ElementFilter(uk.gov.gchq.gaffer.data.element.function.ElementFilter) Element(uk.gov.gchq.gaffer.data.element.Element) IsMoreThan(uk.gov.gchq.koryphe.impl.predicate.IsMoreThan) Edge(uk.gov.gchq.gaffer.data.element.Edge) Test(org.junit.jupiter.api.Test)

Aggregations

IsMoreThan (uk.gov.gchq.koryphe.impl.predicate.IsMoreThan)72 Test (org.junit.jupiter.api.Test)42 ElementFilter (uk.gov.gchq.gaffer.data.element.function.ElementFilter)40 View (uk.gov.gchq.gaffer.data.elementdefinition.view.View)34 ViewElementDefinition (uk.gov.gchq.gaffer.data.elementdefinition.view.ViewElementDefinition)24 Element (uk.gov.gchq.gaffer.data.element.Element)22 EntitySeed (uk.gov.gchq.gaffer.operation.data.EntitySeed)22 Edge (uk.gov.gchq.gaffer.data.element.Edge)20 GetElements (uk.gov.gchq.gaffer.operation.impl.get.GetElements)20 User (uk.gov.gchq.gaffer.user.User)20 Graph (uk.gov.gchq.gaffer.graph.Graph)19 AddElements (uk.gov.gchq.gaffer.operation.impl.add.AddElements)19 ArrayList (java.util.ArrayList)18 HashSet (java.util.HashSet)16 Entity (uk.gov.gchq.gaffer.data.element.Entity)16 IsEqual (uk.gov.gchq.koryphe.impl.predicate.IsEqual)13 IsLessThan (uk.gov.gchq.koryphe.impl.predicate.IsLessThan)13 Set (java.util.Set)12 CloseableIterable (uk.gov.gchq.gaffer.commonutil.iterable.CloseableIterable)12 OperationException (uk.gov.gchq.gaffer.operation.OperationException)12