public boolean isExpected ( final HandlingEvent event ) { if ( getLegs ( ) . isEmpty ( ) ) { return true ; } if ( event . getType ( ) == Type . RECEIVE ) { // Check that the first leg's origin is the event's location final Leg leg = getLegs ( ) . get ( 0 ) ; return ( leg . getFrom ( ) . equals ( event . getLocation ( ) ) ) ; } if ( event . getType ( ) == Type . LOAD ) { // Check that the there is one leg with same from location and // carrier movement for ( Leg leg : getLegs ( ) ) { if ( leg . getFrom ( ) . equals ( event . getLocation ( ) ) && leg . getCarrierMovement ( ) . equals ( event . getCarrierMovement ( ) ) ) return true ; } return false ; } if ( event . getType ( ) == Type . UNLOAD ) { // Check that the there is one leg with same to loc and carrier // movement for ( Leg leg : getLegs ( ) ) { if ( leg . getTo ( ) . equals ( event . getLocation ( ) ) && leg . getCarrierMovement ( ) . equals ( event . getCarrierMovement ( ) ) ) return true ; } return false ; } if ( event . getType ( ) == Type . CLAIM ) { // Check that the last leg's destination is from the event's // location final Leg leg = getLegs ( ) . get ( getLegs ( ) . size ( ) - 1 ) ; return ( leg . getTo ( ) . equals ( event . getLocation ( ) ) ) ; } // HandlingEvent.Type.CUSTOMS; return true ; }
Test if the given handling event is expected when executing this itinerary .