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 Summary
Modifier and TypeMethodDescriptionvoidassertAllMocksCount(int receivedCount) Assert of all requests to mock-server countvoidassertAllMocksCount(int from, int to) Assert of all requests to mock-server count from tovoidassertMocksCountWithAwait(int from, int to) Assert of all requests to mock-server count from tovoidClean mock-server logs (requests/responses)voidcreateMock(String mockExpectation) Create mock expectationvoidcreateMockCustom(String description, String path) Create mock expectationgetRequestValue(String mockSetup, String extractPath) Return value from request (can be body, header, other)voidReset mock servervoidAdd attachment with mock requests list (only method and path)voidAdd attachment with mock server logs (requests/responses)voidAdd attachment with requests to mock-servervoidverifyMock(String verifySetup) Verify requests to mock-server by verify setupvoidverifyMockCustom(String description, String path) Verify requests to mock-server by setup from filevoidverifyMockCustomWithAwait(String description, String path) Verify requests to mock-server by setup from filevoidverifyMockSequence(String verifySetup) Verify sequence of requests to mock-server by verify setupvoidverifyMockSequenceWithAwait(String verifySetup) Verify sequence of requests to mock server by verify setupvoidverifyMockWithAwait(String verifySetup) Verify requests to mock-server by verify setup
-
Method Details
-
resetMocks
void resetMocks()Reset mock serverClean 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
Create mock expectation- Parameters:
mockExpectation- - String with mock expectation Json
-
createMockCustom
Create mock expectation- Parameters:
description- - description part for steppath- - path to file in resources- Throws:
IllegalArgumentException- on wrong JSON type
-
verifyMock
Verify requests to mock-server by verify setup- Parameters:
verifySetup- - String with mock verify Json- Throws:
AssertionError- an assert failIllegalArgumentException- on wrong JSON type
-
verifyMockCustom
Verify requests to mock-server by setup from file- Parameters:
description- - description part for steppath- - path to file in resources- Throws:
AssertionError- an assert failIllegalArgumentException- on wrong JSON type
-
verifyMockSequence
Verify sequence of requests to mock-server by verify setup- Parameters:
verifySetup- - String with mock verify Json- Throws:
AssertionError- an assert failIllegalArgumentException- on wrong JSON type
-
verifyMockWithAwait
Verify requests to mock-server by verify setupwith await
- Parameters:
verifySetup- - String with mock verify Json- Throws:
AssertionError- an assert failIllegalArgumentException- on wrong JSON type
-
verifyMockCustomWithAwait
Verify requests to mock-server by setup from filewith await
- Parameters:
description- - description part for steppath- - path to file in resources- Throws:
AssertionError- an assert failIllegalArgumentException- on wrong JSON type
-
verifyMockSequenceWithAwait
Verify sequence of requests to mock server by verify setupwith await
- Parameters:
verifySetup- - String with mock verify Json- Throws:
AssertionError- an assert failIllegalArgumentException- on wrong JSON type
-
assertMocksCountWithAwait
void assertMocksCountWithAwait(int from, int to) Assert of all requests to mock-server count from towith await
- Parameters:
from- int minimum expected requeststo- int maximum expected requests- Throws:
AssertionError- an assert failIllegalArgumentException- 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 failIllegalArgumentException- 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 fromto- int expected to- Throws:
AssertionError- an assert failIllegalArgumentException- on wrong JSON type
-
getRequestValue
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 requestextractPath- - json path in request to mock (example: "[0].body.parameters.name")- Returns:
- Object (any types)
-