Search in sources :

Example 1 with CustomerRecordEntity

use of org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordEntity 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");
}
Also used : CustomerEntity(org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity) CustomerRecordDto(org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto) CustomerRecordEntity(org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordEntity) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 2 with CustomerRecordEntity

use of org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordEntity in project mapstruct by mapstruct.

the class SpringConstructorMapperTest 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");
}
Also used : CustomerEntity(org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity) CustomerRecordDto(org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto) CustomerRecordEntity(org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordEntity) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

CustomerEntity (org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity)2 CustomerRecordDto (org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordDto)2 CustomerRecordEntity (org.mapstruct.ap.test.injectionstrategy.shared.CustomerRecordEntity)2 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)2