CinemaResponseToCinema { public List<Cinema> map(CinemaResponse cinemaResponse) { List<Cinema> cinemas = new ArrayList<>(); if (cinemaResponse.getCinemas() != null){ for (int i = 0; i < cinemaResponse.getCinemas().size(); i++){ final Cinema cinema = new Cinema(); final CinemaNetwork response = cinemaResponse.getCinemas().get(i); cinema.setPage(cinemaResponse.getPage()); cinema.setTotalPages(cinemaResponse.getTotalPages()); cinema.setTotalResults(cinemaResponse.getTotalResults()); cinema.setId(response.getId()); cinema.setVoteAverage(response.getVoteAverage()); cinema.setTitle(response.getTitle()); cinema.setAdult(response.isAdult()); cinema.setDescription(response.getDescription()); cinema.setPosterUrl(response.getPosterUrl()); cinema.setReleaseDate(response.getReleaseDate()); cinema.setPopularity(response.getPopularity()); cinema.setGenres(response.getGenreIds()); cinemas.add(cinema); } } return cinemas; }  List<Cinema> map(CinemaResponse cinemaResponse); Cinema map(CinemaDetailResponse response);  }
@Test public void shouldMapId(){ doReturn(77).when(cinemaDetailResponseMock).getId(); final Cinema cinema = mapper.map(cinemaDetailResponseMock); assertThat(cinema.getId() , is(cinemaDetailResponseMock.getId())); }
@Test public void shouldMapListOfCinemas(){ CinemaNetwork cinemaNetwork = Mockito.mock(CinemaNetwork.class); doReturn(cinemaNetwork).when(cinemaNetworkListMock).get(eq(0)); doReturn(true).when(cinemaNetworkIteratorMock).hasNext(); doReturn(1).when(cinemaNetworkListMock).size(); doReturn(cinemaNetworkIteratorMock).when(cinemaNetworkListMock).iterator(); doReturn(cinemaNetworkListMock).when(cinemaResponseMock).getCinemas(); final List<Cinema> cinemaList = mapper.map(cinemaResponseMock); assertNotNull(cinemaList); assertEquals(cinemaNetworkListMock.size() , cinemaList.size()); assertFalse(cinemaList.isEmpty()); }