public void assertEquals(final String sessionId,final Iterable<String> expectedEvents){
  assertNotNull("Queue was not initialized. One should call #init(int) before invoking #assertEquals()",latch);
  try {
    latch.await(20L,SECONDS);
    unregisterSupplier.get();
  }
 catch (  final InterruptedException e) {
    throw new AssertionError("Time outed while waiting to receive all expected test events.",e);
  }
  final Collection<String> eventsForSession=events.get(sessionId);
  if (size(expectedEvents) != eventsForSession.size()) {
    throw new ComparisonFailure("Expected:",toString(expectedEvents),toString(eventsForSession));
  }
  final Iterator<String> actItr=eventsForSession.iterator();
  final Iterator<String> expItr=expectedEvents.iterator();
  while (expItr.hasNext()) {
    if (!actItr.hasNext()) {
      throw new ComparisonFailure("Expected:",toString(expectedEvents),toString(eventsForSession));
    }
    final String expected=expItr.next();
    final String actual=actItr.next();
    if (null == expected || null == actual) {
      if (expected != actual) {
        throw new ComparisonFailure("Expected:",toString(expectedEvents),toString(eventsForSession));
      }
    }
 else {
      if (!expected.equals(actual)) {
        throw new ComparisonFailure("Expected:",toString(expectedEvents),toString(eventsForSession));
      }
    }
    Assert.assertEquals(expected,actual);
  }
}

public void assertEquals ( final String sessionId , final Iterable < String > expectedEvents ) { assertNotNull ( "Queue was not initialized. One should call #init(int) before invoking #assertEquals()" , latch ) ; try { latch . await ( 20L , SECONDS ) ; unregisterSupplier . get ( ) ; } catch ( final InterruptedException e ) { throw new AssertionError ( "Time outed while waiting to receive all expected test events." , e ) ; } final Collection < String > eventsForSession = events . get ( sessionId ) ; if ( size ( expectedEvents ) != eventsForSession . size ( ) ) { throw new ComparisonFailure ( "Expected:" , toString ( expectedEvents ) , toString ( eventsForSession ) ) ; } final Iterator < String > actItr = eventsForSession . iterator ( ) ; final Iterator < String > expItr = expectedEvents . iterator ( ) ; while ( expItr . hasNext ( ) ) { if ( ! actItr . hasNext ( ) ) { throw new ComparisonFailure ( "Expected:" , toString ( expectedEvents ) , toString ( eventsForSession ) ) ; } final String expected = expItr . next ( ) ; final String actual = actItr . next ( ) ; if ( null == expected || null == actual ) { if ( expected != actual ) { throw new ComparisonFailure ( "Expected:" , toString ( expectedEvents ) , toString ( eventsForSession ) ) ; } } else { if ( ! expected . equals ( actual ) ) { throw new ComparisonFailure ( "Expected:" , toString ( expectedEvents ) , toString ( eventsForSession ) ) ; } } Assert . assertEquals ( expected , actual ) ; } }
asserts the actual events with the expected ones .
