Examples of InvRefParentModel


Examples of org.slim3.json.test.issue103.InvRefParentModel

public class InverseModelRefAttrModelTest extends AppEngineTestCase{
    @Test
    public void modelToJson() throws Exception {
        InvRefChildModel child1 = new InvRefChildModel();
        InvRefChildModel child2 = new InvRefChildModel();
        InvRefParentModel parent = new InvRefParentModel();
        child1.setName("child1");
        child1.getParentRef().setModel(parent);
        child2.setName("child2");
        child2.getParentRef().setModel(parent);
        parent.setName("parent");
        parent.getRef().setModel(child1);
        Datastore.put(child1, child2, parent);

        String json = meta.modelToJson(parent, 1);
        System.out.println(json);
        System.out.println(InvRefChildModelMeta.get().modelToJson(child1, 1));
        JSON.decode(json);

        assertEquals(
            "{\"invListRef\":[{\"name\":\"child1\"},{\"name\":\"child2\"}]" +
            ",\"name\":\"parent\",\"ref\":\"" + Datastore.keyToString(parent.getRef().getKey()) + "\"}",
            json);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.