1
1
package com .maxsoft .intelliapi .stepimpl .api ;
2
2
3
- import com .maxsoft .intelliapi .api .ApiInvoker ;
4
3
import com .maxsoft .intelliapi .util .FrameworkUtil ;
5
4
import com .thoughtworks .gauge .Step ;
6
- import io .restassured .http .Headers ;
7
5
8
- import static com .maxsoft .intelliapi .api .ApiRequestPayloadProcessor .getHeaders ;
9
- import static com .maxsoft .intelliapi .Constants .*;
10
- import static com .maxsoft .intelliapi .api .ApiResponseProcessor .saveResponseJsonPathValue ;
11
- import static com .maxsoft .intelliapi .api .JsonRequestProcessor .getApiWithAuthMultipleHeaders ;
12
- import static com .maxsoft .intelliapi .util .DataStoreProcessor .getSavedValueForScenario ;
13
- import static com .maxsoft .intelliapi .util .FrameworkUtil .isTrue ;
14
- import static com .maxsoft .intelliapi .util .FrameworkUtil .readAccessToken ;
15
- import static com .maxsoft .intelliapi .util .LogUtil .printInfo ;
6
+ import static com .maxsoft .intelliapi .Constants .CURRENT_DIRECTORY ;
16
7
17
8
/**
18
9
* Project Name : MaxSoft-IntelliAPI
@@ -31,70 +22,6 @@ public void printTestingEnvDetails() {
31
22
FrameworkUtil .printTestingEnvDetails ();
32
23
}
33
24
34
- /* Use this method when you need to pass the JSON request in previous step and the access token from the text file into the GET/POST/PUT/DELETE API.
35
- The "saveRequestAuthConfigurations" must use before using this step */
36
- @ Step ("When the user invokes the API" )
37
- public void invokeApi () {
38
- String jsonRequest = String .valueOf (getSavedValueForScenario (VAR_API_JSON_REQUEST_BODY ));
39
- String headerNamesList = getSavedValueForScenario (VAR_API_HEADER_NAMES_LIST );
40
- String headerValuesList = getSavedValueForScenario (VAR_API_HEADER_VALUES_LIST );
41
-
42
- if (headerNamesList == null || headerNamesList .equals ("" ) ||
43
- headerValuesList == null || headerValuesList .equals ("" )) {
44
- ApiInvoker .invoke (jsonRequest , new Headers ());
45
- } else {
46
- ApiInvoker .invoke (jsonRequest , new Headers (getHeaders (headerNamesList , headerValuesList )));
47
- }
48
- }
49
-
50
- @ Step ("And the user saves an API request url in the JSON Path <jsonPath> to a data store" )
51
- public void saveApiEndpointInResponseBody (String jsonPath ) {
52
- saveResponseJsonPathValue (SCENARIO , VAR_API_ENDPOINT , jsonPath );
53
- }
54
-
55
- @ Step ("And invoke a GET request from the API request url saved in the data store" )
56
- public void doGetRequestFromDataStore () {
57
- String invokingEndpoint = getSavedValueForScenario (VAR_API_ENDPOINT );
58
- String headerNamesList = getSavedValueForScenario (VAR_API_HEADER_NAMES_LIST );
59
- String headerValuesList = getSavedValueForScenario (VAR_API_HEADER_VALUES_LIST );
60
-
61
- String accessToken , isAuthenticationRequired , isAccessTokenRetrievedFromTextFile , accessTokenString ;
62
- String accessTokenInFile = readAccessToken ();
63
-
64
- try {
65
- isAuthenticationRequired = getSavedValueForScenario (IS_AUTHENTICATION_REQUIRED ).toLowerCase ();
66
- isAccessTokenRetrievedFromTextFile = getSavedValueForScenario (RETRIEVE_TOKEN_FROM_TEXT_FILE ).toLowerCase ();
67
- accessTokenString = getSavedValueForScenario (MANUAL_TOKEN );
68
- } catch (Exception ex ) {
69
- isAuthenticationRequired = "" ;
70
- isAccessTokenRetrievedFromTextFile = "" ;
71
- accessTokenString = "" ;
72
- }
73
-
74
- if (isTrue (isAuthenticationRequired )) {
75
- if (isTrue (isAccessTokenRetrievedFromTextFile )) {
76
- accessToken = accessTokenInFile ;
77
- } else {
78
- accessToken = accessTokenString ;
79
- }
80
- } else {
81
- accessToken = "" ;
82
- }
83
-
84
- printInfo ("" );
85
- printInfo ("" );
86
- printInfo ("Invoked API Endpoint:\n " + invokingEndpoint + "\n \n " );
87
- printInfo ("HTTP Method is: GET\n \n " );
88
-
89
- if (headerNamesList == null || headerNamesList .equals ("" ) ||
90
- headerValuesList == null || headerValuesList .equals ("" )) {
91
- getApiWithAuthMultipleHeaders (invokingEndpoint , accessToken , new Headers ());
92
- } else {
93
- getApiWithAuthMultipleHeaders (invokingEndpoint , accessToken ,
94
- new Headers (getHeaders (headerNamesList , headerValuesList )));
95
- }
96
- }
97
-
98
25
// Use this method to replace the rows of a column in a given CSV with the timestamp
99
26
@ Step ("And replace the row values in <columnName> column of the CSV <filePath> into the <timestampPattern> timestamp pattern" )
100
27
public void replaceAllColumnValuesToCurrentTimestamp (String columnName , String filePath , String timestampPattern ) {
0 commit comments