### Question:
ProvenanceResourceValueFactory implements Factory<Provenance> { @Override public Provenance provide() { final HttpServletRequest request = injector.getInstance(HttpServletRequest.class); final String headerValue = request.getHeader(PROVENANCE_HEADER); if (headerValue == null) { throw new WebApplicationException(String.format("Must have %s header", PROVENANCE_HEADER), Response.Status.BAD_REQUEST); } final Provenance provenance; try { provenance = ctx.newJsonParser().parseResource(Provenance.class, headerValue); } catch (Exception e) { logger.error("Cannot parse Provenance", e); throw new WebApplicationException("Cannot parse FHIR `Provenance` resource", Response.Status.BAD_REQUEST); } return provenance; } ProvenanceResourceValueFactory(Injector injector, FhirContext ctx); @Override Provenance provide(); @Override void dispose(Provenance instance);  }### Answer:
@Test void testValidProvenance() { final Provenance provenance = new Provenance(); provenance.addTarget(new Reference("Organization/nothing-real")); final String provString = ctx.newJsonParser().encodeResourceToString(provenance); final HttpServletRequest mock = Mockito.mock(HttpServletRequest.class); Mockito.when(mock.getHeader(ProvenanceResourceValueFactory.PROVENANCE_HEADER)).thenReturn(provString); final Injector mockInjector = Mockito.mock(Injector.class); Mockito.when(mockInjector.getInstance(HttpServletRequest.class)).thenReturn(mock); final ProvenanceResourceValueFactory factory = new ProvenanceResourceValueFactory(mockInjector, ctx); final Provenance prov2 = factory.provide(); assertTrue(provenance.equalsDeep(prov2), "Should have matching provenance resource"); }