use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class SourcePropertyMapSeveralTimesTest method shouldMapSameSourcePropertyToSeveralTargetPropertiesInvokingOtherMapper.
@Test
@IssueKey("94")
public void shouldMapSameSourcePropertyToSeveralTargetPropertiesInvokingOtherMapper() throws ParseException {
Source source = new Source();
String sourceFormat = "dd-MM-yyyy";
SimpleDateFormat dateFormat = new SimpleDateFormat(sourceFormat);
Date sourceTime = dateFormat.parse("09-01-2014");
TimeAndFormat sourceTimeAndFormat = new TimeAndFormat();
sourceTimeAndFormat.setTfFormat(sourceFormat);
sourceTimeAndFormat.setTfTime(sourceTime);
source.setTimeAndFormat(sourceTimeAndFormat);
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getFormat()).isEqualTo(sourceFormat);
assertThat(target.getTime()).isEqualTo(sourceTime);
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class BigNumbersConversionTest method shouldApplyReverseBigDecimalConversions.
@ProcessorTest
@IssueKey("21")
@WithClasses({ BigDecimalSource.class, BigDecimalTarget.class, BigDecimalMapper.class })
public void shouldApplyReverseBigDecimalConversions() {
BigDecimalTarget target = new BigDecimalTarget();
target.setB((byte) 1);
target.setBb((byte) 2);
target.setS((short) 3);
target.setSs((short) 4);
target.setI(5);
target.setIi(6);
target.setL(7);
target.setLl(8L);
target.setF(9.0f);
target.setFf(10.0f);
target.setD(11.0d);
target.setDd(12.0d);
target.setString("13.45");
target.setBigInteger(new BigInteger("14"));
BigDecimalSource source = BigDecimalMapper.INSTANCE.targetToSource(target);
assertThat(source).isNotNull();
assertThat(source.getB()).isEqualTo(new BigDecimal("1"));
assertThat(source.getBb()).isEqualTo(new BigDecimal("2"));
assertThat(source.getS()).isEqualTo(new BigDecimal("3"));
assertThat(source.getSs()).isEqualTo(new BigDecimal("4"));
assertThat(source.getI()).isEqualTo(new BigDecimal("5"));
assertThat(source.getIi()).isEqualTo(new BigDecimal("6"));
assertThat(source.getL()).isEqualTo(new BigDecimal("7"));
assertThat(source.getLl()).isEqualTo(new BigDecimal("8"));
assertThat(source.getF()).isEqualTo(new BigDecimal("9.0"));
assertThat(source.getFf()).isEqualTo(new BigDecimal("10.0"));
assertThat(source.getD()).isEqualTo(new BigDecimal("11.0"));
assertThat(source.getDd()).isEqualTo(new BigDecimal("12.0"));
assertThat(source.getString()).isEqualTo(new BigDecimal("13.45"));
assertThat(source.getBigInteger()).isEqualTo(new BigDecimal("14"));
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class BigNumbersConversionTest method shouldApplyBigIntegerConversions.
@ProcessorTest
@IssueKey("21")
@WithClasses({ BigIntegerSource.class, BigIntegerTarget.class, BigIntegerMapper.class })
public void shouldApplyBigIntegerConversions() {
BigIntegerSource source = new BigIntegerSource();
source.setB(new BigInteger("1"));
source.setBb(new BigInteger("2"));
source.setS(new BigInteger("3"));
source.setSs(new BigInteger("4"));
source.setI(new BigInteger("5"));
source.setIi(new BigInteger("6"));
source.setL(new BigInteger("7"));
source.setLl(new BigInteger("8"));
source.setF(new BigInteger("9"));
source.setFf(new BigInteger("10"));
source.setD(new BigInteger("11"));
source.setDd(new BigInteger("12"));
source.setString(new BigInteger("13"));
BigIntegerTarget target = BigIntegerMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getB()).isEqualTo((byte) 1);
assertThat(target.getBb()).isEqualTo((byte) 2);
assertThat(target.getS()).isEqualTo((short) 3);
assertThat(target.getSs()).isEqualTo((short) 4);
assertThat(target.getI()).isEqualTo(5);
assertThat(target.getIi()).isEqualTo(6);
assertThat(target.getL()).isEqualTo(7);
assertThat(target.getLl()).isEqualTo(8);
assertThat(target.getF()).isEqualTo(9.0f);
assertThat(target.getFf()).isEqualTo(10.0f);
assertThat(target.getD()).isEqualTo(11.0d);
assertThat(target.getDd()).isEqualTo(12.0d);
assertThat(target.getString()).isEqualTo("13");
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class IgnorePropertyTest method shouldOnlyIgnoreBase.
@ProcessorTest
@IssueKey("1933")
public void shouldOnlyIgnoreBase() {
WorkBenchDto workBenchDto = new WorkBenchDto();
workBenchDto.setArticleName("MyBench");
workBenchDto.setArticleDescription("Beautiful");
workBenchDto.setCreationDate(new Date());
workBenchDto.setModificationDate(new Date());
WorkBenchEntity benchTarget = ToolMapper.INSTANCE.mapBenchWithImplicit(workBenchDto);
assertThat(benchTarget).isNotNull();
assertThat(benchTarget.getArticleName()).isEqualTo("MyBench");
assertThat(benchTarget.getDescription()).isEqualTo("Beautiful");
assertThat(benchTarget.getKey()).isNull();
assertThat(benchTarget.getModificationDate()).isNull();
assertThat(benchTarget.getCreationDate()).isNull();
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class ConflictingTypesNamesTest method mapperHasNoUnnecessaryImports.
@ProcessorTest
@IssueKey("178")
public void mapperHasNoUnnecessaryImports() {
Source source = new Source();
source.setNotImported(new NotImportedDatatype(42));
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getNotImported()).isSameAs(source.getNotImported());
target = SecondSourceTargetMapper.INSTANCE.sourceToTarget(source);
assertThat(target).isNotNull();
assertThat(target.getNotImported()).isSameAs(source.getNotImported());
generatedSource.forMapper(SourceTargetMapper.class).containsNoImportFor(NotImportedDatatype.class);
generatedSource.forMapper(SecondSourceTargetMapper.class).containsNoImportFor(NotImportedDatatype.class);
}
Aggregations