### Question:
QueryMetricsEnrichmentInterceptor extends BaseMethodStatsInterceptor { @Override public void filter(ContainerRequestContext request) throws IOException { doPreProcess((PreMatchContainerRequestContext) request); }  @Override void filter(ContainerRequestContext request); @Override void filter(ContainerRequestContext request, ContainerResponseContext response); @Override void aroundWriteTo(WriterInterceptorContext context);  }### Answer:
@Test public void testPreProcess_HappyPath() throws Exception { QueryMetricsEnrichmentInterceptor subject = new QueryMetricsEnrichmentInterceptor(); URI requestUri = new URI("http: expect(requestContext.getUriInfo()).andReturn(uriInfo); expect(uriInfo.getRequestUri()).andReturn(requestUri); expect(requestContext.getMethod()).andReturn(null); expect(requestContext.getHeaders()).andReturn(requestHeaders); expect(requestHeaders.keySet()).andReturn(new HashSet<>()); expect(requestContext.getMediaType()).andReturn(MediaType.APPLICATION_FORM_URLENCODED_TYPE); expect(requestContext.getHttpRequest()).andReturn(httpRequest); expect(httpRequest.getDecodedFormParameters()).andReturn(decodedFormParameters); expect(decodedFormParameters.keySet()).andReturn(new HashSet<>()); requestContext.setProperty(eq((String) Whitebox.getInternalState(subject, "REQUEST_STATS_NAME")), anyObject()); PowerMock.replayAll(); subject.filter(requestContext); PowerMock.verifyAll(); }
@Test public void testPostProcess_BaseQueryResponse() throws Exception { QueryMetricsEnrichmentInterceptor subject = new QueryMetricsEnrichmentInterceptor(); expect(responseContext.getHeaders()).andReturn(writeHeaders); expect(writeHeaders.keySet()).andReturn(new HashSet<>()); expect(responseContext.getStatus()).andReturn(HttpResponseCodes.SC_OK); expect(responseContext.getJaxrsResponse()).andReturn(jaxrsResponse); expect(jaxrsResponse.getAnnotations()).andReturn(new Annotation[] {enrichQueryMetrics}); PowerMock.mockStaticPartial(FindAnnotation.class, "findAnnotation"); expect(FindAnnotation.findAnnotation(isA(Annotation[].class), eq(EnrichQueryMetrics.class))).andReturn(this.enrichQueryMetrics); expect(responseContext.getEntity()).andReturn(baseQueryResponse); expect(enrichQueryMetrics.methodType()).andReturn(EnrichQueryMetrics.MethodType.CREATE); expect(baseQueryResponse.getQueryId()).andReturn(UUID.randomUUID().toString()); requestContext.setProperty(eq((String) Whitebox.getInternalState(subject, "RESPONSE_STATS_NAME")), anyObject()); requestContext.setProperty(eq(QueryCall.class.getName()), isA(QueryCall.class)); PowerMock.replayAll(); subject.filter(requestContext, responseContext); PowerMock.verifyAll(); }