@Test public void testBuildEndPoints() { when(resourceHelper.resolveResourcePath("/students", ResourceTemplate.THREE_PART)).thenReturn(true); ResourceEndPointTemplate template = new ResourceEndPointTemplate(); template.setPath("/students"); template.setResourceClass("someClass"); ResourceEndPointTemplate subResource = new ResourceEndPointTemplate(); subResource.setPath("/{id}/studentSectionAssociations"); template.setSubResources(Arrays.asList(subResource)); Map<String, String> resources = resourceEndPoint.buildEndPoints("v1", "", template); assertEquals("Should match", 2, resources.keySet().size()); assertEquals("Should match", "someClass", resources.get("v1/students")); assertEquals("Should match", "org.slc.sli.api.resources.generic.ThreePartResource", resources.get("v1/students/{id}/studentSectionAssociations")); }
protected Map<String, String> buildEndPoints(String nameSpace, String resourcePath, ResourceEndPointTemplate template) { Map<String, String> resources = new HashMap<String, String>(); String fullPath = nameSpace + resourcePath + template.getPath(); resources.put(fullPath, getResourceClass("/rest/" + fullPath, template)); List<ResourceEndPointTemplate> subResources = template.getSubResources(); if (subResources != null) { for (ResourceEndPointTemplate subTemplate : subResources) { resources.putAll(buildEndPoints(nameSpace, resourcePath + template.getPath(), subTemplate)); } } return resources; }
ResourceEndPoint { protected Map<String, String> buildEndPoints(String nameSpace, String resourcePath, ResourceEndPointTemplate template) { Map<String, String> resources = new HashMap<String, String>(); String fullPath = nameSpace + resourcePath + template.getPath(); resources.put(fullPath, getResourceClass("/rest/" + fullPath, template)); List<ResourceEndPointTemplate> subResources = template.getSubResources(); if (subResources != null) { for (ResourceEndPointTemplate subTemplate : subResources) { resources.putAll(buildEndPoints(nameSpace, resourcePath + template.getPath(), subTemplate)); } } return resources; } }
ResourceEndPoint { protected Map<String, String> buildEndPoints(String nameSpace, String resourcePath, ResourceEndPointTemplate template) { Map<String, String> resources = new HashMap<String, String>(); String fullPath = nameSpace + resourcePath + template.getPath(); resources.put(fullPath, getResourceClass("/rest/" + fullPath, template)); List<ResourceEndPointTemplate> subResources = template.getSubResources(); if (subResources != null) { for (ResourceEndPointTemplate subTemplate : subResources) { resources.putAll(buildEndPoints(nameSpace, resourcePath + template.getPath(), subTemplate)); } } return resources; }  }
ResourceEndPoint { protected Map<String, String> buildEndPoints(String nameSpace, String resourcePath, ResourceEndPointTemplate template) { Map<String, String> resources = new HashMap<String, String>(); String fullPath = nameSpace + resourcePath + template.getPath(); resources.put(fullPath, getResourceClass("/rest/" + fullPath, template)); List<ResourceEndPointTemplate> subResources = template.getSubResources(); if (subResources != null) { for (ResourceEndPointTemplate subTemplate : subResources) { resources.putAll(buildEndPoints(nameSpace, resourcePath + template.getPath(), subTemplate)); } } return resources; }  @PostConstruct void load(); List<String> getQueryingDisallowedEndPoints(); Set<String> getDateRangeDisallowedEndPoints(); Set<String> getBlockGetRequestEndPoints(); Map<String, String> getResources(); Map<String, SortedSet<String>> getNameSpaceMappings(); void setNameSpaceMappings(Map<String, SortedSet<String>> nameSpaceMappings); }
ResourceEndPoint { protected Map<String, String> buildEndPoints(String nameSpace, String resourcePath, ResourceEndPointTemplate template) { Map<String, String> resources = new HashMap<String, String>(); String fullPath = nameSpace + resourcePath + template.getPath(); resources.put(fullPath, getResourceClass("/rest/" + fullPath, template)); List<ResourceEndPointTemplate> subResources = template.getSubResources(); if (subResources != null) { for (ResourceEndPointTemplate subTemplate : subResources) { resources.putAll(buildEndPoints(nameSpace, resourcePath + template.getPath(), subTemplate)); } } return resources; }  @PostConstruct void load(); List<String> getQueryingDisallowedEndPoints(); Set<String> getDateRangeDisallowedEndPoints(); Set<String> getBlockGetRequestEndPoints(); Map<String, String> getResources(); Map<String, SortedSet<String>> getNameSpaceMappings(); void setNameSpaceMappings(Map<String, SortedSet<String>> nameSpaceMappings);  }