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);
}
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);
}
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");
}
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));
}
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();
}
Aggregations