Search in sources :

Example 1 with Builder

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);
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) Builder(org.glassfish.jersey.server.internal.monitoring.RequestEventImpl.Builder) ContainerRequest(org.glassfish.jersey.server.ContainerRequest) UriTemplate(org.glassfish.jersey.uri.UriTemplate) ExtendedUriInfo(org.glassfish.jersey.server.ExtendedUriInfo)

Aggregations

ContainerRequest (org.glassfish.jersey.server.ContainerRequest)1 ContainerResponse (org.glassfish.jersey.server.ContainerResponse)1 ExtendedUriInfo (org.glassfish.jersey.server.ExtendedUriInfo)1 Builder (org.glassfish.jersey.server.internal.monitoring.RequestEventImpl.Builder)1 UriTemplate (org.glassfish.jersey.uri.UriTemplate)1