protected void executeAndVerifySorting(String sortBy, String sortOrder, Status expectedStatus) { Map<String, String> params = new HashMap<String, String>(); params.put("sortBy", sortBy); params.put("sortOrder", sortOrder); given() .queryParams(params) .then().expect() .statusCode(expectedStatus.getStatusCode()) .when() .get(FILTER_QUERY_URL); if (expectedStatus.equals(Status.OK)) { verifyQueryMockSorting(sortBy, sortOrder); } }
/** * The possibly existing URI is used as location in Response.created * * @return a Response created based on the contained data */ public Response getResponse() { Response res; if (this.getUri() == null) { res = Response.status(this.getStatus()).entity(message).build(); } else { assert (this.getStatus().equals(Status.CREATED)); res = Response.created(this.getUri()).entity(this.getUri().toString()).build(); } return res; } }
ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).get(ClientResponse.class); if (response.getResponseStatus().equals(Status.OK)) { productList = response.getEntity(ProductListDto.class); String cacheDate = response.getMetadata().getFirst("Expires");
stream.reset(); if (Response.Status.FORBIDDEN.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is FORBIDDEN"; } else if (Response.Status.UNAUTHORIZED.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is UNAUTHORIZED"; } else if (Response.Status.BAD_REQUEST.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is BAD_REQUEST. Response data: " + getResponseData(r); } else if (Response.Status.NOT_FOUND.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is NOT_FOUND."; } else if (!Response.Status.OK.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token. Response status is " + response.getResponseStatus() + ". Response data: " + getResponseData(r);
stream.reset(); if (Response.Status.FORBIDDEN.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is FORBIDDEN"; } else if (Response.Status.UNAUTHORIZED.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is UNAUTHORIZED"; } else if (Response.Status.BAD_REQUEST.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is BAD_REQUEST. Response data: " + getResponseData(r); } else if (Response.Status.NOT_FOUND.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token, status is NOT_FOUND."; } else if (!Response.Status.OK.equals(response.getResponseStatus())) { error = "Error handling the Keycloak token. Response status is " + response.getResponseStatus() + ". Response data: " + getResponseData(r);
if (response.getResponseStatus().equals(Status.NOT_MODIFIED)) { LOG.debug("Order has not been modified..returning Cached Order..."); return (OrderDto) entry.getObject(); else if (response.getResponseStatus().equals(Status.OK)) { LOG.debug("Obtained full Order from Service...Caching it.."); OrderDto dto = response.getEntity(OrderDto.class);
return creationResult.getResponse(); if (creationResult.getStatus().equals(Status.CREATED)) { final DefinitionsChildId id = (DefinitionsChildId) creationResult.getId(); final IRepository repository = RepositoryFactory.getRepository();
/** * Hook method to deal with responses. * <p> * SNS cannot react to responses this is mainly here to log issues. * <p> * The default implementation logs all non 2xx responses to error and non * 204 responses to warning. * * @param snsRecordAndContext * the request * @param statusType * the response status type * @param headers * the response headers * @param entityOutputStream * the response body */ public void handleReponse(SnsRecordAndLambdaContext snsRecordAndContext, StatusType statusType, Map<String, List<String>> headers, ByteArrayOutputStream entityOutputStream) { Supplier<String> logMsgSupplier = () -> "endpoints consuming sns events should respond with 204 but got '" + statusType.getStatusCode() + "' for topic '" + snsRecordAndContext.getSnsRecord().getSNS().getTopicArn() + "'"; if (!Status.Family.SUCCESSFUL.equals(statusType.getFamily())) { LOG.error(logMsgSupplier.get()); } else if (!Status.NO_CONTENT.equals(statusType)) { LOG.warn(logMsgSupplier.get()); } }
/** * Validates response the response from the server against the expected HTTP status and * the returned secret token, if either is not correct will throw a GitLabApiException. * * @param response response * @param expected expected response status * @return original response if the response status is expected * @throws GitLabApiException if HTTP status is not as expected, or the secret token doesn't match */ protected Response validate(Response response, Response.Status expected) throws GitLabApiException { if (Response.Status.UNAUTHORIZED.equals(response.getStatus())){ throw new GitLabApiException("=============="+response+"\nAccessToken invalid"); } if (response.getStatus() != expected.getStatusCode()) { throw new GitLabApiException(response); } if (!getApiClient().validateSecretToken(response)) { throw new GitLabApiException(new NotAuthorizedException("Invalid secret token in response.")); } return (response); }