### Question:
SearchFactory extends AbstractContainerRequestValueFactory<SearchModel> { @Override public SearchModel provide() { SearchModel searchModel = new SearchModel(); searchModel.setResponse(response); String method = getMethod(); if ("GET".equals(method)) { MultivaluedMap<String, String> queryParameters = getUriInfo().getQueryParameters(); for (Map.Entry<String, List<String>> param : queryParameters.entrySet()) { if (param.getValue().get(0) == null) continue; if ("_q".equalsIgnoreCase(param.getKey())) { searchModel.setQ(param.getValue().get(0)); } else if ("_limit".equalsIgnoreCase(param.getKey())) { searchModel.setLimit(Integer.parseInt(param.getValue().get(0))); } else if ("_offset".equalsIgnoreCase(param.getKey())) { searchModel.setOffset(Integer.parseInt(param.getValue().get(0))); } else if ("_fields".equalsIgnoreCase(param.getKey())) { searchModel.setFields(param.getValue().get(0).split(",")); } else if ("_sort".equalsIgnoreCase(param.getKey())) { searchModel.setSort(param.getValue().get(0).split(",")); } else if ("_filter".equalsIgnoreCase(param.getKey())) { searchModel.setFilterExpression(param.getValue().get(0)); } } } return searchModel; } SearchFactory(); UriInfo getUriInfo(); @Override SearchModel provide(); String getMethod();  }### Answer:
@Test public void provide() throws Exception { SearchModel expected = new SearchModel(); expected.setQ("qparam"); expected.setOffset(1); expected.setLimit(10); expected.setFields(new String[]{"field1", "field2"}); expected.setSort(new String[]{"+field1", "-field2"}); expected.setFilterExpression("field1=1"); MultivaluedMap<String, String> queryParameters = new MultivaluedHashMap<>(); queryParameters.put("_q", Lists.newArrayList("qparam")); queryParameters.put("_offset", Lists.newArrayList("1")); queryParameters.put("_limit", Lists.newArrayList("10")); queryParameters.put("_fields", Lists.newArrayList("field1,field2")); queryParameters.put("_sort", Lists.newArrayList("+field1,-field2")); queryParameters.put("_filter", Lists.newArrayList("field1=1")); queryParameters.put("_none", Lists.newArrayList("none")); UriInfo uriInfo = mock(UriInfo.class); when(uriInfo.getQueryParameters()).thenReturn(queryParameters); SearchFactory factory = mock(SearchFactory.class); when(factory.getUriInfo()).thenReturn(uriInfo); when(factory.getMethod()).thenReturn("GET"); when(factory.provide()).thenCallRealMethod(); assertEquals(uriInfo, factory.getUriInfo()); assertEquals("GET", factory.getMethod()); SearchModel actual = factory.provide(); assertEquals(expected, actual); }