mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#517 make order of target properties in generated code and in messages stable
This commit is contained in:
parent
fb8a6e3ae0
commit
fb6c4dbfbd
@ -26,6 +26,7 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@ -92,7 +93,7 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
CollectionMappingStrategyPrism cms = sourceMethod.getMapperConfiguration().getCollectionMappingStrategy();
|
||||
Map<String, ExecutableElement> accessors = method.getResultType().getPropertyWriteAccessors( cms );
|
||||
this.targetProperties = accessors.keySet();
|
||||
this.unprocessedTargetProperties = new HashMap<String, ExecutableElement>( accessors );
|
||||
this.unprocessedTargetProperties = new LinkedHashMap<String, ExecutableElement>( accessors );
|
||||
for ( Parameter sourceParameter : method.getSourceParameters() ) {
|
||||
unprocessedSourceParameters.add( sourceParameter );
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package org.mapstruct.ap.model.common;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -353,7 +352,7 @@ public class Type extends ModelElement implements Comparable<Type> {
|
||||
candidates.addAll( getSetters() );
|
||||
candidates.addAll( getAlternativeTargetAccessors() );
|
||||
|
||||
Map<String, ExecutableElement> result = new HashMap<String, ExecutableElement>();
|
||||
Map<String, ExecutableElement> result = new LinkedHashMap<String, ExecutableElement>();
|
||||
|
||||
for ( ExecutableElement candidate : candidates ) {
|
||||
String targetPropertyName = Executables.getPropertyName( candidate );
|
||||
|
@ -178,7 +178,7 @@ public class InheritFromConfigTest {
|
||||
@Diagnostic(type = Erroneous1Mapper.class,
|
||||
kind = Kind.WARNING,
|
||||
line = 36,
|
||||
messageRegExp = "Unmapped target properties: \"auditTrail, primaryKey\"\\."),
|
||||
messageRegExp = "Unmapped target properties: \"primaryKey, auditTrail\"\\."),
|
||||
@Diagnostic(type = Erroneous1Mapper.class,
|
||||
kind = Kind.ERROR,
|
||||
line = 42,
|
||||
|
@ -18,8 +18,6 @@
|
||||
*/
|
||||
package org.mapstruct.ap.test.severalsources;
|
||||
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
@ -33,6 +31,8 @@ import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutco
|
||||
import org.mapstruct.ap.testutil.compilation.annotation.ProcessorOption;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Test for propagation of attribute without setter in source and getter in
|
||||
* target.
|
||||
@ -127,12 +127,13 @@ public class SeveralSourceParametersTest {
|
||||
@Diagnostic(type = ErroneousSourceTargetMapper.class,
|
||||
kind = Kind.ERROR,
|
||||
line = 29,
|
||||
messageRegExp = "Several possible source properties for target property \"zipCode\".") ,
|
||||
messageRegExp = "Several possible source properties for target property \"zipCode\".",
|
||||
javaVersions = { SourceVersion.RELEASE_6 } ),
|
||||
@Diagnostic(type = ErroneousSourceTargetMapper.class,
|
||||
kind = Kind.ERROR,
|
||||
line = 29,
|
||||
messageRegExp = "Several possible source properties for target property \"street\".",
|
||||
javaVersions = { SourceVersion.RELEASE_6 } )
|
||||
messageRegExp = "Several possible source properties for target property \"street\"."),
|
||||
|
||||
})
|
||||
|
||||
public void shouldFailToGenerateMappingsForAmbigiousSourceProperty() {
|
||||
|
@ -136,8 +136,8 @@ public class InheritConfigurationTest {
|
||||
@Diagnostic(type = SourceTargetMapperAmbiguous1.class,
|
||||
kind = Kind.WARNING,
|
||||
line = 55,
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, nestedResultProp, integerPropY, "
|
||||
+ "constantProp, expressionProp\"")
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
|
||||
+ "expressionProp, nestedResultProp\"")
|
||||
}
|
||||
)
|
||||
public void shouldRaiseAmbiguousReverseMethodError() {
|
||||
@ -156,8 +156,8 @@ public class InheritConfigurationTest {
|
||||
@Diagnostic(type = SourceTargetMapperAmbiguous2.class,
|
||||
kind = Kind.WARNING,
|
||||
line = 55,
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, nestedResultProp, integerPropY, "
|
||||
+ "constantProp, expressionProp\"")
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
|
||||
+ "expressionProp, nestedResultProp\"")
|
||||
}
|
||||
)
|
||||
public void shouldRaiseAmbiguousReverseMethodErrorWrongName() {
|
||||
@ -176,8 +176,8 @@ public class InheritConfigurationTest {
|
||||
@Diagnostic(type = SourceTargetMapperAmbiguous3.class,
|
||||
kind = Kind.WARNING,
|
||||
line = 55,
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, nestedResultProp, integerPropY, "
|
||||
+ "constantProp, expressionProp\"") }
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
|
||||
+ "expressionProp, nestedResultProp\"") }
|
||||
)
|
||||
public void shouldRaiseAmbiguousReverseMethodErrorDuplicatedName() {
|
||||
}
|
||||
@ -195,8 +195,8 @@ public class InheritConfigurationTest {
|
||||
@Diagnostic(type = SourceTargetMapperNonMatchingName.class,
|
||||
kind = Kind.WARNING,
|
||||
line = 46,
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, nestedResultProp, integerPropY, "
|
||||
+ "constantProp, expressionProp\"")
|
||||
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
|
||||
+ "expressionProp, nestedResultProp\"")
|
||||
}
|
||||
)
|
||||
public void shouldAdviseOnSpecifyingCorrectName() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user