@Test public void returnsNullWhenListOfPathSegmentsIsEmptyAndDefaultValueIsNull() throws Exception { when(applicationContext.getUriInfo().getPathSegments(true)).thenReturn(newArrayList()); Object resolvedMatrixParameter = matrixParameterResolver.resolve(parameter, applicationContext); assertNull(resolvedMatrixParameter); verify(typeProducer).createValue(eq("foo"), emptyMultivaluedMap(), (String)isNull()); }
@Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = matrixParam.value(); TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); List<PathSegment> pathSegments = context.getUriInfo().getPathSegments(!parameter.isEncoded()); PathSegment pathSegment = Iterables.getLast(pathSegments, null); return typeProducer.createValue(param, pathSegment == null ? new MultivaluedHashMap<>() : pathSegment.getMatrixParameters(), parameter.getDefaultValue()); }
MatrixParameterResolver implements ParameterResolver<MatrixParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = matrixParam.value(); TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); List<PathSegment> pathSegments = context.getUriInfo().getPathSegments(!parameter.isEncoded()); PathSegment pathSegment = Iterables.getLast(pathSegments, null); return typeProducer.createValue(param, pathSegment == null ? new MultivaluedHashMap<>() : pathSegment.getMatrixParameters(), parameter.getDefaultValue()); } }
MatrixParameterResolver implements ParameterResolver<MatrixParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = matrixParam.value(); TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); List<PathSegment> pathSegments = context.getUriInfo().getPathSegments(!parameter.isEncoded()); PathSegment pathSegment = Iterables.getLast(pathSegments, null); return typeProducer.createValue(param, pathSegment == null ? new MultivaluedHashMap<>() : pathSegment.getMatrixParameters(), parameter.getDefaultValue()); } MatrixParameterResolver(MatrixParam matrixParam, TypeProducerFactory typeProducerFactory); }
MatrixParameterResolver implements ParameterResolver<MatrixParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = matrixParam.value(); TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); List<PathSegment> pathSegments = context.getUriInfo().getPathSegments(!parameter.isEncoded()); PathSegment pathSegment = Iterables.getLast(pathSegments, null); return typeProducer.createValue(param, pathSegment == null ? new MultivaluedHashMap<>() : pathSegment.getMatrixParameters(), parameter.getDefaultValue()); } MatrixParameterResolver(MatrixParam matrixParam, TypeProducerFactory typeProducerFactory); @Override Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context); }
MatrixParameterResolver implements ParameterResolver<MatrixParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = matrixParam.value(); TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); List<PathSegment> pathSegments = context.getUriInfo().getPathSegments(!parameter.isEncoded()); PathSegment pathSegment = Iterables.getLast(pathSegments, null); return typeProducer.createValue(param, pathSegment == null ? new MultivaluedHashMap<>() : pathSegment.getMatrixParameters(), parameter.getDefaultValue()); } MatrixParameterResolver(MatrixParam matrixParam, TypeProducerFactory typeProducerFactory); @Override Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context);  }