use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class JavaDefaultExpressionTest method testJavaDefaultExpressionWithNoValues.
@ProcessorTest
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
public void testJavaDefaultExpressionWithNoValues() {
Source source = new Source();
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getSourceId()).isEqualTo("test");
assertThat(target.getSourceDate()).isEqualTo(new Date(30L));
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class JavaExpressionTest method testJavaExpressionInsertionWithExistingTarget.
@ProcessorTest
@WithClasses({ Source.class, Target.class, TimeAndFormat.class, SourceTargetMapper.class })
public void testJavaExpressionInsertionWithExistingTarget() throws ParseException {
Source source = new Source();
String format = "dd-MM-yyyy,hh:mm:ss";
Date time = getTime(format, "09-01-2014,01:35:03");
source.setFormat(format);
source.setTime(time);
Target target = new Target();
Target target2 = SourceTargetMapper.INSTANCE.sourceToTargetWithMappingTarget(source, target);
assertThat(target).isNotNull();
assertThat(target.getTimeAndFormat().getTime()).isEqualTo(time);
assertThat(target.getTimeAndFormat().getFormat()).isEqualTo(format);
assertThat(target.getAnotherProp()).isNull();
assertThat(target).isEqualTo(target2);
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class WildCardTest method testWildCardAsSourceType.
@ProcessorTest
@WithClasses(SourceWildCardExtendsMapper.class)
public void testWildCardAsSourceType() {
// prepare source
SourceWildCardExtendsMapper.Wrapper<BigInteger> wrapper = new SourceWildCardExtendsMapper.Wrapper<>(new BigInteger("5"));
SourceWildCardExtendsMapper.Source source = new SourceWildCardExtendsMapper.Source(wrapper);
// action
SourceWildCardExtendsMapper.Target target = SourceWildCardExtendsMapper.INSTANCE.map(source);
// verify target
assertThat(target).isNotNull();
assertThat(target.getProp()).isEqualTo("5");
}
use of org.mapstruct.ap.testutil.WithClasses in project mapstruct by mapstruct.
the class WildCardTest method testWildCard.
@ProcessorTest
@WithClasses(SourceWildCardExtendsMapper.class)
public void testWildCard() {
// prepare source
SourceWildCardExtendsMapper.Wrapper<BigInteger> wrapper = new SourceWildCardExtendsMapper.Wrapper<>(new BigInteger("5"));
SourceWildCardExtendsMapper.Source source = new SourceWildCardExtendsMapper.Source(wrapper);
// action
SourceWildCardExtendsMapper.Target target = SourceWildCardExtendsMapper.INSTANCE.map(source);
// verify target
assertThat(target).isNotNull();
assertThat(target.getProp()).isEqualTo("5");
}
use of org.mapstruct.ap.testutil.WithClasses 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);
}
Aggregations