@Test public void negate_thenReturnEqualPredicate() { NotEqualPredicate notEqualPredicate = new NotEqualPredicate("foo", 1); EqualPredicate negate = (EqualPredicate) notEqualPredicate.negate(); assertEquals("foo", negate.attributeName); assertEquals(1, negate.value); }
@Test public void getId_isConstant() { NotEqualPredicate predicate = new NotEqualPredicate("bar", "foo"); int id = predicate.getId(); // make sure the ID has not been changed by accident assertEquals(id, 9); }
@Test public void toString_containsAttributeName() { String fieldName = "name"; NotEqualPredicate predicate = new NotEqualPredicate(fieldName, "foo"); String result = predicate.toString(); assertThat(result, containsString(fieldName)); }
@Test public void apply_givenAttributeValueIsFoo_whenEntryHasEqualAttribute_thenReturnFalse() { NotEqualPredicate name = new NotEqualPredicate("name", "foo"); QueryableEntry mockEntry = newMockEntry("foo"); boolean result = name.apply(mockEntry); assertFalse(result); }
@Test public void apply_givenAttributeValueIsNull_whenEntryHasTheAttributeIsNotNull_thenReturnTrue() { NotEqualPredicate name = new NotEqualPredicate("name", null); QueryableEntry mockEntry = newMockEntry("foo"); boolean result = name.apply(mockEntry); assertTrue(result); }
@Test public void isIndexed_givenAttributeNameIsFoo_whenTheFooFieldIsIndexed_returnFalse() { // see https://github.com/hazelcast/hazelcast/pull/5847 String fieldName = "name"; NotEqualPredicate name = new NotEqualPredicate(fieldName, "foo"); QueryContext queryContext = newMockContextWithIndex(fieldName); boolean indexed = name.isIndexed(queryContext); assertFalse(indexed); }
@Test public void filter_givenAttributeNameIsFoo_whenTheFooFieldIsIndex_thenReturnsNullAndDoesNotTouchQueryContext() { /** see {@link #isIndexed_givenAttributeNameIsFoo_whenTheFooFieldIsIndexed_returnFalse()} */ String fieldName = "foo"; NotEqualPredicate predicate = new NotEqualPredicate(fieldName, "foo"); QueryContext queryContext = newMockContextWithIndex(fieldName); Set<QueryableEntry> filter = predicate.filter(queryContext); assertNull(filter); verifyZeroInteractions(queryContext); }