Class OpenShiftRecorderHandler

  • All Implemented Interfaces:
    org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler, org.junit.jupiter.api.extension.TestExecutionExceptionHandler, org.junit.jupiter.api.extension.TestWatcher

    public class OpenShiftRecorderHandler
    extends Object
    implements org.junit.jupiter.api.extension.TestWatcher, org.junit.jupiter.api.extension.TestExecutionExceptionHandler, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler
    Implements JUnit lifecycle events handling in order to record OCP state for different purposes (e.g.: debug). The operational logic to perform the steps to get the status from OCP is delegated to OpenShiftRecorderService. Based on the JUnit test life cycle event that is being handled, an instance of this class will either call OpenShiftRecorderService.initFilters(ExtensionContext) - beforeAllCallback: used to get information on what resources are on a cluster before a test class is processed OpenShiftRecorderService.updateFilters(ExtensionContext) - beforeEachCallback: used to get information on what resources are on a cluster before a test case is processed OpenShiftRecorderService.recordState(ExtensionContext) - on various events: used to record state of selected resources (by name) or make an estimation based on information collected when previous events like the two described above took place

    OpenShift state is recorded in the following cases:

    • TestExecutionExceptionHandler.handleTestExecutionException(org.junit.jupiter.api.extension.ExtensionContext, java.lang.Throwable)
    • LifecycleMethodExecutionExceptionHandler.handleBeforeAllMethodExecutionException(ExtensionContext, Throwable) and LifecycleMethodExecutionExceptionHandler.handleBeforeEachMethodExecutionException(ExtensionContext, Throwable) in case xtf.record.before is set
    • TestWatcher.testSuccessful(ExtensionContext) in case xtf.record.before is set
    • Constructor Detail

      • OpenShiftRecorderHandler

        public OpenShiftRecorderHandler()
    • Method Detail

      • beforeAll

        public void beforeAll​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
      • beforeEach

        public void beforeEach​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
      • handleTestExecutionException

        public void handleTestExecutionException​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                 Throwable throwable)
                                          throws Throwable
        Specified by:
        handleTestExecutionException in interface org.junit.jupiter.api.extension.TestExecutionExceptionHandler
        Throws:
        Throwable
      • handleBeforeAllMethodExecutionException

        public void handleBeforeAllMethodExecutionException​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                            Throwable throwable)
                                                     throws Throwable
        Specified by:
        handleBeforeAllMethodExecutionException in interface org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler
        Throws:
        Throwable
      • handleBeforeEachMethodExecutionException

        public void handleBeforeEachMethodExecutionException​(org.junit.jupiter.api.extension.ExtensionContext context,
                                                             Throwable throwable)
                                                      throws Throwable
        Specified by:
        handleBeforeEachMethodExecutionException in interface org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler
        Throws:
        Throwable
      • testSuccessful

        public void testSuccessful​(org.junit.jupiter.api.extension.ExtensionContext context)
        Specified by:
        testSuccessful in interface org.junit.jupiter.api.extension.TestWatcher