Class TestCaseRunner

java.lang.Object
ch.admin.bit.jeap.testorchestrator.testsupport.TestCaseRunner
All Implemented Interfaces:
org.springframework.context.ApplicationEventPublisher

public class TestCaseRunner extends Object implements org.springframework.context.ApplicationEventPublisher
Support class for running test cases in unit tests. Test cases can be run without starting up a Spring context.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.context.ApplicationEventPublisher
    Get the ApplicationEventPublisher instance to be used by the test case instance run by this runner.
    Get the callback URL provided to the test case by the test runner.
    Get the the test id assigned to this test case run.
    boolean
    Check if the test case run has finished.
    void
    notify(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto)
    Publish the given notification as NotificationEvent to the test case run by this test case runner.
    void
    notifyAsync(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto, long delay, TimeUnit unit)
    Publish the given notification asynchronously after the given delay as NotificationEvent to the test case run by this test case runner.
    void
    Spring application event publishing implementation provided to the test case run by this runner to receive the test case events.
    void
    Run the given test case.
    Run the given test case asynchronously with support for asynchronous notifications.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.context.ApplicationEventPublisher

    publishEvent
  • Constructor Details

    • TestCaseRunner

      public TestCaseRunner()
  • Method Details

    • run

      public void run(TestCaseBaseInterface testCase)
      Run the given test case. Can only be called once on a TestCaseRunner instance. Does not support asynchronous notifications.
      Parameters:
      testCase - The test case to run.
    • runAsync

      public CompletableFuture<Void> runAsync(TestCaseBaseInterface testCase)
      Run the given test case asynchronously with support for asynchronous notifications. Can only be called once on a TestCaseRunner instance. Use this run method if your tests needs asynchronous notifications.
      Parameters:
      testCase - The test case to run.
    • hasFinished

      public boolean hasFinished()
      Check if the test case run has finished.
      Returns:
      true if the test case run has finished, false otherwise.
    • getTestId

      public String getTestId()
      Get the the test id assigned to this test case run.
      Returns:
      the test id assigned to this test case run
    • getCallbackUrl

      public String getCallbackUrl()
      Get the callback URL provided to the test case by the test runner.
      Returns:
      the callback URL provided to the test case by the test runner.
    • getApplicationEventPublisher

      public org.springframework.context.ApplicationEventPublisher getApplicationEventPublisher()
      Get the ApplicationEventPublisher instance to be used by the test case instance run by this runner. Test cases communicate with the TestCaseService by publishing Spring application events. A test case run by this test case runner must use this ApplicationEventPublisher for the test case runner to be able to react on the events.
      Returns:
      The ApplicationEventPublisher instance to be used by the test case instance run by this runner.
    • notify

      public void notify(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto)
      Publish the given notification as NotificationEvent to the test case run by this test case runner. Test cases listen to notification events initiated by the test agents. Use this method to simulate the test agent callbacks to the test orchestrator that result in such notification events.
      Parameters:
      notificationDto - The notification.
    • notifyAsync

      public void notifyAsync(ch.admin.bit.jeap.testagent.api.notification.NotificationDto notificationDto, long delay, TimeUnit unit)
      Publish the given notification asynchronously after the given delay as NotificationEvent to the test case run by this test case runner.
      Parameters:
      notificationDto - The notification.
      See Also:
    • publishEvent

      public void publishEvent(Object event)
      Spring application event publishing implementation provided to the test case run by this runner to receive the test case events.
      Specified by:
      publishEvent in interface org.springframework.context.ApplicationEventPublisher