NetworkMapper { public List<com.nilhcem.droidcontn.data.app.model.Speaker> toAppSpeakers(@Nullable List<Speaker> from) { if (from == null) { return null; } return stream(from).map(speaker -> new com.nilhcem.droidcontn.data.app.model.Speaker( speaker.getId(), speaker.getName(), speaker.getTitle(), speaker.getBio(), speaker.getWebsite(), speaker.getTwitter(), speaker.getGithub(), speaker.getPhoto()) ).collect(Collectors.toList()); } @Inject  NetworkMapper(AppMapper appMapper); List<com.nilhcem.droidcontn.data.app.model.Speaker> toAppSpeakers(@Nullable List<Speaker> from); List<com.nilhcem.droidcontn.data.app.model.Session> toAppSessions(@Nullable List<Session> from, @NonNull Map<Integer, com.nilhcem.droidcontn.data.app.model.Speaker> speakersMap);  }
@Test public void should_convert_network_speakers_to_app_speakers() { Speaker speaker1 = new Speaker(1, "speaker1", "title1", "bio1", "website1", "twitter1", "github1", "photo1"); Speaker speaker2 = new Speaker(2, "speaker2", "title2", "bio2", "website2", "twitter2", "github2", "photo2"); List<Speaker> speakers = Arrays.asList(speaker1, speaker2); List<com.nilhcem.droidcontn.data.app.model.Speaker> result = networkMapper.toAppSpeakers(speakers); assertThat(result).hasSize(2); assertThat(result.get(0).getId()).isEqualTo(1); assertThat(result.get(0).getName()).isEqualTo("speaker1"); assertThat(result.get(0).getTitle()).isEqualTo("title1"); assertThat(result.get(0).getBio()).isEqualTo("bio1"); assertThat(result.get(0).getWebsite()).isEqualTo("website1"); assertThat(result.get(0).getTwitter()).isEqualTo("twitter1"); assertThat(result.get(0).getGithub()).isEqualTo("github1"); assertThat(result.get(0).getPhoto()).isEqualTo("photo1"); assertThat(result.get(1).getId()).isEqualTo(2); assertThat(result.get(1).getName()).isEqualTo("speaker2"); assertThat(result.get(1).getTitle()).isEqualTo("title2"); assertThat(result.get(1).getBio()).isEqualTo("bio2"); assertThat(result.get(1).getWebsite()).isEqualTo("website2"); assertThat(result.get(1).getTwitter()).isEqualTo("twitter2"); assertThat(result.get(1).getGithub()).isEqualTo("github2"); assertThat(result.get(1).getPhoto()).isEqualTo("photo2"); }