public void testGetDataObject() { DataCollection allItems = getDefaultCollection(); int count = 0; while (allItems.next()) { DataObject obj = allItems.getDataObject(); assertEquals("Somehow failed to retrieve a Node?", "Node", obj.getObjectType().getName()); count++; } assertTrue("No data objects?", count > 0); }
private DataCollection getOrderCollection() { int id = 1; Calendar now = Calendar.getInstance(); int currentDay = now.get(Calendar.DAY_OF_YEAR); DataObject order = getSession().create("examples.Order"); order.set("id", new BigDecimal(id++)); order.set("buyer", "Rafael H. Schloming"); order.set("shippingAddress", "102 R Inman St.\nCambridge MA, 02139"); order.set("seller", "ArsDigita"); order.set("shippingDate", now.getTime()); order.set("hasShipped", Boolean.FALSE); order.save(); now.set(Calendar.DAY_OF_YEAR, ++currentDay); order = getSession().create("examples.Order"); order.set("id", new BigDecimal(id++)); order.set("buyer", "Jon Orris"); order.set("shippingAddress", "80 Prospect St"); order.set("shippingDate", now.getTime()); order.set("hasShipped", Boolean.TRUE); order.set("seller", "ArsDigita"); order.save(); now.set(Calendar.DAY_OF_YEAR, ++currentDay); order = getSession().create("examples.Order"); order.set("id", new BigDecimal(id++)); order.set("buyer", "Foo Bar"); order.set("shippingAddress", "Nowhere, MA"); order.set("shippingDate", now.getTime()); order.set("seller", "ArsDigita"); order.set("hasShipped", Boolean.TRUE); order.save(); now.set(Calendar.DAY_OF_YEAR, ++currentDay); order = getSession().create("examples.Order"); order.set("id", new BigDecimal(id++)); order.set("buyer", "Micro Soft"); order.set("shippingAddress", "Redmond, WA"); order.set("shippingDate", now.getTime()); order.set("seller", "ArsDigita"); order.set("hasShipped", Boolean.TRUE); order.save(); now.set(Calendar.DAY_OF_YEAR, ++currentDay); order = getSession().create("examples.Order"); order.set("id", new BigDecimal(id++)); order.set("buyer", "Micro Soft"); order.set("shippingAddress", "Redmond, WA"); order.set("shippingDate", now.getTime()); order.set("seller", "FooBar consulting"); order.set("hasShipped", Boolean.TRUE); order.save(); now.set(Calendar.DAY_OF_YEAR, ++currentDay); order = getSession().create("examples.Order"); order.set("id", new BigDecimal(id++)); order.set("buyer", "Foo Bar"); order.set("shippingAddress", "Nowhere, MA"); order.set("shippingDate", now.getTime()); order.set("seller", "Smurf!"); order.set("hasShipped", Boolean.TRUE); order.save(); return getSession().retrieve("examples.Order"); }
protected void setUp() { DataObject parent = getSession().create("examples.Node"); m_nodeType = parent.getObjectType(); parent.set("id", new BigDecimal(0)); parent.set("name", "Root"); parent.save(); for (int i = 1; i < 10; i++) { DataObject child = getSession().create("examples.Node"); child.set("id", new BigDecimal(i)); child.set("name", "child" + i); child.set("parent", parent); child.save(); parent.save(); parent = child; } }