Class ListenerOrderDeterminer


  • public final class ListenerOrderDeterminer
    extends java.lang.Object
    A Utility that helps us differentiate between a user's listener and preferential Listener.

    When dealing with TestNG listeners we would need to ensure that the user created listeners are invoked first followed by Preferential listeners. This is required so that we always honour any state changes that a user's listener may have done to the internal state of objects that can affect the outcome of the execution (for e.g.,ITestResult)

    The ordering must be done such that, when dealing with "beforeXXX|afterXXX" we group all the IDE listeners at the end. That way, we can always ensure that the preferential listeners (for e.g., IDE listeners) always honour the changes that were done to the TestNG internal states and give a consistent experience for users.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.List<java.lang.String> PREFERENTIAL_PACKAGES  
      private static java.util.function.Predicate<java.lang.Class<?>> SHOULD_ADD_AT_END  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static <T> Pair<java.util.List<T>,​java.util.List<T>> arrange​(java.util.Collection<T> original)  
      static <T> java.util.List<T> order​(java.util.Collection<T> original)  
      static <T> java.util.List<T> reversedOrder​(java.util.Collection<T> original)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PREFERENTIAL_PACKAGES

        private static final java.util.List<java.lang.String> PREFERENTIAL_PACKAGES
      • SHOULD_ADD_AT_END

        private static final java.util.function.Predicate<java.lang.Class<?>> SHOULD_ADD_AT_END
    • Constructor Detail

      • ListenerOrderDeterminer

        private ListenerOrderDeterminer()
    • Method Detail

      • order

        public static <T> java.util.List<T> order​(java.util.Collection<T> original)
        Parameters:
        original - - The original collection of listeners
        Returns:
        - A re-ordered collection wherein preferential listeners are added at the end
      • reversedOrder

        public static <T> java.util.List<T> reversedOrder​(java.util.Collection<T> original)
        Parameters:
        original - - The original collection of listeners
        Returns:
        - A reversed ordered list wherein the user listeners are found in reverse order followed by preferential listeners also in reverse order.
      • arrange

        private static <T> Pair<java.util.List<T>,​java.util.List<T>> arrange​(java.util.Collection<T> original)