AnyElementPosition 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; } AnyElementPosition that = (AnyElementPosition) obj; return this.anyElement.equals( that.anyElement ); } AnyElementPosition( String xmlMessage, AnyElementProperties anyElement ); @Override String createPlaceholder( PayloadPosition payloadPosition ); @Override int hashCode(); @Override boolean equals( Object obj ); @Override String toString();  }
@Test public void equalsTest() throws ParserConfigurationException { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setFeature( XMLConstants.FEATURE_SECURE_PROCESSING, true ); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element element = doc.createElementNS( "http: Element element2 = doc.createElementNS( "http: Element element3 = doc.createElementNS( "http: AnyElementProperties anyElement = new NullAnyElementProperties( element ); AnyElementPosition anyElementPosition = new AnyElementPosition( xmlMessage, anyElement ); assertThat( anyElementPosition.equals( null ), is( Boolean.FALSE ) ); assertThat( anyElementPosition.equals( anyElementPosition ), is( Boolean.TRUE ) ); assertThat( anyElementPosition.equals( Integer.valueOf( 1 ) ), is( Boolean.FALSE ) ); AnyElementProperties anyElement2 = new NullAnyElementProperties( element ); AnyElementPosition anyElementEQ = new AnyElementPosition( xmlMessage, anyElement2 ); assertThat( anyElementPosition.equals( anyElementEQ ), is( Boolean.TRUE ) ); AnyElementProperties anyElement3 = new NullAnyElementProperties( element2 ); AnyElementPosition anyElementEQ2 = new AnyElementPosition( xmlMessage, anyElement3 ); assertThat( anyElementPosition.equals( anyElementEQ2 ), is( Boolean.TRUE ) ); AnyElementProperties anyElement4 = new NullAnyElementProperties( element3 ); AnyElementPosition anyElementNEW = new AnyElementPosition( xmlMessage, anyElement4 ); assertThat( anyElementPosition.equals( anyElementNEW ), is( Boolean.FALSE ) ); }