use of org.mapstruct.ap.test.conditional.Employee in project mapstruct by mapstruct.
the class ConditionalQualifierTest method conditionalMethodWithSourceParameter.
@ProcessorTest
@WithClasses({ ConditionalMethodWithSourceParameterMapper.class })
public void conditionalMethodWithSourceParameter() {
ConditionalMethodWithSourceParameterMapper mapper = ConditionalMethodWithSourceParameterMapper.INSTANCE;
EmployeeDto dto = new EmployeeDto();
dto.setName("Tester");
dto.setUniqueIdNumber("SSID-001");
dto.setCountry(null);
Employee employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
dto.setCountry("UK");
employee = mapper.map(dto);
assertThat(employee.getNin()).isEqualTo("SSID-001");
assertThat(employee.getSsid()).isNull();
dto.setCountry("US");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isEqualTo("SSID-001");
dto.setCountry("CH");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
}
use of org.mapstruct.ap.test.conditional.Employee in project mapstruct by mapstruct.
the class ConditionalQualifierTest method conditionalClassQualifiers.
@ProcessorTest
@WithClasses({ ConditionalMethodWithClassQualifiersMapper.class })
public void conditionalClassQualifiers() {
ConditionalMethodWithClassQualifiersMapper mapper = ConditionalMethodWithClassQualifiersMapper.INSTANCE;
EmployeeDto dto = new EmployeeDto();
dto.setName("Tester");
dto.setUniqueIdNumber("SSID-001");
dto.setCountry(null);
Employee employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
dto.setCountry("UK");
employee = mapper.map(dto);
assertThat(employee.getNin()).isEqualTo("SSID-001");
assertThat(employee.getSsid()).isNull();
dto.setCountry("US");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isEqualTo("SSID-001");
dto.setCountry("CH");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
}
use of org.mapstruct.ap.test.conditional.Employee in project mapstruct by mapstruct.
the class ConditionalExpressionTest method conditionalExpressionInStaticClassMethod.
@ProcessorTest
@WithClasses({ ConditionalMethodsInUtilClassMapper.class })
public void conditionalExpressionInStaticClassMethod() {
ConditionalMethodsInUtilClassMapper mapper = ConditionalMethodsInUtilClassMapper.INSTANCE;
EmployeeDto dto = new EmployeeDto();
dto.setName("Tester");
dto.setUniqueIdNumber("SSID-001");
dto.setCountry(null);
Employee employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
dto.setCountry("UK");
employee = mapper.map(dto);
assertThat(employee.getNin()).isEqualTo("SSID-001");
assertThat(employee.getSsid()).isNull();
dto.setCountry("US");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isEqualTo("SSID-001");
dto.setCountry("CH");
employee = mapper.map(dto);
assertThat(employee.getNin()).isNull();
assertThat(employee.getSsid()).isNull();
}
Aggregations