Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,7 @@ private void applyParameterNameBasedMapping() {
sourceParameters.remove();
unprocessedDefinedTargets.remove( targetProperty.getKey() );
unprocessedSourceProperties.remove( targetProperty.getKey() );
unprocessedConstructorProperties.remove( targetProperty.getKey() );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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.bugs._2251;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface Issue2251Mapper {

Issue2251Mapper INSTANCE = Mappers.getMapper( Issue2251Mapper.class );

@Mapping(target = "value1", source = "source.value")
Target map(Source source, String value2);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.bugs._2251;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author Filip Hrisafov
*/
@IssueKey("2251")
@RunWith(AnnotationProcessorTestRunner.class)
@WithClasses({
Issue2251Mapper.class,
Source.class,
Target.class,
})
public class Issue2251Test {

@Test
public void shouldGenerateCorrectCode() {

Target target = Issue2251Mapper.INSTANCE.map( new Source( "source" ), "test" );

assertThat( target ).isNotNull();
assertThat( target.getValue1() ).isEqualTo( "source" );
assertThat( target.getValue2() ).isEqualTo( "test" );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* 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.bugs._2251;

/**
* @author Filip Hrisafov
*/
public class Source {

private final String value;

public Source(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.bugs._2251;

public class Target {
private final String value1;
private final String value2;

public Target(String value1, String value2) {
this.value1 = value1;
this.value2 = value2;
}

public String getValue1() {
return value1;
}

public String getValue2() {
return value2;
}
}