ResourceModel implements ResourceModelComponent { private ResourceModel(List<Resource> rootResources, List<Resource> allResources) { this.resources = allResources; this.rootResources = rootResources; this.runtimeRootResourceModelValue = Values.lazy(new Value<RuntimeResourceModel>() { @Override public RuntimeResourceModel get() { return new RuntimeResourceModel(ResourceModel.this.resources); } }); } private  ResourceModel(List<Resource> rootResources, List<Resource> allResources); List<Resource> getRootResources(); List<Resource> getResources(); @Override void accept(ResourceModelVisitor visitor); @Override List<? extends ResourceModelComponent> getComponents(); RuntimeResourceModel getRuntimeResourceModel();  }
@Test public void testResourceModel() { ResourceModel resourceModel = getResourceModel(); final List<Resource> rootResources = resourceModel.getRootResources(); assertEquals(3, rootResources.size()); assertEquals(3, resourceModel.getResources().size()); final Resource resourceA = ResourceTestUtils.getResource(getResourceModel().getRootResources(), "a"); ResourceTestUtils.containsExactMethods(resourceA, false, "GET", "POST"); final List<Resource> childResources = resourceA.getChildResources(); assertEquals(3, childResources.size()); ResourceTestUtils.containsExactMethods(ResourceTestUtils.getResource(childResources, "{child-template-x}"), false, "GET"); ResourceTestUtils.containsExactMethods(ResourceTestUtils.getResource(childResources, "{child-template-y}"), false, "POST"); final Resource templateA = ResourceTestUtils.getResource(getResourceModel().getRootResources(), "{a}"); ResourceTestUtils.containsExactMethods(templateA, false, "GET", "PUT"); final List<Resource> templateAChildResources = templateA.getChildResources(); assertEquals(2, templateAChildResources.size()); ResourceTestUtils.containsExactMethods(ResourceTestUtils.getResource(templateAChildResources, "{a-child-template-q}"), false, "GET"); ResourceTestUtils.containsExactMethods(ResourceTestUtils.getResource(templateAChildResources, "{a-child-template-w}"), false, "POST"); final Resource templateB = ResourceTestUtils.getResource(getResourceModel().getRootResources(), "{b}"); ResourceTestUtils.containsExactMethods(templateB, false, "POST"); final List<Resource> templateBChildResources = templateB.getChildResources(); assertEquals(3, templateBChildResources.size()); ResourceTestUtils.containsExactMethods(ResourceTestUtils.getResource(templateBChildResources, "{a-child-template-q}"), false, "DELETE"); ResourceTestUtils.containsExactMethods(ResourceTestUtils.getResource(templateBChildResources, "{b-child-template-z}"), false, "PUT"); ResourceTestUtils.containsExactMethods(ResourceTestUtils.getResource(templateBChildResources, "another-child"), false, "PUT"); }