question: private static void assertChangeEvents ( Collection < PortChangeEvent > earlyEvents , Collection < PortChangeEvent > lateEvents , Collection < PortChangeEvent > anytimeEvents , Collection < PortChangeEvent > actualEvents ) { String inputDesc = String . format ( "earlyEvents=%s, lateEvents=%s, " + "anytimeEvents=%s, actualEvents=%s" , earlyEvents , lateEvents , anytimeEvents , actualEvents ) ; Collection < PortChangeEvent > early = new ArrayList < PortChangeEvent > ( earlyEvents ) ; Collection < PortChangeEvent > late = new ArrayList < PortChangeEvent > ( lateEvents ) ; Collection < PortChangeEvent > any = new ArrayList < PortChangeEvent > ( anytimeEvents ) ; for ( PortChangeEvent ev : early ) { assertFalse ( "Test setup error. Early and late overlap" , late . contains ( ev ) ) ; assertFalse ( "Test setup error. Early and anytime overlap" , any . contains ( ev ) ) ; } for ( PortChangeEvent ev : late ) { assertFalse ( "Test setup error. Late and early overlap" , early . contains ( ev ) ) ; assertFalse ( "Test setup error. Late and any overlap" , any . contains ( ev ) ) ; } for ( PortChangeEvent ev : any ) { assertFalse ( "Test setup error. Anytime and early overlap" , early . contains ( ev ) ) ; assertFalse ( "Test setup error. Anytime and late overlap" , late . contains ( ev ) ) ; } for ( PortChangeEvent a : actualEvents ) { if ( early . remove ( a ) ) { continue ; } if ( any . remove ( a ) ) { continue ; } if ( late . remove ( a ) ) { if ( ! early . isEmpty ( ) ) { fail ( a + " is in late list, but haven't seen all required " + "early events. " + inputDesc ) ; } else { continue ; } } fail ( a + " was not expected. " + inputDesc ) ; } if ( ! early . isEmpty ( ) ) fail ( "Elements left in early: " + early + ". " + inputDesc ) ; if ( ! late . isEmpty ( ) ) fail ( "Elements left in late: " + late + ". " + inputDesc ) ; if ( ! any . isEmpty ( ) ) fail ( "Elements left in any: " + any + ". " + inputDesc ) ; }
target:  Assert that the expected PortChangeEvents have been recevied, asserting the expected ordering. All events in earlyEvents have to appear in actualEvents before any event in lateEvent appears. Events in anytimeEvents can appear at any given time. earlyEvents, lateEvents, and anytimeEvents must be mutually exclusive (their intersection must be none) and their union must contain all elements from actualEvents