Search in sources :

Example 16 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class PojoUtilsTest method test_PojoArray.

@Test
public void test_PojoArray() throws Exception {
    Person[] array = new Person[2];
    array[0] = new Person();
    {
        Person person = new Person();
        person.setName("xxxx");
        array[1] = person;
    }
    assertArrayObject(array);
}
Also used : BigPerson(com.alibaba.dubbo.common.model.person.BigPerson) SerializablePerson(com.alibaba.dubbo.common.model.SerializablePerson) Person(com.alibaba.dubbo.common.model.Person) Test(org.junit.Test)

Example 17 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class PojoUtilsTest method testRealizeLinkedList.

@Test
public void testRealizeLinkedList() throws Exception {
    LinkedList<Person> input = new LinkedList<Person>();
    Person person = new Person();
    person.setAge(37);
    input.add(person);
    Object obj = PojoUtils.generalize(input);
    Assert.assertTrue(obj instanceof List);
    Assert.assertTrue(input.get(0) instanceof Person);
    Object output = PojoUtils.realize(obj, LinkedList.class);
    Assert.assertTrue(output instanceof LinkedList);
}
Also used : ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) BigPerson(com.alibaba.dubbo.common.model.person.BigPerson) SerializablePerson(com.alibaba.dubbo.common.model.SerializablePerson) Person(com.alibaba.dubbo.common.model.Person) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 18 with Person

use of com.alibaba.dubbo.common.model.Person in project dubbo by alibaba.

the class PojoUtilsTest method test_Map_List_pojo.

@Test
public void test_Map_List_pojo() throws Exception {
    Map<String, List<Object>> map = new HashMap<String, List<Object>>();
    List<Object> list = new ArrayList<Object>();
    list.add(new Person());
    list.add(new SerializablePerson());
    map.put("k", list);
    Object generalize = PojoUtils.generalize(map);
    Object realize = PojoUtils.realize(generalize, Map.class);
    assertEquals(map, realize);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SerializablePerson(com.alibaba.dubbo.common.model.SerializablePerson) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) BigPerson(com.alibaba.dubbo.common.model.person.BigPerson) SerializablePerson(com.alibaba.dubbo.common.model.SerializablePerson) Person(com.alibaba.dubbo.common.model.Person) Test(org.junit.Test)

Aggregations

Person (com.alibaba.dubbo.common.model.Person)18 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)9 ObjectOutput (com.alibaba.dubbo.common.serialize.ObjectOutput)7 NotSerializableException (java.io.NotSerializableException)7 HashMap (java.util.HashMap)7 List (java.util.List)6 SerializablePerson (com.alibaba.dubbo.common.model.SerializablePerson)5 BigPerson (com.alibaba.dubbo.common.model.person.BigPerson)5 HashSet (java.util.HashSet)2 LinkedList (java.util.LinkedList)2 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)2 Type (java.lang.reflect.Type)1 LinkedHashMap (java.util.LinkedHashMap)1