### Question:
OpaqueExtendedResponse extends AbstractExtendedResponse { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !super.equals( obj ) ) { return false; } if ( !( obj instanceof OpaqueExtendedResponse ) ) { return false; } OpaqueExtendedResponse extendedRequest = ( OpaqueExtendedResponse ) obj; if ( ( ( responseName != null ) && !responseName.equals( extendedRequest.responseName ) ) || ( ( responseName == null ) && ( extendedRequest.responseName != null ) ) ) { return false; } return Arrays.equals( responseValue, extendedRequest.responseValue ); } OpaqueExtendedResponse();  OpaqueExtendedResponse( int messageId );  OpaqueExtendedResponse( String responseName );  OpaqueExtendedResponse( int messageId, String responseName ); byte[] getResponseValue(); void setResponseValue( byte[] responseValue ); @Override int hashCode(); @Override boolean equals( Object obj ); @Override String toString();  }### Answer:
@Test public void testEqualsSameObj() { ExtendedResponse resp = createStub(); assertTrue( resp.equals( resp ) ); }
@Test public void testEqualsExactCopy() { ExtendedResponse resp0 = createStub(); ExtendedResponse resp1 = createStub(); assertTrue( resp0.equals( resp1 ) ); assertTrue( resp1.equals( resp0 ) ); }
@Test public void testEqualsDiffImpl() throws LdapInvalidDnException { ExtendedResponse resp0 = createStub(); ExtendedResponse resp1 = new OpaqueExtendedResponse( 45, "1.1.1.1" ); resp1.getLdapResult().setMatchedDn( new Dn( "dc=example,dc=com" ) ); resp1.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS ); ReferralImpl refs = new ReferralImpl(); refs.addLdapUrl( "ldap: refs.addLdapUrl( "ldap: refs.addLdapUrl( "ldap: resp1.getLdapResult().setReferral( refs ); assertTrue( resp0.equals( resp1 ) ); assertTrue( resp1.equals( resp0 ) ); }
@Test public void testNotEqualsDiffIds() { ExtendedResponse resp0 = new OpaqueExtendedResponse( 3 ); ExtendedResponse resp1 = new OpaqueExtendedResponse( 4 ); assertFalse( resp0.equals( resp1 ) ); assertFalse( resp1.equals( resp0 ) ); }
@Test public void testNotEqualsDiffNames() { ExtendedResponse resp0 = createStub(); resp0.setResponseName( "1.2.3.4" ); ExtendedResponse resp1 = createStub(); resp1.setResponseName( "1.2.3.4.5" ); assertFalse( resp0.equals( resp1 ) ); assertFalse( resp1.equals( resp0 ) ); }