use of com.adobe.cq.wcm.core.components.models.form.Container in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContainerImplTest method testFormWithoutCustomAttributesAndField.
@Test
public void testFormWithoutCustomAttributesAndField() {
Resource resource = context.currentResource(FORM2_PATH);
slingBindings.put(RESOURCE_PROPERTY, resource);
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
Container container = context.request().adaptTo(Container.class);
assertEquals("multipart/form-data", container.getEnctype());
assertEquals("POST", container.getMethod());
assertEquals(CONTAINING_PAGE + ".html", container.getAction());
assertEquals("core/wcm/components/form/container/v1/container/new", container.getResourceTypeForDropArea());
assertNull(container.getRedirect());
}
use of com.adobe.cq.wcm.core.components.models.form.Container in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContainerImplTest method testFormWithCustomAttributesAndFields.
@Test
public void testFormWithCustomAttributesAndFields() {
Resource resource = context.currentResource(FORM1_PATH);
when(formStructureHelperFactory.getFormStructureHelper(resource)).thenReturn(formStructureHelper);
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
slingBindings.put(RESOURCE_PROPERTY, resource);
MockSlingHttpServletRequest request = context.request();
request.setRequestDispatcherFactory(requestDispatcherFactory);
when(requestDispatcherFactory.getRequestDispatcher((Resource) any(), (RequestDispatcherOptions) any())).thenReturn(requestDispatcher);
Container container = request.adaptTo(Container.class);
assertEquals("my-id", container.getId());
assertEquals("my-id", container.getName());
assertEquals("application/x-www-form-urlencoded", container.getEnctype());
assertEquals("GET", container.getMethod());
assertEquals(CONTAINING_PAGE + ".html", container.getAction());
assertEquals("core/wcm/components/form/container/v1/container/new", container.getResourceTypeForDropArea());
assertEquals("/content/we-retail/home", container.getRedirect());
}
use of com.adobe.cq.wcm.core.components.models.form.Container in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ContainerImplTest method testFormRedirectWithContextPath.
@Test
public void testFormRedirectWithContextPath() {
Resource resource = context.currentResource(FORM1_PATH);
slingBindings.put(RESOURCE_PROPERTY, resource);
slingBindings.put(WCMBindings.PROPERTIES, resource.adaptTo(ValueMap.class));
context.request().setContextPath("/contextPath/test");
when(formStructureHelperFactory.getFormStructureHelper(resource)).thenReturn(formStructureHelper);
Container container = context.request().adaptTo(Container.class);
assertEquals("/contextPath/test/content/we-retail/home", container.getRedirect());
}
Aggregations