### Question:
OAuthClientDetailsMapper implements DataMapper<OAuthClientDetails, OAuthClientDetailsDto> { @Override public Collection<OAuthClientDetailsDto> mapEntitiesToDtos(Collection<OAuthClientDetails> input) { return input.stream().map(this::mapEntityToDto).collect(Collectors.toList()); }  @Override OAuthClientDetails mapDtoToEntity(OAuthClientDetailsDto input); @Override OAuthClientDetailsDto mapEntityToDto(OAuthClientDetails input); @Override Collection<OAuthClientDetails> mapDtosToEntities(Collection<OAuthClientDetailsDto> input); @Override Collection<OAuthClientDetailsDto> mapEntitiesToDtos(Collection<OAuthClientDetails> input);  }### Answer:
@Test public void mapEntitiesToDtos_expectEmptyList() { Collection<OAuthClientDetails> oauthClientDetailsCollection = new ArrayList<>(); Collection<OAuthClientDetailsDto> oauthClientDetailsDtoCollection = oauthClientDetailsMapper.mapEntitiesToDtos(oauthClientDetailsCollection); assertTrue(oauthClientDetailsDtoCollection.isEmpty()); }
@Test public void mapEntitiesToDtos_expectAllMapped() { OAuthClientDetails oauthClientDetails1 = new OAuthClientDetails(); oauthClientDetails1.setClientId("Test123"); oauthClientDetails1.setClientSecret("TestABC"); oauthClientDetails1.setRefreshTokenValidity(10); oauthClientDetails1.setAccessTokenValidity(10); oauthClientDetails1.setWebServerRedirectUri("localhost"); oauthClientDetails1.setAdditionalInformation("Hallo 123"); oauthClientDetails1.setAuthorities("Authorities"); oauthClientDetails1.setAuthorizedGrantTypes("Grant Types"); oauthClientDetails1.setAutoapprove("OKR Tool Approves"); oauthClientDetails1.setResourceIds("Resource Ids"); oauthClientDetails1.setScope("scope"); OAuthClientDetails oauthClientDetails2 = new OAuthClientDetails(); oauthClientDetails2.setClientId("Test456"); oauthClientDetails2.setClientSecret("TestDEF"); oauthClientDetails2.setRefreshTokenValidity(20); oauthClientDetails2.setAccessTokenValidity(20); oauthClientDetails2.setWebServerRedirectUri("google.com"); oauthClientDetails2.setAdditionalInformation("Hallo 123"); oauthClientDetails2.setAuthorities("Authorities"); oauthClientDetails2.setAuthorizedGrantTypes("Grant Types"); oauthClientDetails2.setAutoapprove("OKR Tool Approves"); oauthClientDetails2.setResourceIds("Resource Ids"); oauthClientDetails2.setScope("scope"); Collection<OAuthClientDetails> oauthClientDetailsCollection = Arrays.asList(oauthClientDetails1, oauthClientDetails2); Collection<OAuthClientDetailsDto> oauthClientDetailsDtoCollection = oauthClientDetailsMapper.mapEntitiesToDtos(oauthClientDetailsCollection); assertEquals(oauthClientDetailsCollection.size(), oauthClientDetailsDtoCollection.size()); Optional<OAuthClientDetailsDto> firstOAuthClientDetailsDto = oauthClientDetailsDtoCollection.stream().findFirst(); Optional<OAuthClientDetailsDto> secondOAuthClientDetailsDto = oauthClientDetailsDtoCollection.stream().skip(1).findFirst(); if (firstOAuthClientDetailsDto.isPresent() && secondOAuthClientDetailsDto.isPresent()) { assertEquals( oauthClientDetails1.getClientId(), firstOAuthClientDetailsDto.get().getClientId()); assertEquals( oauthClientDetails1.getClientSecret(), firstOAuthClientDetailsDto.get().getClientSecret()); assertEquals( oauthClientDetails1.getAccessTokenValidity(), firstOAuthClientDetailsDto.get().getAccessTokenValidity()); assertEquals( oauthClientDetails1.getRefreshTokenValidity(), firstOAuthClientDetailsDto.get().getRefreshTokenValidity()); } else { Assert.fail(); } }