@Test public void savePhoto_shouldSavePhotoToCacheAndLocal() { final Photo photo = new Photo(1, 10, "a"); repository.savePhoto(photo); verify(remoteDataSource, never()).savePhoto(photo); verify(localDataSource, times(1)).savePhoto(photo); assertThat(repository.cachedPhotos.size(), is(1)); }
@Override public void savePhoto(@NonNull Photo photo) { photoLocalDataSource.savePhoto(photo); cachedPhotos.put(photo.getPhotoId(), photo); }
PhotoRepository implements PhotoDataSource { @Override public void savePhoto(@NonNull Photo photo) { photoLocalDataSource.savePhoto(photo); cachedPhotos.put(photo.getPhotoId(), photo); } }
PhotoRepository implements PhotoDataSource { @Override public void savePhoto(@NonNull Photo photo) { photoLocalDataSource.savePhoto(photo); cachedPhotos.put(photo.getPhotoId(), photo); } PhotoRepository(@NonNull PhotoDataSource photoRemoteDataSource,
                           @NonNull PhotoDataSource photoLocalDataSource); }
PhotoRepository implements PhotoDataSource { @Override public void savePhoto(@NonNull Photo photo) { photoLocalDataSource.savePhoto(photo); cachedPhotos.put(photo.getPhotoId(), photo); } PhotoRepository(@NonNull PhotoDataSource photoRemoteDataSource,
                           @NonNull PhotoDataSource photoLocalDataSource); @Override void getPhotos(@NonNull LoadPhotosCallback callback); @Override void getPhoto(int photoId, @NonNull LoadPhotoCallback callback); @Override void savePhoto(@NonNull Photo photo); @Override void deletePhoto(int photoId); @Override void deleteAllPhotos(); @Override void refreshPhotos(); }
PhotoRepository implements PhotoDataSource { @Override public void savePhoto(@NonNull Photo photo) { photoLocalDataSource.savePhoto(photo); cachedPhotos.put(photo.getPhotoId(), photo); } PhotoRepository(@NonNull PhotoDataSource photoRemoteDataSource,
                           @NonNull PhotoDataSource photoLocalDataSource); @Override void getPhotos(@NonNull LoadPhotosCallback callback); @Override void getPhoto(int photoId, @NonNull LoadPhotoCallback callback); @Override void savePhoto(@NonNull Photo photo); @Override void deletePhoto(int photoId); @Override void deleteAllPhotos(); @Override void refreshPhotos();  }