Java Code Examples for io.restassured.builder.ResponseBuilder#build()
The following examples show how to use
io.restassured.builder.ResponseBuilder#build() .
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: YamlToJsonFilter.java From microprofile-open-api with Apache License 2.0 | 6 votes |
@Override public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) { try { Response response = ctx.next(requestSpec, responseSpec); ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); Object obj = yamlReader.readValue(response.getBody().asString(), Object.class); ObjectMapper jsonWriter = new ObjectMapper(); String json = jsonWriter.writeValueAsString(obj); ResponseBuilder builder = new ResponseBuilder(); builder.clone(response); builder.setBody(json); builder.setContentType(ContentType.JSON); return builder.build(); } catch (Exception e) { throw new IllegalStateException("Failed to convert the request: " + ExceptionUtils.getMessage(e), e); } }
Example 2
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(48) public void testApplicationSimpleTimerUnitOpenMetrics() { String prefix = "org_eclipse_microprofile_metrics_test_MetricAppBean_simpleTimeMeA_"; Response resp = given().header("Accept", TEXT_PLAIN). get("/metrics/application/org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA"); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then().statusCode(200) .and() .body(containsString("# TYPE application_" + prefix + "total counter")) .body(containsString(prefix + "total")) .body(containsString(prefix + "elapsedTime_seconds")) .body(containsString(prefix + "maxTimeDuration_seconds")) .body(containsString(prefix + "minTimeDuration_seconds")) ; }
Example 3
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 6 votes |
/** * Test that semicolons `;` in tag values are translated to underscores `_` * in the JSON output */ @Test @RunAsClient @InSequence(46) public void testTranslateSemiColonToUnderScoreJSON() { Header wantJson = new Header("Accept", APPLICATION_JSON); Response resp = given().header(wantJson).get("/metrics/application"); JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify())); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filteredJSONPath.prettify()); resp = responseBuilder.build(); resp.then().statusCode(200) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.semiColonTaggedCounter;" + "scTag=semi_colons_are_bad;tier=integration'", equalTo(0)); }
Example 4
Source File: ReusedMetricsTest.java From microprofile-metrics with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(4) public void testSharedCounterAgain() { Header acceptJson = new Header("Accept", APPLICATION_JSON); Response resp = given().header(acceptJson).get("/metrics/application"); JsonPath filteredJSONPath = new JsonPath(resp.jsonPath().prettify().replaceAll(JSON_APP_LABEL_REGEX, JSON_APP_LABEL_REGEXS_SUB)); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filteredJSONPath.prettify()); resp = responseBuilder.build(); resp.then() .assertThat().body("'countMe2;tier=integration'", equalTo(2)) .assertThat().body("'org.eclipse.microprofile.metrics.test.MetricAppBean2.meterMe2'.'count;tier=integration'", equalTo(2)) .assertThat().body("'timeMe2'.'count;tier=integration'", equalTo(2)) .assertThat().body("'simplyTimeMe2'.'count;tier=integration'", equalTo(2)); }
Example 5
Source File: ReusedMetricsTest.java From microprofile-metrics with Apache License 2.0 | 6 votes |
@Test @RunAsClient @InSequence(2) public void testSharedCounter() { Header acceptJson = new Header("Accept", APPLICATION_JSON); Response resp = given().header(acceptJson).get("/metrics/application"); JsonPath filteredJSONPath = new JsonPath(resp.jsonPath().prettify().replaceAll(JSON_APP_LABEL_REGEX, JSON_APP_LABEL_REGEXS_SUB)); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filteredJSONPath.prettify()); resp = responseBuilder.build(); resp.then() .assertThat().body("'countMe2;tier=integration'", equalTo(1)) .assertThat().body("'org.eclipse.microprofile.metrics.test.MetricAppBean2.meterMe2'.'count;tier=integration'", equalTo(1)) .assertThat().body("'timeMe2'.'count;tier=integration'", equalTo(1)) .assertThat().body("'simplyTimeMe2'.'count;tier=integration'", equalTo(1)); }
Example 6
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(1) public void testSimpleRESTGet() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). when(). get(contextRoot+"/get-noparam"). then(). statusCode(200); Response resp = given().header(acceptHeader).when().get(METRICS_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "getNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getNoParam" + OM_BASE_REQUEST_END)); }
Example 7
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(6) public void testBaseOpenMetrics() { Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests")); Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/base"); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then().statusCode(200).and().contentType(TEXT_PLAIN).and() .body(containsString("# TYPE base_thread_max_count"), containsString("base_thread_max_count{tier=\"integration\"}")); }
Example 8
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(24) public void testApplicationTimerUnitOpenMetrics() { String prefix = "org_eclipse_microprofile_metrics_test_MetricAppBean_timeMeA_"; Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/application/org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA"); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then().statusCode(200) .and() .body(containsString("# TYPE application_" + prefix + "seconds summary")) .body(containsString(prefix + "seconds_count")) .body(containsString(prefix + "rate_per_second")) .body(containsString(prefix + "one_min_rate_per_second")) .body(containsString(prefix + "five_min_rate_per_second")) .body(containsString(prefix + "fifteen_min_rate_per_second")) .body(containsString(prefix + "elapsedTime")) .body(containsString(prefix + "mean_seconds")) .body(containsString(prefix + "min_seconds")) .body(containsString(prefix + "max_seconds")) .body(containsString(prefix + "stddev_second")) .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.5\"}")) .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.75\"}")) .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.95\"}")) .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.98\"}")) .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.99\"}")) .body(containsString(prefix + "seconds{tier=\"integration\",quantile=\"0.999\"}")) ; }
Example 9
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(13) public void testGetNameObject() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). when(). get(contextRoot+"/get-name-object"). then(). statusCode(200); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getNameObject" + NAME_OBJECT_PARAM + OM_BASE_REQUEST_END)); }
Example 10
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(9) public void testBaseAttributeOpenMetrics() { Assume.assumeFalse(Boolean.getBoolean("skip.base.metric.tests")); Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/base/thread.max.count"); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then().statusCode(200).and() .contentType(TEXT_PLAIN).and().body(containsString("# TYPE base_thread_max_count"), containsString("base_thread_max_count{tier=\"integration\"}")); }
Example 11
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(25) public void testApplicationHistogramUnitBytesOpenMetrics() { String prefix = "metricTest_test1_histogram_"; Response resp = given().header("Accept", TEXT_PLAIN).get("/metrics/application/metricTest.test1.histogram"); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then().statusCode(200) .and() .body(containsString(prefix + "bytes_count")) .body(containsString("# TYPE application_" + prefix + "bytes summary")) .body(containsString(prefix + "mean_bytes")) .body(containsString(prefix + "min_bytes")) .body(containsString(prefix + "max_bytes")) .body(containsString(prefix + "stddev_bytes")) .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.5\"}")) .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.75\"}")) .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.95\"}")) .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.98\"}")) .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.99\"}")) .body(containsString(prefix + "bytes{tier=\"integration\",quantile=\"0.999\"}")) ; }
Example 12
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(6) public void testSimpleRESTPost() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). when(). post(contextRoot+"/post-noparam"). then(). statusCode(200); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "postNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "postNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "postNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "postNoParam" + OM_BASE_REQUEST_END)); }
Example 13
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(5) public void testSimpleRESTPut() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). when(). put(contextRoot+"/put-noparam"). then(). statusCode(200); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "putNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "putNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "putNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "putNoParam" + OM_BASE_REQUEST_END)); }
Example 14
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(3) public void testSimpleRESTOptions() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). when(). options(contextRoot+"/options-noparam"). then(). statusCode(200); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "optionsNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "optionsNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "optionsNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "optionsNoParam" + OM_BASE_REQUEST_END)); }
Example 15
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 5 votes |
@Test @RunAsClient @InSequence(2) public void testSimpleRESTGetExplicit() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). when(). get(contextRoot+"/get-noparam"). then(). statusCode(200); /* * Explicitly hitting /metrics/base/REST.request from now on */ Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "getNoParam" + OM_BASE_REQUEST_END +" 2") , containsString(OM_BASE_REQUEST_TIME_START + "getNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getNoParam" + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getNoParam" + OM_BASE_REQUEST_END)); }
Example 16
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 4 votes |
@Test @RunAsClient @InSequence(9) public void testGetContextParams() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). when(). get(contextRoot+"/get-context-params"). then(). statusCode(200); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then().statusCode(200).contentType(TEXT_PLAIN).body( containsString( OM_BASE_REQUEST_COUNT_START + "getContextParams" + HTTP_HEADERS_PARAM + REQUEST_PARAM + URI_INFO_PARAM + RESOURCE_CONTEXT_PARAM + PROVIDERS_PARAM + APPLICATION_PARAM + SECURITY_CONTEXT_PARAM + CONFIGURATION_PARAM + OM_BASE_REQUEST_END), containsString( OM_BASE_REQUEST_TIME_START + "getContextParams" + HTTP_HEADERS_PARAM + REQUEST_PARAM + URI_INFO_PARAM + RESOURCE_CONTEXT_PARAM + PROVIDERS_PARAM + APPLICATION_PARAM + SECURITY_CONTEXT_PARAM + CONFIGURATION_PARAM + OM_BASE_REQUEST_END), containsString( OM_BASE_MAX_TIME_START + "getContextParams" + HTTP_HEADERS_PARAM + REQUEST_PARAM + URI_INFO_PARAM + RESOURCE_CONTEXT_PARAM + PROVIDERS_PARAM + APPLICATION_PARAM + SECURITY_CONTEXT_PARAM + CONFIGURATION_PARAM + OM_BASE_REQUEST_END), containsString( OM_BASE_MIN_TIME_START + "getContextParams" + HTTP_HEADERS_PARAM + REQUEST_PARAM + URI_INFO_PARAM + RESOURCE_CONTEXT_PARAM + PROVIDERS_PARAM + APPLICATION_PARAM + SECURITY_CONTEXT_PARAM + CONFIGURATION_PARAM + OM_BASE_REQUEST_END)); }
Example 17
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 4 votes |
@Test @RunAsClient @InSequence(10) public void testGetListParam() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList("a","b","c")). when(). get(contextRoot+"/get-list-param1"). then(). statusCode(200); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList(1, 2)) .when() .get(contextRoot + "/get-list-param2") .then() .statusCode(200); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList(1.0, 2.0)). queryParam("qp2", Arrays.asList(1L, 2L)) .when() .get(contextRoot + "/get-list-param3") .then() .statusCode(200); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "getListParam1" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getListParam1" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getListParam1" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getListParam1" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_COUNT_START + "getListParam2" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getListParam2" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getListParam2" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getListParam2" + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_COUNT_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getListParam3" + LIST_PARAM + LIST_PARAM + OM_BASE_REQUEST_END) ); }
Example 18
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 4 votes |
@Test @RunAsClient @InSequence(11) public void testGetArrayVarargParams() throws InterruptedException { Header acceptHeader = new Header("Accept", TEXT_PLAIN); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList(true, false)). when(). get(contextRoot+"/get-vararg-param1"). then(). statusCode(200); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList(1, 2)). queryParam("qp2", Arrays.asList("a", "b")) .when() .get(contextRoot + "/get-vararg-param2") .then() .statusCode(200); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList("a","b")) .when() .get(contextRoot + "/get-array-param1") .then() .statusCode(200); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList(1, 2)) .when() .get(contextRoot + "/get-array-param2") .then() .statusCode(200); given(). header(acceptHeader). port(applicationPort). queryParam("qp1", Arrays.asList(1.0, 2.0)) .when() .get(contextRoot + "/get-array-param3") .then() .statusCode(200); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filterOutAppLabelOpenMetrics(resp.getBody().asString())); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(TEXT_PLAIN). body(containsString(OM_BASE_REQUEST_COUNT_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getVarargParam1" + BOOLEANW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_COUNT_START + "getVarargParam2" + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getVarargParam2" + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getVarargParam2" + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getVarargParam2" + INT_PARAM + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_COUNT_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getArrayParam1" + STRING_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_COUNT_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getArrayParam2" + INT_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_COUNT_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_REQUEST_TIME_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MAX_TIME_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END) , containsString(OM_BASE_MIN_TIME_START + "getArrayParam3" + DOUBLEW_PARAM + ARRAY_BRACKETS + OM_BASE_REQUEST_END)); }
Example 19
Source File: MpMetricTest.java From microprofile-metrics with Apache License 2.0 | 4 votes |
@Test @RunAsClient @InSequence(18) public void testApplicationMetricsJSON() { Header wantJson = new Header("Accept", APPLICATION_JSON); Response resp = given().header(wantJson).get("/metrics/application"); JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify())); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filteredJSONPath.prettify()); resp = responseBuilder.build(); resp.then().statusCode(200) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.redCount;tier=integration'", equalTo(0)) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.blue;tier=integration'", equalTo(0)) .body("'greenCount;tier=integration'", equalTo(0)) .body("'purple;app=myShop;tier=integration'", equalTo(0)) .body("'metricTest.test1.count;tier=integration'", equalTo(1)) .body("'metricTest.test1.countMeA;tier=integration'", equalTo(1)) .body("'metricTest.test1.countMeB;tier=integration'", equalTo(1)) .body("'metricTest.test1.gauge;tier=integration'", equalTo(19)) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.gaugeMeA;tier=integration'", equalTo(1000)) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.gaugeMeB;tier=integration'", equalTo(7777777)) .body("'metricTest.test1.histogram'.'count;tier=integration'", equalTo(1000)) .body("'metricTest.test1.histogram'.'max;tier=integration'", equalTo(999)) .body("'metricTest.test1.histogram'.'mean;tier=integration'", closeTo(499.5)) .body("'metricTest.test1.histogram'.'min;tier=integration'", equalTo(0)) .body("'metricTest.test1.histogram'.'p50;tier=integration'", closeTo(499.0)) .body("'metricTest.test1.histogram'.'p75;tier=integration'", closeTo(749)) .body("'metricTest.test1.histogram'.'p95;tier=integration'", closeTo(949)) .body("'metricTest.test1.histogram'.'p98;tier=integration'", closeTo(979)) .body("'metricTest.test1.histogram'.'p99;tier=integration'", closeTo(989)) .body("'metricTest.test1.histogram'.'p999;tier=integration'", closeTo(998)) .body("'metricTest.test1.histogram'", hasKey("stddev;tier=integration")) .body("'metricTest.test1.meter'.'count;tier=integration'", equalTo(1)) .body("'metricTest.test1.meter'", hasKey("fifteenMinRate;tier=integration")) .body("'metricTest.test1.meter'", hasKey("fiveMinRate;tier=integration")) .body("'metricTest.test1.meter'", hasKey("meanRate;tier=integration")) .body("'metricTest.test1.meter'", hasKey("oneMinRate;tier=integration")) .body("'meterMeA'.'count;tier=integration'", equalTo(1)) .body("'meterMeA'", hasKey("fifteenMinRate;tier=integration")) .body("'meterMeA'", hasKey("fiveMinRate;tier=integration")) .body("'meterMeA'", hasKey("meanRate;tier=integration")) .body("'meterMeA'", hasKey("oneMinRate;tier=integration")) .body("'metricTest.test1.timer'.'count;tier=integration'", equalTo(1)) .body("'metricTest.test1.timer'", hasKey("fifteenMinRate;tier=integration")) .body("'metricTest.test1.timer'", hasKey("fiveMinRate;tier=integration")) .body("'metricTest.test1.timer'", hasKey("meanRate;tier=integration")) .body("'metricTest.test1.timer'", hasKey("oneMinRate;tier=integration")) .body("'metricTest.test1.timer'", hasKey("elapsedTime;tier=integration")) .body("'metricTest.test1.timer'", hasKey("max;tier=integration")) .body("'metricTest.test1.timer'", hasKey("mean;tier=integration")) .body("'metricTest.test1.timer'", hasKey("min;tier=integration")) .body("'metricTest.test1.timer'", hasKey("p50;tier=integration")) .body("'metricTest.test1.timer'", hasKey("p75;tier=integration")) .body("'metricTest.test1.timer'", hasKey("p95;tier=integration")) .body("'metricTest.test1.timer'", hasKey("p98;tier=integration")) .body("'metricTest.test1.timer'", hasKey("p99;tier=integration")) .body("'metricTest.test1.timer'", hasKey("p999;tier=integration")) .body("'metricTest.test1.timer'", hasKey("stddev;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'.'count;tier=integration'", equalTo(1)) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("fifteenMinRate;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("fiveMinRate;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("meanRate;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("oneMinRate;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("elapsedTime;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("max;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("mean;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("min;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p50;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p75;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p95;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p98;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p99;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("p999;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.timeMeA'", hasKey("stddev;tier=integration")) .body("'metricTest.test1.simpleTimer'.'count;tier=integration'", equalTo(1)) .body("'metricTest.test1.simpleTimer'", hasKey("elapsedTime;tier=integration")) .body("'metricTest.test1.simpleTimer'", hasKey("minTimeDuration;tier=integration")) .body("'metricTest.test1.simpleTimer'", hasKey("maxTimeDuration;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'.'count;tier=integration'", equalTo(1)) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'", hasKey("elapsedTime;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'", hasKey("minTimeDuration;tier=integration")) .body("'org.eclipse.microprofile.metrics.test.MetricAppBean.simpleTimeMeA'", hasKey("maxTimeDuration;tier=integration")); }
Example 20
Source File: MpMetricOptionalTest.java From microprofile-metrics with Apache License 2.0 | 4 votes |
@Test @RunAsClient @InSequence(16) public void testValidateGetJSONnoParam() throws InterruptedException { Header acceptHeader = new Header("Accept", APPLICATION_JSON); Response resp = given().header(acceptHeader).when().get(RESTREQUEST_METRIC_ENDPOINT); JsonPath filteredJSONPath = new JsonPath(filterOutAppLabelJSON(resp.jsonPath().prettify())); ResponseBuilder responseBuilder = new ResponseBuilder(); responseBuilder.clone(resp); responseBuilder.setBody(filteredJSONPath.prettify()); resp = responseBuilder.build(); resp.then(). statusCode(200). contentType(APPLICATION_JSON) .body(JSON_BASE_REQUEST_COUNT_START +"getNoParam"+JSON_BASE_REQUEST_END, equalTo(2)) //end-point was hit twice .body(JSON_BASE_REQUEST_TIME_START +"getNoParam"+JSON_BASE_REQUEST_END, not(0)) .body(JSON_BASE_MAX_TIME_START +"getNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_MIN_TIME_START +"getNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_REQUEST_COUNT_START +"optionsNoParam"+JSON_BASE_REQUEST_END, equalTo(1)) .body(JSON_BASE_REQUEST_TIME_START +"optionsNoParam"+JSON_BASE_REQUEST_END, not(0)) .body(JSON_BASE_MAX_TIME_START +"optionsNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_MIN_TIME_START +"optionsNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_REQUEST_COUNT_START +"headNoParam"+JSON_BASE_REQUEST_END, equalTo(1)) .body(JSON_BASE_REQUEST_TIME_START +"headNoParam"+JSON_BASE_REQUEST_END, not(0)) .body(JSON_BASE_MAX_TIME_START +"headNoParam"+JSON_BASE_REQUEST_END,nullOrGreaterThanZero()) .body(JSON_BASE_MIN_TIME_START +"headNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_REQUEST_COUNT_START +"putNoParam"+JSON_BASE_REQUEST_END, equalTo(1)) .body(JSON_BASE_REQUEST_TIME_START +"putNoParam"+JSON_BASE_REQUEST_END, not(0)) .body(JSON_BASE_MAX_TIME_START +"putNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_MIN_TIME_START +"putNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_REQUEST_COUNT_START +"postNoParam"+JSON_BASE_REQUEST_END, equalTo(1)) .body(JSON_BASE_REQUEST_TIME_START +"postNoParam"+JSON_BASE_REQUEST_END, not(0)) .body(JSON_BASE_MAX_TIME_START +"postNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_MIN_TIME_START +"postNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_REQUEST_COUNT_START +"deleteNoParam"+JSON_BASE_REQUEST_END, equalTo(1)) .body(JSON_BASE_REQUEST_TIME_START +"deleteNoParam"+JSON_BASE_REQUEST_END, not(0)) .body(JSON_BASE_MAX_TIME_START +"deleteNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()) .body(JSON_BASE_MIN_TIME_START +"deleteNoParam"+JSON_BASE_REQUEST_END, nullOrGreaterThanZero()); }