MatcherPosition implements Position { @Override public boolean equals( Object obj ) { if ( obj == null ) { return false; } if ( obj == this ) { return true; } if ( !obj.getClass().equals( getClass() ) ) { return false; } MatcherPosition that = (MatcherPosition) obj; return this.finding.equals( that.finding ); } MatcherPosition( String xmlWithPlaceholder, Finding finding ); @Override String createPlaceholder( PayloadPosition payloadPosition ); @Override int hashCode(); @Override boolean equals( Object obj ); @Override String toString();  }
@Test public void equalsTest() { Finding finding = new Finding(); finding.start = 18; finding.end = 33; finding.placeholder = "$$PAYLOADATTR$$"; MatcherPosition matcherPosition = new MatcherPosition( xmlWithPlaceholder, finding ); assertThat( matcherPosition.equals( null ), is( Boolean.FALSE ) ); assertThat( matcherPosition.equals( matcherPosition ), is( Boolean.TRUE ) ); assertThat( matcherPosition.equals( Integer.valueOf( 1 ) ), is( Boolean.FALSE ) ); Finding finding2 = new Finding(); finding2.start = 18; finding2.end = 33; finding2.placeholder = "$$PAYLOADATTR$$"; MatcherPosition findingEQ = new MatcherPosition( xmlWithPlaceholder, finding2 ); assertThat( matcherPosition.equals( findingEQ ), is( Boolean.TRUE ) ); Finding finding3 = new Finding(); finding2.start = 20; finding2.end = 35; finding2.placeholder = "$$PAYLOADATTR$$"; MatcherPosition findingNEQ = new MatcherPosition( xmlWithPlaceholder, finding3 ); assertThat( matcherPosition.equals( findingNEQ ), is( Boolean.FALSE ) ); }