mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#119 Formatting
This commit is contained in:
parent
859c51368d
commit
fd3aa63e2d
@ -142,7 +142,7 @@
|
|||||||
<groupId>org.bsc.maven</groupId>
|
<groupId>org.bsc.maven</groupId>
|
||||||
<artifactId>maven-processor-plugin</artifactId>
|
<artifactId>maven-processor-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<defaultOutputDirectory>${project.build.directory}/generated-sources</defaultOutputDirectory>
|
<defaultOutputDirectory>${project.build.directory}/generated-sources/mapstruct</defaultOutputDirectory>
|
||||||
<processors>
|
<processors>
|
||||||
<processor>org.mapstruct.ap.MappingProcessor</processor>
|
<processor>org.mapstruct.ap.MappingProcessor</processor>
|
||||||
</processors>
|
</processors>
|
||||||
|
@ -21,6 +21,7 @@ package org.mapstruct.itest.jaxb;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
|
|
||||||
import org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory;
|
import org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,6 +38,7 @@ public class JaxbMapper {
|
|||||||
* the proper factory method for Lists
|
* the proper factory method for Lists
|
||||||
*
|
*
|
||||||
* @param orderDetailsDescriptions
|
* @param orderDetailsDescriptions
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<JAXBElement<String>> toJaxbList(List<String> orderDetailsDescriptions) {
|
List<JAXBElement<String>> toJaxbList(List<String> orderDetailsDescriptions) {
|
||||||
|
@ -21,7 +21,6 @@ package org.mapstruct.itest.jaxb;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class OrderDetailsDto {
|
public class OrderDetailsDto {
|
||||||
|
@ -22,7 +22,6 @@ package org.mapstruct.itest.jaxb;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class OrderDto {
|
public class OrderDto {
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.mapstruct.itest.jaxb;
|
package org.mapstruct.itest.jaxb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public enum OrderStatusDto {
|
public enum OrderStatusDto {
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
package org.mapstruct.itest.jaxb;
|
package org.mapstruct.itest.jaxb;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class ShippingAddressDto {
|
public class ShippingAddressDto {
|
||||||
|
@ -28,25 +28,32 @@ import org.mapstruct.itest.jaxb.xsd.test2.ShippingAddressType;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
@Mapper(uses = { org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory.class,
|
@Mapper(uses = {
|
||||||
|
org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory.class,
|
||||||
org.mapstruct.itest.jaxb.xsd.test2.ObjectFactory.class,
|
org.mapstruct.itest.jaxb.xsd.test2.ObjectFactory.class,
|
||||||
JaxbMapper.class })
|
JaxbMapper.class
|
||||||
|
})
|
||||||
public interface SourceTargetMapper {
|
public interface SourceTargetMapper {
|
||||||
|
|
||||||
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
|
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
|
||||||
|
|
||||||
// source 2 target methods
|
// source 2 target methods
|
||||||
OrderDto sourceToTarget(OrderType source);
|
OrderDto sourceToTarget(OrderType source);
|
||||||
|
|
||||||
OrderDetailsDto detailsToDto(OrderDetailsType source);
|
OrderDetailsDto detailsToDto(OrderDetailsType source);
|
||||||
|
|
||||||
OrderStatusDto statusToDto(OrderStatusType source);
|
OrderStatusDto statusToDto(OrderStatusType source);
|
||||||
|
|
||||||
ShippingAddressDto shippingAddressToDto(ShippingAddressType source);
|
ShippingAddressDto shippingAddressToDto(ShippingAddressType source);
|
||||||
|
|
||||||
// target 2 source methods
|
// target 2 source methods
|
||||||
OrderType targetToSource(OrderDto target);
|
OrderType targetToSource(OrderDto target);
|
||||||
|
|
||||||
OrderDetailsType dtoToDetails(OrderDetailsDto target);
|
OrderDetailsType dtoToDetails(OrderDetailsDto target);
|
||||||
|
|
||||||
OrderStatusType dtoToStatus(OrderStatusDto target);
|
OrderStatusType dtoToStatus(OrderStatusDto target);
|
||||||
|
|
||||||
ShippingAddressType dtoToShippingAddress(ShippingAddressDto source);
|
ShippingAddressType dtoToShippingAddress(ShippingAddressDto source);
|
||||||
}
|
}
|
||||||
|
@ -32,11 +32,11 @@ import org.jboss.arquillian.container.test.api.Deployment;
|
|||||||
import org.jboss.arquillian.testng.Arquillian;
|
import org.jboss.arquillian.testng.Arquillian;
|
||||||
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
import org.jboss.shrinkwrap.api.ShrinkWrap;
|
||||||
import org.jboss.shrinkwrap.api.spec.JavaArchive;
|
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 org.testng.annotations.Test;
|
||||||
|
|
||||||
import static org.fest.assertions.Assertions.assertThat;
|
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.
|
* Test for generation of JAXB based mapper implementations.
|
||||||
@ -67,7 +67,7 @@ public class JaxbBasedMapperTest extends Arquillian {
|
|||||||
source1.getShippingAddress().setHouseNumber( "11a" );
|
source1.getShippingAddress().setHouseNumber( "11a" );
|
||||||
source1.getShippingAddress().setStreet( "Awesome rd" );
|
source1.getShippingAddress().setStreet( "Awesome rd" );
|
||||||
source1.getShippingAddress().setCountry( "USA" );
|
source1.getShippingAddress().setCountry( "USA" );
|
||||||
source1.getOrderDetails().setDescription( new ArrayList() );
|
source1.getOrderDetails().setDescription( new ArrayList<String>() );
|
||||||
source1.getOrderDetails().setName( "Shopping list for a Mapper" );
|
source1.getOrderDetails().setName( "Shopping list for a Mapper" );
|
||||||
source1.getOrderDetails().getDescription().add( "1 MapStruct" );
|
source1.getOrderDetails().getDescription().add( "1 MapStruct" );
|
||||||
source1.getOrderDetails().getDescription().add( "3 Lines of Code" );
|
source1.getOrderDetails().getDescription().add( "3 Lines of Code" );
|
||||||
@ -88,13 +88,17 @@ public class JaxbBasedMapperTest extends Arquillian {
|
|||||||
assertThat( source2.getOrderNumber() ).isEqualTo( source1.getOrderNumber() );
|
assertThat( source2.getOrderNumber() ).isEqualTo( source1.getOrderNumber() );
|
||||||
assertThat( source2.getOrderDate() ).isEqualTo( source1.getOrderDate() );
|
assertThat( source2.getOrderDate() ).isEqualTo( source1.getOrderDate() );
|
||||||
assertThat( source2.getOrderDetails().getDescription().size() ).isEqualTo(
|
assertThat( source2.getOrderDetails().getDescription().size() ).isEqualTo(
|
||||||
source1.getOrderDetails().getDescription().size() );
|
source1.getOrderDetails().getDescription().size()
|
||||||
|
);
|
||||||
assertThat( source2.getOrderDetails().getDescription().get( 0 ) ).isEqualTo(
|
assertThat( source2.getOrderDetails().getDescription().get( 0 ) ).isEqualTo(
|
||||||
source1.getOrderDetails().getDescription().get( 0 ) );
|
source1.getOrderDetails().getDescription().get( 0 )
|
||||||
|
);
|
||||||
assertThat( source2.getOrderDetails().getDescription().get( 1 ) ).isEqualTo(
|
assertThat( source2.getOrderDetails().getDescription().get( 1 ) ).isEqualTo(
|
||||||
source1.getOrderDetails().getDescription().get( 1 ) );
|
source1.getOrderDetails().getDescription().get( 1 )
|
||||||
|
);
|
||||||
assertThat( source2.getOrderDetails().getDescription().get( 2 ) ).isEqualTo(
|
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().getName() ).isEqualTo( source1.getOrderDetails().getName() );
|
||||||
assertThat( source2.getOrderDetails().getStatus() ).isEqualTo( source1.getOrderDetails().getStatus() );
|
assertThat( source2.getOrderDetails().getStatus() ).isEqualTo( source1.getOrderDetails().getStatus() );
|
||||||
}
|
}
|
||||||
@ -104,7 +108,7 @@ public class JaxbBasedMapperTest extends Arquillian {
|
|||||||
return sdf.parse( date );
|
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() );
|
JAXBContext jc = JAXBContext.newInstance( element.getValue().getClass() );
|
||||||
Marshaller marshaller = jc.createMarshaller();
|
Marshaller marshaller = jc.createMarshaller();
|
||||||
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
|
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user