FunctionContextImpl implements FunctionContext { @Override public Cache getCache() throws CacheClosedException { if (cache == null) { throw new CacheClosedException("FunctionContext does not have a valid Cache"); } return cache; } FunctionContextImpl(final Cache cache, final String functionId, final Object args,
      ResultSender resultSender);  FunctionContextImpl(final Cache cache, final String functionId, final Object args,
      ResultSender resultSender, boolean isPossibleDuplicate); @Override Object getArguments(); @Override String getFunctionId(); @Override String toString(); @Override ResultSender getResultSender(); @Override boolean isPossibleDuplicate(); @Override Cache getCache();  }
@Test public void executeWithNullCacheInstanceThrowsCacheClosedException() { FunctionContextImpl context = new FunctionContextImpl(null, null, null, null); Throwable thrown = catchThrowable(() -> context.getCache()); assertThat(thrown) .isInstanceOf(CacheClosedException.class) .hasMessage("FunctionContext does not have a valid Cache"); }