#1593 additional testcase to test multiple source arguments icw @MappingConfig (#1630)

This commit is contained in:
Sjaak Derksen 2018-10-20 11:21:13 +01:00 committed by GitHub
parent 71e9bd3699
commit a09d980773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 77 additions and 16 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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")

View File

@ -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 {

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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

View File

@ -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;

View File

@ -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")

View File

@ -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;

View File

@ -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;

View File

@ -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;