UniversalBaseDiscCache extends UniversalDiscCache { @Override public synchronized void initialize() { if (cacheDir.exists()) { return; } if (!cacheDir.mkdir()) { VolleyLog.e("Unable to create cache dir %s", cacheDir.getAbsolutePath()); } } protected  UniversalBaseDiscCache(File cacheDir, DiscCacheAware delegate); @Override synchronized void initialize();  }
@Test public void mkdirShoudNotBeCalledWhenDirectoryExists() { File cacheDir = mock(File.class); given(cacheDir.exists()).willReturn(true); UniversalBaseDiscCache discCache = new UniversalBaseDiscCache(cacheDir, delegate){}; discCache.initialize(); verify(cacheDir, never()).mkdir(); }
@Test public void mkdirShoudBeCalledWhenDirectoryNotExists() { File cacheDir = mock(File.class); given(cacheDir.exists()).willReturn(false); given(cacheDir.mkdir()).willReturn(true); UniversalBaseDiscCache discCache = new UniversalBaseDiscCache(cacheDir, delegate){}; discCache.initialize(); verify(cacheDir).mkdir(); }