Search in sources :

Example 86 with ProcessorTest

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

the class Issue2023Test method shouldUseDefaultExpressionCorrectly.

@ProcessorTest
public void shouldUseDefaultExpressionCorrectly() {
    PersonDto person = new PersonDto();
    person.setName("John");
    person.setEmail("john@doe.com");
    NewPersonRequest request = Issue2023Mapper.INSTANCE.createRequest(person, null);
    assertThat(request).isNotNull();
    assertThat(request.getName()).isEqualTo("John");
    assertThat(request.getEmail()).isEqualTo("john@doe.com");
    assertThat(request.getCorrelationId()).isNotNull();
    UUID correlationId = UUID.randomUUID();
    request = Issue2023Mapper.INSTANCE.createRequest(person, correlationId);
    assertThat(request).isNotNull();
    assertThat(request.getName()).isEqualTo("John");
    assertThat(request.getEmail()).isEqualTo("john@doe.com");
    assertThat(request.getCorrelationId()).isEqualTo(correlationId);
}
Also used : UUID(java.util.UUID) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 87 with ProcessorTest

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

the class Issue843Test method testMapperCreation.

@ProcessorTest
public void testMapperCreation() {
    Commit commit = new Commit();
    commit.setAuthoredDate(new Date());
    GitlabTag gitlabTag = new GitlabTag();
    gitlabTag.setCommit(commit);
    Commit.resetCallCounter();
    GitlabTag.resetCallCounter();
    TagMapper.INSTANCE.gitlabTagToTagInfo(gitlabTag);
    assertThat(Commit.getCallCounter()).isEqualTo(1);
    assertThat(GitlabTag.getCallCounter()).isEqualTo(1);
}
Also used : Date(java.util.Date) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 88 with ProcessorTest

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

the class Issue2352Test method shouldGenerateValidCode.

@ProcessorTest
public void shouldGenerateValidCode() {
    TheModels theModels = new TheModels();
    theModels.add(new TheModel("1"));
    theModels.add(new TheModel("2"));
    List<TheDto> theDtos = TheModelsMapper.INSTANCE.convert(theModels);
    assertThat(theDtos).extracting(TheDto::getId).containsExactly("1", "2");
}
Also used : TheDto(org.mapstruct.ap.test.bugs._2352.dto.TheDto) TheModel(org.mapstruct.ap.test.bugs._2352.dto.TheModel) TheModels(org.mapstruct.ap.test.bugs._2352.dto.TheModels) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 89 with ProcessorTest

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

the class Java8CustomPatternDateTimeFormatterGeneratedTest method testDateTimeFormattersGenerated.

@ProcessorTest
public void testDateTimeFormattersGenerated() {
    Source source = new Source();
    source.setLocalDateTime1(LocalDateTime.of(2021, Month.MAY, 16, 12, 13, 10));
    source.setLocalDateTime2(LocalDateTime.of(2020, Month.APRIL, 10, 15, 10, 12));
    source.setLocalDateTime3(LocalDateTime.of(2021, Month.APRIL, 25, 9, 46, 13));
    Target target = SourceTargetMapper.INSTANCE.map(source);
    assertThat(target.getLocalDateTime1()).isEqualTo("16.05.2021 12:13");
    assertThat(target.getLocalDateTime2()).isEqualTo("10.04.2020 15:10");
    assertThat(target.getLocalDateTime3()).isEqualTo("25.04.2021 09.46");
    source = SourceTargetMapper.INSTANCE.map(target);
    assertThat(source.getLocalDateTime1()).isEqualTo(LocalDateTime.of(2021, Month.MAY, 16, 12, 13, 0));
    assertThat(source.getLocalDateTime2()).isEqualTo(LocalDateTime.of(2020, Month.APRIL, 10, 15, 10, 0));
    assertThat(source.getLocalDateTime3()).isEqualTo(LocalDateTime.of(2021, Month.APRIL, 25, 9, 46, 0));
}
Also used : Target(org.mapstruct.ap.test.conversion.java8time.custompatterndatetimeformattergenerated.Target) Source(org.mapstruct.ap.test.conversion.java8time.custompatterndatetimeformattergenerated.Source) GeneratedSource(org.mapstruct.ap.testutil.runner.GeneratedSource) ProcessorTest(org.mapstruct.ap.testutil.ProcessorTest)

Example 90 with ProcessorTest

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

the class LocalDateTimeToXMLGregorianCalendarConversionTest method shouldNullCheckOnConversionToSource.

@ProcessorTest
public void shouldNullCheckOnConversionToSource() {
    Source source = SourceTargetMapper.INSTANCE.toSource(new Target());
    assertThat(source).isNotNull();
    assertThat(source.getXmlGregorianCalendar()).isNull();
}
Also used : Target(org.mapstruct.ap.test.conversion.java8time.localdatetimetoxmlgregoriancalendarconversion.Target) Source(org.mapstruct.ap.test.conversion.java8time.localdatetimetoxmlgregoriancalendarconversion.Source) 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