use of com.ibm.cloud.cloudant.v1.model.GetSessionInformationOptions in project cloudant-java-sdk by IBM.
the class Cloudant method getSessionInformation.
/**
* Retrieve current session cookie information.
*
* Retrieves information about the authenticated user's session.
*
* @param getSessionInformationOptions the {@link GetSessionInformationOptions} containing the options for the call
* @return a {@link ServiceCall} with a result of type {@link SessionInformation}
*/
public ServiceCall<SessionInformation> getSessionInformation(GetSessionInformationOptions getSessionInformationOptions) {
RequestBuilder builder = RequestBuilder.get(RequestBuilder.resolveRequestUrl(getServiceUrl(), "/_session"));
Map<String, String> sdkHeaders = SdkCommon.getSdkHeaders("cloudant", "v1", "getSessionInformation");
for (Entry<String, String> header : sdkHeaders.entrySet()) {
builder.header(header.getKey(), header.getValue());
}
builder.header("Accept", "application/json");
ResponseConverter<SessionInformation> responseConverter = ResponseConverterUtils.getValue(new com.google.gson.reflect.TypeToken<SessionInformation>() {
}.getType());
return createServiceCall(builder.build(), responseConverter);
}
use of com.ibm.cloud.cloudant.v1.model.GetSessionInformationOptions in project cloudant-java-sdk by IBM.
the class GetSessionInformationOptionsTest method testGetSessionInformationOptions.
@Test
public void testGetSessionInformationOptions() throws Throwable {
GetSessionInformationOptions getSessionInformationOptionsModel = new GetSessionInformationOptions();
assertNotNull(getSessionInformationOptionsModel);
}
use of com.ibm.cloud.cloudant.v1.model.GetSessionInformationOptions in project cloudant-java-sdk by IBM.
the class CloudantTest method testGetSessionInformationWOptions.
@Test
public void testGetSessionInformationWOptions() throws Throwable {
// Schedule some responses.
String mockResponseBody = "{\"ok\": true, \"info\": {\"authenticated\": \"authenticated\", \"authentication_db\": \"authenticationDb\", \"authentication_handlers\": [\"authenticationHandlers\"]}, \"userCtx\": {\"db\": \"db\", \"name\": \"name\", \"roles\": [\"_reader\"]}}";
String getSessionInformationPath = "/_session";
server.enqueue(new MockResponse().setHeader("Content-type", "application/json").setResponseCode(200).setBody(mockResponseBody));
constructClientService();
// Construct an instance of the GetSessionInformationOptions model
GetSessionInformationOptions getSessionInformationOptionsModel = new GetSessionInformationOptions();
// Invoke operation with valid options model (positive test)
Response<SessionInformation> response = cloudantService.getSessionInformation(getSessionInformationOptionsModel).execute();
assertNotNull(response);
SessionInformation responseObj = response.getResult();
assertNotNull(responseObj);
// Verify the contents of the request
RecordedRequest request = server.takeRequest();
assertNotNull(request);
assertEquals(request.getMethod(), "GET");
// Check query
Map<String, String> query = TestUtilities.parseQueryString(request);
assertNull(query);
// Check request path
String parsedPath = TestUtilities.parseReqPath(request);
assertEquals(parsedPath, getSessionInformationPath);
}
Aggregations