Element implements IAttributes { @Override public boolean isDefined(String identifier) { if (attributes.isDefined(identifier)) { return true; } else if (parent != null) { return parent.isDefined(identifier); } else { return false; } } Element(String id);  Element(Element parent); String getId(); Element getParent(); void setParent(Element element); @SuppressWarnings("unchecked") @Override O getAttribute(String identifier); @Override boolean isDefined(String identifier); @Override Attributes getAttributes(); Attributes getLocalAttributes(); Set<String> getLocalAttributeNames(); @Override void setAttribute(String identifier, Object object); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override Parameter getAttributeParameter(String identifier); @Override Set<String> getAttributeNames(); String getType(); void setType(String type); static String TYPE; }
@Test public void testIsdefined() { Element parent = new Element("id"); String parentattribute = "a"; parent.setAttribute(parentattribute, 1); Element element = new Element(parent); String attribute = "b"; element.setAttribute(attribute, 1); Assert.assertTrue(element.isDefined(attribute)); Assert.assertTrue(element.isDefined(parentattribute)); Assert.assertFalse(element.isDefined("c")); }