@Test public void testSimpleJsonForm() throws Exception { String testJsonResource = readJsonToString(JSON_RESOURCE_1); FormDefinition formDefinition = new FormJsonConverter().convertToForm(testJsonResource, "11", 1); assertNotNull(formDefinition); assertEquals("11", formDefinition.getId()); assertEquals("form1", formDefinition.getKey()); assertEquals("My first form", formDefinition.getName()); assertNotNull(formDefinition.getFields()); assertEquals(1, formDefinition.getFields().size()); FormField formField = formDefinition.getFields().get(0); assertEquals("input1", formField.getId()); assertEquals("Input1", formField.getName()); assertEquals("text", formField.getType()); assertEquals(false, formField.isRequired()); assertEquals("empty", formField.getPlaceholder()); }
public FormDefinition convertToForm(String modelJson, String modelId, int modelVersion) { try { FormDefinition definition = objectMapper.readValue(modelJson, FormDefinition.class); definition.setId(modelId); definition.setVersion(modelVersion); return definition; } catch (Exception e) { throw new ActivitiFormJsonException("Error reading form json", e); } }
FormJsonConverter { public FormDefinition convertToForm(String modelJson, String modelId, int modelVersion) { try { FormDefinition definition = objectMapper.readValue(modelJson, FormDefinition.class); definition.setId(modelId); definition.setVersion(modelVersion); return definition; } catch (Exception e) { throw new ActivitiFormJsonException("Error reading form json", e); } } }
FormJsonConverter { public FormDefinition convertToForm(String modelJson, String modelId, int modelVersion) { try { FormDefinition definition = objectMapper.readValue(modelJson, FormDefinition.class); definition.setId(modelId); definition.setVersion(modelVersion); return definition; } catch (Exception e) { throw new ActivitiFormJsonException("Error reading form json", e); } }  }
FormJsonConverter { public FormDefinition convertToForm(String modelJson, String modelId, int modelVersion) { try { FormDefinition definition = objectMapper.readValue(modelJson, FormDefinition.class); definition.setId(modelId); definition.setVersion(modelVersion); return definition; } catch (Exception e) { throw new ActivitiFormJsonException("Error reading form json", e); } }  FormDefinition convertToForm(String modelJson, String modelId, int modelVersion); String convertToJson(FormDefinition definition); }
FormJsonConverter { public FormDefinition convertToForm(String modelJson, String modelId, int modelVersion) { try { FormDefinition definition = objectMapper.readValue(modelJson, FormDefinition.class); definition.setId(modelId); definition.setVersion(modelVersion); return definition; } catch (Exception e) { throw new ActivitiFormJsonException("Error reading form json", e); } }  FormDefinition convertToForm(String modelJson, String modelId, int modelVersion); String convertToJson(FormDefinition definition);  }