### Question:
UserMapper implements DataMapper<User, UserDto> { @Override public User mapDtoToEntity(UserDto dto) { User user = getEmptyUser(); user.setGivenName(dto.getGivenName()); user.setSurname(dto.getSurname()); user.setId(dto.getId()); user.setMail(dto.getEmail()); user.setDepartment(dto.getDepartment()); user.setJobTitle(dto.getJobTitle()); user.setPhoto(dto.getPhoto()); logger.info("Mapped UserDto (id: " + dto.getId() + " ) to User"); return user; } @Autowired  UserMapper(AppEnvironment appEnvironment); @Override User mapDtoToEntity(UserDto dto); @Override UserDto mapEntityToDto(User user); @Override Collection<User> mapDtosToEntities(Collection<UserDto> userDtos); @Override Collection<UserDto> mapEntitiesToDtos(Collection<User> users);  }### Answer:
@Test public void test_mapDtoToEntity_aadUser_ShouldMapCorrectly() { when(appEnvironment.getAuthMode()).thenReturn(AuthModes.AZURE); User user = userMapper.mapDtoToEntity(userDto1); Assert.assertThat(user, instanceOf(AadUser.class)); assertDtoWithUser(userDto1, user); }
@Test public void test_mapDtoToEntity_localUser_ShouldMapCorrectly() { when(appEnvironment.getAuthMode()).thenReturn(AuthModes.LOCAL); User user = userMapper.mapDtoToEntity(userDto1); Assert.assertThat(user, instanceOf(LocalUser.class)); assertDtoWithUser(userDto1, user); }