use of com.wikia.webdriver.common.remote.RemoteException in project selenium-tests by Wikia.
the class CreateCategory method execute.
public CategoryPill.Data execute(final CreateCategoryContext context) {
JSONObject jsonObject = new JSONObject(ImmutableMap.builder().put("name", context.getCategoryName()).put("parentId", PARENT_ID).put("siteId", context.getSiteId()).build());
String response;
try {
response = remoteOperation.execute(buildUrl(context), jsonObject);
} catch (RemoteException e) {
PageObjectLogging.logError("error: ", e);
throw new CategoryNotCreated("Could not create a new category.", e);
}
DocumentContext json = JsonPath.parse(response);
CategoryPill.Data data = new CategoryPill.Data(json.read("$.id"), json.read("$.name"));
data.setDisplayOrder(json.read("$.displayOrder"));
return data;
}
use of com.wikia.webdriver.common.remote.RemoteException in project selenium-tests by Wikia.
the class BaseRemoteOperation method handleResponse.
String handleResponse(final HttpRequestBase requestBase, final CloseableHttpResponse response) throws IOException {
String result = StringUtils.EMPTY;
final HttpEntity entity = response.getEntity();
if (null != entity) {
result = EntityUtils.toString(entity);
if (response.getStatusLine().getStatusCode() >= 400) {
throw new RemoteException("Error while invoking request. " + " Method: " + requestBase.getMethod() + " Url: " + requestBase.getURI().toString() + " Response: " + result);
}
}
return result;
}
use of com.wikia.webdriver.common.remote.RemoteException in project selenium-tests by Wikia.
the class BaseRemoteOperation method execute.
String execute(final HttpEntityEnclosingRequestBase request, final JSONObject jsonObject) {
String result = StringUtils.EMPTY;
try {
request.setHeader(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON.toString());
request.setEntity(new StringEntity(jsonObject.toString(), ContentType.APPLICATION_JSON));
result = execute(request);
} catch (RemoteException ex) {
PageObjectLogging.log("Request: ", getRequestString(request) + "\n" + request.getEntity(), false);
PageObjectLogging.log("Error while creating http post entity.", ExceptionUtils.getStackTrace(ex), false);
}
return result;
}
Aggregations