FormStructureHelperImpl implements FormStructureHelper { @Override public Resource getFormResource(Resource resource) { if (resource == null || StringUtils.equals(resource.getPath(), "/")) { return null; } for (String resourceType : FormConstants.RT_ALL_CORE_FORM_CONTAINER) { if (resource.isResourceType(resourceType)) { return resource; } } return getFormResource(resource.getParent()); }  @Override Resource getFormResource(Resource resource); @Override Iterable<Resource> getFormElements(Resource resource); @Override boolean canManage(Resource resource); @Override Resource updateFormStructure(Resource formResource);  }
@Test public void testGetFormResource() { Resource resource = null; Resource formResource = formStructureHelper.getFormResource(resource); assertNull(formResource); resource = context.resourceResolver().getResource(CONTAINING_PAGE + "/jcr:content/root/responsivegrid/title"); formResource = formStructureHelper.getFormResource(resource); assertNull(formResource); resource = context.resourceResolver().getResource(CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container"); formResource = formStructureHelper.getFormResource(resource); assertEquals(CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container", formResource.getPath()); resource = context.resourceResolver().getResource(CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container/text"); formResource = formStructureHelper.getFormResource(resource); assertEquals(CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container", formResource.getPath()); }