use of uk.gov.gchq.gaffer.function.MapFilter in project Gaffer by gchq.
the class FreqMapIsMoreThanTest method shouldClone.
@Test
public void shouldClone() {
// Given
final MapFilter filter = new MapFilter(KEY1, new IsMoreThan(1L, true));
// When
final MapFilter clonedFilter = filter.statelessClone();
// Then
assertNotSame(filter, clonedFilter);
assertEquals(KEY1, clonedFilter.getKey());
assertEquals(1L, ((IsMoreThan) clonedFilter.getFunction()).getControlValue());
assertTrue(((IsMoreThan) clonedFilter.getFunction()).getOrEqualTo());
}
use of uk.gov.gchq.gaffer.function.MapFilter in project Gaffer by gchq.
the class FreqMapIsMoreThanTest method shouldAcceptWhenFreqIsGreaterThan0.
@Test
public void shouldAcceptWhenFreqIsGreaterThan0() {
// Given
final MapFilter filter = new MapFilter(KEY1, new IsMoreThan(0L));
// When
boolean accepted = filter.isValid(new Object[] { map1 });
// Then
assertTrue(accepted);
}
use of uk.gov.gchq.gaffer.function.MapFilter in project Gaffer by gchq.
the class FreqMapIsMoreThanTest method shouldRejectWhenEqualToAndFlagNotSet.
@Test
public void shouldRejectWhenEqualToAndFlagNotSet() {
// Given
final MapFilter filter = new MapFilter(KEY1, new IsMoreThan(1L, false));
// When
boolean accepted = filter.isValid(new Object[] { map1 });
// Then
assertFalse(accepted);
}
use of uk.gov.gchq.gaffer.function.MapFilter in project Gaffer by gchq.
the class MapFilterExample method mapWithDateKeyHasAValueThatExists.
public void mapWithDateKeyHasAValueThatExists() {
// ---------------------------------------------------------
final MapFilter function = new MapFilter(new Date(0L), new Exists());
// ---------------------------------------------------------
final Map<Date, Long> map1 = new HashMap<>();
map1.put(new Date(0L), 1L);
final Map<Date, Long> map2 = new HashMap<>();
map2.put(new Date(), 2L);
runExample(function, map1, map2);
}
use of uk.gov.gchq.gaffer.function.MapFilter in project Gaffer by gchq.
the class MapFilterExample method freqMapIsMoreThanOrEqualTo2.
public void freqMapIsMoreThanOrEqualTo2() {
// ---------------------------------------------------------
final MapFilter function = new MapFilter("key1", new IsMoreThan(2L, true));
// ---------------------------------------------------------
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, map1, map2, map3, map4, map5);
}
Aggregations