createFormDefinition(appDef, TEST_FORM_B, TEST_FORM_C, TEST_APP_VERSION);
createFormDefinition(appDef, TEST_FORM_C, TEST_FORM_C, TEST_APP_VERSION);
createFormDefinition(appDef, TEST_FORM_D, TEST_FORM_D, TEST_APP_VERSION);
// add values for reference form E
FormData dataE = new FormData();
dataE.addRequestParameterValues("id", new String[]{valueE1});
dataE.addRequestParameterValues("e1", new String[]{valueE1});
dataE.addRequestParameterValues("e2", new String[]{valueE1});
dataE.addRequestParameterValues("e3", new String[]{valueE1});
appService.submitForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_E, dataE, true);
FormData dataE2 = new FormData();
dataE2.addRequestParameterValues("id", new String[]{valueE2});
dataE2.addRequestParameterValues("e1", new String[]{valueE2});
dataE2.addRequestParameterValues("e2", new String[]{valueE2});
dataE2.addRequestParameterValues("e3", new String[]{valueE2});
appService.submitForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_E, dataE2, true);
// create data to store
FormData data = new FormData();
// add values for root form D
String valueD = "d001";
data.addRequestParameterValues("id", new String[]{valueD});
data.addRequestParameterValues("d1", new String[]{valueD});
data.addRequestParameterValues("d2", new String[]{valueD});
// add values for subform C
String valueC = "c001";
data.addRequestParameterValues("formC_testFormC_c1", new String[]{valueC});
data.addRequestParameterValues("formC_testFormC_c2", new String[]{valueC});
data.addRequestParameterValues("formC_testFormC_eref", new String[]{valueE1, valueE2});
// add values for subform B
String valueB = "b001";
data.addRequestParameterValues("formC_testFormC_formB_testFormB_b1", new String[]{valueB});
data.addRequestParameterValues("formC_testFormC_formB_testFormB_b2", new String[]{valueB});
// add values for subform A
String valueA = "a001";
data.addRequestParameterValues("formC_testFormC_formB_testFormB_formA_testFormA_id", new String[]{""}); // empty ID, to be automatically generated
data.addRequestParameterValues("formC_testFormC_formB_testFormB_formA_testFormA_a1", new String[]{valueA});
data.addRequestParameterValues("formC_testFormC_formB_testFormB_formA_testFormA_a2", new String[]{valueA});
// submit form
appService.submitForm(TEST_APP_ID, TEST_APP_VERSION.toString(), TEST_FORM_D, data, true);
// load and verify data for form D