DbMapper { public Session fromAppSession(@Nullable com.nilhcem.devoxxfr.data.app.model.Session from) { if (from == null) { return null; } return new Session(from.getId(), localDateTimeAdapter.toText(from.getFromTime()), (int) ChronoUnit.MINUTES.between(from.getFromTime(), from.getToTime()), Room.getFromName(from.getRoom()).id, serialize(appMapper.toSpeakersIds(from.getSpeakers())), from.getTitle(), from.getDescription()); } @Inject  DbMapper(Moshi moshi, AppMapper appMapper, LocalDateTimeAdapter localDateTimeAdapter); List<com.nilhcem.devoxxfr.data.app.model.Session> toAppSessions(@NonNull List<Session> from, @NonNull Map<Integer, com.nilhcem.devoxxfr.data.app.model.Speaker> speakersMap); Session fromAppSession(@Nullable com.nilhcem.devoxxfr.data.app.model.Session from); Speaker fromAppSpeaker(@Nullable com.nilhcem.devoxxfr.data.app.model.Speaker from); List<com.nilhcem.devoxxfr.data.app.model.Speaker> toAppSpeakers(@Nullable List<Speaker> from);  }
@Test public void should_convert_app_session_to_db_session() { List<Speaker> speakers = singletonList(new Speaker(7, null, null, null, null, null, null, null)); Session session = new Session(11, Room.EXHIBITION_FLOOR.name, speakers, "title", "description", now, now.plusMinutes(45)); com.nilhcem.devoxxfr.data.database.model.Session result = dbMapper.fromAppSession(session); assertThat(result.id).isEqualTo(11); assertThat(result.roomId).isEqualTo(Room.EXHIBITION_FLOOR.id); assertThat(result.speakersIds).isEqualTo("[7]"); assertThat(result.title).isEqualTo("title"); assertThat(result.description).isEqualTo("description"); }