Class DefaultTestInstances

  • All Implemented Interfaces:
    TestInstances

    @API(status=INTERNAL,
         since="5.4")
    public class DefaultTestInstances
    extends java.lang.Object
    implements TestInstances
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<java.lang.Object> instances  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private DefaultTestInstances​(java.util.List<java.lang.Object> instances)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> java.util.Optional<T> findInstance​(java.lang.Class<T> requiredType)
      Find the first test instance that is an instance of the supplied required type, checking from innermost to outermost.
      java.util.List<java.lang.Object> getAllInstances()
      Get all test instances, ordered from outermost to innermost.
      java.util.List<java.lang.Object> getEnclosingInstances()
      Get the enclosing test instances, excluding the innermost test instance, ordered from outermost to innermost.
      java.lang.Object getInnermostInstance()
      Get the innermost test instance.
      static DefaultTestInstances of​(java.lang.Object instance)  
      static DefaultTestInstances of​(TestInstances testInstances, java.lang.Object instance)  
      • Methods inherited from class java.lang.Object

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

      • instances

        private final java.util.List<java.lang.Object> instances
    • Constructor Detail

      • DefaultTestInstances

        private DefaultTestInstances​(java.util.List<java.lang.Object> instances)
    • Method Detail

      • getInnermostInstance

        public java.lang.Object getInnermostInstance()
        Description copied from interface: TestInstances
        Get the innermost test instance.

        The innermost instance is the one closest to the test method.

        Specified by:
        getInnermostInstance in interface TestInstances
        Returns:
        the innermost test instance; never null
      • getEnclosingInstances

        public java.util.List<java.lang.Object> getEnclosingInstances()
        Description copied from interface: TestInstances
        Get the enclosing test instances, excluding the innermost test instance, ordered from outermost to innermost.
        Specified by:
        getEnclosingInstances in interface TestInstances
        Returns:
        the enclosing test instances; never null or containing null, but potentially empty
      • getAllInstances

        public java.util.List<java.lang.Object> getAllInstances()
        Description copied from interface: TestInstances
        Get all test instances, ordered from outermost to innermost.
        Specified by:
        getAllInstances in interface TestInstances
        Returns:
        all test instances; never null, containing null, or empty
      • findInstance

        public <T> java.util.Optional<T> findInstance​(java.lang.Class<T> requiredType)
        Description copied from interface: TestInstances
        Find the first test instance that is an instance of the supplied required type, checking from innermost to outermost.
        Specified by:
        findInstance in interface TestInstances
        Parameters:
        requiredType - the type to search for
        Returns:
        the first test instance of the required type; never null but potentially empty