DDMFormLayoutJSONSerializer implements DDMFormLayoutSerializer { @Override public DDMFormLayoutSerializerSerializeResponse serialize( DDMFormLayoutSerializerSerializeRequest ddmFormLayoutSerializerSerializeRequest) { DDMFormLayout ddmFormLayout = ddmFormLayoutSerializerSerializeRequest.getDDMFormLayout(); JSONObject jsonObject = _jsonFactory.createJSONObject(); addDefaultLanguageId(jsonObject, ddmFormLayout.getDefaultLocale()); addPages(jsonObject, ddmFormLayout.getDDMFormLayoutPages()); addPaginationMode(jsonObject, ddmFormLayout.getPaginationMode()); addRules(jsonObject, ddmFormLayout.getDDMFormRules()); if (Validator.isNotNull(ddmFormLayout.getDefinitionSchemaVersion())) { jsonObject.put( "definitionSchemaVersion", ddmFormLayout.getDefinitionSchemaVersion()); } DDMFormLayoutSerializerSerializeResponse.Builder builder = DDMFormLayoutSerializerSerializeResponse.Builder.newBuilder( jsonObject.toString()); return builder.build(); }  @Override DDMFormLayoutSerializerSerializeResponse serialize(
		DDMFormLayoutSerializerSerializeRequest
			ddmFormLayoutSerializerSerializeRequest);  }
@Test public void testDDMFormLayoutSerialization() throws Exception { String expectedJSON = read( "ddm-form-layout-json-serializer-test-data.json"); DDMFormLayout ddmFormLayout = createDDMFormLayout(); String actualJSON = serialize(ddmFormLayout); JSONAssert.assertEquals(expectedJSON, actualJSON, false); }
@Test public void testDDMFormLayoutSerializationWithSchemaVersion() throws Exception { String expectedJSON = read( "ddm-form-layout-json-serializer-with-definition-schema-" + "version.json"); DDMFormLayout ddmFormLayout = createDDMFormLayout(); ddmFormLayout.setDefinitionSchemaVersion("2.0"); String actualJSON = serialize(ddmFormLayout); JSONAssert.assertEquals(expectedJSON, actualJSON, false); }