MatcherPositionIterator implements PositionIterator { @Override public void reset() { for ( Entry<PayloadPosition, List<Finding>> entry : findingsMap.entrySet() ) { findingsIteratorMap.put( entry.getKey(), entry.getValue().iterator() ); } } MatcherPositionIterator( String xmlWithPlaceholder ); @Override boolean hasNext( PayloadPosition payloadPosition ); @Override Position next( PayloadPosition payloadPosition ); @Override void reset();  }
@Test public void resetTest() { String xmlWithPlaceholder = "<soapenv:Envelope>" + " <soapenv:Header>$$PAYLOADELEMENT$$</soapenv:Header>" + " <soapenv:Body>" + " <cxf:celsiusToFarenheit>" + " <arg0>1</arg0>" + " </cxf:celsiusToFarenheit>" + " $$PAYLOADELEMENT$$</soapenv:Body>" + "$$PAYLOADELEMENT$$</soapenv:Envelope>"; MatcherPositionIterator iterator = new MatcherPositionIterator( xmlWithPlaceholder ); assertThat( iterator.hasNext( PayloadPosition.ATTRIBUTE ), is( Boolean.FALSE ) ); for ( int i = 0; i < 3; i++ ) { assertThat( iterator.hasNext( PayloadPosition.ELEMENT ), is( Boolean.TRUE ) ); assertNotNull( iterator.next( PayloadPosition.ELEMENT ) ); } assertThat( iterator.hasNext( PayloadPosition.ELEMENT ), is( Boolean.FALSE ) ); iterator.reset(); for ( int i = 0; i < 3; i++ ) { assertThat( iterator.hasNext( PayloadPosition.ELEMENT ), is( Boolean.TRUE ) ); assertNotNull( iterator.next( PayloadPosition.ELEMENT ) ); } }