mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
This commit is contained in:
parent
71e9bd3699
commit
a09d980773
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
public class Address {
|
public class Address {
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
public class DeliveryAddress {
|
public class DeliveryAddress {
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
*/
|
*/
|
||||||
@IssueKey("31")
|
@IssueKey("31")
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class SeveralSourceParametersTest {
|
public class ManySourceArgumentsTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void reset() {
|
public void reset() {
|
||||||
@ -134,6 +134,29 @@ public class SeveralSourceParametersTest {
|
|||||||
assertThat( deliveryAddress.getStreet() ).isEqualTo( "Main street" );
|
assertThat( deliveryAddress.getStreet() ).isEqualTo( "Main street" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@IssueKey( "1593" )
|
||||||
|
@Test
|
||||||
|
@WithClasses( {
|
||||||
|
Person.class,
|
||||||
|
Address.class,
|
||||||
|
DeliveryAddress.class,
|
||||||
|
SourceTargetMapperWithConfig.class,
|
||||||
|
SourceTargetConfig.class } )
|
||||||
|
public void shouldUseConfig() {
|
||||||
|
Person person = new Person( "Bob", "Garner", 181, "An actor" );
|
||||||
|
Address address = new Address( "Main street", 12345, 42, "His address" );
|
||||||
|
|
||||||
|
DeliveryAddress deliveryAddress = SourceTargetMapperWithConfig.INSTANCE
|
||||||
|
.personAndAddressToDeliveryAddress( person, address );
|
||||||
|
|
||||||
|
assertThat( deliveryAddress ).isNotNull();
|
||||||
|
assertThat( deliveryAddress.getLastName() ).isEqualTo( "Garner" );
|
||||||
|
assertThat( deliveryAddress.getZipCode() ).isEqualTo( 12345 );
|
||||||
|
assertThat( deliveryAddress.getHouseNumber() ).isEqualTo( 42 );
|
||||||
|
assertThat( deliveryAddress.getDescription() ).isEqualTo( "An actor" );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithClasses({ ErroneousSourceTargetMapper.class, Address.class, DeliveryAddress.class })
|
@WithClasses({ ErroneousSourceTargetMapper.class, Address.class, DeliveryAddress.class })
|
||||||
@ProcessorOption(name = "mapstruct.unmappedTargetPolicy", value = "IGNORE")
|
@ProcessorOption(name = "mapstruct.unmappedTargetPolicy", value = "IGNORE")
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
public class Person {
|
public class Person {
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
import org.mapstruct.BeforeMapping;
|
import org.mapstruct.BeforeMapping;
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright MapStruct Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
|
import org.mapstruct.MapperConfig;
|
||||||
|
import org.mapstruct.Mapping;
|
||||||
|
|
||||||
|
@MapperConfig
|
||||||
|
public interface SourceTargetConfig {
|
||||||
|
|
||||||
|
@Mapping(source = "address.houseNo", target = "houseNumber")
|
||||||
|
@Mapping(source = "person.description", target = "description")
|
||||||
|
DeliveryAddress personAndAddressToDeliveryAddress(Person person, Address address);
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severalsources;
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright MapStruct Authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*/
|
||||||
|
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||||
|
|
||||||
|
import org.mapstruct.InheritConfiguration;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper( config = SourceTargetConfig.class )
|
||||||
|
public interface SourceTargetMapperWithConfig {
|
||||||
|
|
||||||
|
SourceTargetMapperWithConfig INSTANCE = Mappers.getMapper( SourceTargetMapperWithConfig.class );
|
||||||
|
|
||||||
|
@InheritConfiguration
|
||||||
|
DeliveryAddress personAndAddressToDeliveryAddress(Person person, Address address);
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severaltargets;
|
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severaltargets;
|
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||||
|
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severaltargets;
|
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
TimeAndFormatMapper.class
|
TimeAndFormatMapper.class
|
||||||
})
|
})
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class SourcePropertyMapSeveralTimesTest {
|
public class SourceToManyTargetPropertiesTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@IssueKey("94")
|
@IssueKey("94")
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severaltargets;
|
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severaltargets;
|
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.severaltargets;
|
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user