Search in sources :

Example 1 with JBPMFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImplTest method testGenerateProcessForm.

@Test
public void testGenerateProcessForm() {
    generator.generateProcessForm(diagram);
    verify(generator, times(1)).createFormForModel(formModelArgumentCaptor.capture(), any());
    verify(formDefinitionSerializer, times(1)).serialize(formDefinitionArgumentCaptor.capture());
    verify(ioService, times(1)).createFile(any());
    verify(ioService, times(1)).write(any(), anyString());
    JBPMFormModel formModel = formModelArgumentCaptor.getValue();
    Assertions.assertThat(formModel).isNotNull().isInstanceOf(BusinessProcessFormModel.class);
    checkProcessFormGenerated((BusinessProcessFormModel) formModel, formDefinitionArgumentCaptor.getValue());
}
Also used : JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) Test(org.junit.Test)

Example 2 with JBPMFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel in project kie-wb-common by kiegroup.

the class JBPMFormModelCreationViewImpl method init.

@PostConstruct
protected void init() {
    processes.addValueChangeHandler(event -> {
        JBPMProcessModel model = processes.getValue();
        if (model != null) {
            List<JBPMFormModel> models = new ArrayList<JBPMFormModel>();
            models.add(model.getProcessFormModel());
            models.addAll(model.getTaskFormModels());
            tasks.setValue(null);
            tasks.setAcceptableValues(models);
        } else {
            tasks.setAcceptableValues(new ArrayList<>());
            tasks.setValue(null, true);
        }
    });
    tasks.addValueChangeHandler(event -> {
        presenter.setModel(event.getValue());
        clearValidationErrors();
    });
}
Also used : JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) ArrayList(java.util.ArrayList) JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) PostConstruct(javax.annotation.PostConstruct)

Example 3 with JBPMFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImplTest method testGenerateSelectedTaskForms.

@Test
public void testGenerateSelectedTaskForms() {
    generator.generateSelectedForms(diagram, FULL_TASK_ID, INPUTS_TASK_ID, OUTPUTS_TASK_ID);
    verify(generator, times(3)).createFormForModel(formModelArgumentCaptor.capture(), any());
    verify(formDefinitionSerializer, times(3)).serialize(formDefinitionArgumentCaptor.capture());
    verify(ioService, times(1)).startBatch(any());
    verify(ioService, times(1)).getFileSystem(any());
    verify(ioService, times(3)).createFile(any());
    verify(ioService, times(3)).write(any(), anyString());
    verify(ioService, times(1)).endBatch();
    List<JBPMFormModel> formModels = formModelArgumentCaptor.getAllValues();
    List<FormDefinition> taskForms = formDefinitionArgumentCaptor.getAllValues();
    Assertions.assertThat(formModels).isNotEmpty().hasSize(taskForms.size()).allMatch(formModel -> formModel instanceof TaskFormModel);
    for (int i = 0; i < formModels.size(); i++) {
        TaskFormModel taskFormModel = (TaskFormModel) formModels.get(i);
        FormDefinition taskForm = taskForms.get(i);
        checkTaskFormGenerated(taskFormModel, taskFormModel.getTaskName(), taskForm);
    }
}
Also used : JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 4 with JBPMFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImplTest method testGenerateAllForms.

@Test
public void testGenerateAllForms() {
    generator.generateAllForms(diagram);
    verify(generator, times(4)).createFormForModel(formModelArgumentCaptor.capture(), any());
    verify(formDefinitionSerializer, times(4)).serialize(formDefinitionArgumentCaptor.capture());
    verify(ioService, times(1)).startBatch(any());
    verify(ioService, times(1)).getFileSystem(any());
    verify(ioService, times(4)).createFile(any());
    verify(ioService, times(4)).write(any(), anyString());
    verify(ioService, times(1)).endBatch();
    List<JBPMFormModel> formModels = formModelArgumentCaptor.getAllValues();
    List<FormDefinition> forms = formDefinitionArgumentCaptor.getAllValues();
    Assertions.assertThat(formModels).isNotEmpty().hasSize(forms.size()).hasSize(4);
    for (int i = 0; i < formModels.size(); i++) {
        JBPMFormModel formModel = formModels.get(i);
        FormDefinition form = forms.get(i);
        if (formModel instanceof BusinessProcessFormModel) {
            checkProcessFormGenerated((BusinessProcessFormModel) formModel, form);
        } else {
            TaskFormModel taskFormModel = (TaskFormModel) formModel;
            checkTaskFormGenerated(taskFormModel, taskFormModel.getTaskName(), form);
        }
    }
}
Also used : BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 5 with JBPMFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImplTest method checkSingleSelectedTaskFormGenerated.

private void checkSingleSelectedTaskFormGenerated(String taskId, String taskName) {
    generator.generateSelectedForms(diagram, taskId);
    verify(generator, times(1)).createFormForModel(formModelArgumentCaptor.capture(), any());
    verify(formDefinitionSerializer, times(1)).serialize(formDefinitionArgumentCaptor.capture());
    verify(ioService, times(1)).startBatch(any());
    verify(ioService, times(1)).getFileSystem(any());
    verify(ioService, times(1)).createFile(any());
    verify(ioService, times(1)).write(any(), anyString());
    verify(ioService, times(1)).endBatch();
    JBPMFormModel formModel = formModelArgumentCaptor.getValue();
    FormDefinition taskForm = formDefinitionArgumentCaptor.getValue();
    Assertions.assertThat(formModel).isNotNull().isInstanceOf(TaskFormModel.class);
    checkTaskFormGenerated((TaskFormModel) formModel, taskName, taskForm);
}
Also used : JBPMFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Aggregations

JBPMFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.JBPMFormModel)5 Test (org.junit.Test)3 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)3 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)2 ArrayList (java.util.ArrayList)1 PostConstruct (javax.annotation.PostConstruct)1 JBPMProcessModel (org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel)1 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)1