RestService extends AbstractInterface<RestServiceConfig> implements RestResourceContainer { public void deleteResource(RestResource resource) { resource.deleteAllChildResources(resource); int ix = resources.indexOf(resource); if (!resources.remove(resource)) { return; } fireOperationRemoved(resource); getConfig().removeResource(ix); resource.release(); } RestService(WsdlProject project, RestServiceConfig serviceConfig); String getWadlVersion(); String getInterfaceType(); RestResource getOperationAt(int index); RestResource getOperationByName(String name); int getOperationCount(); List<Operation> getOperationList(); String getBasePath(); void setBasePath(String basePath); String getInferredSchema(); void setInferredSchema(String inferredSchema); boolean isGenerated(); String getWadlUrl(); String generateWadlUrl(); void setWadlUrl(String wadlUrl); String getTechnicalId(); RestResource addNewResource(String name, String path); RestResource cloneResource(RestResource resource, String name); void deleteResource(RestResource resource); List<RestResource> getAllResources(); Map<String, RestResource> getResources(); RestResource getResourceByFullPath(String resourcePath); RestResource[] getResourcesByFullPath(String resourcePath); @Override WadlDefinitionContext getDefinitionContext(); WadlDefinitionContext getWadlContext(); @Override String getDefinition(); String getType(); boolean isDefinitionShareble(); @Override Operation[] getAllOperations(); void beforeSave(); @Override void release(); List<RestResource> getResourceList(); boolean exportChanges(); void setExportChanges(boolean exportChanges);  }
@Test public void deletingResourceDeletesAllChildResources() throws Exception { RestResource childResourceA = restResource.addNewChildResource("ChildA", "/childPath"); RestResource grandChildAA = childResourceA.addNewChildResource("GrandChildAA", "/grandChildPathAA"); childResourceA.addNewChildResource("GrandChildAB", "/grandChildPathAB"); grandChildAA.addNewChildResource("GreatGrandChildAAA", "/greatGrandChildAAA"); restService.deleteResource(restResource); assertThat(restService.getChildren().size(), is(0)); assertThat(restResource.getChildResourceList().size(), is(0)); assertThat(childResourceA.getChildResourceList().size(), is(0)); assertThat(grandChildAA.getChildResourceList().size(), is(0)); }