Search in sources :

Example 1 with Group

use of jodd.json.mock.Group in project jodd by oblac.

the class JSONDeserializerTest method testArrayType.

@Test
public void testArrayType() {
    Person igor = creator.createJodder();
    Person modesty = creator.createModesty();
    Group group = new Group("brothers", igor, modesty);
    String json = new JsonSerializer().include("people").exclude("*.class").serialize(group);
    Group bro = new JsonParser().map(Group.class).parse(json);
    assertNotNull(bro);
    assertEquals("brothers", bro.getGroupName());
    assertEquals(2, bro.getPeople().length);
    assertEquals("Igor", bro.getPeople()[0].getFirstname());
    assertEquals("Modesty", bro.getPeople()[1].getFirstname());
}
Also used : Group(jodd.json.mock.Group) DateJsonSerializer(jodd.json.impl.DateJsonSerializer) Person(jodd.json.mock.Person) Test(org.junit.Test)

Example 2 with Group

use of jodd.json.mock.Group in project jodd by oblac.

the class JSONDeserializerTest method testEmptyArray.

@Test
public void testEmptyArray() {
    Group group = new JsonParser().parse("{\"people\": [], \"groupName\": \"Nobody\" }", Group.class);
    assertEquals("Nobody", group.getGroupName());
    assertEquals(0, group.getPeople().length);
}
Also used : Group(jodd.json.mock.Group) Test(org.junit.Test)

Aggregations

Group (jodd.json.mock.Group)2 Test (org.junit.Test)2 DateJsonSerializer (jodd.json.impl.DateJsonSerializer)1 Person (jodd.json.mock.Person)1