Skip to content

Commit aeff591

Browse files
authored
4.x: Remove unused private methods from HelloWorldAsyncResponseWithRestRequestTest (helidon-io#8624)
1 parent beb18c9 commit aeff591

1 file changed

Lines changed: 1 addition & 61 deletions

File tree

microprofile/metrics/src/test/java/io/helidon/microprofile/metrics/HelloWorldAsyncResponseWithRestRequestTest.java

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,14 +15,8 @@
1515
*/
1616
package io.helidon.microprofile.metrics;
1717

18-
import java.io.IOException;
19-
import java.io.LineNumberReader;
20-
import java.io.StringReader;
2118
import java.util.Map;
22-
import java.util.StringJoiner;
2319
import java.util.concurrent.atomic.AtomicReference;
24-
import java.util.regex.Matcher;
25-
import java.util.regex.Pattern;
2620

2721
import io.helidon.microprofile.testing.junit5.AddConfig;
2822
import io.helidon.microprofile.testing.junit5.HelidonTest;
@@ -148,60 +142,6 @@ private JsonObject getRESTRequestJSON() {
148142
return restRequestValue.asJsonObject();
149143
}
150144

151-
private String getRESTRequestProm() throws IOException {
152-
Response metricsResponse = webTarget.path("/metrics/base")
153-
.request(MediaType.TEXT_PLAIN)
154-
.get();
155-
156-
assertThat("Status retrieving REST request metrics", metricsResponse.getStatus(), is(200));
157-
158-
String metrics = metricsResponse.readEntity(String.class);
159-
StringJoiner sj = new StringJoiner(System.lineSeparator());
160-
LineNumberReader reader = new LineNumberReader(new StringReader(metrics));
161-
String line;
162-
boolean proceed = true;
163-
while (proceed) {
164-
line = reader.readLine();
165-
proceed = (line != null);
166-
if (proceed) {
167-
if (line.startsWith("REST_request_seconds_count")) {
168-
sj.add(line);
169-
}
170-
}
171-
}
172-
return sj.toString();
173-
}
174-
175-
private double getRESTRequestValueForGetAsyncMethod(String prometheusOutput,
176-
String valueName,
177-
boolean nullOK) throws NoSuchMethodException {
178-
Pattern pattern = Pattern.compile(".*?^" + valueName + "\\{([^}]+)}\\s+(\\S+).*?",
179-
Pattern.MULTILINE | Pattern.DOTALL);
180-
Matcher matcher = pattern.matcher(prometheusOutput);
181-
182-
assertThat("Match for REST request count", matcher.matches(), is(true));
183-
// Digest the tags to make sure the class and method tags are correct.
184-
String[] tags = matcher.group(1).split(",");
185-
boolean foundCorrectClass = false;
186-
boolean foundCorrectMethod = false;
187-
188-
String expectedMethodName = HelloWorldResource.class.getMethod("getAsync", AsyncResponse.class).getName()
189-
+ "_" + AsyncResponse.class.getName();
190-
191-
for (String tag : tags) {
192-
if (tag.isBlank()) {
193-
continue;
194-
}
195-
String[] parts = tag.split("=");
196-
foundCorrectClass |= (parts[0].equals("class") && parts[1].equals(HelloWorldResource.class.getName()));
197-
foundCorrectMethod |= (parts[0].equals("method") && parts[1].equals(expectedMethodName));
198-
}
199-
assertThat("Class tag correct", foundCorrectClass, is(true));
200-
assertThat("Method tag correct", foundCorrectMethod, is(true));
201-
202-
return Double.parseDouble(matcher.group(2));
203-
}
204-
205145
private JsonValue getRESTRequestValueForGetAsyncMethod(JsonObject restRequestJson,
206146
String valueName,
207147
boolean nullOK) {

0 commit comments

Comments
 (0)