@Before public void setUp() { FacebookPhotosInterface photosInterface = mock(FacebookPhotosInterface.class); // Set up example album Album album = new Album(); album.setId(ALBUM_ID); album.setName(ALBUM_NAME); album.setDescription(ALBUM_DESCRIPTION); ArrayList<Album> albums = new ArrayList<>(); albums.add(album); @SuppressWarnings("unchecked") Connection<Album> albumConnection = mock(Connection.class); when(photosInterface.getAlbums(Mockito.any())).thenReturn(albumConnection); when(albumConnection.getData()).thenReturn(albums); // Set up example photo Photo photo = new Photo(); photo.setId(PHOTO_ID); Photo.Image image = new Photo.Image(); image.setSource(PHOTO_SOURCE); photo.addImage(image); photo.setName(PHOTO_NAME); ArrayList<Photo> photos = new ArrayList<>(); photos.add(photo); @SuppressWarnings("unchecked") Connection<Photo> photoConnection = mock(Connection.class); when(photosInterface.getPhotos(ALBUM_ID, Optional.empty())).thenReturn(photoConnection); when(photoConnection.getData()).thenReturn(photos); facebookPhotosExporter = new FacebookPhotosExporter(new AppCredentials("key", "secret"), photosInterface); }