HrefVarsGenerator { public final List<HrefVar> hrefVarsFor(final URI varTypeBaseUri, final boolean varTypeUrisAsFragment, final Method method) { final List<HrefVar> hrefVars; final HrefTemplate hrefTemplateAnnotation = findAnnotation(method, HrefTemplate.class); if (hrefTemplateAnnotation != null) { hrefVars = new ArrayList<>(); final String template = hrefTemplateAnnotation.value(); for (String varName : variableNamesFrom(template)) { hrefVars.add(hrefVar(varName, varTypeUriFrom(varTypeBaseUri, varName, varTypeUrisAsFragment), emptyDocs())); } if(hrefVars.isEmpty()) { throw new IllegalArgumentException("no variables found"); } } else { hrefVars = new ArrayList<>(); for (final ParameterInfo parameterInfo : getParameterInfos(method)) { final String varName = parameterInfo.getName(); final Documentation docs = docsGenerator.documentationFor(parameterInfo); if (hasPathVariable(parameterInfo) || hasRequestParam(parameterInfo)) { hrefVars.add(hrefVar(varName, varTypeUriFrom(varTypeBaseUri, varName, varTypeUrisAsFragment), docs)); } } } return hrefVars; } protected  HrefVarsGenerator(final URI relationTypeBaseUri, final String docRootDir); final List<HrefVar> hrefVarsFor(final URI varTypeBaseUri, final boolean varTypeUrisAsFragment, final Method method);  }
@Test public void testHrefVarsWithFragmentVarTypeUri() throws Exception { final HrefVarsGenerator generator = new TestHrefVarsGenerator(); final Method method = MethodFixture.class.getMethod("foo", String.class); final List<HrefVar> hrefVars = generator.hrefVarsFor(VARTYPE_BASE_URI, true, method); assertEquals(hrefVars.size(), 1); assertEquals(hrefVars.get(0), hrefVar("bar", create("http: }
@Test public void testHrefVarsWithFragmentVarTypeUriWithTrailingSlash() throws Exception { final HrefVarsGenerator generator = new TestHrefVarsGenerator(); final Method method = MethodFixture.class.getMethod("foo", String.class); final List<HrefVar> hrefVars = generator.hrefVarsFor(VARTYPE_BASE_URI_WITH_TRAILING_SLASH, true, method); assertEquals(hrefVars.size(), 1); assertEquals(hrefVars.get(0), hrefVar("bar", create("http: }
@Test public void testHrefVarsWithSubResourceVarTypeUri() throws Exception { final HrefVarsGenerator generator = new TestHrefVarsGenerator(); final Method method = MethodFixture.class.getMethod("foo", String.class); final List<HrefVar> hrefVars = generator.hrefVarsFor(VARTYPE_BASE_URI, false, method); assertEquals(hrefVars.size(), 1); assertEquals(hrefVars.get(0), hrefVar("bar", create("http: }
@Test public void testHrefVarsWithSubResourceVarTypeUriWithTrailingSlash() throws Exception { final HrefVarsGenerator generator = new TestHrefVarsGenerator(); final Method method = MethodFixture.class.getMethod("foo", String.class); final List<HrefVar> hrefVars = generator.hrefVarsFor(VARTYPE_BASE_URI_WITH_TRAILING_SLASH, false, method); assertEquals(hrefVars.size(), 1); assertEquals(hrefVars.get(0), hrefVar("bar", create("http: }