### Question:
SearchFactoryProvider extends AbstractValueFactoryProvider { @Override protected Factory<?> createValueFactory(Parameter parameter) { Class<?> paramType = parameter.getRawType(); SearchParam annotation = parameter.getAnnotation(SearchParam.class); if (annotation != null && paramType.isAssignableFrom(SearchModel.class)) { return new SearchFactory(); } return null; } @Inject  SearchFactoryProvider(final MultivaluedParameterExtractorProvider extractorProvider,
                                 ServiceLocator locator);   }### Answer:
@Test public void createValueFactory() throws Exception { Parameter parameter = getParameter("test1", SearchModel.class); SearchFactoryProvider provider = Mockito.mock(SearchFactoryProvider.class); Mockito.when(provider.createValueFactory(parameter)).thenCallRealMethod(); SearchFactory factory = (SearchFactory) provider.createValueFactory(parameter); assertNotNull(factory); }
@Test public void createValueFactoryWithoutAnnotation() throws Exception { Parameter parameter = getParameter("test2", SearchModel.class); SearchFactoryProvider provider = Mockito.mock(SearchFactoryProvider.class); Mockito.when(provider.createValueFactory(parameter)).thenCallRealMethod(); SearchFactory factory = (SearchFactory) provider.createValueFactory(parameter); assertNull(factory); }
@Test public void createValueFactoryWrongType() throws Exception { Parameter parameter = getParameter("test3", String.class); SearchFactoryProvider provider = Mockito.mock(SearchFactoryProvider.class); Mockito.when(provider.createValueFactory(parameter)).thenCallRealMethod(); SearchFactory factory = (SearchFactory) provider.createValueFactory(parameter); assertNull(factory); }