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