#2018 Add test case with properties with underscore verifying that it is working as expected

This commit is contained in:
Filip Hrisafov 2020-02-23 17:10:00 +01:00
parent f5771c4177
commit b9f86fe6ac
4 changed files with 104 additions and 0 deletions

View File

@ -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._2018;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
/**
* @author Filip Hrisafov
*/
@Mapper
public interface Issue2018Mapper {
Issue2018Mapper INSTANCE = Mappers.getMapper( Issue2018Mapper.class );
@Mapping(target = "some_value", source = "someValue")
Target map(Source source);
}

View File

@ -0,0 +1,38 @@
/*
* 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._2018;
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("2018")
@RunWith(AnnotationProcessorTestRunner.class)
@WithClasses({
Issue2018Mapper.class,
Source.class,
Target.class
})
public class Issue2018Test {
@Test
public void shouldGenerateCorrectCode() {
Source source = new Source();
source.setSomeValue( "value" );
Target target = Issue2018Mapper.INSTANCE.map( source );
assertThat( target ).isNotNull();
assertThat( target.getSome_value() ).isEqualTo( "value" );
}
}

View File

@ -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._2018;
/**
* @author Filip Hrisafov
*/
public class Source {
private String someValue;
public String getSomeValue() {
return someValue;
}
public void setSomeValue(String someValue) {
this.someValue = someValue;
}
}

View File

@ -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._2018;
/**
* @author Filip Hrisafov
*/
public class Target {
private String some_value;
public String getSome_value() {
return some_value;
}
public void setSome_value(String some_value) {
this.some_value = some_value;
}
}