Java Code Examples for io.restassured.response.ExtractableResponse#as()
The following examples show how to use
io.restassured.response.ExtractableResponse#as() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VerifySampleEndpointsComponentTest.java From wingtips with Apache License 2.0 | 4 votes |
@DataProvider(value = { "true | true", "true | false", "false | true", "false | false" }, splitBy = "\\|") @Test public void verify_span_info_endpoint_traced_correctly(boolean upstreamSendsSpan, boolean upstreamSendsUserId) { Pair<Span, Map<String, String>> upstreamSpanInfo = (upstreamSendsSpan) ? generateUpstreamSpanHeaders(upstreamSendsUserId) : Pair.of((Span)null, Collections.<String, String>emptyMap()); ExtractableResponse response = given() .baseUri("http://localhost") .port(SERVER_PORT) .headers(upstreamSpanInfo.getRight()) .queryParam("foo", "bar") .log().all() .when() .get(SPAN_INFO_CALL_PATH) .then() .log().all() .extract(); assertThat(response.statusCode()).isEqualTo(200); Span completedSpan = verifySingleSpanCompletedAndReturnedInResponse(response, SLEEP_TIME_MILLIS, upstreamSpanInfo.getLeft()); verifySpanNameAndTags( completedSpan, "GET " + SPAN_INFO_CALL_PATH, "GET", SPAN_INFO_CALL_PATH, "http://localhost:" + SERVER_PORT + SPAN_INFO_CALL_PATH + "?foo=bar", SPAN_INFO_CALL_PATH, response.statusCode(), null, "servlet" ); EndpointSpanInfoDto resultDto = response.as(EndpointSpanInfoDto.class); if (upstreamSendsSpan) { verifySpanInfoEqual(resultDto.parent_span_info, spanInfoDtoFromSpan(upstreamSpanInfo.getLeft())); verifyParentChildRelationship(resultDto); } else { verifySpanInfoEqual(resultDto.parent_span_info, emptySpanInfoDto()); } }
Example 2
Source File: VerifySampleEndpointsComponentTest.java From wingtips with Apache License 2.0 | 4 votes |
private void verifyNestedCallEndpoint(boolean upstreamSendsSpan, boolean upstreamSendsUserId, String endpointPath) { Pair<Span, Map<String, String>> upstreamSpanInfo = (upstreamSendsSpan) ? generateUpstreamSpanHeaders(upstreamSendsUserId) : Pair.of((Span)null, Collections.<String, String>emptyMap()); ExtractableResponse response = given() .baseUri("http://localhost") .port(SERVER_PORT) .headers(upstreamSpanInfo.getRight()) .queryParam("foo", "bar") .log().all() .when() .get(endpointPath) .then() .log().all() .extract(); assertThat(response.statusCode()).isEqualTo(200); // The nested-*-call endpoints sleep once for the outer endpoint, and again for the span-info endpoint sub-call. // We expect 3 spans to have been completed: (1) the server span around the span-info endpoint, // (2) the client subspan around the RestTemplate/AsyncRestTemplate call, and (3) the server span around // the nested-*-call endpoint. verifyMultipleSpansCompletedAndReturnedInResponse( response, SLEEP_TIME_MILLIS * 2, 3, upstreamSpanInfo.getLeft() ); verifySpanTaggingForNestedCallEndpoint(endpointPath); EndpointSpanInfoDto resultDto = response.as(EndpointSpanInfoDto.class); if (upstreamSendsSpan) { // The span-info endpoint would have received span info generated by the nested-blocking-call endpoint, // *not* what we sent in our original call. We can still verify trace ID and user ID though, and // verify that the span-info endpoint had the correct parent/child relationship between spans. Span spanSent = upstreamSpanInfo.getLeft(); assertThat(resultDto.parent_span_info.trace_id).isEqualTo(spanSent.getTraceId()); assertThat(resultDto.parent_span_info.user_id).isEqualTo(spanSent.getUserId()); verifyParentChildRelationship(resultDto); } else { verifyParentChildRelationship(resultDto); } }
Example 3
Source File: VerifySampleEndpointsComponentTest.java From wingtips with Apache License 2.0 | 4 votes |
@DataProvider(value = { "true | true", "true | false", "false | true", "false | false" }, splitBy = "\\|") @Test public void verify_span_info_endpoint_traced_correctly(boolean upstreamSendsSpan, boolean upstreamSendsUserId) { Pair<Span, Map<String, String>> upstreamSpanInfo = (upstreamSendsSpan) ? generateUpstreamSpanHeaders(upstreamSendsUserId) : Pair.of((Span)null, Collections.emptyMap()); ExtractableResponse response = given() .baseUri("http://localhost") .port(SERVER_PORT) .headers(upstreamSpanInfo.getRight()) .queryParam("foo", "bar") .log().all() .when() .get(SPAN_INFO_CALL_PATH) .then() .log().all() .extract(); assertThat(response.statusCode()).isEqualTo(200); Span completedSpan = verifySingleSpanCompletedAndReturnedInResponse(response, SLEEP_TIME_MILLIS, upstreamSpanInfo.getLeft()); verifySpanNameAndTags( completedSpan, "GET " + SPAN_INFO_CALL_PATH, "GET", SPAN_INFO_CALL_PATH, "http://localhost:" + SERVER_PORT + SPAN_INFO_CALL_PATH + "?foo=bar", SPAN_INFO_CALL_PATH, response.statusCode(), null, "spring.webflux.server" ); EndpointSpanInfoDto resultDto = response.as(EndpointSpanInfoDto.class); if (upstreamSendsSpan) { verifySpanInfoEqual(resultDto.parent_span_info, spanInfoDtoFromSpan(upstreamSpanInfo.getLeft())); verifyParentChildRelationship(resultDto); } else { verifySpanInfoEqual(resultDto.parent_span_info, emptySpanInfoDto()); } }
Example 4
Source File: VerifySampleEndpointsComponentTest.java From wingtips with Apache License 2.0 | 4 votes |
@DataProvider(value = { "true | true", "true | false", "false | true", "false | false" }, splitBy = "\\|") @Test public void verify_nested_webclient_call_endpoint(boolean upstreamSendsSpan, boolean upstreamSendsUserId) { Pair<Span, Map<String, String>> upstreamSpanInfo = (upstreamSendsSpan) ? generateUpstreamSpanHeaders(upstreamSendsUserId) : Pair.of((Span)null, Collections.emptyMap()); ExtractableResponse response = given() .baseUri("http://localhost") .port(SERVER_PORT) .headers(upstreamSpanInfo.getRight()) .queryParam("foo", "bar") .log().all() .when() .get(NESTED_WEB_CLIENT_CALL_PATH) .then() .log().all() .extract(); assertThat(response.statusCode()).isEqualTo(200); // The nested-webclient-call endpoint sleeps once for the outer endpoint, and again for the span-info endpoint // sub-call. // We expect 3 spans to have been completed: (1) the server span around the span-info endpoint, // (2) the client subspan around the WebClient call, and (3) the server span around the // nested-webclient-call endpoint. verifyMultipleSpansCompletedAndReturnedInResponse( response, SLEEP_TIME_MILLIS * 2, 3, upstreamSpanInfo.getLeft() ); verifySpanTaggingForNestedCallEndpoint(NESTED_WEB_CLIENT_CALL_PATH); EndpointSpanInfoDto resultDto = response.as(EndpointSpanInfoDto.class); if (upstreamSendsSpan) { // The span-info endpoint would have received span info generated by the nested-webclient-call endpoint, // *not* what we sent in our original call. We can still verify trace ID and user ID though, and // verify that the span-info endpoint had the correct parent/child relationship between spans. Span spanSent = upstreamSpanInfo.getLeft(); assertThat(resultDto.parent_span_info.trace_id).isEqualTo(spanSent.getTraceId()); assertThat(resultDto.parent_span_info.user_id).isEqualTo(spanSent.getUserId()); verifyParentChildRelationship(resultDto); } else { verifyParentChildRelationship(resultDto); } }
Example 5
Source File: VerifySampleEndpointsComponentTest.java From wingtips with Apache License 2.0 | 4 votes |
@DataProvider(value = { "true | true", "true | false", "false | true", "false | false" }, splitBy = "\\|") @Test public void verify_span_info_endpoint_traced_correctly(boolean upstreamSendsSpan, boolean upstreamSendsUserId) { Pair<Span, Map<String, String>> upstreamSpanInfo = (upstreamSendsSpan) ? generateUpstreamSpanHeaders(upstreamSendsUserId) : Pair.of((Span)null, Collections.<String, String>emptyMap()); ExtractableResponse response = given() .baseUri("http://localhost") .port(SERVER_PORT) .headers(upstreamSpanInfo.getRight()) .queryParam("foo", "bar") .log().all() .when() .get(SPAN_INFO_CALL_PATH) .then() .log().all() .extract(); assertThat(response.statusCode()).isEqualTo(200); Span completedSpan = verifySingleSpanCompletedAndReturnedInResponse(response, SLEEP_TIME_MILLIS, upstreamSpanInfo.getLeft()); verifySpanNameAndTags( completedSpan, "GET " + SPAN_INFO_CALL_PATH, "GET", SPAN_INFO_CALL_PATH, "http://localhost:" + SERVER_PORT + SPAN_INFO_CALL_PATH + "?foo=bar", SPAN_INFO_CALL_PATH, response.statusCode(), null, "servlet" ); EndpointSpanInfoDto resultDto = response.as(EndpointSpanInfoDto.class); if (upstreamSendsSpan) { verifySpanInfoEqual(resultDto.parent_span_info, spanInfoDtoFromSpan(upstreamSpanInfo.getLeft())); verifyParentChildRelationship(resultDto); } else { verifySpanInfoEqual(resultDto.parent_span_info, emptySpanInfoDto()); } }
Example 6
Source File: VerifySampleEndpointsComponentTest.java From wingtips with Apache License 2.0 | 4 votes |
private void verifyNestedCallEndpoint(boolean upstreamSendsSpan, boolean upstreamSendsUserId, String endpointPath) { Pair<Span, Map<String, String>> upstreamSpanInfo = (upstreamSendsSpan) ? generateUpstreamSpanHeaders(upstreamSendsUserId) : Pair.of((Span)null, Collections.<String, String>emptyMap()); ExtractableResponse response = given() .baseUri("http://localhost") .port(SERVER_PORT) .headers(upstreamSpanInfo.getRight()) .queryParam("foo", "bar") .log().all() .when() .get(endpointPath) .then() .log().all() .extract(); assertThat(response.statusCode()).isEqualTo(200); // The nested-*-call endpoints sleep once for the outer endpoint, and again for the span-info endpoint sub-call. // We expect 3 spans to have been completed: (1) the server span around the span-info endpoint, // (2) the client subspan around the RestTemplate/AsyncRestTemplate call, and (3) the server span around // the nested-*-call endpoint. verifyMultipleSpansCompletedAndReturnedInResponse( response, SLEEP_TIME_MILLIS * 2, 3, upstreamSpanInfo.getLeft() ); verifySpanTaggingForNestedCallEndpoint(endpointPath); EndpointSpanInfoDto resultDto = response.as(EndpointSpanInfoDto.class); if (upstreamSendsSpan) { // The span-info endpoint would have received span info generated by the nested-blocking-call endpoint, // *not* what we sent in our original call. We can still verify trace ID and user ID though, and // verify that the span-info endpoint had the correct parent/child relationship between spans. Span spanSent = upstreamSpanInfo.getLeft(); assertThat(resultDto.parent_span_info.trace_id).isEqualTo(spanSent.getTraceId()); assertThat(resultDto.parent_span_info.user_id).isEqualTo(spanSent.getUserId()); verifyParentChildRelationship(resultDto); } else { verifyParentChildRelationship(resultDto); } }