FormStructureHelperImpl implements FormStructureHelper { @Override public Iterable<Resource> getFormElements(Resource resource) { final List<Resource> list = new ArrayList<>(); if (isFormContainer(resource)) { for (Resource child : resource.getChildren()) { filterFormElements(child, list); } } return list; }  @Override Resource getFormResource(Resource resource); @Override Iterable<Resource> getFormElements(Resource resource); @Override boolean canManage(Resource resource); @Override Resource updateFormStructure(Resource formResource);  }
@Test public void testGetFormElements() { Resource resource = context.resourceResolver().getResource(CONTAINING_PAGE + "/jcr:content/root/responsivegrid"); Iterator<Resource> formFields = formStructureHelper.getFormElements(resource).iterator(); assertFalse(formFields.hasNext()); when(scriptingResourceResolverProvider.getRequestScopedResourceResolver()).thenReturn(context.resourceResolver()); Set<String> allowedFields = new HashSet<>(); allowedFields.add("text"); allowedFields.add("hidden"); allowedFields.add("button_button"); allowedFields.add("text_inside_non_form_node"); allowedFields.add("button_button_inherited"); Set<String> returnedFormFields = new HashSet<>(); resource = context.resourceResolver().getResource(CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container"); formFields = formStructureHelper.getFormElements(resource).iterator(); while (formFields.hasNext()) { Resource field = formFields.next(); assertTrue(allowedFields.contains(field.getName())); returnedFormFields.add(field.getName()); } for (String field : allowedFields) { assertTrue(returnedFormFields.contains(field)); } }