use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class WildCardTest method testWildCard.
@ProcessorTest
@WithClasses(SourceWildCardExtendsMapper.class)
public void testWildCard() {
// prepare source
SourceWildCardExtendsMapper.Wrapper<BigInteger> wrapper = new SourceWildCardExtendsMapper.Wrapper<>(new BigInteger("5"));
SourceWildCardExtendsMapper.Source source = new SourceWildCardExtendsMapper.Source(wrapper);
// action
SourceWildCardExtendsMapper.Target target = SourceWildCardExtendsMapper.INSTANCE.map(source);
// verify target
assertThat(target).isNotNull();
assertThat(target.getProp()).isEqualTo("5");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class SpringCompileOptionConstructorMapperTest method shouldConvertToTarget.
@ProcessorTest
public void shouldConvertToTarget() throws Exception {
// given
CustomerEntity customerEntity = new CustomerEntity();
customerEntity.setName("Samuel");
customerEntity.setGender(Gender.MALE);
CustomerRecordEntity customerRecordEntity = new CustomerRecordEntity();
customerRecordEntity.setCustomer(customerEntity);
customerRecordEntity.setRegistrationDate(createDate("31-08-1982 10:20:56"));
// when
CustomerRecordDto customerRecordDto = customerRecordMapper.asTarget(customerRecordEntity);
// then
assertThat(customerRecordDto).isNotNull();
assertThat(customerRecordDto.getCustomer()).isNotNull();
assertThat(customerRecordDto.getCustomer().getName()).isEqualTo("Samuel");
assertThat(customerRecordDto.getCustomer().getGender()).isEqualTo(GenderDto.M);
assertThat(customerRecordDto.getRegistrationDate()).isNotNull();
assertThat(customerRecordDto.getRegistrationDate().toString()).isEqualTo("1982-08-31T10:20:56.000+02:00");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class Jsr330ConstructorMapperTest method shouldConvertToTarget.
@ProcessorTest
public void shouldConvertToTarget() {
// given
CustomerEntity customerEntity = new CustomerEntity();
customerEntity.setName("Samuel");
customerEntity.setGender(Gender.MALE);
// when
CustomerDto customerDto = customerMapper.asTarget(customerEntity);
// then
assertThat(customerDto).isNotNull();
assertThat(customerDto.getName()).isEqualTo("Samuel");
assertThat(customerDto.getGender()).isEqualTo(GenderDto.M);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class Jsr330DefaultCompileOptionFieldMapperTest method shouldConvertToTarget.
@ProcessorTest
public void shouldConvertToTarget() {
// given
CustomerEntity customerEntity = new CustomerEntity();
customerEntity.setName("Samuel");
customerEntity.setGender(Gender.MALE);
// when
CustomerDto customerDto = customerMapper.asTarget(customerEntity);
// then
assertThat(customerDto).isNotNull();
assertThat(customerDto.getName()).isEqualTo("Samuel");
assertThat(customerDto.getGender()).isEqualTo(GenderDto.M);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class InnerClassesImportsTest method mapperRequiresInnerClassImports.
@ProcessorTest
@IssueKey("412")
public void mapperRequiresInnerClassImports() {
SourceWithInnerClass source = new SourceWithInnerClass();
source.setInnerClassMember(new SourceInnerClass(412));
TargetWithInnerClass target = InnerClassMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getInnerClassMember().getValue()).isEqualTo(412);
generatedSource.addComparisonToFixtureFor(InnerClassMapper.class);
}
Aggregations