Search in sources :

Example 81 with ProcessorTest

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

the class Issue1801Test method shouldIncludeBuildeType.

@ProcessorTest
public void shouldIncludeBuildeType() {
    ItemDTO item = ImmutableItemDTO.builder().id("test").build();
    Item target = ItemMapper.INSTANCE.map(item);
    assertThat(target).isNotNull();
    assertThat(target.getId()).isEqualTo("test");
}
Also used : Item(org.mapstruct.ap.test.bugs._1801.domain.Item) ImmutableItem(org.mapstruct.ap.test.bugs._1801.domain.ImmutableItem) ItemDTO(org.mapstruct.ap.test.bugs._1801.dto.ItemDTO) ImmutableItemDTO(org.mapstruct.ap.test.bugs._1801.dto.ImmutableItemDTO) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 82 with ProcessorTest

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

the class Issue2170Test method shouldGenerateCodeThatCompiles.

@ProcessorTest
public void shouldGenerateCodeThatCompiles() {
    AddressDto addressDto = AddressMapper.INSTANCE.toDto(new Address("10000", Collections.singletonList(new Person("Tester"))));
    assertThat(addressDto).isNotNull();
    assertThat(addressDto.getZipCode()).isEqualTo("10000");
    assertThat(addressDto.getPeople()).extracting(PersonDto::getName).containsExactly("Tester");
}
Also used : Address(org.mapstruct.ap.test.bugs._2170.entity.Address) AddressDto(org.mapstruct.ap.test.bugs._2170.dto.AddressDto) Person(org.mapstruct.ap.test.bugs._2170.entity.Person) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 83 with ProcessorTest

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

the class Issue2195Test method test.

@ProcessorTest
@WithClasses(Issue2195Mapper.class)
public void test() {
    Source source = new Source();
    source.setName("JohnDoe");
    TargetBase target = Issue2195Mapper.INSTANCE.map(source);
    assertThat(target).isInstanceOf(Target.class);
}
Also used : TargetBase(org.mapstruct.ap.test.bugs._2195.dto.TargetBase) Source(org.mapstruct.ap.test.bugs._2195.dto.Source) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest) WithClasses(org.mapstruct.ap.testutil.WithClasses)

Example 84 with ProcessorTest

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

the class Issue2544Test method shouldConvertEn.

// Parsing numbers is sensitive to locale settings (e.g. decimal point)
@ProcessorTest
@DefaultLocale("en")
public void shouldConvertEn() {
    Issue2544Mapper.Target target = Issue2544Mapper.INSTANCE.map("123.45679E6");
    assertThat(target).isNotNull();
    assertThat(target.getBigNumber()).isEqualTo(new BigDecimal("1.2345679E+8"));
}
Also used : BigDecimal(java.math.BigDecimal) DefaultLocale(org.junitpioneer.jupiter.DefaultLocale) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 85 with ProcessorTest

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

the class Issue2544Test method shouldConvertDe.

@ProcessorTest
@DefaultLocale("de")
public void shouldConvertDe() {
    Issue2544Mapper.Target target = Issue2544Mapper.INSTANCE.map("123,45679E6");
    assertThat(target).isNotNull();
    assertThat(target.getBigNumber()).isEqualTo(new BigDecimal("1.2345679E+8"));
}
Also used : BigDecimal(java.math.BigDecimal) DefaultLocale(org.junitpioneer.jupiter.DefaultLocale) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Aggregations

ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)314 WithClasses (org.mapstruct.ap.testutil.WithClasses)118 GeneratedSource (org.mapstruct.ap.testutil.runner.GeneratedSource)51 IssueKey (org.mapstruct.ap.testutil.IssueKey)39 XmlGregorianCalendarBean (org.mapstruct.ap.test.builtin.jodatime.bean.XmlGregorianCalendarBean)24 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)22 Date (java.util.Date)16 LocalDateTimeBean (org.mapstruct.ap.test.builtin.jodatime.bean.LocalDateTimeBean)16 Calendar (java.util.Calendar)13 LocalDateTime (org.joda.time.LocalDateTime)13 CarDto (org.mapstruct.ap.test.complex._target.CarDto)13 Car (org.mapstruct.ap.test.complex.source.Car)13 PersonDto (org.mapstruct.ap.test.constructor.PersonDto)13 GregorianCalendar (java.util.GregorianCalendar)12 XmlGregorianCalendarProperty (org.mapstruct.ap.test.builtin.bean.XmlGregorianCalendarProperty)12 Song (org.mapstruct.ap.test.nestedsourceproperties.source.Song)12 BigDecimal (java.math.BigDecimal)11 ChartEntry (org.mapstruct.ap.test.nestedsourceproperties._target.ChartEntry)11 DriverAndCarDto (org.mapstruct.ap.test.nullvaluemapping._target.DriverAndCarDto)11 DateTime (org.joda.time.DateTime)10