### Question:
AbstractMessage implements Message { @Override public boolean equals( Object obj ) { if ( obj == this ) { return true; } if ( !( obj instanceof Message ) ) { return false; } Message msg = ( Message ) obj; if ( msg.getMessageId() != id ) { return false; } if ( msg.getType() != type ) { return false; } Map<String, Control> controlMap = msg.getControls(); if ( controlMap.size() != controls.size() ) { return false; } for ( String key : controls.keySet() ) { if ( !controlMap.containsKey( key ) ) { return false; } } return true; } protected  AbstractMessage( final int id, final MessageTypeEnum type ); @Override int getMessageId(); @Override Message setMessageId( int id ); @Override Map<String, Control> getControls(); @Override Control getControl( String oid ); @Override boolean hasControl( String oid ); @Override Message addControl( Control control ); @Override Message removeControl( Control control ); @Override MessageTypeEnum getType(); @Override Object get( Object key ); @Override Object put( Object key, Object value ); @Override boolean equals( Object obj ); @Override int hashCode(); @Override Message addAllControls( Control[] controls ); String toString( String message );  }### Answer:
@Test public void testEqualsSameObj() { AbstractMessage msg; msg = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST ) { }; assertTrue( msg.equals( msg ) ); }
@Test public void testEqualsExactCopy() { AbstractMessage msg0; AbstractMessage msg1; msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST ) { }; msg1 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST ) { }; assertTrue( msg0.equals( msg1 ) ); assertTrue( msg1.equals( msg0 ) ); }
@Test public void testNotEqualsDiffId() { AbstractMessage msg0; AbstractMessage msg1; msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST ) { }; msg1 = new AbstractMessage( 6, MessageTypeEnum.BIND_REQUEST ) { }; assertFalse( msg0.equals( msg1 ) ); assertFalse( msg1.equals( msg0 ) ); }
@Test public void testNotEqualsDiffType() { AbstractMessage msg0; AbstractMessage msg1; msg0 = new AbstractMessage( 5, MessageTypeEnum.BIND_REQUEST ) { }; msg1 = new AbstractMessage( 5, MessageTypeEnum.UNBIND_REQUEST ) { }; assertFalse( msg0.equals( msg1 ) ); assertFalse( msg1.equals( msg0 ) ); }