|
@@ -1,17 +1,17 @@
|
|
|
package net.ranides.assira.reflection;
|
|
package net.ranides.assira.reflection;
|
|
|
|
|
|
|
|
-import org.junit.Assume;
|
|
|
|
|
-import org.junit.Ignore;
|
|
|
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import net.ranides.assira.generic.SerializationUtils;
|
|
import net.ranides.assira.generic.SerializationUtils;
|
|
|
import net.ranides.assira.generic.TypeToken;
|
|
import net.ranides.assira.generic.TypeToken;
|
|
|
|
|
+import net.ranides.assira.reflection.mockup.ForIClass;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
-import java.lang.reflect.Type;
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
-import static org.junit.Assert.*;
|
|
|
|
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
|
|
+import static org.junit.Assert.assertNotNull;
|
|
|
|
|
|
|
|
public class IClassTest {
|
|
public class IClassTest {
|
|
|
|
|
|
|
@@ -26,23 +26,36 @@ public class IClassTest {
|
|
|
assertNotNull(SerializationUtils.copy(type2));
|
|
assertNotNull(SerializationUtils.copy(type2));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Ignore("todo #19")
|
|
|
|
|
@Test
|
|
@Test
|
|
|
public void genericSerialization() throws IOException {
|
|
public void genericSerialization() throws IOException {
|
|
|
IClass<?> type2 = IClass.typeinfo(Lister.class).field("list").get().type();
|
|
IClass<?> type2 = IClass.typeinfo(Lister.class).field("list").get().type();
|
|
|
- IClass<?> type3 = new TypeToken<List<String>>() {};
|
|
|
|
|
|
|
+ IClass<?> type3 = IClass.typeinfo(Lister.class).field("nested").get().type();
|
|
|
|
|
|
|
|
- // this lines work, but generic information is lost
|
|
|
|
|
- assertNotNull(SerializationUtils.copy(type2.reflective()));
|
|
|
|
|
- assertNotNull(SerializationUtils.copy(type3.reflective()));
|
|
|
|
|
|
|
+ IClass<?> copy2 = SerializationUtils.copy(type2);
|
|
|
|
|
+ assertNotNull(copy2);
|
|
|
|
|
+ assertEquals(type2.toString(), copy2.toString());
|
|
|
|
|
+ assertEquals(ForIClass.FLOAT, type2.params().get(0));
|
|
|
|
|
|
|
|
- assertNotNull(SerializationUtils.copy(type2));
|
|
|
|
|
- assertNotNull(SerializationUtils.copy(type3));
|
|
|
|
|
|
|
+ IClass<?> copy3 = SerializationUtils.copy(type3);
|
|
|
|
|
+ assertNotNull(copy3);
|
|
|
|
|
+ assertEquals(type3.toString(), copy3.toString());
|
|
|
|
|
+ assertEquals(ForIClass.I_NUMBER, copy3.params().get(0).params().get(1));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Test
|
|
|
|
|
+ public void tokenSerialization() throws IOException {
|
|
|
|
|
+ IClass<?> type4 = new TypeToken<List<String>>() {};
|
|
|
|
|
+
|
|
|
|
|
+ IClass<?> copy4 = SerializationUtils.read(IClass.class, SerializationUtils.write(type4));
|
|
|
|
|
+ assertNotNull(copy4);
|
|
|
|
|
+ assertEquals(type4.toString(), copy4.toString());
|
|
|
|
|
+ assertEquals(ForIClass.STRING, type4.params().get(0));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private static final class Lister {
|
|
private static final class Lister {
|
|
|
|
|
|
|
|
public List<Float> list;
|
|
public List<Float> list;
|
|
|
|
|
+ public List<Map<String, Number>> nested;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|