private boolean isEnabled() throws Exception { String responseText = RequestFacade.doGetForText("service/local/lvo_config"); XStreamRepresentation representation = new XStreamRepresentation(getXMLXStream(), responseText, MediaType.APPLICATION_XML); LvoConfigResponse resp = (LvoConfigResponse) representation.getPayload(new LvoConfigResponse()); return resp.getData().isEnabled(); }
@SuppressWarnings("unchecked") public static List<RepositoryRouteListResource> getList() throws IOException { String serviceURI = "service/local/repo_routes"; String entityText = RequestFacade.doGetForText(serviceURI); XStreamRepresentation representation = new XStreamRepresentation( XStreamFactory.getXmlXStream(), entityText, MediaType.APPLICATION_XML); RepositoryRouteListResourceResponse resourceResponse = (RepositoryRouteListResourceResponse) representation.getPayload(new RepositoryRouteListResourceResponse()); return resourceResponse.getData(); }
public RepositoryBaseResource getTemplate(String id) throws IOException { String responseText = RequestFacade.doGetForText("service/local/templates/repositories/" + id, not(inError())); LOG.debug("responseText: \n" + responseText); XStreamRepresentation representation = new XStreamRepresentation( XStreamFactory.getXmlXStream(), responseText, MediaType.APPLICATION_XML); RepositoryResourceResponse resourceResponse = (RepositoryResourceResponse) representation.getPayload(new RepositoryResourceResponse()); return resourceResponse.getData(); }
private void test(String query, String expected) throws IOException { String serviceURIpart = "service/local/lucene/search?q=" + URLEncoder.encode(query, "UTF-8"); log.info("Testing query {}: {}", query, serviceURIpart); String errorPayload = RequestFacade.doGetForText(serviceURIpart, respondsWithStatusCode(400)); log.info("Received 'Bad Request' error: " + errorPayload); MediaType type = MediaType.APPLICATION_XML; XStreamRepresentation representation = new XStreamRepresentation(getXMLXStream(), errorPayload, type); ErrorResponse payload = (ErrorResponse) representation.getPayload(new ErrorResponse()); List errors = payload.getErrors(); assertThat((Collection<?>) errors, hasSize(1)); ErrorMessage error = (ErrorMessage) errors.get(0); String msg = error.getMsg(); msg = msg.replaceAll("Cannot parse '([^']*)':.*", "$1"); log.info("msg: " + msg); assertThat(msg, equalTo(expected)); }