Search in sources :

Example 36 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey 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");
}
Also used : DepartmentDto(org.mapstruct.ap.test.updatemethods.DepartmentDto) DepartmentEntity(org.mapstruct.ap.test.updatemethods.DepartmentEntity) ConstructableDepartmentEntity(org.mapstruct.ap.test.updatemethods.ConstructableDepartmentEntity) EmployeeDto(org.mapstruct.ap.test.updatemethods.EmployeeDto) HashMap(java.util.HashMap) EmployeeEntity(org.mapstruct.ap.test.updatemethods.EmployeeEntity) SecretaryDto(org.mapstruct.ap.test.updatemethods.SecretaryDto) HashMap(java.util.HashMap) Map(java.util.Map) SecretaryEntity(org.mapstruct.ap.test.updatemethods.SecretaryEntity) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 37 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class ExternalSelectionTest method shouldSelectGeneratedExternalMapperWithImportForPropertyType.

@ProcessorTest
@WithClasses({ OrganizationMapper3.class })
@IssueKey("604")
public void shouldSelectGeneratedExternalMapperWithImportForPropertyType() {
    generatedSource.addComparisonToFixtureFor(OrganizationMapper3.class);
    BossEntity entity = new BossEntity();
    BossDto dto = new BossDto();
    OrganizationMapper3.INSTANCE.toBossEntity(dto, entity);
}
Also used : BossEntity(org.mapstruct.ap.test.updatemethods.BossEntity) BossDto(org.mapstruct.ap.test.updatemethods.BossDto) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 38 with IssueKey

use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.

the class EnumToEnumMappingTest method shouldMapAnyRemainingToNullCorrectly.

@IssueKey("1091")
@ProcessorTest
public void shouldMapAnyRemainingToNullCorrectly() {
    ExternalOrderType externalOrderType = SpecialOrderMapper.INSTANCE.anyRemainingToNull(OrderType.RETAIL);
    assertThat(externalOrderType).isNotNull().isEqualTo(ExternalOrderType.RETAIL);
    externalOrderType = SpecialOrderMapper.INSTANCE.anyRemainingToNull(OrderType.B2B);
    assertThat(externalOrderType).isNotNull().isEqualTo(ExternalOrderType.B2B);
    externalOrderType = SpecialOrderMapper.INSTANCE.anyRemainingToNull(OrderType.EXTRA);
    assertThat(externalOrderType).isNull();
    externalOrderType = SpecialOrderMapper.INSTANCE.anyRemainingToNull(OrderType.STANDARD);
    assertThat(externalOrderType).isNull();
    externalOrderType = SpecialOrderMapper.INSTANCE.anyRemainingToNull(OrderType.NORMAL);
    assertThat(externalOrderType).isNull();
}
Also used : ExternalOrderType(org.mapstruct.ap.test.value.ExternalOrderType) IssueKey(org.mapstruct.ap.testutil.IssueKey) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

IssueKey (org.mapstruct.ap.testutil.IssueKey)38 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)36 WithClasses (org.mapstruct.ap.testutil.WithClasses)14 Date (java.util.Date)6 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)6 BigInteger (java.math.BigInteger)4 Target (org.mapstruct.ap.test.collection.adder._target.Target)4 SingleElementSource (org.mapstruct.ap.test.collection.adder.source.SingleElementSource)4 BigDecimal (java.math.BigDecimal)3 HashMap (java.util.HashMap)3 Source (org.mapstruct.ap.test.collection.adder.source.Source)3 OriginalRelease (org.mapstruct.ap.test.selection.qualifier.bean.OriginalRelease)3 Time (java.sql.Time)2 Timestamp (java.sql.Timestamp)2 SimpleDateFormat (java.text.SimpleDateFormat)2 GregorianCalendar (java.util.GregorianCalendar)2 List (java.util.List)2 ListAssert (org.assertj.core.api.ListAssert)2 Test (org.junit.Test)2 Target (org.mapstruct.ap.test.bugs._1170._target.Target)2