use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class Issue892Test method compiles.
@ProcessorTest
public void compiles() {
Source src = new Source();
src.setType(42);
Target target = Mappers.getMapper(Issue892Mapper.class).toTarget(src);
assertThat(target.getType()).isEqualTo(42);
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class Issue895Test method properlyMapsMultiDimensionalArrays.
@ProcessorTest
public void properlyMapsMultiDimensionalArrays() {
WithArrayOfByteArray arrayOfByteArray = new WithArrayOfByteArray();
arrayOfByteArray.setBytes(new byte[][] { new byte[] { 0, 1 }, new byte[] { 1, 2 } });
WithListOfByteArray listOfByteArray = Mappers.getMapper(MultiArrayMapper.class).convert(arrayOfByteArray);
assertThat(listOfByteArray.getBytes()).containsExactly(new byte[] { 0, 1 }, new byte[] { 1, 2 });
arrayOfByteArray = Mappers.getMapper(MultiArrayMapper.class).convert(listOfByteArray);
assertThat(arrayOfByteArray.getBytes()).isDeepEqualTo(new byte[][] { { 0, 1 }, { 1, 2 } });
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class NamedTest method testFactorySelectionWithQualifier.
@ProcessorTest
@WithClasses({ MovieFactoryMapper.class, ReleaseFactory.class, CreateGermanRelease.class })
@IssueKey("342")
public void testFactorySelectionWithQualifier() {
OriginalRelease foreignMovies = new OriginalRelease();
foreignMovies.setTitle("Sixth Sense, The");
foreignMovies.setKeyWords(Arrays.asList("evergreen", "magnificent"));
Map<String, List<String>> facts = new HashMap<>();
facts.put("director", Arrays.asList("M. Night Shyamalan"));
facts.put("cast", Arrays.asList("Bruce Willis", "Haley Joel Osment", "Toni Collette"));
facts.put("plot keywords", Arrays.asList("boy", "child psychologist", "I see dead people"));
foreignMovies.setFacts(facts);
AbstractEntry abstractEntry = MovieFactoryMapper.INSTANCE.toGerman(foreignMovies);
assertThat(abstractEntry).isNotNull();
assertThat(abstractEntry).isInstanceOf(GermanRelease.class);
assertThat(abstractEntry.getTitle()).isEqualTo("Sixth Sense, The");
assertThat(abstractEntry.getKeyWords()).isNotNull();
assertThat(abstractEntry.getKeyWords().size()).isEqualTo(2);
assertThat(abstractEntry.getKeyWords()).containsSequence("evergreen", "magnificent");
assertThat(abstractEntry.getFacts()).isNotNull();
assertThat(abstractEntry.getFacts()).hasSize(3);
assertThat(abstractEntry.getFacts()).contains(entry("director", Arrays.asList("M. Night Shyamalan")), entry("cast", Arrays.asList("Bruce Willis", "Haley Joel Osment", "Toni Collette")), entry("plot keywords", Arrays.asList("boy", "child psychologist", "I see dead people")));
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class UnderscoreSelectionTest method selectingUnderscorePropertiesWorks.
@ProcessorTest
public void selectingUnderscorePropertiesWorks() {
SubType target = UnderscoreMapper.INSTANCE.map(createSource());
assertThat(target.getInheritedUnderscore().getValue()).isEqualTo("hi");
assertThat(target.getDeclaredUnderscore().getValue()).isEqualTo("there");
}
use of org.mapstruct.ap.testutil.ProcessorTest in project mapstruct by mapstruct.
the class JavaDefaultExpressionTest method testJavaDefaultExpressionWithValues.
@ProcessorTest
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
public void testJavaDefaultExpressionWithValues() {
Source source = new Source();
source.setId(123);
source.setDate(new Date(0L));
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getSourceId()).isEqualTo("123");
assertThat(target.getSourceDate()).isEqualTo(source.getDate());
}
Aggregations