ocm.save();
//---------------------------------------------------------------------------------------------------------
// Retrieve Descendant class
//---------------------------------------------------------------------------------------------------------
QueryManager queryManager = ocm.getQueryManager();
Filter filter = queryManager.createFilter(Descendant.class);
Query query = queryManager.createQuery(filter);
Collection result = ocm.getObjects(query);
assertEquals("Invalid number of Descendant found", result.size(), 4);
assertTrue("Invalid item in the collection", this.contains(result, "/descendant1", Descendant.class));
assertTrue("Invalid item in the collection", this.contains(result, "/descendant2", Descendant.class));
assertTrue("Invalid item in the collection", this.contains(result, "/subdescendant", SubDescendant.class));
assertTrue("Invalid item in the collection", this.contains(result, "/subdescendant2", SubDescendant.class));
//---------------------------------------------------------------------------------------------------------
// Retrieve AnotherDescendant class
//---------------------------------------------------------------------------------------------------------
queryManager = ocm.getQueryManager();
filter = queryManager.createFilter(AnotherDescendant.class);
filter.addEqualTo("anotherDescendantField", "anotherDescendantValue");
query = queryManager.createQuery(filter);
result = ocm.getObjects(query);
assertEquals("Invalid number of AnotherDescendant found", result.size(),2);
assertTrue("Invalid item in the collection", this.contains(result, "/anotherdescendant1", AnotherDescendant.class));
assertTrue("Invalid item in the collection", this.contains(result, "/anotherdescendant2", AnotherDescendant.class));
//---------------------------------------------------------------------------------------------------------
// Retrieve some descendants & subdescendants
//---------------------------------------------------------------------------------------------------------
queryManager = ocm.getQueryManager();
filter = queryManager.createFilter(Descendant.class);
filter.addEqualTo("descendantField","descendantValue2");
query = queryManager.createQuery(filter);
result = ocm.getObjects(query);
assertEquals("Invalid ancestor object found", result.size(),2);
assertTrue("Invalid item in the collection", this.contains(result, "/descendant2", Descendant.class));
assertTrue("Invalid item in the collection", this.contains(result, "/subdescendant", SubDescendant.class));
//---------------------------------------------------------------------------------------------------------
// Retrieve all class
//---------------------------------------------------------------------------------------------------------
queryManager = ocm.getQueryManager();
filter = queryManager.createFilter(Ancestor.class);
query = queryManager.createQuery(filter);
result = ocm.getObjects(query);
assertEquals("Invalid ancestor object found", result.size(),7);
assertTrue("Invalid item in the collection", this.contains(result, "/descendant1", Descendant.class));
assertTrue("Invalid item in the collection", this.contains(result, "/descendant2", Descendant.class));