use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class ArrayMappingTest method shouldCopyArraysInBean.
@ProcessorTest
public void shouldCopyArraysInBean() {
Scientist source = new Scientist("Bob");
source.setPublications(new String[] { "the Lancet", "Nature" });
source.publicPublications = new String[] { "public the Lancet", "public Nature" };
ScientistDto dto = ScienceMapper.INSTANCE.scientistToDto(source);
assertThat(dto).isNotNull();
assertThat(dto).isNotEqualTo(source);
assertThat(dto.getPublications()).containsOnly("the Lancet", "Nature");
assertThat(dto.publicPublications).containsOnly("public the Lancet", "public Nature");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class AdderTest method testWildcardAdderTargetToSource.
@IssueKey("1170")
@ProcessorTest
public void testWildcardAdderTargetToSource() {
Target target = new Target();
target.addWithoutWildcard(2L);
target.addWildcardInTarget(2L);
target.getWildcardInSources().add(2L);
target.addWildcardInBoth(2L);
target.setWildcardAdderToSetters(Arrays.asList(2L));
Source source = AdderSourceTargetMapper.INSTANCE.toSource(target);
assertThat(source).isNotNull();
assertThat(source.getWithoutWildcards()).containsExactly("mouse");
((ListAssert<String>) assertThat(source.getWildcardInSources())).containsExactly("mouse");
assertThat(source.getWildcardInTargets()).containsExactly("mouse");
((ListAssert<String>) assertThat(source.getWildcardInBoths())).containsExactly("mouse");
((ListAssert<String>) assertThat(source.getWildcardAdderToSetters())).containsExactly("mouse");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class AdderTest method testWildcardAdder.
@IssueKey("1170")
@ProcessorTest
public void testWildcardAdder() {
Source source = new Source();
source.addWithoutWildcard("mouse");
source.addWildcardInTarget("mouse");
source.addWildcardInSource("mouse");
source.addWildcardInBoth("mouse");
source.addWildcardAdderToSetter("mouse");
Target target = AdderSourceTargetMapper.INSTANCE.toTarget(source);
assertThat(target).isNotNull();
assertThat(target.getWithoutWildcards()).containsExactly(2L);
assertThat(target.getWildcardInSources()).containsExactly(2L);
((ListAssert<Long>) assertThat(target.getWildcardInTargets())).containsExactly(2L);
((ListAssert<Long>) assertThat(target.getWildcardInBoths())).containsExactly(2L);
assertThat(target.getWildcardAdderToSetters()).containsExactly(2L);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class Issue1482Test method testReverse.
@ProcessorTest
@WithClasses(TargetSourceMapper.class)
public void testReverse() {
Target target = new Target();
target.setBigDecimal(new BigDecimal(5));
target.setTest("VAL1");
Source2 source2 = TargetSourceMapper.INSTANCE.map(target);
assertThat(source2).isNotNull();
assertThat(source2.getTest()).isEqualTo(SourceEnum.VAL1);
assertThat(source2.getWrapper().getValue()).isEqualTo(new BigDecimal(5));
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class Issue1561Test method shouldCorrectlyUseAdder.
@ProcessorTest
public void shouldCorrectlyUseAdder() {
Source source = new Source();
source.addProperty("first");
source.addProperty("second");
Target target = Issue1561Mapper.INSTANCE.map(source);
assertThat(target.getNestedTarget().getProperties()).containsExactly("first", "second");
Source mapped = Issue1561Mapper.INSTANCE.map(target);
assertThat(mapped.getProperties()).containsExactly("first", "second");
}
Aggregations