### Question:
BasicIpRule implements IpRule { @Override public boolean equals( final Object obj ) { if( ! ( obj instanceof IpRule ) ) { return false; } IpRule rule = ( IpRule )obj; if( ! fromPort.equals( rule.getFromPort() ) || ! toPort.equals( rule.getToPort() ) || ! ipProtocol.equals( rule.getIpProtocol() ) || ipRanges.size() != rule.getIpRanges().size() ) { return false; } for( String myRange: ipRanges ) { boolean exists = false; for( String range: rule.getIpRanges() ) { if( myRange.equals( range ) ) { exists = true; break; } } if( ! exists ) { return false; } } return true; }  @Override String getIpProtocol(); void setIpProtocol( final String ipProtocol ); @Override IpRule withIpProtocol( final String ipProtocol ); @Override Integer getFromPort(); void setFromPort( Integer fromPort ); @Override IpRule withFromPort( final Integer fromPort ); @Override Integer getToPort(); @Override IpRule withToPort( final Integer toPort ); void setToPort( Integer toPort ); @Override List<String> getIpRanges(); void setIpRanges( List<String> ipRanges ); @Override IpRule withIpRanges( final String... ipRanges ); @Override boolean equals( final Object obj );  }### Answer:
@Test public void testEquals() { assertTrue( ipRuleSet1.equals( ipRuleSet2 ) ); }
@Test public void testNotEquals() { assertTrue( ! ipRuleSet1.equals( ipRuleSet4 ) ); assertTrue( ! ipRuleSet1.equals( ipRuleSet3 ) ); assertTrue( ! ipRuleSet1.equals( ipRuleSet5 ) ); assertTrue( ! ipRuleSet3.equals( ipRuleSet5 ) ); }