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>
|
||||
<artifactId>maven-processor-plugin</artifactId>
|
||||
<configuration>
|
||||
<defaultOutputDirectory>${project.build.directory}/generated-sources</defaultOutputDirectory>
|
||||
<defaultOutputDirectory>${project.build.directory}/generated-sources/mapstruct</defaultOutputDirectory>
|
||||
<processors>
|
||||
<processor>org.mapstruct.ap.MappingProcessor</processor>
|
||||
</processors>
|
||||
|
@ -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,6 +38,7 @@ public class JaxbMapper {
|
||||
* the proper factory method for Lists
|
||||
*
|
||||
* @param orderDetailsDescriptions
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<JAXBElement<String>> toJaxbList(List<String> orderDetailsDescriptions) {
|
||||
|
@ -21,7 +21,6 @@ package org.mapstruct.itest.jaxb;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderDetailsDto {
|
||||
|
@ -22,7 +22,6 @@ package org.mapstruct.itest.jaxb;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderDto {
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.mapstruct.itest.jaxb;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public enum OrderStatusDto {
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.mapstruct.itest.jaxb;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class ShippingAddressDto {
|
||||
|
@ -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,
|
||||
@Mapper(uses = {
|
||||
org.mapstruct.itest.jaxb.xsd.test1.ObjectFactory.class,
|
||||
org.mapstruct.itest.jaxb.xsd.test2.ObjectFactory.class,
|
||||
JaxbMapper.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);
|
||||
}
|
||||
|
@ -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.
|
||||
@ -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<String>() );
|
||||
source1.getOrderDetails().setName( "Shopping list for a Mapper" );
|
||||
source1.getOrderDetails().getDescription().add( "1 MapStruct" );
|
||||
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.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() );
|
||||
}
|
||||
@ -104,7 +108,7 @@ public class JaxbBasedMapperTest extends Arquillian {
|
||||
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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user