UNPKG

rest-assured-ts

Version:
156 lines (155 loc) 9.72 kB
import { DataTable } from "@cucumber/cucumber"; /** * This method is used to display JSON response in an easy-to-read format * @param {object} json - JSON response */ export declare function prettyPrintJSON(json: object): string; /** * This method is used for the negative validation of JSON response after making REST call * Json response should not contain json path parameter or values that are passed from feature file (DataTable) or Map * Where sending input as JSON Response and DataTable or Map * Where DataTable is a 2D array , sending row and columns as key value pair * This will internally refer invalidJsonPathWithRegularExpressionForMap by passing JSON path(responseBody) * invalidJsonPathWithRegularExpressionForMap: It validates JSON response with DataTable values * @param {object} responseBody - json response after making REST call * @param {DataTable | Map<string, any>} jsonKeyValues - Send Json response path parameter and values as a Cucumber DataTable or Map * @returns {void} */ export declare function validateJsonResponseNotIncludes(responseBody: object, jsonKeyValues: DataTable | Map<string, any>): void; export declare function invalidJsonPathWithRegularExpressionForMap(responseBody: object, datableFieldsInMap: Map<string, string>): void; export declare function validJsonPathWithRegularExpressionForMap(responseBody: object, responsemap: Map<string, string>): void; export declare function replaceJsonPathFollowedByParentIndex(responseBody: object, parentnode: string, value: string): string; /** * This method is used for validating JSON response followed by parent node index after making http request * Where sending input as JSON Response and DataTable or Map * Where DataTable is 2D array , sending row and columns as key value pair * Constructing Map out of DataTable which is defined in feature file * Constructed Map will contain json node(key) and value pair * Json response should contain json key and values that are passed from feature file (DataTable) * validateJsonMapFollowedByParentIndex: It validates map values with JSON response followed by parent node * followed by responseBody JSON path and parent index. * @param {string} parentNode - parent node * @param {object} responseBody - response body * @param {DataTable | Map<string, any> } responseFields - json response key(path parameter) and value as Map or DataTable * @returns {void} */ export declare function validateJsonResponseFollowedByParentIndex(parentNode: string, responseBody: object, jsonKeyValues: DataTable | Map<string, any>): void; export declare function validateJsonKeyValuePairFollowedByParentIndex(parentKey: string, responseBody: object, responseMap: Map<string, string>): void; /** * This method is used to read the JSON file from the path specified * @param {string} jsonfilepath - JSON file path */ export declare function readJson(jsonfilepath: string): Promise<object>; /** * This method is used to read the JSON file from the specified path to create a JSON object * @param {string} jsonfilepath - JSON file path */ export declare function readJsonToObject(jsonfilepath: string): Promise<object>; /** * This method is used to read the JSON file from the specified path to create a JSON string * @param {string} jsonfilepath - JSON file path */ export declare function readJsonToString(jsonfilepath: string): Promise<string>; /** * This method is used to find the parent node by name * @param {object} jsonData - JSON data * @param {string} nodeName - name of the node */ export declare function findNodeByName(jsonData: object, nodeName: string): Promise<string[]>; /** * This method is used to POST request parameters from the DataTable that are specified in the input json file * These request parameters will replace for input json file object. * Where input json file just template for request parameters * @param {string} jsonFilepath - JSON file path * @param {DataTable | Map<string, any>} jsonKeyValuePair - response fields */ export declare function sendRequestBodyAsFile(jsonFilepath: string, jsonKeyValuePair: DataTable | Map<string, any>): Promise<string>; /** * This method is used to POST request parameters from the DataTable that are specified in the input json file * These request parameters will replace for input json file object. * Where input json file just template for request parameters * Note: Need to provide exact json path to replace node values * @param {string} jsonFilepath - JSON file path * @param {DataTable} responseFields - response fields */ export declare function sendRequestBodyAsJsonFile(jsonFilepath: string, jsonKeyValuePair: DataTable | Map<string, any>): Promise<string>; /** * This method is used to send request json key value pair from the DataTable as Map specified in the input json file * These request parameters will replace for input json file object. * Where input json file just template for request parameters * @param {string} jsonFilepath - JSON file path * @param {Map<string, any>} dataTableFieldsInMap - data table fields Map */ export declare function sendRequestParametersFromMap(jsonFilepath: string, dataTableFieldsInMap: Map<string, any>): Promise<string>; /** * This method is used to find the parent node value by node name * @param {object} jsonData - JSON data * @param {string} nodename - name of the node */ export declare function findNodeValue(jsonData: object, nodeName: string): Promise<string[]>; /** * This method is used for validation of JSON response after making http request by giving JSON path * returns the table as a 2-D array, without the first row * where first row from datatable using it as column headers. * validJsonPathWithRegularExpressionForMap: It validates JSON response passed as key and value pair * after making service(REST) call, where key is JSON node(path) name and value is JSON node(path) * value with the responseBody JSON path. * @param {object} jsoneResponse - json response body as an object * @param {DataTable | Map<string, string>} jsonResponseKeyValuePair - send json path and corrosponding value as in the form of DataTable or Map * @returns {void} */ export declare function validateJsonResponse(jsonResponse: object, jsonResponseKeyValuePair: Map<string, string> | DataTable): void; /** * This method is used to validate json response objects * These input json response file converting as json object. * Where internally calls deepCompareOfJsonObjects method to validate two json objects * @param {string} jsonResponseFilepath - JSON Response as Input File * @param {object} actualJsonResponseObject - Getting json response after making REST call * @returns {Promise<void>} - returns nothing */ export declare function validateJsonResponseFile(jsonResponseFilepath: string, actualJsonResponseObject: object, jsonkeyValue?: Map<string, any> | DataTable): Promise<void>; /** * This method is used to read response file in json format as well parameters as Map * Where values of Map needs to be replaced in the input json file object * Where input response json file just template for request parameters * @param {string} jsonResponseFilepath - JSON file path * @param {Map<string, string>} dataTableFieldsInMap - data table fields Map * @returns {object} - Returns Json object */ export declare function createJsonResponseObjectFromMap(jsonResponseFilepath: string, dataTableFieldsInMap: Map<string, string>): Promise<object>; /** * This method is used to compare of two json objects by every Key * Which gives exactly Key that fails for particular test * Where passing two json objects as inputs * @param {object} expectedJsonObject - First json object * @param {object} actualJsonObject - second json object that needs to be compared * @returns {void} - Returns Json object */ export declare function deepCompareOfJsonObjects(actualJsonObject: object, expectedJsonObject: object): void; /** * This method is used to replace required json path parameter values on the json request or response object * Note: Need to provide exact json path to replace node values * Where input json file just template for json path parameters * @param {object} jsonObject - JSON request/response object * @param {Map<string, string>} dataTableFieldsInMap - dataTable fields reading from the feature file * and sending it as Map */ export declare function replaceExactJsonNodeValues(jsonObject: object, dataTableFieldsInMap: Map<string, string>): Promise<string>; export declare function replaceExactJsonFileNodeValues(jsonFilePath: string, dataTableFieldsInMap: Map<string, string>): Promise<string>; /** * This method is used to exclude Json Path parameters(keys) from request body or response body * Note: Need to provide exact json path to replace node values * @param {string | object} requestBody - request body sending it as string or JSON object * @param {DataTable | Map<string, string> | string[]} dataTableFieldsInMap - dataTable fields reading from the feature file * and sending it as Map or string array * Note: |key1| {exclude_path_parameter}| * key1 is path parameter value is {exclude_path_parameter} in the dataTable or Map */ export declare function excludeJsonPathParameters(requestBody: string | object, jsonKeyValues: DataTable | Map<string, string> | string[]): Promise<string>; /** * This method is used to validate response body whether json or not * Note: Other than json means, response could be xml, normal string or html etc * @param {any} responseBody - response body after making http(Rest) call * @returns {boolean} - Returns true if it is valid json otherwise false */ export declare function isValidJson(responseBody: any): Promise<boolean>;