### Question:
FHIRParamValueFactory implements ValueFactoryProvider { @Override public Factory<?> getValueFactory(Parameter parameter) { if (parameter.getDeclaredAnnotation(FHIRParameter.class) != null) { if (IBaseResource.class.isAssignableFrom(parameter.getRawType())) return new ParamResourceFactory(injector, parameter, ctx.newJsonParser()); } return null; } @Inject  FHIRParamValueFactory(Injector injector, FhirContext ctx); @Override Factory<?> getValueFactory(Parameter parameter); @Override PriorityType getPriority();  }### Answer:
@Test void testCorrectFactory() { final Parameter parameter = Mockito.mock(Parameter.class); final FHIRParameter mockAnnotation = Mockito.mock(FHIRParameter.class); Mockito.when(parameter.getDeclaredAnnotation(FHIRParameter.class)).thenReturn(mockAnnotation); Mockito.when(parameter.getRawType()).thenAnswer(answer -> Patient.class); final Factory<?> valueFactory = factory.getValueFactory(parameter); assertAll(() -> assertNotNull(valueFactory, "Should have factory"), () -> assertEquals(ParamResourceFactory.class, valueFactory.getClass(), "Should have provenance factory")); }
@Test void testMissingAnnotation() { final Parameter parameter = Mockito.mock(Parameter.class); Mockito.when(parameter.getDeclaredAnnotation(FHIRParameter.class)).thenReturn(null); Mockito.when(parameter.getRawType()).thenAnswer(answer -> Patient.class); assertNull(factory.getValueFactory(parameter), "Should not have factory"); }
@Test void testIncorrectParameter() { final Parameter parameter = Mockito.mock(Parameter.class); final FHIRParameter mockAnnotation = Mockito.mock(FHIRParameter.class); Mockito.when(parameter.getDeclaredAnnotation(FHIRParameter.class)).thenReturn(mockAnnotation); Mockito.when(parameter.getRawType()).thenAnswer(answer -> Mockito.class); assertNull(factory.getValueFactory(parameter), "Should not have factory"); }