diff --git a/integrationtest/pom.xml b/integrationtest/pom.xml index 8e2686f27..3f38e0c4b 100644 --- a/integrationtest/pom.xml +++ b/integrationtest/pom.xml @@ -142,7 +142,7 @@ org.bsc.maven maven-processor-plugin - ${project.build.directory}/generated-sources + ${project.build.directory}/generated-sources/mapstruct org.mapstruct.ap.MappingProcessor diff --git a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/JaxbMapper.java b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/JaxbMapper.java index 7aa7f6d6c..e3e03bf46 100644 --- a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/JaxbMapper.java +++ b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/JaxbMapper.java @@ -21,6 +21,7 @@ package org.mapstruct.itest.jaxb; import java.util.ArrayList; import java.util.List; import javax.xml.bind.JAXBElement; + import org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory; /** @@ -37,12 +38,13 @@ public class JaxbMapper { * the proper factory method for Lists * * @param orderDetailsDescriptions + * * @return */ - List> toJaxbList( List orderDetailsDescriptions ) { + List> toJaxbList(List orderDetailsDescriptions) { List> result = new ArrayList>(); - for (String orderDetailDescription : orderDetailsDescriptions) { + for ( String orderDetailDescription : orderDetailsDescriptions ) { result.add( of.createOrderDetailsTypeDescription( orderDetailDescription ) ); } return result; diff --git a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDetailsDto.java b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDetailsDto.java index a398bd115..6860e83f6 100644 --- a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDetailsDto.java +++ b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDetailsDto.java @@ -21,7 +21,6 @@ package org.mapstruct.itest.jaxb; import java.util.List; /** - * * @author Sjaak Derksen */ public class OrderDetailsDto { @@ -34,7 +33,7 @@ public class OrderDetailsDto { return name; } - public void setName( String name ) { + public void setName(String name) { this.name = name; } @@ -42,7 +41,7 @@ public class OrderDetailsDto { return description; } - public void setDescription( List description ) { + public void setDescription(List description) { this.description = description; } @@ -50,7 +49,7 @@ public class OrderDetailsDto { return status; } - public void setStatus( OrderStatusDto status ) { + public void setStatus(OrderStatusDto status) { this.status = status; } } diff --git a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDto.java b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDto.java index a8f604c1d..0bc97a709 100644 --- a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDto.java +++ b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderDto.java @@ -22,7 +22,6 @@ package org.mapstruct.itest.jaxb; import java.util.Date; /** - * * @author Sjaak Derksen */ public class OrderDto { @@ -37,7 +36,7 @@ public class OrderDto { return orderNumber; } - public void setOrderNumber( Long orderNumber ) { + public void setOrderNumber(Long orderNumber) { this.orderNumber = orderNumber; } @@ -45,7 +44,7 @@ public class OrderDto { return orderDate; } - public void setOrderDate( Date orderDate ) { + public void setOrderDate(Date orderDate) { this.orderDate = orderDate; } @@ -53,7 +52,7 @@ public class OrderDto { return orderDetails; } - public void setOrderDetails( OrderDetailsDto orderDetails ) { + public void setOrderDetails(OrderDetailsDto orderDetails) { this.orderDetails = orderDetails; } @@ -61,7 +60,7 @@ public class OrderDto { return shippingAddress; } - public void setShippingAddress( ShippingAddressDto shippingAddress ) { + public void setShippingAddress(ShippingAddressDto shippingAddress) { this.shippingAddress = shippingAddress; } diff --git a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderStatusDto.java b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderStatusDto.java index 8859f1623..7a35464c0 100644 --- a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderStatusDto.java +++ b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/OrderStatusDto.java @@ -19,14 +19,13 @@ package org.mapstruct.itest.jaxb; /** - * * @author Sjaak Derksen */ public enum OrderStatusDto { - ORDERED("small"), - PROCESSED("medium"), - DELIVERED("large"); + ORDERED( "small" ), + PROCESSED( "medium" ), + DELIVERED( "large" ); private final String value; OrderStatusDto(String v) { @@ -38,12 +37,12 @@ public enum OrderStatusDto { } public static OrderStatusDto fromValue(String v) { - for (OrderStatusDto c: OrderStatusDto.values()) { + for ( OrderStatusDto c : OrderStatusDto.values() ) { if ( c.value.equals( v ) ) { return c; } } - throw new IllegalArgumentException(v); + throw new IllegalArgumentException( v ); } } diff --git a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/ShippingAddressDto.java b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/ShippingAddressDto.java index af85bb7ce..c0550cdd1 100644 --- a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/ShippingAddressDto.java +++ b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/ShippingAddressDto.java @@ -19,7 +19,6 @@ package org.mapstruct.itest.jaxb; /** - * * @author Sjaak Derksen */ public class ShippingAddressDto { @@ -33,7 +32,7 @@ public class ShippingAddressDto { return street; } - public void setStreet( String street ) { + public void setStreet(String street) { this.street = street; } @@ -41,7 +40,7 @@ public class ShippingAddressDto { return houseNumber; } - public void setHouseNumber( String houseNumber ) { + public void setHouseNumber(String houseNumber) { this.houseNumber = houseNumber; } @@ -49,7 +48,7 @@ public class ShippingAddressDto { return city; } - public void setCity( String city ) { + public void setCity(String city) { this.city = city; } @@ -57,7 +56,7 @@ public class ShippingAddressDto { return country; } - public void setCountry( String country ) { + public void setCountry(String country) { this.country = country; } diff --git a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/SourceTargetMapper.java b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/SourceTargetMapper.java index 3444e6e46..49ae79b6f 100644 --- a/integrationtest/src/main/java/org/mapstruct/itest/jaxb/SourceTargetMapper.java +++ b/integrationtest/src/main/java/org/mapstruct/itest/jaxb/SourceTargetMapper.java @@ -28,25 +28,32 @@ import org.mapstruct.itest.jaxb.xsd.test2.ShippingAddressType; /** - * * @author Sjaak Derksen */ -@Mapper(uses = { org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory.class, - org.mapstruct.itest.jaxb.xsd.test2.ObjectFactory.class, - JaxbMapper.class }) -public interface SourceTargetMapper { +@Mapper(uses = { + org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory.class, + org.mapstruct.itest.jaxb.xsd.test2.ObjectFactory.class, + JaxbMapper.class +}) +public interface SourceTargetMapper { SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); // source 2 target methods OrderDto sourceToTarget(OrderType source); + OrderDetailsDto detailsToDto(OrderDetailsType source); + OrderStatusDto statusToDto(OrderStatusType source); + ShippingAddressDto shippingAddressToDto(ShippingAddressType source); // target 2 source methods OrderType targetToSource(OrderDto target); + OrderDetailsType dtoToDetails(OrderDetailsDto target); + OrderStatusType dtoToStatus(OrderStatusDto target); + ShippingAddressType dtoToShippingAddress(ShippingAddressDto source); } diff --git a/integrationtest/src/test/java/org/mapstruct/itest/jaxb/JaxbBasedMapperTest.java b/integrationtest/src/test/java/org/mapstruct/itest/jaxb/JaxbBasedMapperTest.java index ba1e7023e..ba128671b 100644 --- a/integrationtest/src/test/java/org/mapstruct/itest/jaxb/JaxbBasedMapperTest.java +++ b/integrationtest/src/test/java/org/mapstruct/itest/jaxb/JaxbBasedMapperTest.java @@ -32,11 +32,11 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.testng.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory; +import org.mapstruct.itest.jaxb.xsd.test1.OrderType; import org.testng.annotations.Test; import static org.fest.assertions.Assertions.assertThat; -import org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory; -import org.mapstruct.itest.jaxb.xsd.test1.OrderType; /** * Test for generation of JAXB based mapper implementations. @@ -48,9 +48,9 @@ public class JaxbBasedMapperTest extends Arquillian { @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create( JavaArchive.class ) - .addPackage( SourceTargetMapper.class.getPackage() ) - .addPackage( org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory.class.getPackage() ) - .addPackage( org.mapstruct.itest.jaxb.xsd.test2.ObjectFactory.class.getPackage() ); + .addPackage( SourceTargetMapper.class.getPackage() ) + .addPackage( org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory.class.getPackage() ) + .addPackage( org.mapstruct.itest.jaxb.xsd.test2.ObjectFactory.class.getPackage() ); } @Test @@ -67,7 +67,7 @@ public class JaxbBasedMapperTest extends Arquillian { source1.getShippingAddress().setHouseNumber( "11a" ); source1.getShippingAddress().setStreet( "Awesome rd" ); source1.getShippingAddress().setCountry( "USA" ); - source1.getOrderDetails().setDescription( new ArrayList() ); + source1.getOrderDetails().setDescription( new ArrayList() ); source1.getOrderDetails().setName( "Shopping list for a Mapper" ); source1.getOrderDetails().getDescription().add( "1 MapStruct" ); source1.getOrderDetails().getDescription().add( "3 Lines of Code" ); @@ -88,23 +88,27 @@ public class JaxbBasedMapperTest extends Arquillian { assertThat( source2.getOrderNumber() ).isEqualTo( source1.getOrderNumber() ); assertThat( source2.getOrderDate() ).isEqualTo( source1.getOrderDate() ); assertThat( source2.getOrderDetails().getDescription().size() ).isEqualTo( - source1.getOrderDetails().getDescription().size() ); + source1.getOrderDetails().getDescription().size() + ); assertThat( source2.getOrderDetails().getDescription().get( 0 ) ).isEqualTo( - source1.getOrderDetails().getDescription().get( 0 ) ); + source1.getOrderDetails().getDescription().get( 0 ) + ); assertThat( source2.getOrderDetails().getDescription().get( 1 ) ).isEqualTo( - source1.getOrderDetails().getDescription().get( 1 ) ); + source1.getOrderDetails().getDescription().get( 1 ) + ); assertThat( source2.getOrderDetails().getDescription().get( 2 ) ).isEqualTo( - source1.getOrderDetails().getDescription().get( 2 ) ); + source1.getOrderDetails().getDescription().get( 2 ) + ); assertThat( source2.getOrderDetails().getName() ).isEqualTo( source1.getOrderDetails().getName() ); assertThat( source2.getOrderDetails().getStatus() ).isEqualTo( source1.getOrderDetails().getStatus() ); } - private Date createDate( String date ) throws ParseException { + private Date createDate(String date) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat( "dd-M-yyyy hh:mm:ss" ); return sdf.parse( date ); } - private String toXml( JAXBElement element ) throws JAXBException { + private String toXml(JAXBElement element) throws JAXBException { JAXBContext jc = JAXBContext.newInstance( element.getValue().getClass() ); Marshaller marshaller = jc.createMarshaller(); marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );