Platform Mock Server
To know about Mock Server framework.
Platform Mock Server is used to test the working of agents by creating expectations for each DevOps tool. When Mock Server receives a requests it matches the request against active expectations that have been configured. Platform Mock Server is available to use in the form of jar file.
Every expectation can have 4 fields:
- Path:- URL of the expectation which agent will call for the response (String).
- Parameters:- List of additional parameters required in the URL (list of key-value Pairs).
- isResponseJson:- Whether the response is a json object or a list of json(true/false)
- Response:- Mock Response (String).
How to Create Expectations:
- Create a json file and put it in mock_json folder inside INSIGHTS_HOME. One json file will be created for each DevOps tool.
- Create a list in json file using square brackets like [].
- Create expectations using four fields specified above.
- Sample expectation looks like:-
{
"path": "/rally/release",
"parameters": {
"workspace" : "",
"fetch" : "true?pagesize=20",
"start" : "1"
},
"isResponseJson": true,
"response": []
}
5. Remember response will always return list.
- If isResponseJson field is set to true then response will contain only one json object in the list.
- If isResponseJson field is set to false then response can contain multiple json objects in the list.
- isResponseJson is set to false by default.
6. Path and Response are mandatory fields which needs to be present inside every json object. Others are not mandatory.
7. For more details, visit http://www.mock-server.com/.
How to Start Platform Mock Server:
- Open command prompt and change directory to the folder where your mock server jar is present.
- Execute command:
java –jar PlatformMockServer.jar
3. Restart Mock Server after any change in the json file to take changes into effect.
4.Default port of Mock Server is 1080.
5. localhost:1080/toolname will be your base URL in the agent config file. Tool name is just for identification.
Back to Top
©2021 Cognizant, all rights reserved. US Patent 10,410,152