### Question:
BuildCacheUtils { @NonNull @VisibleForTesting static FileCache createBuildCache( @Nullable String buildCacheDir, @NonNull Function<Object, File> pathToFileResolver, @NonNull Supplier<File> defaultBuildCacheDirSupplier, @NonNull String pluginVersion) { File sharedBuildCacheDir = buildCacheDir != null ? pathToFileResolver.apply(buildCacheDir) : defaultBuildCacheDirSupplier.get(); return FileCache.getInstanceWithMultiProcessLocking( new File(sharedBuildCacheDir, pluginVersion)); }  @SuppressWarnings("ResultOfMethodCallIgnored") @Nullable static FileCache createBuildCacheIfEnabled(
            @NonNull Project project, @NonNull ProjectOptions projectOptions); @NonNull static final String BUILD_CACHE_TROUBLESHOOTING_MESSAGE; }### Answer:
@Test public void testCreateBuildCache_DirectorySet() throws IOException { File buildCacheDir = testDir.newFolder(); Function<Object, File> pathToFileResolver = (path) -> new File(path.toString()); Supplier<File> defaultBuildCacheDirSupplier = () -> { fail("This should not run"); return null; }; FileCache buildCache = BuildCacheUtils.createBuildCache( buildCacheDir.getPath(), pathToFileResolver, defaultBuildCacheDirSupplier, fakePluginVersion); assertThat(buildCache.getCacheDirectory()) .isEqualTo(new File(buildCacheDir, fakePluginVersion)); }
@Test public void testCreateBuildCache_DirectoryNotSet() throws IOException { File defaultBuildCacheDir = testDir.newFolder(); Function<Object, File> pathToFileResolver = (path) -> { fail("This should not run"); return null; }; Supplier<File> defaultBuildCacheDirSupplier = () -> defaultBuildCacheDir; FileCache buildCache = BuildCacheUtils.createBuildCache( null, pathToFileResolver, defaultBuildCacheDirSupplier, fakePluginVersion); assertThat(buildCache.getCacheDirectory()) .isEqualTo(new File(defaultBuildCacheDir, fakePluginVersion)); }