summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/style/layers/FilterTest.java
blob: 933bf05b3917494a07febd60434b35c29e0c01cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package com.mapbox.mapboxsdk.style.layers;

import org.junit.Test;

import static com.mapbox.mapboxsdk.style.layers.Filter.all;
import static com.mapbox.mapboxsdk.style.layers.Filter.any;
import static com.mapbox.mapboxsdk.style.layers.Filter.eq;
import static com.mapbox.mapboxsdk.style.layers.Filter.gt;
import static com.mapbox.mapboxsdk.style.layers.Filter.gte;
import static com.mapbox.mapboxsdk.style.layers.Filter.has;
import static com.mapbox.mapboxsdk.style.layers.Filter.in;
import static com.mapbox.mapboxsdk.style.layers.Filter.lt;
import static com.mapbox.mapboxsdk.style.layers.Filter.lte;
import static com.mapbox.mapboxsdk.style.layers.Filter.neq;
import static com.mapbox.mapboxsdk.style.layers.Filter.none;
import static com.mapbox.mapboxsdk.style.layers.Filter.notHas;
import static com.mapbox.mapboxsdk.style.layers.Filter.notIn;
import static org.junit.Assert.assertArrayEquals;

/**
 * Tests for Filter
 */
public class FilterTest {

  @Test
  public void testAll() {
    assertArrayEquals(all().toArray(), new Object[] {"all"});
    assertArrayEquals(
      all(eq("key", 2), neq("key", 3)).toArray(),
      new Object[] {"all", new Object[] {"==", "key", 2}, new Object[] {"!=", "key", 3}}
    );
  }

  @Test
  public void testAny() {
    assertArrayEquals(any().toArray(), new Object[] {"any"});
    assertArrayEquals(
      any(eq("key", 2), neq("key", 3)).toArray(),
      new Object[] {"any", new Object[] {"==", "key", 2}, new Object[] {"!=", "key", 3}}
    );
  }

  @Test
  public void testNone() {
    assertArrayEquals(none().toArray(), new Object[] {"none"});
    assertArrayEquals(
      none(eq("key", 2), neq("key", 3)).toArray(),
      new Object[] {"none", new Object[] {"==", "key", 2}, new Object[] {"!=", "key", 3}}
    );
  }

  @Test
  public void testHas() {
    assertArrayEquals(has("key").toArray(), new Object[] {"has", "key"});
  }

  @Test
  public void testHasNot() {
    assertArrayEquals(notHas("key").toArray(), new Object[] {"!has", "key"});
  }

  @Test
  public void testEq() {
    assertArrayEquals(eq("key", 1).toArray(), new Object[] {"==", "key", 1});

  }

  @Test
  public void testNeq() {
    assertArrayEquals(neq("key", 1).toArray(), new Object[] {"!=", "key", 1});
  }

  @Test
  public void testGt() {
    assertArrayEquals(gt("key", 1).toArray(), new Object[] {">", "key", 1});
  }

  @Test
  public void testGte() {
    assertArrayEquals(gte("key", 1).toArray(), new Object[] {">=", "key", 1});
  }

  @Test
  public void testLt() {
    assertArrayEquals(lt("key", 1).toArray(), new Object[] {"<", "key", 1});
  }

  @Test
  public void testLte() {
    assertArrayEquals(lte("key", 1).toArray(), new Object[] {"<=", "key", 1});
  }

  @Test
  public void testIn() {
    assertArrayEquals(in("key", 1, 2, "Aap").toArray(), new Object[] {"in", "key", 1, 2, "Aap"});
  }

  @Test
  public void testNotIn() {
    assertArrayEquals(notIn("key", 1, 2, "Noot").toArray(), new Object[] {"!in", "key", 1, 2, "Noot"});
  }
}