use of org.mapstruct.ap.test.nestedproperties.simple._target.TargetObject in project mapstruct by mapstruct.
the class SimpleNestedPropertiesTest method testViaNull.
@ProcessorTest
@WithClasses({ SimpleMapper.class })
public void testViaNull() {
SourceRoot sourceRoot = new SourceRoot();
// sourceRoot.getProps() is null
TargetObject targetObject = SimpleMapper.MAPPER.toTargetObject(sourceRoot);
assertEquals(0L, targetObject.getPublicLongValue());
assertEquals(0L, targetObject.getLongValue());
assertEquals(0, targetObject.getIntValue());
assertEquals(0.0, targetObject.getDoubleValue(), 0.01);
assertEquals(0.0f, targetObject.getFloatValue(), 0.01f);
assertEquals(0, targetObject.getShortValue());
assertEquals(0, targetObject.getCharValue());
assertEquals(0, targetObject.getByteValue());
assertFalse(targetObject.isBooleanValue());
assertNull(targetObject.getByteArray());
assertNull(targetObject.getStringValue());
}
use of org.mapstruct.ap.test.nestedproperties.simple._target.TargetObject in project mapstruct by mapstruct.
the class SimpleNestedPropertiesTest method testFilled.
@ProcessorTest
@WithClasses({ SimpleMapper.class })
public void testFilled() {
SourceRoot sourceRoot = new SourceRoot();
SourceProps sourceProps = new SourceProps();
sourceRoot.setProps(sourceProps);
sourceProps.publicLongValue = Long.MAX_VALUE;
sourceProps.setLongValue(Long.MAX_VALUE);
sourceProps.setIntValue(Integer.MAX_VALUE);
sourceProps.setDoubleValue(Double.MAX_VALUE);
sourceProps.setFloatValue(Float.MAX_VALUE);
sourceProps.setShortValue(Short.MAX_VALUE);
sourceProps.setCharValue(Character.MAX_VALUE);
sourceProps.setByteValue(Byte.MAX_VALUE);
sourceProps.setBooleanValue(true);
String stringValue = "lorem ipsum";
sourceProps.setByteArray(stringValue.getBytes());
sourceProps.setStringValue(stringValue);
TargetObject targetObject = SimpleMapper.MAPPER.toTargetObject(sourceRoot);
assertEquals(Long.MAX_VALUE, targetObject.getPublicLongValue());
assertEquals(Long.MAX_VALUE, targetObject.getLongValue());
assertEquals(Integer.MAX_VALUE, targetObject.getIntValue());
assertEquals(Double.MAX_VALUE, targetObject.getDoubleValue(), 0.01);
assertEquals(Float.MAX_VALUE, targetObject.getFloatValue(), 0.01f);
assertEquals(Short.MAX_VALUE, targetObject.getShortValue());
assertEquals(Character.MAX_VALUE, targetObject.getCharValue());
assertEquals(Byte.MAX_VALUE, targetObject.getByteValue());
assertTrue(targetObject.isBooleanValue());
assertArrayEquals(stringValue.getBytes(), targetObject.getByteArray());
assertEquals(stringValue, targetObject.getStringValue());
}
use of org.mapstruct.ap.test.nestedproperties.simple._target.TargetObject in project mapstruct by mapstruct.
the class SimpleNestedPropertiesTest method testNull.
@ProcessorTest
@WithClasses({ SimpleMapper.class })
public void testNull() {
TargetObject targetObject = SimpleMapper.MAPPER.toTargetObject(null);
assertThat(targetObject).isNull();
}
Aggregations