AppMapper { public Map<Integer, Speaker> speakersToMap(@NonNull List<Speaker> from) { return stream(from).collect(Collectors.toMap(Speaker::getId, speaker -> speaker)); } @Inject  AppMapper(); Map<Integer, Speaker> speakersToMap(@NonNull List<Speaker> from); List<Speaker> toSpeakersList(@Nullable List<Integer> speakerIds, @NonNull Map<Integer, Speaker> speakersMap); List<Integer> toSpeakersIds(@Nullable List<Speaker> speakers); Schedule toSchedule(@NonNull List<Session> sessions);  }
@Test public void should_create_map_of_speakers_with_id_as_speakerId_and_value_as_speaker() { Map<Integer, Speaker> map = appMapper.speakersToMap(speakers); assertThat(map.get(10)).isEqualTo(speaker1); assertThat(map.get(20)).isEqualTo(speaker2); assertThat(map.get(30)).isEqualTo(speaker3); assertThat(map.get(40)).isEqualTo(speaker4); assertThat(map.get(50)).isEqualTo(speaker5); assertThat(map).doesNotContainKey(8); }