Search in sources :

Example 1 with CustomerEntity

use of org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity 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 CustomerEntity

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

Example 3 with CustomerEntity

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

Example 4 with CustomerEntity

use of org.mapstruct.ap.test.injectionstrategy.shared.CustomerEntity 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)

Example 5 with CustomerEntity

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

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

Aggregations

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