NetworkMapper { public List<com.nilhcem.droidcontn.data.app.model.Session> toAppSessions(@Nullable List<Session> from, @NonNull Map<Integer, com.nilhcem.droidcontn.data.app.model.Speaker> speakersMap) { if (from == null) { return null; } return stream(from).map(session -> new com.nilhcem.droidcontn.data.app.model.Session(session.getId(), Room.getFromId(session.getRoomId()).name, appMapper.toSpeakersList(session.getSpeakersId(), speakersMap), session.getTitle(), session.getDescription(), session.getStartAt(), session.getStartAt().plusMinutes(session.getDuration())) ).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_sessions_to_app_sessions() { LocalDateTime startAt = LocalDateTime.now(); Session session = new Session(1, startAt, 20, Room.CESAR_1.id, singletonList(10), "title", "description"); Map<Integer, com.nilhcem.droidcontn.data.app.model.Speaker> speakersMap = new HashMap<>(); speakersMap.put(10, new com.nilhcem.droidcontn.data.app.model.Speaker(10, "ten", null, null, null, null, null, null)); List<com.nilhcem.droidcontn.data.app.model.Session> result = networkMapper.toAppSessions(singletonList(session), speakersMap); assertThat(result).hasSize(1); assertThat(result.get(0).getId()).isEqualTo(1); assertThat(result.get(0).getFromTime()).isEqualTo(startAt); assertThat(result.get(0).getToTime()).isEqualTo(startAt.plusMinutes(20)); assertThat(result.get(0).getRoom()).isEqualTo(Room.CESAR_1.name); assertThat(result.get(0).getSpeakers().get(0).getId()).isEqualTo(10); assertThat(result.get(0).getSpeakers().get(0).getName()).isEqualTo("ten"); assertThat(result.get(0).getTitle()).isEqualTo("title"); assertThat(result.get(0).getDescription()).isEqualTo("description"); }