### Question:
LdapResultImpl implements LdapResult { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !( obj instanceof LdapResult ) ) { return false; } LdapResult result = ( LdapResult ) obj; if ( referral == null && result.getReferral() != null ) { return false; } if ( result.getReferral() == null && referral != null ) { return false; } if ( referral != null && result.getReferral() != null && !referral.equals( result.getReferral() ) ) { return false; } if ( !resultCode.equals( result.getResultCode() ) ) { return false; } String errMsg0 = diagnosticMessage; String errMsg1 = result.getDiagnosticMessage(); if ( errMsg0 == null ) { errMsg0 = ""; } if ( errMsg1 == null ) { errMsg1 = ""; } if ( !errMsg0.equals( errMsg1 ) ) { return false; } if ( matchedDn != null ) { if ( !matchedDn.equals( result.getMatchedDn() ) ) { return false; } } else if ( result.getMatchedDn() != null ) { return false; } return true; }  @Override String getDiagnosticMessage(); @Override void setDiagnosticMessage( String diagnosticMessage ); @Override Dn getMatchedDn(); @Override void setMatchedDn( Dn matchedDn ); @Override ResultCodeEnum getResultCode(); @Override void setResultCode( ResultCodeEnum resultCode ); @Override Referral getReferral(); @Override boolean isReferral(); @Override void setReferral( Referral referral ); @Override boolean isDefaultSuccess(); @Override int hashCode(); @Override boolean equals( Object obj ); @Override String toString();  }### Answer:
@Test public void testEqualsSameObj() { LdapResultImpl r0 = new LdapResultImpl(); assertTrue( r0.equals( r0 ), "same object should be equal" ); }
@Test public void testEqualsDefaultCopy() { LdapResultImpl r0 = new LdapResultImpl(); LdapResultImpl r1 = new LdapResultImpl(); assertTrue( r0.equals( r1 ), "default copy should be equal" ); assertTrue( r1.equals( r0 ), "default copy should be equal" ); }
@Test public void testEqualsDiffLockableParent() { LdapResultImpl r0 = new LdapResultImpl(); LdapResultImpl r1 = new LdapResultImpl(); assertTrue( r0.equals( r1 ), "default copy with different lockable parents should be equal" ); assertTrue( r1.equals( r0 ), "default copy with different lockable parents should be equal" ); }
@Test public void testEqualsDiffImpl() { LdapResultImpl r0 = new LdapResultImpl(); LdapResult r1 = new LdapResult() { public ResultCodeEnum getResultCode() { return ResultCodeEnum.SUCCESS; } public void setResultCode( ResultCodeEnum a_resultCode ) { } public Dn getMatchedDn() { return null; } public void setMatchedDn( Dn dn ) { } public String getDiagnosticMessage() { return null; } public void setDiagnosticMessage( String diagnosticMessage ) { } public boolean isReferral() { return false; } public Referral getReferral() { return null; } public void setReferral( Referral referral ) { } public boolean isDefaultSuccess() { return false; } }; assertTrue( r0.equals( r1 ), "r0 equals should see other impl r1 as equal" ); assertFalse( r1.equals( r0 ), "r1 impl uses Object.equals() so it should not see r0 as the same object" ); }