Search in sources :

Example 1 with MockDataObject

use of org.apache.cayenne.MockDataObject in project cayenne by apache.

the class ObjectStoreIT method testRegisteredObjectsCount.

@Test
public void testRegisteredObjectsCount() throws Exception {
    assertEquals(0, context.getObjectStore().registeredObjectsCount());
    DataObject o1 = new MockDataObject();
    o1.setObjectId(new ObjectId("T", "key1", "v1"));
    context.getObjectStore().registerNode(o1.getObjectId(), o1);
    assertEquals(1, context.getObjectStore().registeredObjectsCount());
    // test object with same id
    DataObject o2 = new MockDataObject();
    o2.setObjectId(new ObjectId("T", "key1", "v1"));
    context.getObjectStore().registerNode(o2.getObjectId(), o2);
    assertEquals(1, context.getObjectStore().registeredObjectsCount());
    // test new object
    DataObject o3 = new MockDataObject();
    o3.setObjectId(new ObjectId("T", "key3", "v3"));
    context.getObjectStore().registerNode(o3.getObjectId(), o3);
    assertEquals(2, context.getObjectStore().registeredObjectsCount());
}
Also used : MockDataObject(org.apache.cayenne.MockDataObject) DataObject(org.apache.cayenne.DataObject) ObjectId(org.apache.cayenne.ObjectId) MockDataObject(org.apache.cayenne.MockDataObject) Test(org.junit.Test)

Aggregations

DataObject (org.apache.cayenne.DataObject)1 MockDataObject (org.apache.cayenne.MockDataObject)1 ObjectId (org.apache.cayenne.ObjectId)1 Test (org.junit.Test)1