CachingContext implements Closeable { public void invalidate(final String experimentName, boolean async) { if (async) { executorService.execute(new Runnable() { @Override public void run() { safeInvalidate(experimentName, builderFactory.createBuilder(experimentName)); } }); } else { safeInvalidate(experimentName, builderFactory.createBuilder(experimentName)); } } CachingContext(ExperimentsCache cache,
                          Experiment.BuilderFactory builderFactory,
                          ExecutorService executorService);  CachingContext(ExperimentsCache cache,
                          Experiment.BuilderFactory builderFactory); void invalidateAll(boolean async); void invalidate(final String experimentName, boolean async); void update(Experiment experiment); void delete(String experimentName); boolean checkIfAnyStale(); boolean checkIfStale(String experimentName); @Override void close();  }
@Test public void testInvalidate() { context.invalidate("foo", false); verifyNoMoreInteractions(executorService); verify(cache).invalidate(eq("foo"), any()); }
@Test public void testInvalidateAsync() { context.invalidate("foo", true); verify(executorService).execute(any(Runnable.class)); }