@Test
public void testGridFieldTemplateContext() throws Exception {

	// Dynamic data mapping form
	DDMForm ddmForm = DDMFormTestUtil.createDDMForm();
	String formFieldLabel = String.format(_HTML_WRAPPER, "label");
	String formFieldTip = String.format(_HTML_WRAPPER, "tip");
	String formFieldOption = String.format(_HTML_WRAPPER, "option");
	ddmForm.addDDMFormField(
		DDMFormTestUtil.createGridDDMFormField(
			"Field1", formFieldLabel, "grid", "string", false, false, true,
			formFieldTip, formFieldOption));
	mockDDMFormFieldTypeServicesTracker(
		"grid",
		_ddmFormFieldTemplateContextContributorTestHelper.
			createGridDDMFormFieldTemplateContextContributor());
	// Dynamic data mapping form layout
	DDMFormLayout ddmFormLayout = new DDMFormLayout();
	ddmFormLayout = createDDMFormLayoutPage(
		ddmFormLayout, "Page 1", "Page 1 Description", "Field1");
	// Template context
	DDMFormValues ddmFormValues = DDMFormValuesTestUtil.createDDMFormValues(
		ddmForm);
	ddmFormValues.addDDMFormFieldValue(
		DDMFormValuesTestUtil.createDDMFormFieldValue(
			"Field1", new UnlocalizedValue("{}")));
	DDMFormPagesTemplateContextFactory ddmFormPagesTemplateContextFactory =
		createDDMFormPagesTemplateContextFactory(
			ddmForm, ddmFormLayout, ddmFormValues, false, true, true);
	List<Object> pages = ddmFormPagesTemplateContextFactory.create();
	Map<String, Object> fieldTemplateContext = getFieldTemplateContext(
		pages);
	Assert.assertEquals(formFieldLabel, fieldTemplateContext.get("label"));
	List<Map<String, String>> columns =
		(List<Map<String, String>>)fieldTemplateContext.get("columns");
	Map<String, String> columnField = columns.get(0);
	Assert.assertEquals(formFieldOption, columnField.get("label"));
	List<Map<String, String>> rows =
		(List<Map<String, String>>)fieldTemplateContext.get("rows");
	Map<String, String> rowField = rows.get(0);
	Assert.assertEquals(formFieldOption, rowField.get("label"));
	Assert.assertEquals(formFieldTip, fieldTemplateContext.get("tip"));
}