@Test public void shouldOutjectACollectionAsAList() throws NoSuchMethodException { Method myComponentMethod = MyComponent.class.getMethod("returnsStrings"); when(method.getMethod()).thenReturn(myComponentMethod); when(info.getResult()).thenReturn("myString"); when(extractor.nameFor(myComponentMethod.getGenericReturnType())).thenReturn("stringList"); interceptor.intercept(stack, method, instance); verify(result).include("stringList", "myString"); verify(stack).next(method, instance); }
public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { Type returnType = method.getMethod().getGenericReturnType(); String name = extractor.nameFor(returnType); Object value = this.info.getResult(); logger.debug("outjecting {}={}", name, value); result.include(name, value); stack.next(method, resourceInstance); }
OutjectResult implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { Type returnType = method.getMethod().getGenericReturnType(); String name = extractor.nameFor(returnType); Object value = this.info.getResult(); logger.debug("outjecting {}={}", name, value); result.include(name, value); stack.next(method, resourceInstance); } }
OutjectResult implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { Type returnType = method.getMethod().getGenericReturnType(); String name = extractor.nameFor(returnType); Object value = this.info.getResult(); logger.debug("outjecting {}={}", name, value); result.include(name, value); stack.next(method, resourceInstance); } OutjectResult(Result result, MethodInfo info, TypeNameExtractor extractor); }
OutjectResult implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { Type returnType = method.getMethod().getGenericReturnType(); String name = extractor.nameFor(returnType); Object value = this.info.getResult(); logger.debug("outjecting {}={}", name, value); result.include(name, value); stack.next(method, resourceInstance); } OutjectResult(Result result, MethodInfo info, TypeNameExtractor extractor); boolean accepts(ResourceMethod method); void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance); }
OutjectResult implements Interceptor { public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException { Type returnType = method.getMethod().getGenericReturnType(); String name = extractor.nameFor(returnType); Object value = this.info.getResult(); logger.debug("outjecting {}={}", name, value); result.include(name, value); stack.next(method, resourceInstance); } OutjectResult(Result result, MethodInfo info, TypeNameExtractor extractor); boolean accepts(ResourceMethod method); void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance);  }