Class TraceContext

java.lang.Object
com.atlassian.jira.pageobjects.util.TraceContext

public class TraceContext extends Object
Provides utility methods for waiting for ajax results. To send events from the javascript side, call JIRA.trace(key, args...). To turn on logging:
org.apache.log4j.Logger.getLogger(TraceContext.class).setLevel(org.apache.log4j.Level.DEBUG);
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a tracer containing the current state of trace list.
    com.atlassian.pageobjects.elements.query.TimedCondition
    condition(Tracer tracer, String key)
    Waits for the occurrence of a trace with the given key after the given tracer.
    com.atlassian.pageobjects.elements.query.TimedCondition
    condition(Tracer tracer, String key, Pattern argumentPattern)
    Waits for the occurrence of a trace with the given key and optionally arguments after the given tracer.
    com.atlassian.pageobjects.elements.query.TimedCondition
    condition(Tracer tracer, String key, org.hamcrest.Matcher<?> argumentMatcher)
    Waits for the occurrence of a trace with the given key and optionally arguments after the given tracer.
    com.atlassian.pageobjects.elements.query.TimedCondition
    Return a TimedCondition that waits for the occurrence of a trace at some point after the page load.
    static void
     
    <T> T
    Used together with CheckpointTracer annotation to inject page objects with Tracer instance obtained just before supplier invocation.
    boolean
    exists(Tracer tracer, String key)
     
    boolean
    exists(Tracer tracer, String key, Pattern argumentPattern)
    Check whether trace record of given key exists, also test argument if argumentPattern is provided
    boolean
    exists(Tracer tracer, String key, org.hamcrest.Matcher<?> argumentMatcher)
    Check whether trace record of given key exists, also test argument if argumentPattern is provided
     
    getArguments(Tracer tracer, String key)
     
    void
    waitFor(Tracer tracer, String key)
    Waits for the occurrence of a trace with the given key after the given tracer.
    void
    waitFor(Tracer tracer, String key, Pattern argumentPattern)
    Waits for the occurrence of a trace with the given key and optionally test argument against given argumentPattern
    void
    waitFor(Tracer tracer, String key, org.hamcrest.Matcher<?> argumentMatcher)
    Waits for the occurrence of a trace with the given key and optionally test argument against given argumentMatcher

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TraceContext

      public TraceContext()
  • Method Details

    • checkpoint

      public Tracer checkpoint()
      Returns a tracer containing the current state of trace list.
    • doWithCheckpoint

      public <T> T doWithCheckpoint(Supplier<T> supplier)
      Used together with CheckpointTracer annotation to inject page objects with Tracer instance obtained just before supplier invocation.
      Type Parameters:
      T -
      Parameters:
      supplier - Action to perform
      Returns:
      value returned by supplier
      See Also:
    • consumeCheckpoint

      public static void consumeCheckpoint(Consumer<Tracer> consumer)
    • waitFor

      public void waitFor(Tracer tracer, String key)
      Waits for the occurrence of a trace with the given key after the given tracer.
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
    • waitFor

      public void waitFor(Tracer tracer, String key, @Nullable Pattern argumentPattern)
      Waits for the occurrence of a trace with the given key and optionally test argument against given argumentPattern
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
      argumentPattern - test argument of JIRA.trace call(after key argument)
    • waitFor

      public void waitFor(Tracer tracer, String key, @Nullable org.hamcrest.Matcher<?> argumentMatcher)
      Waits for the occurrence of a trace with the given key and optionally test argument against given argumentMatcher
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
      argumentMatcher - test argument of JIRA.trace call(after key argument).
    • exists

      public boolean exists(Tracer tracer, String key)
    • exists

      public boolean exists(Tracer tracer, String key, @Nullable Pattern argumentPattern)
      Check whether trace record of given key exists, also test argument if argumentPattern is provided
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
      argumentPattern - test argument of JIRA.trace call(after key argument)
      Returns:
    • exists

      public boolean exists(Tracer tracer, String key, @Nullable org.hamcrest.Matcher<?> argumentMatcher)
      Check whether trace record of given key exists, also test argument if argumentPattern is provided
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
      argumentMatcher - test argument of JIRA.trace call(after key argument).
      Returns:
    • getAllTraceIds

      public List<String> getAllTraceIds()
    • getArguments

      public List<Map<String,Object>> getArguments(Tracer tracer, String key)
    • conditionFromPageLoad

      public com.atlassian.pageobjects.elements.query.TimedCondition conditionFromPageLoad(String key)
      Return a TimedCondition that waits for the occurrence of a trace at some point after the page load.
      Parameters:
      key - the key to check for.
      Returns:
      a TimedCondition that waits for the occurrence of a trace at some point after the page load.
    • condition

      public com.atlassian.pageobjects.elements.query.TimedCondition condition(Tracer tracer, String key)
      Waits for the occurrence of a trace with the given key after the given tracer.
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
    • condition

      public com.atlassian.pageobjects.elements.query.TimedCondition condition(Tracer tracer, String key, Pattern argumentPattern)
      Waits for the occurrence of a trace with the given key and optionally arguments after the given tracer.
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
      argumentPattern - check consecutive arguments of JIRA.trace call(after key argument)
    • condition

      public com.atlassian.pageobjects.elements.query.TimedCondition condition(Tracer tracer, String key, @Nullable org.hamcrest.Matcher<?> argumentMatcher)
      Waits for the occurrence of a trace with the given key and optionally arguments after the given tracer.
      Parameters:
      tracer - checkpoint. Only traces after this checkpoint will be inspected.
      key - tracer key to watch for
      argumentMatcher - check consecutive arguments of JIRA.trace call(after key argument)