mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2018 Add test case with properties with underscore verifying that it is working as expected
This commit is contained in:
parent
f5771c4177
commit
b9f86fe6ac
@ -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);
|
||||||
|
}
|
@ -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" );
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user