Interface MocksInt

All Known Implementing Classes:
MocksApi

public interface MocksInt
Interface defines methods for facilitating helper interactions and assertions. Validates that all required methods are implemented.
  • Method Details

    • resetMocks

      void resetMocks()
      Reset mock server

      Clean all: logs, requests, expectations

    • cleanMockLogs

      void cleanMockLogs()
      Clean mock-server logs (requests/responses)
    • showMockLogs

      void showMockLogs()
      Add attachment with mock server logs (requests/responses)

      On DEBUG level also print to console

    • showMockRequests

      void showMockRequests()
      Add attachment with requests to mock-server
    • showBaseRequestsList

      void showBaseRequestsList()
      Add attachment with mock requests list (only method and path)
    • createMock

      void createMock(String mockExpectation)
      Create mock expectation
      Parameters:
      mockExpectation - - String with mock expectation Json
    • createMockCustom

      void createMockCustom(String description, String path)
      Create mock expectation
      Parameters:
      description - - description part for step
      path - - path to file in resources
      Throws:
      IllegalArgumentException - on wrong JSON type
    • verifyMock

      void verifyMock(String verifySetup)
      Verify requests to mock-server by verify setup
      Parameters:
      verifySetup - - String with mock verify Json
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • verifyMockCustom

      void verifyMockCustom(String description, String path)
      Verify requests to mock-server by setup from file
      Parameters:
      description - - description part for step
      path - - path to file in resources
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • verifyMockSequence

      void verifyMockSequence(String verifySetup)
      Verify sequence of requests to mock-server by verify setup
      Parameters:
      verifySetup - - String with mock verify Json
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • verifyMockWithAwait

      void verifyMockWithAwait(String verifySetup)
      Verify requests to mock-server by verify setup

      with await

      Parameters:
      verifySetup - - String with mock verify Json
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • verifyMockCustomWithAwait

      void verifyMockCustomWithAwait(String description, String path)
      Verify requests to mock-server by setup from file

      with await

      Parameters:
      description - - description part for step
      path - - path to file in resources
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • verifyMockSequenceWithAwait

      void verifyMockSequenceWithAwait(String verifySetup)
      Verify sequence of requests to mock server by verify setup

      with await

      Parameters:
      verifySetup - - String with mock verify Json
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • assertMocksCountWithAwait

      void assertMocksCountWithAwait(int from, int to)
      Assert of all requests to mock-server count from to

      with await

      Parameters:
      from - int minimum expected requests
      to - int maximum expected requests
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • assertAllMocksCount

      void assertAllMocksCount(int receivedCount)
      Assert of all requests to mock-server count
      Parameters:
      receivedCount - - expected EXACTLY count of requests
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • assertAllMocksCount

      void assertAllMocksCount(int from, int to)
      Assert of all requests to mock-server count from to
      Parameters:
      from - int expected from
      to - int expected to
      Throws:
      AssertionError - an assert fail
      IllegalArgumentException - on wrong JSON type
    • getRequestValue

      Object getRequestValue(String mockSetup, String extractPath)
      Return value from request (can be body, header, other)

      Can be used to get some info (id, hash, base64...) for next check

      
       var value = mocksApi.getRequestValue(
            """
            {
                 "method": "POST",
                 "path": "/api/user"
            }""",
            "[0].body.name"); //grab value from key "name" from body of first request by condition
       
      Parameters:
      mockSetup - - setup for request
      extractPath - - json path in request to mock (example: "[0].body.parameters.name")
      Returns:
      Object (any types)