party = getSession().create("examples.Party"); party.set("id", BigInteger.ZERO); party.set("email", "jorris@arsdigita.com"); party.save();  ObjectType userType = getSession().create("examples.User").getObjectType(); party.specialize( userType );
DataObject user = getSession().create(new OID("examples.User", BigInteger.ZERO)); user.set("email", "jorris@arsdigita.com"); user.set("firstName", "NA"); user.set("lastNames", "NA"); user.save();  party = getSession().retrieve(new OID("examples.Party", BigInteger.ZERO)); party.specialize(user.getObjectType()); assertEquals("NA", party.get("firstName")); assertEquals("NA", party.get("lastNames"));
    public void testSetAssociationToNull() {        DataObject parent = getSession().create("examples.Node");        parent.set("id", new BigDecimal(42));        parent.set("name", "Parent");        parent.save();        DataObject node = getSession().create("examples.Node");        node.set("id", new BigDecimal(7));        node.set("name", "Child");        node.set("parent", parent);        node.save();        DataObject node2 = getSession().retrieve(            new OID("examples.Node", new BigDecimal(7)));        DataObject parent2 = (DataObject)node2.get("parent");        assert("Parents not equal", parent.equals(parent2));        DataObject node3 = getSession().retrieve(            new OID("examples.Node", new BigDecimal(7)));        // try erasing the parent.        node3.set("parent", null);        node3.save();        parent2 = (DataObject)node3.get("parent");        assert("Parent not set to null", parent2 == null);    }        public void testSpecialize() {        DataObject node = getSession().create("examples.Node");        try {            node.specialize("grick!");            fail("Specialized on a nonsensical ObjectType name!");            } catch (RuntimeException e) {        }        try {            node.specialize( node.getObjectType() );        } catch (RuntimeException e) {            fail("Failed to Specialize on self!");        }        DataObject party = getSession().create("examples.Party");        party.specialize("examples.User");        party = getSession().create("examples.Party");        party.set("id", BigInteger.ZERO);        party.set("email", "jorris@arsdigita.com");        party.save();                ObjectType userType = getSession().create("examples.User").getObjectType();        party.specialize( userType );        party.set("firstName", "Jon");        party.set("lastNames", "Orris");        party.save();                try {            party.specialize("examples.Party");            fail("Reversed specialization!");        } catch (RuntimeException e) {        }               }