Class TestScenarioLogCollection

java.lang.Object
de.qytera.qtaf.core.log.model.collection.TestScenarioLogCollection

public class TestScenarioLogCollection extends Object
This class works as a collection for log messages that are produced during a test execution.
  • Method Details

    • createTestScenarioLogCollection

      public static TestScenarioLogCollection createTestScenarioLogCollection(String featureId, String abstractScenarioId, String instanceId, String scenarioName)
      Factory method.

      Creates new test log collection.

      If a collection with the given ID exists then return the existing collection. This method has to be synchronized so that it works correctly when using multiple threads.
      Parameters:
      featureId - Unique collection ID
      abstractScenarioId - Method ID (packageName + className + methodName)
      instanceId - Test object ID
      scenarioName - Test ID
      Returns:
      test log collection
    • fromQtafTestEventPayload

      public static TestScenarioLogCollection fromQtafTestEventPayload(IQtafTestEventPayload iQtafTestEventPayload)
      Factory method.

      Factory method that creates new log collection from test event payload.

      This method has to be synchronized so that it works correctly when using multiple threads.
      Parameters:
      iQtafTestEventPayload - test event payload
      Returns:
      test log collection
    • equals

      public boolean equals(Object o)
      Override equals to compare two TestScenarioLogCollection objects.
      Overrides:
      equals in class Object
      Parameters:
      o - Object to compare with this instance
      Returns:
      true if both are equal, false otherwise
    • hashCode

      public int hashCode()
      Calculate hash code for this instance. The contains() methods of the collections use the hash code to check if object is already stored.
      Overrides:
      hashCode in class Object
      Returns:
      hash code
    • getFeatureId

      public String getFeatureId()
      Get uniqueId.
      Returns:
      uniqueId
    • buildId

      public static String buildId(String abstractScenarioId, String instanceId)
      Build ID.
      Parameters:
      abstractScenarioId - Method ID
      instanceId - Test ID
      Returns:
      ID
    • getScenarioId

      public String getScenarioId()
      Get test ID.
      Returns:
      test ID
    • getScenarioName

      public String getScenarioName()
      Get testId.
      Returns:
      testId Test Id
    • getAbstractScenarioId

      public String getAbstractScenarioId()
      Get abstractScenarioId.
      Returns:
      abstractScenarioId
    • setAbstractScenarioId

      public TestScenarioLogCollection setAbstractScenarioId(String abstractScenarioId)
      Set abstractScenarioId.
      Parameters:
      abstractScenarioId - AbstractScenarioId
      Returns:
      this
    • getInstanceId

      public String getInstanceId()
      Get instanceId.
      Returns:
      instanceId
    • setInstanceId

      public TestScenarioLogCollection setInstanceId(String instanceId)
      Set instanceId.
      Parameters:
      instanceId - InstanceId
      Returns:
      this
    • getStatus

      Get status.
      Returns:
      status Status
    • computeStatus

      public void computeStatus()
      Method to compute the status of the test scenario.
    • setStatus

      Sets the test status.
      Parameters:
      status - test status
      Returns:
      this
    • setDescription

      public TestScenarioLogCollection setDescription(String description)
      Set test description.
      Parameters:
      description - test description
      Returns:
      this
    • setGroupDependencies

      public TestScenarioLogCollection setGroupDependencies(String[] groupDependencies)
      Set test group dependencies.
      Parameters:
      groupDependencies - test group dependencies
      Returns:
      this
    • setMethodDependencies

      public void setMethodDependencies(String[] methodDependencies)
      Set test method dependencies.
      Parameters:
      methodDependencies - test method dependencies
    • getTestParameters

      public List<TestScenarioLogCollection.TestParameter> getTestParameters()
      Get testParameters.
      Returns:
      testParameters
    • addParameters

      public TestScenarioLogCollection addParameters(Parameter[] parameters, Object[] values)
      Add test parameters to log.
      Parameters:
      parameters - method parameters
      values - method values
      Returns:
      this
    • addParameters

      public void addParameters(Object[] parameterValues)
      Add test parameters to log.
      Parameters:
      parameterValues - method values
    • getAnnotations

      public Annotation[] getAnnotations()
      Get annotations.
      Returns:
      annotations
    • getAnnotation

      public <T> T getAnnotation(Class<T> annotationClass)
      Get a specific annotation of this scenario. Always returns the first annotation found in case there are more than one.
      Type Parameters:
      T - the annotation's type
      Parameters:
      annotationClass - the class of the annotation to retrieve
      Returns:
      the annotation if it exists or null
    • setAnnotations

      public TestScenarioLogCollection setAnnotations(Annotation[] annotations)
      Set annotations.
      Parameters:
      annotations - Annotations
      Returns:
      this
    • getLogMessages

      public List<LogMessage> getLogMessages()
      Get logMessages.
      Returns:
      logMessages LogMessages
    • getLogMessages

      public <T extends LogMessage> List<T> getLogMessages(Class<T> logMessageClass)
      Returns all log message of the provided class, filtering out log messages that do not match the class.
      Type Parameters:
      T - any class extending the LogMessage class
      Parameters:
      logMessageClass - the desired log messages' class
      Returns:
      a list of log messages with type T
    • getStepLogOfPendingStep

      public LogMessage getStepLogOfPendingStep()
      Get the log message object of the step that is currently pending.
      Returns:
      Step log object of the currently pending step
    • addLogMessage

      public void addLogMessage(LogMessage logMessage)
      Add log message object. This method needs to run synchronized because of the check for existence.
      Parameters:
      logMessage - log message object
    • addLogMessage

      public void addLogMessage(LogLevel level, String message)
      Add log message.
      Parameters:
      level - log level
      message - log message
    • getScreenshotPaths

      public List<String> getScreenshotPaths()
      Get screenshotPaths.
      Returns:
      screenshotPaths
    • addScreenshotPath

      public void addScreenshotPath(String filepath)
      Add screenshot path to test scenario log.
      Parameters:
      filepath - Path to screenshot file
    • getScreenshotBefore

      public String getScreenshotBefore()
      Get screenshotBefore.
      Returns:
      screenshotBefore
    • setScreenshotBefore

      public void setScreenshotBefore(String screenshotBefore)
      Set screenshotBefore.
      Parameters:
      screenshotBefore - ScreenshotBefore
    • getScreenshotAfter

      public String getScreenshotAfter()
      Get screenshotAfter.
      Returns:
      screenshotAfter
    • setScreenshotAfter

      public void setScreenshotAfter(String screenshotAfter)
      Set screenshotAfter.
      Parameters:
      screenshotAfter - ScreenshotAfter
    • getTags

      public Map<String,String> getTags()
      Get tags.
      Returns:
      tags
    • addTag

      public TestScenarioLogCollection addTag(String key, String value)
      Add tag to test scenario log.
      Parameters:
      key - Tag key
      value - Tag value
      Returns:
      this
    • debug

      public TestScenarioLogCollection debug(String message)
      Add debug message.
      Parameters:
      message - message
      Returns:
      this
    • info

      public TestScenarioLogCollection info(String message)
      Add info message.
      Parameters:
      message - message
      Returns:
      this
    • warn

      public TestScenarioLogCollection warn(String message)
      Add warn message.
      Parameters:
      message - message
      Returns:
      this
    • error

      public TestScenarioLogCollection error(String message)
      Add error message.
      Parameters:
      message - message
      Returns:
      this
    • getDescription

      public String getDescription()
      Get description.
      Returns:
      description
    • getGroupDependencies

      public String[] getGroupDependencies()
      Get groupDependencies.
      Returns:
      groupDependencies
    • getMethodDependencies

      public String[] getMethodDependencies()
      Get methodDependencies.
      Returns:
      methodDependencies
    • getStart

      public Date getStart()
      Get start.
      Returns:
      start
    • setStart

      public TestScenarioLogCollection setStart(Date start)
      Set start.
      Parameters:
      start - Start
      Returns:
      this
    • getEnd

      public Date getEnd()
      Get end.
      Returns:
      end
    • setEnd

      public TestScenarioLogCollection setEnd(Date end)
      Set end.
      Parameters:
      end - End
      Returns:
      this
    • getThreadId

      public long getThreadId()
      Get threadId.
      Returns:
      threadId
    • setThreadId

      public TestScenarioLogCollection setThreadId(long threadId)
      Set threadId.
      Parameters:
      threadId - ThreadId
      Returns:
      this
    • getThreadName

      public String getThreadName()
      Get threadName.
      Returns:
      threadName
    • setThreadName

      public TestScenarioLogCollection setThreadName(String threadName)
      Set threadName.
      Parameters:
      threadName - ThreadName
      Returns:
      this
    • getGroups

      public String[] getGroups()
      Get groups.
      Returns:
      groups
    • setGroups

      public TestScenarioLogCollection setGroups(String[] groups)
      Set groups.
      Parameters:
      groups - Groups
      Returns:
      this
    • getDuration

      public long getDuration()
      Get duration.
      Returns:
      duration
    • setDuration

      public TestScenarioLogCollection setDuration(long duration)
      Set duration.
      Parameters:
      duration - Duration
      Returns:
      this
    • exists

      public static boolean exists(TestScenarioLogCollection scenarioLogCollection)
      Check if index already has this ScenarioLogCollection.
      Parameters:
      scenarioLogCollection - Scenario log collection
      Returns:
      true if exists, false otherwise
    • getIndexSize

      public static int getIndexSize()
      Count the number of scenario log collections saved in the index.
      Returns:
      number of scenario log collections saved in the index
    • clearIndex

      public static void clearIndex()
      Remove all scenario log collections.