QueryParameterResolver implements ParameterResolver<QueryParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = this.queryParam.value(); TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); return typeProducer.createValue(param, context.getQueryParameters(!parameter.isEncoded()), parameter.getDefaultValue()); } QueryParameterResolver(QueryParam queryParam, TypeProducerFactory typeProducerFactory); @Override Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context);  }
@Test public void retrievesQueryParameterFromRequest() throws Exception { when(typeProducer.createValue("foo", queryParameters, null)).thenReturn(queryParameters.getFirst("foo")); Object resolvedHeader = queryParameterResolver.resolve(parameter, applicationContext); assertEquals(queryParameters.getFirst("foo"), resolvedHeader); }
@Test public void retrievesDefaultValueWhenQueryParameterDoesNotPresentInRequest() throws Exception { when(parameter.getDefaultValue()).thenReturn("default"); when(typeProducer.createValue("foo", queryParameters, "default")).thenReturn("default"); Object resolvedHeader = queryParameterResolver.resolve(parameter, applicationContext); assertEquals("default", resolvedHeader); }