Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarranzan committed Jun 13, 2024
1 parent 6521ac8 commit 1118728
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public Response notFound() {
return Response.status(Response.Status.NOT_FOUND).build(); //404
}

@GET
@Path("/not-found/{uri}")
public Response notFoundUri(@PathParam("uri") String uri) {
return Response.status(Response.Status.NOT_FOUND).build(); //404
}

@GET
@Path("/moved/{id}")
public Response moved(@PathParam("id") String id) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class HttpPathMetricsPatternIT {
private static final String HTTP_SERVER_REQUESTS_METRICS_FORMAT = "http_server_requests_seconds_%s{method=\"GET\",outcome=\"%s\",status=\"%d\",uri=\"%s\"}";
private static final String REDIRECT_ENDPOINT = "/test/redirect";
private static final String NOT_FOUND_ENDPOINT = "/test/not-found";
private static final String NOT_FOUND_URI_ENDPOINT = "/test/not-found/{uri}";
private static final String MOVED_ENDPOINT = "/test/moved/{id}";
private static final String EMPTY_ENDPOINT = "/test";

Expand All @@ -31,15 +32,21 @@ public class HttpPathMetricsPatternIT {
.withProperty("quarkus.management.enabled", "true");

@Test
public void verifyUriNotFoundInMetrics() {
public void verifyNotFoundInMetrics() {
whenCallNotFoundEndpoint();
thenMetricIsExposedInServiceEndpoint(404, "CLIENT_ERROR", NOT_FOUND_ENDPOINT);
thenMetricIsExposedInServiceEndpoint(404, "CLIENT_ERROR", "NOT_FOUND");
}

@Test
public void verifyUriNotFoundInMetrics() {
whenCallNotFoundWithParamEndpoint("/url123");
thenMetricIsExposedInServiceEndpoint(404, "CLIENT_ERROR", NOT_FOUND_URI_ENDPOINT);
}

@Test
public void verifyRedirectionInMetrtics() {
whenCallRedirectEndpoint();
thenMetricIsExposedInServiceEndpoint(302, "REDIRECTION", REDIRECT_ENDPOINT);
thenMetricIsExposedInServiceEndpoint(302, "REDIRECTION", "REDIRECTION");
}

@Test
Expand Down Expand Up @@ -74,6 +81,14 @@ private void whenCallNotFoundEndpoint() {
.then().statusCode(HttpStatus.SC_NOT_FOUND);
}

private void whenCallNotFoundWithParamEndpoint(String url) {
given()
.pathParam("uri", url)
.redirects().follow(false)
.when().get(NOT_FOUND_URI_ENDPOINT)
.then().statusCode(HttpStatus.SC_NOT_FOUND);
}

private void whenCallDynamicSegmentEndpoint(String id) {
given()
.pathParam("id", id)
Expand Down

0 comments on commit 1118728

Please sign in to comment.