use of org.mapstruct.ap.test.updatemethods.SecretaryEntity in project mapstruct by mapstruct.
the class DepartmentMapperImpl method toSecretaryEntity.
@Override
public SecretaryEntity toSecretaryEntity(SecretaryDto dto) {
if (dto == null) {
return null;
}
SecretaryEntity secretaryEntity = new SecretaryEntity();
secretaryEntity.setName(dto.getName());
return secretaryEntity;
}
use of org.mapstruct.ap.test.updatemethods.SecretaryEntity in project mapstruct by mapstruct.
the class ExternalSelectionTest method shouldSelectGeneratedExternalMapperForIterablesAndMaps.
@ProcessorTest
@IssueKey("487")
public void shouldSelectGeneratedExternalMapperForIterablesAndMaps() {
DepartmentDto departmentDto = new DepartmentDto();
EmployeeDto employeeDto = new EmployeeDto();
employeeDto.setName("Sarah");
SecretaryDto secretaryDto = new SecretaryDto();
secretaryDto.setName("Jim");
departmentDto.setEmployees(Arrays.asList(employeeDto));
Map<SecretaryDto, EmployeeDto> secretaryToEmployee = new HashMap<>();
secretaryToEmployee.put(secretaryDto, employeeDto);
departmentDto.setSecretaryToEmployee(secretaryToEmployee);
DepartmentEntity departmentEntity = new DepartmentEntity(5);
DepartmentMapper.INSTANCE.toDepartmentEntity(departmentDto, departmentEntity);
assertThat(departmentEntity).isNotNull();
assertThat(departmentEntity.getEmployees()).isNotEmpty();
assertThat(departmentEntity.getEmployees().get(0).getName()).isEqualTo("Sarah");
assertThat(departmentEntity.getSecretaryToEmployee()).isNotEmpty();
Map.Entry<SecretaryEntity, EmployeeEntity> firstEntry = departmentEntity.getSecretaryToEmployee().entrySet().iterator().next();
assertThat(firstEntry.getKey().getName()).isEqualTo("Jim");
assertThat(firstEntry.getValue().getName()).isEqualTo("Sarah");
}
Aggregations