PathParameterResolver implements ParameterResolver<PathParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = this.pathParam.value(); TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); return typeProducer.createValue(param, context.getPathParameters(!parameter.isEncoded()), parameter.getDefaultValue()); } PathParameterResolver(PathParam pathParam, TypeProducerFactory typeProducerFactory); @Override Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context);  }
@Test public void retrievesPathParameterFromRequest() throws Exception { when(typeProducer.createValue("foo", pathParameters, null)).thenReturn(pathParameters.getFirst("foo")); Object resolvedHeader = pathParameterResolver.resolve(parameter, applicationContext); assertEquals(pathParameters.getFirst("foo"), resolvedHeader); }
@Test public void retrievesDefaultValueWhenPathParameterDoesNotPresentInRequest() throws Exception { when(parameter.getDefaultValue()).thenReturn("default"); when(typeProducer.createValue("foo", pathParameters, "default")).thenReturn("default"); Object resolvedHeader = pathParameterResolver.resolve(parameter, applicationContext); assertEquals("default", resolvedHeader); }