use of org.glassfish.jersey.server.internal.monitoring.RequestEventImpl.Builder in project micrometer by micrometer-metrics.
the class DefaultJerseyTagsProviderTest method event.
private static RequestEvent event(Integer status, Exception exception, String baseUri, String... uriTemplateStrings) {
Builder builder = new RequestEventImpl.Builder();
ContainerRequest containerRequest = mock(ContainerRequest.class);
when(containerRequest.getMethod()).thenReturn("GET");
builder.setContainerRequest(containerRequest);
ContainerResponse containerResponse = mock(ContainerResponse.class);
when(containerResponse.getStatus()).thenReturn(status);
builder.setContainerResponse(containerResponse);
builder.setException(exception, null);
ExtendedUriInfo extendedUriInfo = mock(ExtendedUriInfo.class);
when(extendedUriInfo.getBaseUri()).thenReturn(URI.create("http://localhost:8080" + (baseUri == null ? "/" : baseUri)));
List<UriTemplate> uriTemplates = uriTemplateStrings == null ? Collections.emptyList() : Arrays.stream(uriTemplateStrings).map(uri -> new UriTemplate(uri)).collect(Collectors.toList());
// UriTemplate are returned in reverse order
Collections.reverse(uriTemplates);
when(extendedUriInfo.getMatchedTemplates()).thenReturn(uriTemplates);
builder.setExtendedUriInfo(extendedUriInfo);
return builder.build(Type.FINISHED);
}
Aggregations