protected void assertSameHits(final IHit[] hits,final Iterator<? extends IHit> itr){
  final int nhits=hits.length;
  for (int i=0; i < nhits; i++) {
    assertTrue("Iterator exhausted after " + (i) + " hits out of "+ nhits,itr.hasNext());
    final IHit expected=hits[i];
    final IHit actual=itr.next();
    if (log.isInfoEnabled())     log.info("rank=" + (i + 1) + ", expected="+ expected+ ", actual: "+ actual);
    assertEquals("wrong document: rank=" + (i + 1),expected.getDocId(),actual.getDocId());
    final double expectedCosine=expected.getCosine();
    final double actualCosine=actual.getCosine();
    if (actualCosine < expectedCosine - .01d || actualCosine > expectedCosine + .01d) {
      assertEquals("wrong cosine: rank=" + (i + 1),expected.getCosine(),actual.getCosine());
    }
  }
  assertFalse("Iterator will visit too many hits - only " + nhits + " are expected",itr.hasNext());
}

protected void assertSameHits ( final IHit [ ] hits , final Iterator < ? extends IHit > itr ) { final int nhits = hits . length ; for ( int i = 0 ; i < nhits ; i ++ ) { assertTrue ( "Iterator exhausted after " + ( i ) + " hits out of " + nhits , itr . hasNext ( ) ) ; final IHit expected = hits [ i ] ; final IHit actual = itr . next ( ) ; if ( log . isInfoEnabled ( ) ) log . info ( "rank=" + ( i + 1 ) + ", expected=" + expected + ", actual: " + actual ) ; assertEquals ( "wrong document: rank=" + ( i + 1 ) , expected . getDocId ( ) , actual . getDocId ( ) ) ; final double expectedCosine = expected . getCosine ( ) ; final double actualCosine = actual . getCosine ( ) ; if ( actualCosine < expectedCosine - .01d || actualCosine > expectedCosine + .01d ) { assertEquals ( "wrong cosine: rank=" + ( i + 1 ) , expected . getCosine ( ) , actual . getCosine ( ) ) ; } } assertFalse ( "Iterator will visit too many hits - only " + nhits + " are expected" , itr . hasNext ( ) ) ; }
compares the hit list to the expected hit list . < p > note : ties on cosine are broken by sorting the ties into increasing order by docid .
