Search in sources :

Example 1 with MapFilter

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());
}
Also used : MapFilter(uk.gov.gchq.gaffer.function.MapFilter) Test(org.junit.Test) FilterFunctionTest(uk.gov.gchq.gaffer.function.FilterFunctionTest)

Example 2 with MapFilter

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);
}
Also used : MapFilter(uk.gov.gchq.gaffer.function.MapFilter) Test(org.junit.Test) FilterFunctionTest(uk.gov.gchq.gaffer.function.FilterFunctionTest)

Example 3 with MapFilter

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);
}
Also used : MapFilter(uk.gov.gchq.gaffer.function.MapFilter) Test(org.junit.Test) FilterFunctionTest(uk.gov.gchq.gaffer.function.FilterFunctionTest)

Example 4 with MapFilter

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);
}
Also used : HashMap(java.util.HashMap) Exists(uk.gov.gchq.gaffer.function.filter.Exists) MapFilter(uk.gov.gchq.gaffer.function.MapFilter) Date(java.util.Date)

Example 5 with MapFilter

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);
}
Also used : FreqMap(uk.gov.gchq.gaffer.types.FreqMap) MapFilter(uk.gov.gchq.gaffer.function.MapFilter) IsMoreThan(uk.gov.gchq.gaffer.function.filter.IsMoreThan)

Aggregations

MapFilter (uk.gov.gchq.gaffer.function.MapFilter)11 Test (org.junit.Test)8 FilterFunctionTest (uk.gov.gchq.gaffer.function.FilterFunctionTest)8 FreqMap (uk.gov.gchq.gaffer.types.FreqMap)3 IsMoreThan (uk.gov.gchq.gaffer.function.filter.IsMoreThan)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Exists (uk.gov.gchq.gaffer.function.filter.Exists)1 JSONSerialiser (uk.gov.gchq.gaffer.jsonserialisation.JSONSerialiser)1