ImmutablePropertyFilter implements PropertySearchFilter { public static ImmutablePropertyFilter of(final Type type, final CharSequence propertyPath, final Collection<JsonValue> filterValues) { return new ImmutablePropertyFilter(type, propertyPath, checkNotNull(filterValues, "filter values")); } private  ImmutablePropertyFilter(final Type type, final CharSequence propertyPath,
            final Collection<JsonValue> values); static ImmutablePropertyFilter of(final Type type, final CharSequence propertyPath,
            final Collection<JsonValue> filterValues); static ImmutablePropertyFilter of(final Type type,
            final CharSequence propertyPath,
            final JsonValue filterValue,
            final JsonValue... furtherFilterValues); @Override Type getType(); @Override JsonPointer getPath(); @Override Collection<JsonValue> getValues(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString();  }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullType() { ImmutablePropertyFilter.of(null, THING_ID_PATH, KNOWN_VALUES); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullPropertyPath() { ImmutablePropertyFilter.of(SearchFilter.Type.EQ, null, KNOWN_VALUES); }
@Test(expected = NullPointerException.class) public void tryToCreateInstanceWithNullValues() { ImmutablePropertyFilter.of(SearchFilter.Type.EQ, THING_ID_PATH, null); }
@Test public void getTypeReturnsExpected() { final SearchFilter.Type type = SearchFilter.Type.EQ; final ImmutablePropertyFilter underTest = ImmutablePropertyFilter.of(type, THING_ID_PATH, KNOWN_VALUES); assertThat(underTest).hasType(type); }
@Test public void getPathReturnsExpected() { final ImmutablePropertyFilter underTest = ImmutablePropertyFilter.of(SearchFilter.Type.EQ, THING_ID_PATH, KNOWN_VALUES); assertThat(underTest).hasPath(THING_ID_PATH); }
@Test public void getValuesReturnsExpected() { final JsonValue valueFoo = newValue("foo"); final JsonValue valueBar = newValue("bar"); final JsonValue valueBaz = newValue("baz"); final ImmutablePropertyFilter underTest = ImmutablePropertyFilter.of(SearchFilter.Type.IN, THING_ID_PATH, Arrays.asList(valueFoo, valueBar, valueBaz)); assertThat(underTest).hasOnlyValue(valueFoo, valueBar, valueBaz); }
@Test public void toStringOfInTypeFilterReturnsExpectedRepresentation() { final JsonValue valueFoo = newValue("foo"); final JsonValue valueBar = newValue("bar"); final JsonValue valueBaz = newValue("baz"); final ImmutablePropertyFilter underTest = ImmutablePropertyFilter.of(SearchFilter.Type.IN, THING_ID_PATH, Arrays.asList(valueFoo, valueBar, valueBaz)); assertThat(underTest) .hasStringRepresentation( "in(" + THING_ID_PATH + ",\"foo\",\"bar\",\"baz\")"); }
@Test public void toStringOfExistsTypeFilterReturnsExpectedRepresentation() { final ImmutablePropertyFilter underTest = ImmutablePropertyFilter.of(SearchFilter.Type.EXISTS, THING_ID_PATH, Collections.emptySet()); assertThat(underTest) .hasStringRepresentation( "exists(" + THING_ID_PATH + ")"); }