Search in sources :

Example 31 with QueryableEntry

use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.

the class QueryEventFilterTest method testEval_givenFilterContainsKey_whenKeyOfEntryIsNotEqual_thenReturnFalse.

@Test
public void testEval_givenFilterContainsKey_whenKeyOfEntryIsNotEqual_thenReturnFalse() {
    //given
    Data key1 = serializationService.toData("key1");
    Predicate predicate = TruePredicate.INSTANCE;
    QueryEventFilter filter = new QueryEventFilter(true, key1, predicate);
    //when
    Data key2 = serializationService.toData("key2");
    QueryableEntry entry = mockEntryWithKeyData(key2);
    //then
    boolean result = filter.eval(entry);
    assertFalse(result);
}
Also used : Data(com.hazelcast.nio.serialization.Data) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) TruePredicate(com.hazelcast.query.TruePredicate) FalsePredicate(com.hazelcast.query.impl.FalsePredicate) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 32 with QueryableEntry

use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.

the class NotEqualPredicateTest method apply_givenAttributeValueIsNull_whenEntryHasTheAttributeNull_thenReturnFalse.

@Test
public void apply_givenAttributeValueIsNull_whenEntryHasTheAttributeNull_thenReturnFalse() {
    NotEqualPredicate name = new NotEqualPredicate("name", null);
    QueryableEntry mockEntry = newMockEntry(null);
    boolean result = name.apply(mockEntry);
    assertFalse(result);
}
Also used : QueryableEntry(com.hazelcast.query.impl.QueryableEntry) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 33 with QueryableEntry

use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.

the class NotEqualPredicateTest method apply_givenAttributeValueIsFoo_whenEntryHasEqualAttribute_thenReturnFalse.

@Test
public void apply_givenAttributeValueIsFoo_whenEntryHasEqualAttribute_thenReturnFalse() {
    NotEqualPredicate name = new NotEqualPredicate("name", "foo");
    QueryableEntry mockEntry = newMockEntry("foo");
    boolean result = name.apply(mockEntry);
    assertFalse(result);
}
Also used : QueryableEntry(com.hazelcast.query.impl.QueryableEntry) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 34 with QueryableEntry

use of com.hazelcast.query.impl.QueryableEntry in project hazelcast by hazelcast.

the class NotEqualPredicateTest method filter_givenAttributeNameIsFoo_whenTheFooFieldIsIndex_thenReturnsNullAndDoesNotTouchQueryContext.

@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);
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Matchers.containsString(org.hamcrest.Matchers.containsString) QueryContext(com.hazelcast.query.impl.QueryContext) QueryableEntry(com.hazelcast.query.impl.QueryableEntry) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

QueryableEntry (com.hazelcast.query.impl.QueryableEntry)34 Data (com.hazelcast.nio.serialization.Data)14 Predicate (com.hazelcast.query.Predicate)10 ParallelTest (com.hazelcast.test.annotation.ParallelTest)10 QuickTest (com.hazelcast.test.annotation.QuickTest)10 Test (org.junit.Test)10 TruePredicate (com.hazelcast.query.TruePredicate)5 FalsePredicate (com.hazelcast.query.impl.FalsePredicate)5 HashSet (java.util.HashSet)5 CachedQueryEntry (com.hazelcast.query.impl.CachedQueryEntry)4 Indexes (com.hazelcast.query.impl.Indexes)4 Extractors (com.hazelcast.query.impl.getters.Extractors)4 SerializationService (com.hazelcast.spi.serialization.SerializationService)4 Map (java.util.Map)4 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)3 MapContainer (com.hazelcast.map.impl.MapContainer)3 Record (com.hazelcast.map.impl.record.Record)3 TransactionalMap (com.hazelcast.core.TransactionalMap)2 MapQueryEngine (com.hazelcast.map.impl.query.MapQueryEngine)2 Query (com.hazelcast.map.impl.query.Query)2