try {
Mapper mapper = getMapper();
assertNotNull("Mapper is null", mapper);
ClassDescriptor classDescriptor = mapper
.getClassDescriptorByClass(Ancestor.class);
assertNotNull("Classdescriptor is null", classDescriptor);
assertEquals("Incorrect path field", classDescriptor
.getPathFieldDescriptor().getFieldName(), "path");
assertTrue("The ancestor class has no discriminator",
classDescriptor.hasDiscriminator());
assertTrue("The ancestor class is not abstract", classDescriptor
.isAbstract());
assertNull("The ancestor class has an ancestor", classDescriptor
.getSuperClassDescriptor());
assertTrue(
"Ancestor class doesn't have a node type per hierarchy strategy",
classDescriptor.usesNodeTypePerHierarchyStrategy());
assertFalse(
"Ancestor class have a node type per hierarchy strategy",
classDescriptor.usesNodeTypePerConcreteClassStrategy());
Collection descendandDescriptors = classDescriptor
.getDescendantClassDescriptors();
assertEquals("Invalid number of descendants", descendandDescriptors
.size(), 2);
classDescriptor = mapper.getClassDescriptorByClass(Descendant.class);
assertNotNull("Classdescriptor is null", classDescriptor);
assertEquals("Incorrect path field", classDescriptor
.getPathFieldDescriptor().getFieldName(), "path");
assertTrue("The descendant class has no discriminator",
classDescriptor.hasDiscriminator());
assertNotNull("ancerstorField is null in the descendant class",
classDescriptor.getFieldDescriptor("ancestorField"));
assertFalse("The descendant class is abstract", classDescriptor
.isAbstract());
assertNotNull("The descendant class has not an ancestor",
classDescriptor.getSuperClassDescriptor());
assertEquals("Invalid ancestor class for the descendant class",
classDescriptor.getSuperClassDescriptor().getClassName(),
"org.apache.jackrabbit.ocm.testmodel.inheritance.Ancestor");
descendandDescriptors = classDescriptor
.getDescendantClassDescriptors();
assertEquals("Invalid number of descendants", descendandDescriptors
.size(), 1);
assertTrue(
"Descendant class doesn't have a node type per hierarchy strategy",
classDescriptor.usesNodeTypePerHierarchyStrategy());
assertFalse(
"Descendant class have a node type per hierarchy strategy",
classDescriptor.usesNodeTypePerConcreteClassStrategy());
classDescriptor = mapper.getClassDescriptorByClass(SubDescendant.class);
assertNotNull("Classdescriptor is null", classDescriptor);
assertEquals("Incorrect path field", classDescriptor
.getPathFieldDescriptor().getFieldName(), "path");
assertTrue("The subdescendant class has no discriminator",
classDescriptor.hasDiscriminator());
assertNotNull("ancestorField is null in the descendant class",
classDescriptor.getFieldDescriptor("ancestorField"));
assertFalse("The subdescendant class is abstract", classDescriptor
.isAbstract());
assertNotNull("The subdescendant class has not an ancestor",
classDescriptor.getSuperClassDescriptor());
assertEquals("Invalid ancestor class for the descendant class",
classDescriptor.getSuperClassDescriptor().getClassName(),
"org.apache.jackrabbit.ocm.testmodel.inheritance.Descendant");
descendandDescriptors = classDescriptor
.getDescendantClassDescriptors();
assertEquals("Invalid number of descendants", descendandDescriptors
.size(), 0);
assertTrue(
"SubDescendant class doesn't have a node type per hierarchy strategy",
classDescriptor.usesNodeTypePerHierarchyStrategy());
assertFalse(
"SubDescendant class have a node type per hierarchy strategy",
classDescriptor.usesNodeTypePerConcreteClassStrategy());
} catch (JcrMappingException e) {
e.printStackTrace();
fail("Impossible to retrieve the converter " + e);
}