Class AbstractApiActionHandler
- java.lang.Object
-
- org.uitnet.testing.smartfwk.api.core.AbstractApiActionHandler
-
- All Implemented Interfaces:
ApiAuthenticationProvider
public abstract class AbstractApiActionHandler extends Object implements ApiAuthenticationProvider
- Author:
- Madhav Krishna
-
-
Field Summary
Fields Modifier and Type Field Description protected StringactiveProfileNameprotected UserProfileactiveUserProfileprotected ApiTestManagerapiTestManagerprotected StringappNameprotected StringbaseURLprotected longlastRequestAccessTimeInMsprotected booleanlogoutRequestprotected HttpSessionsessionprotected intsessionExpiryDurationInSecondsprotected StringtargetServerName
-
Constructor Summary
Constructors Constructor Description AbstractApiActionHandler(String appName, int sessionExpiryDurationInSeconds, String targetServerName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidauthenticate(String profileName)protected voidcheckAndSetSessionCookie(HttpSession session2, HttpResponse httpResponse)AbstractApiActionHandlerclone()protected voiddownloadFile(okhttp3.ResponseBody body, String filePath)StringgetActiveProfileName()UserProfilegetActiveUserProfile()longgetLastRequestAccessTimeInMs()HttpSessiongetSession()intgetSessionExpiryDurationInSeconds()protected voidhandleContentDisposition(HttpResponse httpResponse, okhttp3.Response rawResponse)HttpResponsehttpDelete(String relativeUrl, Map<String,String> headers, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)HttpResponsehttpGet(String relativeUrl, Map<String,String> headers, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)HttpResponsehttpHead(String relativeUrl, Map<String,String> headers, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)HttpResponsehttpPost(String relativeUrl, HttpRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)HttpResponsehttpPut(String relativeUrl, HttpRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)HttpResponsehttpUploadFormFiles(String relativeUrl, HttpMultipartFileRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds, boolean isHttpPut)HttpResponsehttpUploadMultipartFormData(String relativeUrl, HttpMultipartFormRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds, boolean isHttpPut)protected booleanisSessionExpired()protected StringprepareRequestCookieFromHttpSession()protected Map<String,String>prepareRequestHeaders(okhttp3.Request.Builder requestBuilder, Map<String,String> headers)protected HttpResponseprepareResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, boolean expectResponseBody, String targetURL)HttpSessionsetActiveProfileName(String profileName)voidsetApiTestManager(ApiTestManager apiTestManager)-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.uitnet.testing.smartfwk.api.core.ApiAuthenticationProvider
login, logout
-
-
-
-
Field Detail
-
appName
protected String appName
-
baseURL
protected String baseURL
-
session
protected HttpSession session
-
activeProfileName
protected String activeProfileName
-
activeUserProfile
protected UserProfile activeUserProfile
-
sessionExpiryDurationInSeconds
protected int sessionExpiryDurationInSeconds
-
lastRequestAccessTimeInMs
protected long lastRequestAccessTimeInMs
-
logoutRequest
protected boolean logoutRequest
-
apiTestManager
protected ApiTestManager apiTestManager
-
targetServerName
protected String targetServerName
-
-
Method Detail
-
setApiTestManager
public void setApiTestManager(ApiTestManager apiTestManager)
-
setActiveProfileName
public HttpSession setActiveProfileName(String profileName)
-
getSession
public HttpSession getSession()
-
authenticate
protected void authenticate(String profileName)
-
getActiveProfileName
public String getActiveProfileName()
-
prepareRequestHeaders
protected Map<String,String> prepareRequestHeaders(okhttp3.Request.Builder requestBuilder, Map<String,String> headers)
-
httpGet
public HttpResponse httpGet(String relativeUrl, Map<String,String> headers, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)
-
httpHead
public HttpResponse httpHead(String relativeUrl, Map<String,String> headers, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)
-
httpDelete
public HttpResponse httpDelete(String relativeUrl, Map<String,String> headers, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)
-
httpPost
public HttpResponse httpPost(String relativeUrl, HttpRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)
-
httpPut
public HttpResponse httpPut(String relativeUrl, HttpRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds)
-
httpUploadFormFiles
public HttpResponse httpUploadFormFiles(String relativeUrl, HttpMultipartFileRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds, boolean isHttpPut)
-
httpUploadMultipartFormData
public HttpResponse httpUploadMultipartFormData(String relativeUrl, HttpMultipartFormRequest request, Integer connectTimeoutInSeconds, Integer readTimeoutInSeconds, boolean isHttpPut)
-
prepareResponse
protected HttpResponse prepareResponse(okhttp3.OkHttpClient client, okhttp3.Request.Builder requestBuilder, boolean expectResponseBody, String targetURL)
-
prepareRequestCookieFromHttpSession
protected String prepareRequestCookieFromHttpSession()
-
checkAndSetSessionCookie
protected void checkAndSetSessionCookie(HttpSession session2, HttpResponse httpResponse)
-
isSessionExpired
protected boolean isSessionExpired()
-
getActiveUserProfile
public UserProfile getActiveUserProfile()
-
getSessionExpiryDurationInSeconds
public int getSessionExpiryDurationInSeconds()
-
getLastRequestAccessTimeInMs
public long getLastRequestAccessTimeInMs()
-
handleContentDisposition
protected void handleContentDisposition(HttpResponse httpResponse, okhttp3.Response rawResponse) throws IOException
- Throws:
IOException
-
downloadFile
protected void downloadFile(okhttp3.ResponseBody body, String filePath) throws IOException- Throws:
IOException
-
clone
public AbstractApiActionHandler clone()
-
-