void () { DefaultLogger.disableStderrDumping(getTestRootDisposable()); SimpleModificationTracker dependency = new SimpleModificationTracker(); Function<String, String> getCached = arg -> CachedValuesManager.getManager(getProject()).getCachedValue(holder, () -> CachedValueProvider.Result.create("result " + arg, dependency)); assertEquals("result foo", getCached.apply("foo")); dependency.incModificationCount(); assertEquals("result foo", getCached.apply("foo")); dependency.incModificationCount(); try { getCached.apply("bar"); TestCase.fail(); } catch (AssertionError e) { String message = e.getMessage(); assertTrue(message, message.contains("Incorrect CachedValue use")); assertTrue(message, message.contains("foo")); assertTrue(message, message.contains("bar")); } }