### Question:
JaxbAssertion extends PrimitiveAssertion { @Override @SuppressWarnings("unchecked") public boolean equal(PolicyComponent policyComponent) { if (!super.equal(policyComponent)) { return false; } JaxbAssertion<T> a = (JaxbAssertion<T>)policyComponent; return data.equals(a.getData()); } JaxbAssertion();  JaxbAssertion(QName qn, boolean optional);  JaxbAssertion(QName qn, boolean optional, boolean ignorable); @Override @SuppressWarnings("unchecked") boolean equal(PolicyComponent policyComponent); @Override boolean equals(Object o); @Override int hashCode(); void setData(T d); T getData(); @SuppressWarnings("unchecked") static JaxbAssertion<T> cast(Assertion a); @SuppressWarnings("unchecked") static JaxbAssertion<T> cast(Assertion a, Class<T> type); @Override void serialize(XMLStreamWriter writer);  }### Answer:
@Test public void testEqual() { JaxbAssertion<FooType> assertion = new JaxbAssertion<>(); FooType data = new FooType(); data.setName("CXF"); data.setNumber(2); QName qn = new QName("http: assertion.setName(qn); assertion.setData(data); PolicyComponent pc = new Policy(); assertFalse(assertion.equal(pc)); pc = new All(); assertFalse(assertion.equal(pc)); pc = new ExactlyOne(); assertFalse(assertion.equal(pc)); IMocksControl ctrl = EasyMock.createNiceControl(); PrimitiveAssertion xpa = ctrl.createMock(PrimitiveAssertion.class); QName oqn = new QName("http: EasyMock.expect(xpa.getName()).andReturn(oqn); EasyMock.expect(xpa.getType()).andReturn(Constants.TYPE_ASSERTION); ctrl.replay(); assertFalse(assertion.equal(xpa)); ctrl.verify(); FooType odata = new FooType(); odata.setName(data.getName()); odata.setNumber(data.getNumber()); JaxbAssertion<FooType> oassertion = new JaxbAssertion<>(); oassertion.setData(odata); oassertion.setName(qn); assertFalse(assertion.equal(oassertion)); oassertion.setData(data); assertTrue(assertion.equal(oassertion)); assertTrue(assertion.equal(assertion)); }