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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ -28,7 +28,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
*/
|
||||
@IssueKey("31")
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
public class SeveralSourceParametersTest {
|
||||
public class ManySourceArgumentsTest {
|
||||
|
||||
@Before
|
||||
public void reset() {
|
||||
@ -134,6 +134,29 @@ public class SeveralSourceParametersTest {
|
||||
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
|
||||
@WithClasses({ ErroneousSourceTargetMapper.class, Address.class, DeliveryAddress.class })
|
||||
@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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
package org.mapstruct.ap.test.source.manysourcearguments;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severaltargets;
|
||||
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severaltargets;
|
||||
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
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
|
||||
*/
|
||||
package org.mapstruct.ap.test.severaltargets;
|
||||
package org.mapstruct.ap.test.source.manytargetproperties;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ -27,7 +27,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
TimeAndFormatMapper.class
|
||||
})
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
public class SourcePropertyMapSeveralTimesTest {
|
||||
public class SourceToManyTargetPropertiesTest {
|
||||
|
||||
@Test
|
||||
@IssueKey("94")
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* 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;
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* 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;
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user