DbMapper { public List<com.nilhcem.droidconde.data.app.model.Session> toAppSessions(@NonNull List<Session> from, @NonNull Map<Integer, com.nilhcem.droidconde.data.app.model.Speaker> speakersMap) { return stream(from).map(session -> { LocalDateTime fromTime = localDateTimeAdapter.fromText(session.startAt); return new com.nilhcem.droidconde.data.app.model.Session(session.id, Room.getFromId(session.roomId).label, appMapper.toSpeakersList(deserialize(session.speakersIds), speakersMap), session.title, session.description, fromTime, fromTime.plusMinutes(session.duration)); }).collect(Collectors.toList()); } @Inject  DbMapper(Moshi moshi, AppMapper appMapper, LocalDateTimeAdapter localDateTimeAdapter); List<com.nilhcem.droidconde.data.app.model.Session> toAppSessions(@NonNull List<Session> from, @NonNull Map<Integer, com.nilhcem.droidconde.data.app.model.Speaker> speakersMap); Session fromAppSession(@Nullable com.nilhcem.droidconde.data.app.model.Session from); Speaker fromAppSpeaker(@Nullable com.nilhcem.droidconde.data.app.model.Speaker from); List<com.nilhcem.droidconde.data.app.model.Speaker> toAppSpeakers(@Nullable List<Speaker> from);  }
@Test public void should_convert_db_sessions_to_app_sessions() { when(adapter.fromText("now")).thenReturn(now); com.nilhcem.droidconde.data.database.model.Session session = new com.nilhcem.droidconde.data.database.model.Session(2, "now", 10, 3, "[1]", "title", "description"); List<com.nilhcem.droidconde.data.database.model.Session> sessions = singletonList(session); Map<Integer, Speaker> speakersMap = new HashMap<>(); Speaker speaker = new Speaker(1, "name", null, null, null, null, null, null); speakersMap.put(1, speaker); List<Session> result = dbMapper.toAppSessions(sessions, speakersMap); assertThat(result).hasSize(1); assertThat(result.get(0).getId()).isEqualTo(2); assertThat(result.get(0).getFromTime()).isEqualTo(now); assertThat(result.get(0).getTitle()).isEqualTo("title"); assertThat(result.get(0).getDescription()).isEqualTo("description"); assertThat(result.get(0).getSpeakers().get(0)).isEqualTo(speaker); }