### Question:
CachingTaskCollection implements TaskCollection<T> { @Override public synchronized void close() throws IOException { outstandingTasks.clear(); cache.clear(); wrappedCollection.close(); closed = true; } CachingTaskCollection(final TaskCollection<T> collection, final int maxCacheSize);  CachingTaskCollection(final TaskCollection<T> collection); @Override synchronized void add(final T taskData); @Override synchronized Task<T> remove(); @Override synchronized void clear(); @Override synchronized long size(); synchronized int cacheSize(); @Override synchronized boolean isEmpty(); @Override synchronized boolean allTasksCompleted(); @Override synchronized void close(); static final int DEFAULT_CACHE_SIZE; }### Answer:
@Test public void close() throws IOException { final CachingTaskCollection<Bytes> taskCollection = createCachingCollection(10); taskCollection.close(); assertThatThrownBy(() -> taskCollection.add(Bytes.of(1))) .isInstanceOf(IllegalStateException.class); }