use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class DateConversionTest method shouldApplyDateToSqlConversion.
@IssueKey("858")
@ProcessorTest
public void shouldApplyDateToSqlConversion() {
GregorianCalendar time = new GregorianCalendar(2016, Calendar.AUGUST, 24, 20, 30, 30);
GregorianCalendar sqlDate = new GregorianCalendar(2016, Calendar.AUGUST, 23, 21, 35, 35);
GregorianCalendar timestamp = new GregorianCalendar(2016, Calendar.AUGUST, 22, 21, 35, 35);
Source source = new Source();
source.setTime(time.getTime());
source.setSqlDate(sqlDate.getTime());
source.setTimestamp(timestamp.getTime());
Target target = SourceTargetMapper.INSTANCE.sourceToTarget(source);
Time expectedTime = new Time(time.getTime().getTime());
java.sql.Date expectedSqlDate = new java.sql.Date(sqlDate.getTime().getTime());
Timestamp expectedTimestamp = new Timestamp(timestamp.getTime().getTime());
assertThat(target.getTime()).isEqualTo(expectedTime);
assertThat(target.getSqlDate()).isEqualTo(expectedSqlDate);
assertThat(target.getTimestamp()).isEqualTo(expectedTimestamp);
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class DateConversionTest method shouldApplySqlToDateConversion.
@IssueKey("858")
@ProcessorTest
public void shouldApplySqlToDateConversion() {
Target target = new Target();
GregorianCalendar time = new GregorianCalendar(2016, Calendar.AUGUST, 24, 20, 30, 30);
GregorianCalendar sqlDate = new GregorianCalendar(2016, Calendar.AUGUST, 23, 21, 35, 35);
GregorianCalendar timestamp = new GregorianCalendar(2016, Calendar.AUGUST, 22, 21, 35, 35);
target.setTime(new Time(time.getTime().getTime()));
target.setSqlDate(new java.sql.Date(sqlDate.getTime().getTime()));
target.setTimestamp(new Timestamp(timestamp.getTime().getTime()));
Source source = SourceTargetMapper.INSTANCE.targetToSource(target);
assertThat(source).isNotNull();
assertThat(source.getTime()).isEqualTo(target.getTime());
assertThat(source.getSqlDate()).isEqualTo(target.getSqlDate());
assertThat(source.getTimestamp()).isEqualTo(target.getTimestamp());
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class BigNumbersConversionTest method shouldApplyReverseBigIntegerConversions.
@ProcessorTest
@IssueKey("21")
@WithClasses({ BigIntegerSource.class, BigIntegerTarget.class, BigIntegerMapper.class })
public void shouldApplyReverseBigIntegerConversions() {
BigIntegerTarget target = new BigIntegerTarget();
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");
BigIntegerSource source = BigIntegerMapper.INSTANCE.targetToSource(target);
assertThat(source).isNotNull();
assertThat(source.getB()).isEqualTo(new BigInteger("1"));
assertThat(source.getBb()).isEqualTo(new BigInteger("2"));
assertThat(source.getS()).isEqualTo(new BigInteger("3"));
assertThat(source.getSs()).isEqualTo(new BigInteger("4"));
assertThat(source.getI()).isEqualTo(new BigInteger("5"));
assertThat(source.getIi()).isEqualTo(new BigInteger("6"));
assertThat(source.getL()).isEqualTo(new BigInteger("7"));
assertThat(source.getLl()).isEqualTo(new BigInteger("8"));
assertThat(source.getF()).isEqualTo(new BigInteger("9"));
assertThat(source.getFf()).isEqualTo(new BigInteger("10"));
assertThat(source.getD()).isEqualTo(new BigInteger("11"));
assertThat(source.getDd()).isEqualTo(new BigInteger("12"));
assertThat(source.getString()).isEqualTo(new BigInteger("13"));
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class BigNumbersConversionTest method shouldApplyBigDecimalConversions.
@ProcessorTest
@IssueKey("21")
@WithClasses({ BigDecimalSource.class, BigDecimalTarget.class, BigDecimalMapper.class })
public void shouldApplyBigDecimalConversions() {
BigDecimalSource source = new BigDecimalSource();
source.setB(new BigDecimal("1.45"));
source.setBb(new BigDecimal("2.45"));
source.setS(new BigDecimal("3.45"));
source.setSs(new BigDecimal("4.45"));
source.setI(new BigDecimal("5.45"));
source.setIi(new BigDecimal("6.45"));
source.setL(new BigDecimal("7.45"));
source.setLl(new BigDecimal("8.45"));
source.setF(new BigDecimal("9.45"));
source.setFf(new BigDecimal("10.45"));
source.setD(new BigDecimal("11.45"));
source.setDd(new BigDecimal("12.45"));
source.setString(new BigDecimal("13.45"));
source.setBigInteger(new BigDecimal("14.45"));
BigDecimalTarget target = BigDecimalMapper.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.45f);
assertThat(target.getFf()).isEqualTo(10.45f);
assertThat(target.getD()).isEqualTo(11.45d);
assertThat(target.getDd()).isEqualTo(12.45d);
assertThat(target.getString()).isEqualTo("13.45");
assertThat(target.getBigInteger()).isEqualTo(new BigInteger("14"));
}
use of org.mapstruct.ap.testutil.IssueKey in project mapstruct by mapstruct.
the class AdderTest method testSingleElementSource.
@IssueKey("242")
@ProcessorTest
public void testSingleElementSource() {
AdderUsageObserver.setUsed(false);
SingleElementSource source = new SingleElementSource();
source.setPet("mouse");
Target target = SourceTargetMapper.INSTANCE.fromSingleElementSource(source);
assertThat(target).isNotNull();
assertThat(target.getPets().size()).isEqualTo(1);
assertThat(target.getPets().get(0)).isEqualTo(2L);
assertTrue(AdderUsageObserver.isUsed());
}
Aggregations