Search in sources :

Example 1 with CountAggregator

use of com.hazelcast.aggregation.impl.CountAggregator in project hazelcast by hazelcast.

the class AbstractMapNullTest method testNullability.

@Test
public void testNullability() {
    EntryAddedListener sampleMapListener = event -> {
    };
    Predicate<Object, Object> samplePredicate = Predicates.alwaysTrue();
    TimeUnit sampleTimeUnit = TimeUnit.SECONDS;
    assertThrowsNPE(m -> m.putAll(null));
    assertThrowsNPE(m -> m.containsKey(null));
    assertThrowsNPE(m -> m.containsValue(null));
    assertThrowsNPE(m -> m.get(null));
    assertThrowsNPE(m -> m.put(null, ""));
    assertThrowsNPE(m -> m.put("", null));
    assertThrowsNPE(m -> m.remove(null));
    assertThrowsNPE(m -> m.remove(null, ""));
    assertThrowsNPE(m -> m.remove("", null));
    assertThrowsNPE(m -> m.removeAll(null));
    assertThrowsNPE(m -> m.delete(null));
    assertThrowsNPE(m -> m.loadAll(null, true));
    assertThrowsNPE(m -> m.getAsync(null));
    assertThrowsNPE(m -> m.putAsync(null, ""));
    assertThrowsNPE(m -> m.putAsync("", null));
    assertThrowsNPE(m -> m.putAsync(null, "", -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putAsync("", null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putAsync("", "", -1, null));
    assertThrowsNPE(m -> m.putAsync(null, "", -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putAsync("", null, -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putAsync("", "", -1, null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putAsync("", "", -1, sampleTimeUnit, -1, null));
    assertThrowsNPE(m -> m.setAsync(null, ""));
    assertThrowsNPE(m -> m.setAsync("", null));
    assertThrowsNPE(m -> m.setAsync(null, "", -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.setAsync("", null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.setAsync("", "", -1, null));
    assertThrowsNPE(m -> m.setAsync(null, "", -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.setAsync("", null, -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.setAsync("", "", -1, null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.setAsync("", "", -1, sampleTimeUnit, -1, null));
    assertThrowsNPE(m -> m.tryRemove(null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.tryRemove("", -1, null));
    assertThrowsNPE(m -> m.tryPut(null, "", -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.tryPut("", null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.tryPut("", "", -1, null));
    assertThrowsNPE(m -> m.put(null, "", -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.put("", null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.put("", "", -1, null));
    assertThrowsNPE(m -> m.putTransient(null, "", -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putTransient("", null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putTransient("", "", -1, null));
    assertThrowsNPE(m -> m.putTransient(null, "", -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putTransient("", null, -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putTransient("", "", -1, null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putTransient("", "", -1, sampleTimeUnit, -1, null));
    assertThrowsNPE(m -> m.putIfAbsent(null, ""));
    assertThrowsNPE(m -> m.putIfAbsent("", null));
    assertThrowsNPE(m -> m.putIfAbsent(null, "", -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putIfAbsent("", null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putIfAbsent("", "", -1, null));
    assertThrowsNPE(m -> m.putIfAbsent(null, "", -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putIfAbsent("", null, -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putIfAbsent("", "", -1, null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.putIfAbsent("", "", -1, sampleTimeUnit, -1, null));
    assertThrowsNPE(m -> m.replace(null, "", ""));
    assertThrowsNPE(m -> m.replace("", null, ""));
    assertThrowsNPE(m -> m.replace("", "", null));
    assertThrowsNPE(m -> m.replace(null, ""));
    assertThrowsNPE(m -> m.replace("", null));
    assertThrowsNPE(m -> m.set(null, ""));
    assertThrowsNPE(m -> m.set("", null));
    assertThrowsNPE(m -> m.set(null, "", -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.set("", null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.set("", "", -1, null));
    assertThrowsNPE(m -> m.set(null, "", -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.set("", null, -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.set("", "", -1, null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.set("", "", -1, sampleTimeUnit, -1, null));
    assertThrowsNPE(m -> m.setAll(null));
    assertThrowsNPE(m -> m.setAllAsync(null));
    assertThrowsNPE(m -> m.lock(null));
    assertThrowsNPE(m -> m.lock(null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.tryLock(null));
    assertThrowsNPE(m -> m.tryLock(null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.tryLock(null, -1, sampleTimeUnit, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.unlock(null));
    assertThrowsNPE(m -> m.forceUnlock(null));
    if (isNotClient()) {
        assertThrowsNPE(m -> m.addLocalEntryListener((MapListener) null));
        assertThrowsNPE(m -> m.addLocalEntryListener((MapListener) null, samplePredicate, true));
        assertThrowsNPE(m -> m.addLocalEntryListener(sampleMapListener, null, true));
        assertThrowsNPE(m -> m.addLocalEntryListener(sampleMapListener, null, "", true));
        assertThrowsNPE(m -> m.localKeySet(null));
    }
    assertThrowsNPE(m -> m.addInterceptor(null));
    assertThrowsNPE(m -> m.removeInterceptor(null));
    assertThrowsNPE(m -> m.addEntryListener((MapListener) null, "", true));
    assertThrowsNPE(m -> m.addEntryListener((MapListener) null, (Object) null, true));
    assertThrowsNPE(m -> m.addEntryListener((MapListener) null, samplePredicate, true));
    assertThrowsNPE(m -> m.addEntryListener(sampleMapListener, null, true));
    assertThrowsNPE(m -> m.addEntryListener((MapListener) null, samplePredicate, "", true));
    assertThrowsNPE(m -> m.addEntryListener(sampleMapListener, null, "", true));
    assertThrowsNPE(m -> m.removeEntryListener(null));
    assertThrowsNPE(m -> m.addPartitionLostListener(null));
    assertThrowsNPE(m -> m.removePartitionLostListener(null));
    assertThrowsNPE(m -> m.getEntryView(null));
    assertThrowsNPE(m -> m.evict(null));
    assertThrowsNPE(m -> m.keySet(null));
    assertThrowsNPE(m -> m.entrySet(null));
    assertThrowsNPE(m -> m.values(null));
    assertThrows(NullPointerException.class, m -> m.addIndex(null, "attribute"));
    assertThrows(NullPointerException.class, m -> m.addIndex(IndexType.SORTED, null));
    assertThrows(NullPointerException.class, m -> m.addIndex(null));
    assertThrowsNPE(m -> m.aggregate(null));
    assertThrowsNPE(m -> m.aggregate(null, samplePredicate));
    assertThrowsNPE(m -> m.aggregate(new CountAggregator<>(), null));
    assertThrowsNPE(m -> m.project(null, samplePredicate));
    assertThrowsNPE(m -> m.project(Projections.identity(), null));
    assertThrowsNPE(m -> m.getQueryCache(null));
    assertThrowsNPE(m -> m.getQueryCache(null, samplePredicate, true));
    assertThrowsNPE(m -> m.getQueryCache("cache", null, true));
    assertThrowsNPE(m -> m.getQueryCache(null, sampleMapListener, samplePredicate, true));
    assertThrowsNPE(m -> m.getQueryCache("cache", null, samplePredicate, true));
    assertThrowsNPE(m -> m.getQueryCache("cache", sampleMapListener, null, true));
    assertThrowsNPE(m -> m.setTtl(null, -1, sampleTimeUnit));
    assertThrowsNPE(m -> m.setTtl("", -1, null));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastTestSupport(com.hazelcast.test.HazelcastTestSupport) ExceptionUtil(com.hazelcast.internal.util.ExceptionUtil) Test(org.junit.Test) EntryAddedListener(com.hazelcast.map.listener.EntryAddedListener) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) MapListener(com.hazelcast.map.listener.MapListener) CountAggregator(com.hazelcast.aggregation.impl.CountAggregator) IndexType(com.hazelcast.config.IndexType) Predicates(com.hazelcast.query.Predicates) Assert.fail(org.junit.Assert.fail) Projections(com.hazelcast.projection.Projections) Assert(org.junit.Assert) Predicate(com.hazelcast.query.Predicate) MapListener(com.hazelcast.map.listener.MapListener) CountAggregator(com.hazelcast.aggregation.impl.CountAggregator) TimeUnit(java.util.concurrent.TimeUnit) EntryAddedListener(com.hazelcast.map.listener.EntryAddedListener) Test(org.junit.Test)

Aggregations

CountAggregator (com.hazelcast.aggregation.impl.CountAggregator)1 IndexType (com.hazelcast.config.IndexType)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ExceptionUtil (com.hazelcast.internal.util.ExceptionUtil)1 EntryAddedListener (com.hazelcast.map.listener.EntryAddedListener)1 MapListener (com.hazelcast.map.listener.MapListener)1 Projections (com.hazelcast.projection.Projections)1 Predicate (com.hazelcast.query.Predicate)1 Predicates (com.hazelcast.query.Predicates)1 HazelcastTestSupport (com.hazelcast.test.HazelcastTestSupport)1 TimeUnit (java.util.concurrent.TimeUnit)1 Consumer (java.util.function.Consumer)1 Assert (org.junit.Assert)1 Assert.fail (org.junit.Assert.fail)1 Test (org.junit.Test)1