### Question:
OAuthClientDetailsMapper implements DataMapper<OAuthClientDetails, OAuthClientDetailsDto> { @Override public Collection<OAuthClientDetails> mapDtosToEntities(Collection<OAuthClientDetailsDto> input) { return input.stream().map(this::mapDtoToEntity).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 mapDtosToEntities_expectEmptyList() { Collection<OAuthClientDetailsDto> oauthClientDetailsDtoCollection = new ArrayList<>(); Collection<OAuthClientDetails> oauthClientDetailsCollection = oauthClientDetailsMapper.mapDtosToEntities(oauthClientDetailsDtoCollection); assertTrue(oauthClientDetailsCollection.isEmpty()); }
@Test public void mapDtosToEntities_expectAllMapped() { OAuthClientDetailsDto oauthClientDetailsDto1 = new OAuthClientDetailsDto(); oauthClientDetailsDto1.setClientId("Test123"); oauthClientDetailsDto1.setClientSecret("TestABC"); oauthClientDetailsDto1.setRefreshTokenValidity(10); oauthClientDetailsDto1.setAccessTokenValidity(10); oauthClientDetailsDto1.setWebServerRedirectUri("localhost"); OAuthClientDetailsDto oauthClientDetailsDto2 = new OAuthClientDetailsDto(); oauthClientDetailsDto2.setClientId("Test456"); oauthClientDetailsDto2.setClientSecret("TestDEF"); oauthClientDetailsDto2.setRefreshTokenValidity(20); oauthClientDetailsDto2.setAccessTokenValidity(20); oauthClientDetailsDto2.setWebServerRedirectUri("google.com"); Collection<OAuthClientDetailsDto> oauthClientDetailsDtoCollection = Arrays.asList(oauthClientDetailsDto1, oauthClientDetailsDto2); Collection<OAuthClientDetails> oauthClientDetailsCollection = oauthClientDetailsMapper.mapDtosToEntities(oauthClientDetailsDtoCollection); assertEquals(oauthClientDetailsDtoCollection.size(), oauthClientDetailsCollection.size()); Optional<OAuthClientDetails> firstOAuthClientDetails = oauthClientDetailsCollection.stream().findFirst(); Optional<OAuthClientDetails> secondOAuthClientDetails = oauthClientDetailsCollection.stream().skip(1).findFirst(); if (firstOAuthClientDetails.isPresent() && secondOAuthClientDetails.isPresent()) { assertEquals( oauthClientDetailsDto1.getClientId(), firstOAuthClientDetails.get().getClientId()); assertEquals( oauthClientDetailsDto1.getClientSecret(), firstOAuthClientDetails.get().getClientSecret()); assertEquals( oauthClientDetailsDto1.getAccessTokenValidity(), firstOAuthClientDetails.get().getAccessTokenValidity()); assertEquals( oauthClientDetailsDto1.getRefreshTokenValidity(), firstOAuthClientDetails.get().getRefreshTokenValidity()); } else { Assert.fail(); } }