Class SHAFT.Contracts

java.lang.Object
com.shaft.driver.SHAFT.Contracts
Enclosing class:
SHAFT

public static class SHAFT.Contracts extends Object
Controls current-thread HTTP contract recording and validation for browser and API traffic.

Usage example:

SHAFT.Contracts.startRecording("src/test/resources/contracts/checkout.json", "/api/checkout");
api.post("/api/checkout").setRequestBody(order);
SHAFT.Contracts.stopRecording();

SHAFT.Contracts.startAssertMode("src/test/resources/contracts/checkout.json");
api.post("/api/checkout").setRequestBody(order);
SHAFT.Contracts.stopValidation();
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    startAssertMode(String contractFilePath, String... urlContains)
    Starts hard-assert validation against a recorded HTTP contract for the current thread.
    static void
    startRecording(String contractFilePath, String... urlContains)
    Starts recording selected browser and SHAFT API HTTP traffic for the current thread.
    static void
    startVerifyMode(String contractFilePath, String... urlContains)
    Starts soft-verify validation against a recorded HTTP contract for the current thread.
    static void
    Writes the recorded HTTP contract and clears recording mode for the current thread.
    static void
    Clears HTTP contract validation mode for the current thread.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • startRecording

      public static void startRecording(String contractFilePath, String... urlContains)
      Starts recording selected browser and SHAFT API HTTP traffic for the current thread.
      Parameters:
      contractFilePath - destination JSON contract path
      urlContains - optional URL fragments used to select recorded traffic
    • stopRecording

      public static void stopRecording()
      Writes the recorded HTTP contract and clears recording mode for the current thread.
    • startAssertMode

      public static void startAssertMode(String contractFilePath, String... urlContains)
      Starts hard-assert validation against a recorded HTTP contract for the current thread.
      Parameters:
      contractFilePath - source JSON contract path
      urlContains - optional URL fragments used to select validated traffic
    • startVerifyMode

      public static void startVerifyMode(String contractFilePath, String... urlContains)
      Starts soft-verify validation against a recorded HTTP contract for the current thread.
      Parameters:
      contractFilePath - source JSON contract path
      urlContains - optional URL fragments used to select validated traffic
    • stopValidation

      public static void stopValidation()
      Clears HTTP contract validation mode for the current thread.