Package io.keploy.service
Class GrpcService
java.lang.Object
io.keploy.service.GrpcService
This is a service class. This is the class where Java-sdk communicates with Keploy server to
record/store tests and to perform testing.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCapture(Service.TestCaseReq.Builder testCaseReqBuilder, Map<String, List<MultipartContent>> formData, Service.HttpReq.Builder httpReqBuilder) This method runs in threads asynchronously and sends request to Server to capture tests and mocksstatic voidCaptureTestCases(String reqBody, Map<String, String> params, Service.HttpResp httpResp, String protocolType, Map<String, List<MultipartContent>> formData) Modifies all the test cases and mocks that are present into the format which GRPC accepts and send request to GRPC to save tests and mocks that are recordedstatic booleancheck(String testrunId, Service.TestCase tc) Starts the simulate for every test case and compared with the response recorded beforestatic voiddenoise(String id, Service.TestCaseReq testCaseReq) Denoising while recording test casesstatic StringdetermineFilePath(String fileName) static booleandoesFollowAcceptanceRegex(Service.TestCaseReq testCaseReq) Does follow acceptance regex boolean.static booleandoesFollowRejectionRegex(Service.TestCaseReq testCaseReq) Does follow rejection regex boolean.static voidSend request to server that test run is done.static List<Service.TestCase>fetch()Fetch all the test cases and mocks that are recordedstatic Service.HttpResp.Builderstatic StringgetSimulateResponseBody(HttpURLConnection httpConn) static booleanisSuccessfulResponse(HttpURLConnection connection) static booleanisValidTestCaseToBeRecorded(Service.TestCaseReq testCaseReq) Is valid test case to be recorded boolean.static voidput(Service.TestCaseReq testCaseReq) This method sends the testcases to the serverstatic Stringstatic Service.HttpRespsimulate(Service.TestCase testCase) This method runs each test on client application in test mode by setting mocks and data in context.static StringProvides the test run idstatic voidTest()Starts testing of the recorded test cases
-
Field Details
-
blockingStub
-
channel
public static io.grpc.ManagedChannel channel -
AppPath
-
-
Constructor Details
-
GrpcService
public GrpcService()Initialising GRPC server ang Keploy instance
-
-
Method Details
-
CaptureTestCases
public static void CaptureTestCases(String reqBody, Map<String, String> params, Service.HttpResp httpResp, String protocolType, Map<String, List<MultipartContent>> formData) Modifies all the test cases and mocks that are present into the format which GRPC accepts and send request to GRPC to save tests and mocks that are recorded- Parameters:
reqBody- - http request body recorded from the filterparams- - http query params recorded from the filterhttpResp- - http response body recorded from the filterprotocolType- - http protocolType recorded from the filterformData- - http form data
-
Capture
public static void Capture(Service.TestCaseReq.Builder testCaseReqBuilder, Map<String, List<MultipartContent>> formData, Service.HttpReq.Builder httpReqBuilder) This method runs in threads asynchronously and sends request to Server to capture tests and mocks- Parameters:
testCaseReqBuilder- - test case object builderformData- - form data from http requesthttpReqBuilder- - http request builder
-
put
This method sends the testcases to the server- Parameters:
testCaseReq- - test case object
-
isValidTestCaseToBeRecorded
Is valid test case to be recorded boolean. This method is used to check if the test case should be recorded or discarded.- Parameters:
testCaseReq- the test case req object which contains all the information about the test case- Returns:
- the boolean value which indicates if the test case should be recorded or discarded
-
doesFollowAcceptanceRegex
Does follow acceptance regex boolean. This method is used to check if the test case url and header matches the acceptance regex.- Parameters:
testCaseReq- the test case req object which contains all the information about the test case- Returns:
- the boolean value which indicates if the test case url and header matches the acceptance regex
-
doesFollowRejectionRegex
Does follow rejection regex boolean. This method is used to check if the test case url and header matches the rejection regex.- Parameters:
testCaseReq- the test case req object which contains all the information about the test case.- Returns:
- the boolean value which indicates if the test case url and header matches the rejection regex
-
denoise
Denoising while recording test cases- Parameters:
id- - test case idtestCaseReq- - test case object
-
simulate
This method runs each test on client application in test mode by setting mocks and data in context.- Parameters:
testCase- - test case object- Returns:
- - response for the test
-
isSuccessfulResponse
-
getSimulateResponseBody
- Throws:
IOException
-
GetResp
-
Test
public static void Test()Starts testing of the recorded test cases -
start
Provides the test run id- Parameters:
total- - total no of test cases- Returns:
- - test run id
-
end
Send request to server that test run is done. So that post-processing will be done- Parameters:
id- - test run idstatus- - status of the test run
-
fetch
Fetch all the test cases and mocks that are recorded- Returns:
- - list if testcase objects
-
check
Starts the simulate for every test case and compared with the response recorded before- Parameters:
testrunId- - test run idtc- - test case object- Returns:
- - Boolean whether pass or fail
-
saveFile
-
determineFilePath
-