mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#6 Adding test for mapping into raw type
This commit is contained in:
parent
d404775519
commit
321e1a3206
@ -202,4 +202,16 @@ public class CollectionMappingTest extends MapperTestBase {
|
||||
assertThat( source ).isNotNull();
|
||||
assertThat( source.getIntegerList() ).containsOnly( 1, 2 );
|
||||
}
|
||||
|
||||
@Test
|
||||
@IssueKey("6")
|
||||
public void shouldMapIntegerSetToRawSet() {
|
||||
Source source = new Source();
|
||||
source.setIntegerSet( new HashSet<Integer>( Arrays.asList( 1, 2 ) ) );
|
||||
|
||||
Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source );
|
||||
|
||||
assertThat( target ).isNotNull();
|
||||
assertThat( target.getSet() ).containsOnly( 1, 2 );
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ public class Source {
|
||||
|
||||
private List<Integer> integerList;
|
||||
|
||||
private Set<Integer> integerSet;
|
||||
|
||||
public List<String> getStringList() {
|
||||
return stringList;
|
||||
}
|
||||
@ -80,4 +82,12 @@ public class Source {
|
||||
public void setIntegerList(List<Integer> integerList) {
|
||||
this.integerList = integerList;
|
||||
}
|
||||
|
||||
public Set<Integer> getIntegerSet() {
|
||||
return integerSet;
|
||||
}
|
||||
|
||||
public void setIntegerSet(Set<Integer> integerSet) {
|
||||
this.integerSet = integerSet;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ public interface SourceTargetMapper {
|
||||
public static SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
|
||||
|
||||
@Mappings({
|
||||
@Mapping(source = "integerList", target = "integerCollection")
|
||||
@Mapping(source = "integerList", target = "integerCollection"),
|
||||
@Mapping(source = "integerSet", target = "set")
|
||||
})
|
||||
Target sourceToTarget(Source source);
|
||||
|
||||
|
@ -33,6 +33,9 @@ public class Target {
|
||||
|
||||
private Collection<Integer> integerCollection;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private Set set;
|
||||
|
||||
public List<String> getStringList() {
|
||||
return stringList;
|
||||
}
|
||||
@ -80,4 +83,14 @@ public class Target {
|
||||
public void setIntegerCollection(Collection<Integer> integerCollection) {
|
||||
this.integerCollection = integerCollection;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Set getSet() {
|
||||
return set;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void setSet(Set set) {
|
||||
this.set = set;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user