### Question:
UserSettingsMapper implements DataMapper<UserSettings, UserSettingsDto> { @Override public UserSettings mapDtoToEntity(UserSettingsDto dto) { UserSettings entity = new UserSettings(); entity.setId(dto.getId()); if (dto.getDefaultCompanyId() != null) { OkrCompany mockOkrCompany = new OkrCompany(); mockOkrCompany.setId(dto.getDefaultCompanyId()); entity.setDefaultOkrCompany(mockOkrCompany); } if (dto.getDefaultTeamId() != null) { OkrDepartment mockOkrDepartment = new OkrDepartment(); mockOkrDepartment.setId(dto.getDefaultTeamId()); entity.setDefaultTeam(mockOkrDepartment); } return entity; }  @Override UserSettings mapDtoToEntity(UserSettingsDto dto); @Override UserSettingsDto mapEntityToDto(UserSettings entity); @Override Collection<UserSettings> mapDtosToEntities(Collection<UserSettingsDto> input); @Override Collection<UserSettingsDto> mapEntitiesToDtos(Collection<UserSettings> input);  }### Answer:
@Test public void test_mapDtoToEntity_ExpectIdIsMapped() { Long id = 42L; this.dto.setId(id); this.entity = this.mapper.mapDtoToEntity(dto); Assert.assertEquals(id, this.entity.getId()); }
@Test public void test_mapDtoToEntity_ExpectCompanyIsNullIfThereIsNoCompanyId() { this.entity = this.mapper.mapDtoToEntity(dto); Assert.assertNull(this.entity.getDefaultOkrCompany()); }
@Test public void test_mapDtoToEntity_ExpectDefaultCompanyIsMapped() { Long defaultCompanyId = 50L; this.dto.setDefaultCompanyId(defaultCompanyId); this.entity = this.mapper.mapDtoToEntity(dto); Assert.assertEquals(defaultCompanyId, this.entity.getDefaultOkrCompany().getId()); }
@Test public void test_mapDtoToEntity_ExpectTeamIsNullIfThereIsNoTeamId() { this.entity = this.mapper.mapDtoToEntity(dto); Assert.assertNull(this.entity.getDefaultTeam()); }
@Test public void test_mapDtoToEntity_ExpectDefaultTeamIsMapped() { Long defaultTeamId = 40L; this.dto.setDefaultTeamId(defaultTeamId); this.entity = this.mapper.mapDtoToEntity(dto); Assert.assertEquals(defaultTeamId, this.entity.getDefaultTeam().getId()); }