FormStructureHelperImpl implements FormStructureHelper { @Override public Resource updateFormStructure(Resource formResource) { if (formResource != null) { if (isFormContainer(formResource)) { ModifiableValueMap formProperties = formResource.adaptTo(ModifiableValueMap.class); if (formProperties != null) { if (formProperties.get(FormsConstants.START_PROPERTY_ACTION_TYPE, String.class) == null) { formProperties.put(FormsConstants.START_PROPERTY_ACTION_TYPE, FormsConstants.DEFAULT_ACTION_TYPE); String defaultContentPath = "/content/usergenerated" + formResource.getPath().replaceAll("^.content", "").replaceAll("jcr.content.*", "") + "cq-gen" + System.currentTimeMillis() + "/"; formProperties.put(FormsConstants.START_PROPERTY_ACTION_PATH, defaultContentPath); } } else { LOGGER.error("Resource is not adaptable to ValueMap - unable to add default action type and " + "form id for " + formResource); } } } return null; }  @Override Resource getFormResource(Resource resource); @Override Iterable<Resource> getFormElements(Resource resource); @Override boolean canManage(Resource resource); @Override Resource updateFormStructure(Resource formResource);  }
@Test public void testUpdateFormStructure() { Resource resource = Objects.requireNonNull(context.resourceResolver().getResource(CONTAINING_PAGE + "/jcr:content/root/responsivegrid/container")); formStructureHelper.updateFormStructure(resource); ValueMap properties = resource.getValueMap(); assertEquals("foundation/components/form/actions/store", properties.get("actionType", String.class)); String action = properties.get("action", String.class); assertNotNull(action); assertTrue(action.length() > 0); }