Skip to content

Instantly share code, notes, and snippets.

@yonatang
Created April 8, 2015 07:37
Show Gist options
  • Save yonatang/f537ae568a26d08163b8 to your computer and use it in GitHub Desktop.
Save yonatang/f537ae568a26d08163b8 to your computer and use it in GitHub Desktop.
Orika SortedSet test
package orika;
import ma.glasnost.orika.MapperFacade;
import ma.glasnost.orika.impl.DefaultMapperFactory;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.util.SortedSet;
import java.util.TreeSet;
/**
* Created by yonatan on 8/4/2015.
*/
public class SortedSetTest {
MapperFacade mapper;
@Before
public void setup(){
mapper = new DefaultMapperFactory.Builder().build().getMapperFacade();
}
public static class Foo {
public SortedSet<String> getSortedSet(){
return this.sortedSet;
}
public void setSortedSet(SortedSet<String> sortedSet){
this.sortedSet=sortedSet;
}
private SortedSet<String> sortedSet;
}
public static class Bar {
public SortedSet<String> getSortedSet(){
return this.sortedSet;
}
public void setSortedSet(SortedSet<String> sortedSet){
this.sortedSet=sortedSet;
}
private SortedSet<String> sortedSet;
}
@Test
public void shouldMapSortedSet(){
Foo a=new Foo();
a.setSortedSet(new TreeSet<String>());
Bar b = mapper.map(a, Bar.class); //throw ClassCastException: java.util.LinkedHashSet cannot be cast to java.util.SortedSet
Assert.assertTrue(b.getSortedSet().isEmpty());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment