#6 Adding test for mapping into raw type

This commit is contained in:
Gunnar Morling 2013-05-03 19:41:30 +02:00
parent d404775519
commit 321e1a3206
4 changed files with 37 additions and 1 deletions

View File

@ -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 );
}
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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;
}
}