UserCacheImpl implements UserCache { @Override public synchronized void get(int userId, UserCacheCallback callback) { File userEntitiyFile = this.buildFile(userId); String fileContent = this.fileManager.readFileContent(userEntitiyFile); UserEntity userEntity = this.serializer.deserialize(fileContent); if (userEntity != null) { callback.onUserEntityLoaded(userEntity); } else { callback.onError(new UserNotFoundException()); } }  @Override synchronized void get(int userId, UserCacheCallback callback); @Override synchronized void put(UserEntity userEntity); @Override boolean isCached(int userId); @Override boolean isExpired(); @Override synchronized void evictAll();  }
@Test public void testGetFromCacheHappyCase() { given(mockJsonSerializer.deserialize(anyString())).willReturn(mockUserEntity); userCache.get(FAKE_USER_ID, mockUserCacheCallback); verify(mockFileManager).readFileContent(any(File.class)); verify(mockJsonSerializer).deserialize(anyString()); verify(mockUserCacheCallback).onUserEntityLoaded(mockUserEntity); }