### Question:
PlatformIssueServiceImpl implements PlatformIssueService { @Override public Optional<PlatformIssueDto> findBy(final Platform platform, final String platformId) { if (Platform.GITHUB == platform) { return githubIssueService.findBy(platformId) .map(githubIssue -> mappers.map(GithubIssue.class, PlatformIssueDto.class, githubIssue)); } return Optional.empty(); } PlatformIssueServiceImpl(final GithubIssueService githubIssueService, final Mappers mappers); @Override Optional<PlatformIssueDto> findBy(final Platform platform, final String platformId);  }### Answer:
@Test void findBy() { final String platformId = "dfsfd|FR|wfgwar|FR|243"; final GithubIssue githubIssue = GithubIssue.builder().build(); final PlatformIssueDto platformIssueDto = PlatformIssueDto.builder().build(); when(githubIssueService.findBy(platformId)).thenReturn(Optional.of(githubIssue)); when(mappers.map(GithubIssue.class, PlatformIssueDto.class, githubIssue)).thenReturn(platformIssueDto); final Optional<PlatformIssueDto> result = platformIssueService.findBy(Platform.GITHUB, platformId); assertThat(result).isPresent().containsSame(platformIssueDto); }
@Test void findBy_noGithubIssueFound() { final String platformId = "dfsfd|FR|wfgwar|FR|243"; when(githubIssueService.findBy(platformId)).thenReturn(Optional.empty()); final Optional<PlatformIssueDto> result = platformIssueService.findBy(Platform.GITHUB, platformId); assertThat(result).isEmpty(); }
@Test void findBy_platformNotGithub() { final String platformId = "dfsfd|FR|wfgwar|FR|243"; final GithubIssue githubIssue = GithubIssue.builder().build(); final PlatformIssueDto platformIssueDto = PlatformIssueDto.builder().build(); when(githubIssueService.findBy(platformId)).thenReturn(Optional.of(githubIssue)); when(mappers.map(GithubIssue.class, PlatformIssueDto.class, githubIssue)).thenReturn(platformIssueDto); final Optional<PlatformIssueDto> result = platformIssueService.findBy(Platform.STACK_OVERFLOW, platformId); assertThat(result).isEmpty(); }