DataLayoutUtil { public static DDMFormLayout toDDMFormLayout( DataLayout dataLayout, DDMForm ddmForm, DDMFormRuleDeserializer ddmFormRuleDeserializer) throws Exception { DDMFormLayout ddmFormLayout = new DDMFormLayout(); ddmFormLayout.setDDMFormLayoutPages( _toDDMFormLayoutPages( dataLayout.getDataLayoutPages(), ddmForm.getDefaultLocale())); ddmFormLayout.setDefaultLocale(ddmForm.getDefaultLocale()); ddmFormLayout.setPaginationMode(dataLayout.getPaginationMode()); ddmFormLayout.setDDMFormRules( ddmFormRuleDeserializer.deserialize( ddmForm, JSONUtil.toJSONArray( dataLayout.getDataRules(), rule -> _serializeRule(rule)))); return ddmFormLayout; }  static String serialize(
			DataLayout dataLayout, DDMForm ddmForm,
			DDMFormLayoutSerializer ddmFormLayoutSerializer,
			DDMFormRuleDeserializer ddmFormRuleDeserializer); static DataLayout toDataLayout(
			DDMFormLayout ddmFormLayout,
			SPIDDMFormRuleConverter spiDDMFormRuleConverter); static DataLayout toDataLayout(
			DDMStructureLayout ddmStructureLayout,
			SPIDDMFormRuleConverter spiDDMFormRuleConverter); static DDMFormLayout toDDMFormLayout(
			DataLayout dataLayout, DDMForm ddmForm,
			DDMFormRuleDeserializer ddmFormRuleDeserializer);  }
@Test public void testToDDMFormLayoutEquals() throws Exception { Locale locale = LocaleUtil.US; DDMForm ddmForm = DDMFormTestUtil.createDDMForm( SetUtil.fromArray(new Locale[] {locale}), locale); ddmForm.addDDMFormField( new DDMFormField() { { setIndexType("text"); setLabel( LocalizedValueUtil.toLocalizedValue( HashMapBuilder.<String, Object>put( "en_US", "label1" ).build(), locale)); setLocalizable(true); setName("textName"); setPredefinedValue( LocalizedValueUtil.toLocalizedValue( HashMapBuilder.<String, Object>put( "en_US", "enter a text" ).build(), locale)); setReadOnly(true); setRepeatable(true); setRequired(true); setShowLabel(true); setTip( LocalizedValueUtil.toLocalizedValue( HashMapBuilder.<String, Object>put( "en_US", "tip1" ).build(), locale)); setType("text"); } }); DDMFormLayout ddmFormLayout = new DDMFormLayout(); ddmFormLayout.setDefaultLocale(LocaleUtil.US); ddmFormLayout.setPaginationMode("wizard"); ddmFormLayout.addDDMFormLayoutPage( new DDMFormLayoutPage() { { setDDMFormLayoutRows( new ArrayList<DDMFormLayoutRow>() { { add( new DDMFormLayoutRow() { { setDDMFormLayoutColumns( new ArrayList <DDMFormLayoutColumn>() { { add( new DDMFormLayoutColumn( DDMFormLayoutColumn.FULL, "textName")); } }); } }); } }); setDescription( LocalizedValueUtil.toLocalizedValue( HashMapBuilder.<String, Object>put( "en_US", "Description" ).build(), LocaleUtil.US)); setTitle( LocalizedValueUtil.toLocalizedValue( HashMapBuilder.<String, Object>put( "en_US", "Title" ).build(), LocaleUtil.US)); } }); DataLayout dataLayout = new DataLayout(); dataLayout.setDataLayoutPages( new DataLayoutPage[] { new DataLayoutPage() { { setDataLayoutRows( new DataLayoutRow[] { new DataLayoutRow() { { setDataLayoutColumns( new DataLayoutColumn[] { new DataLayoutColumn() { { setColumnSize(12); setFieldNames( new String[] { "textName" }); } } }); } } }); setDescription( HashMapBuilder.<String, Object>put( "en_US", "Description" ).build()); setTitle( HashMapBuilder.<String, Object>put( "en_US", "Title" ).build()); } } }); dataLayout.setPaginationMode("wizard"); DDMFormRuleDeserializer ddmFormRuleDeserializer = PowerMockito.mock( DDMFormRuleDeserializer.class); Mockito.when( ddmFormRuleDeserializer.deserialize( Mockito.anyObject(), Mockito.anyObject()) ).thenReturn( new ArrayList<DDMFormRule>() ); Assert.assertEquals( ddmFormLayout, DataLayoutUtil.toDDMFormLayout( dataLayout, ddmForm, ddmFormRuleDeserializer)); }