@Test public void testComputeRequestTemplateParamsEmptyAncestors() { Stack<Resource> resources = new Stack<Resource>(); Param r1p1 = mock(Param.class); when(r1p1.getStyle()).thenReturn(ParamStyle.TEMPLATE); when(r1p1.getId()).thenReturn(R1P1_ID); List<Param> r1Params = new ArrayList<Param>(1); r1Params.add(r1p1); Resource r1 = mock(Resource.class); when(r1.getParams()).thenReturn(r1Params); List<Param> templateParams = RestHelper.computeRequestTemplateParams(r1, resources); assertEquals(1, templateParams.size()); assertEquals(R1P1_ID, templateParams.get(0).getId()); }
public static final List<Param> computeRequestTemplateParams(final Resource resource, final Stack<Resource> ancestors) { final List<Param> params = new LinkedList<Param>(); final List<Resource> rightToLeftResources = new LinkedList<Resource>(); rightToLeftResources.addAll(reverse(ancestors)); rightToLeftResources.add(resource); for (final Resource rightToLeftResource : rightToLeftResources) { for (final Param param : rightToLeftResource.getParams()) { if (param.getStyle() == ParamStyle.TEMPLATE) { params.add(param); } } } return Collections.unmodifiableList(params); }
RestHelper { public static final List<Param> computeRequestTemplateParams(final Resource resource, final Stack<Resource> ancestors) { final List<Param> params = new LinkedList<Param>(); final List<Resource> rightToLeftResources = new LinkedList<Resource>(); rightToLeftResources.addAll(reverse(ancestors)); rightToLeftResources.add(resource); for (final Resource rightToLeftResource : rightToLeftResources) { for (final Param param : rightToLeftResource.getParams()) { if (param.getStyle() == ParamStyle.TEMPLATE) { params.add(param); } } } return Collections.unmodifiableList(params); } }
RestHelper { public static final List<Param> computeRequestTemplateParams(final Resource resource, final Stack<Resource> ancestors) { final List<Param> params = new LinkedList<Param>(); final List<Resource> rightToLeftResources = new LinkedList<Resource>(); rightToLeftResources.addAll(reverse(ancestors)); rightToLeftResources.add(resource); for (final Resource rightToLeftResource : rightToLeftResources) { for (final Param param : rightToLeftResource.getParams()) { if (param.getStyle() == ParamStyle.TEMPLATE) { params.add(param); } } } return Collections.unmodifiableList(params); }  }
RestHelper { public static final List<Param> computeRequestTemplateParams(final Resource resource, final Stack<Resource> ancestors) { final List<Param> params = new LinkedList<Param>(); final List<Resource> rightToLeftResources = new LinkedList<Resource>(); rightToLeftResources.addAll(reverse(ancestors)); rightToLeftResources.add(resource); for (final Resource rightToLeftResource : rightToLeftResources) { for (final Param param : rightToLeftResource.getParams()) { if (param.getStyle() == ParamStyle.TEMPLATE) { params.add(param); } } } return Collections.unmodifiableList(params); }  static final List<Param> computeRequestTemplateParams(final Resource resource,
            final Stack<Resource> ancestors); static final List<T> reverse(final List<T> strings); }
RestHelper { public static final List<Param> computeRequestTemplateParams(final Resource resource, final Stack<Resource> ancestors) { final List<Param> params = new LinkedList<Param>(); final List<Resource> rightToLeftResources = new LinkedList<Resource>(); rightToLeftResources.addAll(reverse(ancestors)); rightToLeftResources.add(resource); for (final Resource rightToLeftResource : rightToLeftResources) { for (final Param param : rightToLeftResource.getParams()) { if (param.getStyle() == ParamStyle.TEMPLATE) { params.add(param); } } } return Collections.unmodifiableList(params); }  static final List<Param> computeRequestTemplateParams(final Resource resource,
            final Stack<Resource> ancestors); static final List<T> reverse(final List<T> strings);  }