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));
}
Aggregations