Skip to content

Commit

Permalink
Form instance by id test + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsrademakers committed Dec 15, 2016
1 parent 6789334 commit 712881e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ protected FormInstance resolveFormInstance(CommandContext commandContext) {
}

FormInstance formInstance = null;
if (taskId != null) {
if (formInstanceId != null) {
formInstance = formInstances.get(0);

} else if (taskId != null) {
if (formInstances.size() > 1) {
throw new FlowableException("Multiple form instances are found for the same task");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import java.util.Map;

import org.flowable.form.api.FormInstance;
import org.flowable.form.model.FormField;
import org.flowable.form.model.FormInstanceModel;
import org.flowable.form.model.FormModel;
import org.joda.time.LocalDate;
import org.junit.Test;
Expand All @@ -41,6 +43,13 @@ public void submitSimpleForm() throws Exception {
JsonNode formNode = formEngineConfiguration.getObjectMapper().readTree(formInstance.getFormValueBytes());
assertEquals("test", formNode.get("values").get("input1").asText());
assertEquals("default", formNode.get("flowable_form_outcome").asText());

FormInstanceModel formInstanceModel = formService.getFormInstanceModelById(formInstance.getId(), null);
assertEquals("form1", formInstanceModel.getKey());
assertEquals(1, formInstanceModel.getFields().size());
FormField formField = formInstanceModel.getFields().get(0);
assertEquals("input1", formField.getId());
assertEquals("test", formField.getValue());
}

@Test
Expand Down

0 comments on commit 712881e

Please sign in to comment.