### Question:
ObjectClass extends CommonSchemaElements { public boolean isDescendantOf(ObjectClass objectClass) { for(ObjectClass oc : superiorClasses) { if(oc.equals(objectClass) || oc.isDescendantOf(objectClass)) { return true; } } return false; } ObjectClass(String definition, String primaryName,
                     Collection<String> names, String oid,
                     String description,
                     Set<ObjectClass> superiorClasses,
                     Set<AttributeType> requiredAttributes,
                     Set<AttributeType> optionalAttributes,
                     ObjectClassType objectClassType,
                     boolean isObsolete,
                     Map<String, List<String>> extraProperties); Set<ObjectClass> getSuperiorClasses(); boolean isDescendantOf(ObjectClass objectClass); Set<AttributeType> getRequiredAttributes(); Set<AttributeType> getRequiredAttributeChain(); boolean isRequired(AttributeType attributeType); Set<AttributeType> getOptionalAttributes(); Set<AttributeType> getOptionalAttributeChain(); boolean isOptional(AttributeType attributeType); boolean isRequiredOrOptional(AttributeType attributeType); ObjectClassType getObjectClassType(); boolean isExtensibleObject(); @Override String toString(); ObjectClass setDirty(); boolean isDirty();  }### Answer:
@Test public void testIsDescendantOfNoSuperior() throws Exception { ObjectClassBuilder builder = new ObjectClassBuilder("testType1", "1.2.1"); ObjectClass c1 = builder.getInstance(); builder = new ObjectClassBuilder("testType2", "1.2.2"); ObjectClass c2 = builder.getInstance(); Assert.assertFalse(c1.isDescendantOf(c2)); }
@Test public void testIsDescendantOfWithSuperior() throws Exception { ObjectClassBuilder builder = new ObjectClassBuilder( "grandParent", "1.2.1"); ObjectClass grandParent = builder.getInstance(); builder = new ObjectClassBuilder("parent", "1.2.2"); builder.setSuperior(Collections.singleton(grandParent)); ObjectClass parent = builder.getInstance(); builder = new ObjectClassBuilder("child", "1.2.3"); builder.setSuperior(Collections.singleton(parent)); ObjectClass child = builder.getInstance(); Assert.assertTrue(parent.isDescendantOf(grandParent)); Assert.assertTrue(child.isDescendantOf(parent)); Assert.assertTrue(child.isDescendantOf(grandParent)); Assert.assertFalse(child.isDescendantOf(child)); Assert.assertFalse(parent.isDescendantOf(child)); Assert.assertFalse(grandParent.isDescendantOf(child)); }
@Test public void testIsDescendantOfWithMultipleSuperiors() throws Exception { ObjectClassBuilder builder = new ObjectClassBuilder( "grandParent", "1.2.1"); ObjectClass grandParent = builder.getInstance(); builder = new ObjectClassBuilder("parent1", "1.2.2"); builder.setSuperior(Collections.singleton(grandParent)); ObjectClass parent1 = builder.getInstance(); builder = new ObjectClassBuilder("parent2","2.2.2"); ObjectClass parent2 = builder.getInstance(); Set<ObjectClass> superiors = new LinkedHashSet<>(); superiors.add(parent1); superiors.add(parent2); builder = new ObjectClassBuilder("child", "1.2.3"); builder.setSuperior(superiors); ObjectClass child = builder.getInstance(); Assert.assertTrue(parent1.isDescendantOf(grandParent)); Assert.assertTrue(child.isDescendantOf(parent1)); Assert.assertTrue(child.isDescendantOf(parent2)); Assert.assertTrue(child.isDescendantOf(grandParent)); Assert.assertFalse(child.isDescendantOf(child)); Assert.assertFalse(parent1.isDescendantOf(child)); Assert.assertFalse(parent1.isDescendantOf(parent2)); Assert.assertFalse(grandParent.isDescendantOf(child)); }