### Question:
XdgDirectories { public static Path getCacheHome() { return getCacheHome(System.getProperties(), System.getenv()); } private  XdgDirectories(); static Path getCacheHome(); static Path getConfigHome();  }### Answer:
@Test public void testGetCacheHome_hasXdgCacheHome() { Properties fakeProperties = new Properties(); fakeProperties.setProperty("user.home", fakeCacheHome); Map<String, String> fakeEnvironment = ImmutableMap.of("XDG_CACHE_HOME", fakeCacheHome); fakeProperties.setProperty("os.name", "linux"); Assert.assertEquals( Paths.get(fakeCacheHome).resolve("google-cloud-tools-java").resolve("jib"), XdgDirectories.getCacheHome(fakeProperties, fakeEnvironment)); fakeProperties.setProperty("os.name", "windows"); Assert.assertEquals( Paths.get(fakeCacheHome).resolve("Google").resolve("Jib").resolve("Cache"), XdgDirectories.getCacheHome(fakeProperties, fakeEnvironment)); fakeProperties.setProperty("os.name", "mac"); Assert.assertEquals( Paths.get(fakeCacheHome).resolve("Google").resolve("Jib"), XdgDirectories.getCacheHome(fakeProperties, fakeEnvironment)); }
@Test public void testGetCacheHome_linux() { Properties fakeProperties = new Properties(); fakeProperties.setProperty("user.home", fakeCacheHome); fakeProperties.setProperty("os.name", "os is LiNuX"); Assert.assertEquals( Paths.get(fakeCacheHome, ".cache").resolve("google-cloud-tools-java").resolve("jib"), XdgDirectories.getCacheHome(fakeProperties, Collections.emptyMap())); }
@Test public void testGetCacheHome_windows() { Properties fakeProperties = new Properties(); fakeProperties.setProperty("user.home", "nonexistent"); fakeProperties.setProperty("os.name", "os is WiNdOwS"); Map<String, String> fakeEnvironment = ImmutableMap.of("LOCALAPPDATA", fakeCacheHome); Assert.assertEquals( Paths.get(fakeCacheHome).resolve("Google").resolve("Jib").resolve("Cache"), XdgDirectories.getCacheHome(fakeProperties, fakeEnvironment)); }
@Test public void testGetCacheHome_mac() throws IOException { Path libraryApplicationSupport = Paths.get(fakeCacheHome, "Library", "Caches"); Files.createDirectories(libraryApplicationSupport); Properties fakeProperties = new Properties(); fakeProperties.setProperty("user.home", fakeCacheHome); fakeProperties.setProperty("os.name", "os is mAc or DaRwIn"); Assert.assertEquals( libraryApplicationSupport.resolve("Google").resolve("Jib"), XdgDirectories.getCacheHome(fakeProperties, Collections.emptyMap())); }