Search in sources :

Example 16 with TaskFormModel

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

the class BPMNFormModelGeneratorImplTest method testGenerateAllTaskFormModelForTasksWithSharedFormWithWrongMappings.

@Test
public void testGenerateAllTaskFormModelForTasksWithSharedFormWithWrongMappings() {
    final String TASK_NAME = "task";
    final int EXPECTED_MODELS = 1;
    List<TaskFormModel> generatedModels = generator.generateTaskFormModels(processWithSharedFormsWrongMappings, path);
    assertNotNull(generatedModels);
    assertEquals(EXPECTED_MODELS, generatedModels.size());
    for (TaskFormModel formModel : generatedModels) {
        assertNotNull(formModel);
        assertEquals(PROCESS_WITH_SHARED_FORMS_WRONG_MAPPINGS_ID, formModel.getProcessId());
        assertNotNull(formModel.getProperties());
        assertFalse(formModel.getProperties().isEmpty());
        assertNotEquals(TASK_NAME + BPMNVariableUtils.TASK_FORM_SUFFIX, formModel.getFormName());
    }
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 17 with TaskFormModel

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

the class BPMNFormModelGeneratorImplTest method testCorrectTaskFormModelIsGeneratedForTaskWithTheInputsAndOutputsBoundToTheSameNamesInSwimlane.

@Test
public void testCorrectTaskFormModelIsGeneratedForTaskWithTheInputsAndOutputsBoundToTheSameNamesInSwimlane() {
    final String TASK_ID = "_9903B013-C42D-486B-A41D-2DEBC60911E3", TASK_NAME = "taskWithTheSameInputsAndOutputs";
    final Map<String, String> EXPECTED_TASK_VARIABLES = new HashMap<String, String>() {

        {
            put("_string_", String.class.getName());
            put("_integer_", Integer.class.getName());
            put("_boolean_", Boolean.class.getName());
            put("_float_", Float.class.getName());
            put("_object_", Object.class.getName());
            put("_dataObject_", DATA_OBJECT_TYPE);
            put("_customType_", CUSTOM_TYPE);
        }
    };
    TaskFormModel taskFormModel = generator.generateTaskFormModel(processWithAllVariablesDefinitions, TASK_ID, path);
    assertTaskFormModelIsCorrect(taskFormModel, PROCESS_WITH_ALL_VARIABLES_ID, TASK_NAME);
    assertJBPMVariablesAreCorrect(taskFormModel, EXPECTED_TASK_VARIABLES);
}
Also used : HashMap(java.util.HashMap) Matchers.anyString(org.mockito.Matchers.anyString) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) Test(org.junit.Test)

Example 18 with TaskFormModel

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

the class JBPMFormModelCreationPresenterTest method initFormModels.

protected void initFormModels() {
    List<ModelProperty> processVariables = new ArrayList<>();
    processVariables.add(new ModelPropertyImpl("name", new TypeInfoImpl(String.class.getName())));
    processVariables.add(new ModelPropertyImpl("age", new TypeInfoImpl(Integer.class.getName())));
    processVariables.add(new ModelPropertyImpl("twitter", new TypeInfoImpl(String.class.getName())));
    processVariables.add(new ModelPropertyImpl("offering", new TypeInfoImpl(Integer.class.getName())));
    processVariables.add(new ModelPropertyImpl("skills", new TypeInfoImpl(String.class.getName())));
    processVariables.add(new ModelPropertyImpl("mail", new TypeInfoImpl(String.class.getName())));
    processVariables.add(new ModelPropertyImpl("hr_score", new TypeInfoImpl(Integer.class.getName())));
    processVariables.add(new ModelPropertyImpl("tech_score", new TypeInfoImpl(Integer.class.getName())));
    processVariables.add(new ModelPropertyImpl("signed", new TypeInfoImpl(Boolean.class.getName())));
    BusinessProcessFormModel processFormModel = new BusinessProcessFormModel("hiring", "hiring", processVariables);
    TaskFormModel taskFormModel;
    List<TaskFormModel> processTasks = new ArrayList<>();
    List<ModelProperty> taskVariables = new ArrayList<>();
    taskVariables.add(new ModelPropertyImpl("name", new TypeInfoImpl(String.class.getName())));
    taskVariables.add(new ModelPropertyImpl("age", new TypeInfoImpl(Integer.class.getName())));
    taskVariables.add(new ModelPropertyImpl("mail", new TypeInfoImpl(String.class.getName())));
    taskVariables.add(new ModelPropertyImpl("hr_score", new TypeInfoImpl(String.class.getName())));
    taskFormModel = new TaskFormModel("hiring", "HRInterview", taskVariables);
    processTasks.add(taskFormModel);
    taskVariables = new ArrayList<>();
    taskVariables.add(new ModelPropertyImpl("name", new TypeInfoImpl(String.class.getName())));
    taskVariables.add(new ModelPropertyImpl("age", new TypeInfoImpl(Integer.class.getName())));
    taskVariables.add(new ModelPropertyImpl("mail", new TypeInfoImpl(String.class.getName())));
    taskVariables.add(new ModelPropertyImpl("skills", new TypeInfoImpl(String.class.getName())));
    taskVariables.add(new ModelPropertyImpl("tech_score", new TypeInfoImpl(Integer.class.getName())));
    taskVariables.add(new ModelPropertyImpl("twitter", new TypeInfoImpl(String.class.getName())));
    taskFormModel = new TaskFormModel("hiring", "TechInterview", taskVariables);
    processTasks.add(taskFormModel);
    JBPMProcessModel model = new JBPMProcessModel(processFormModel, processTasks);
    formModels.add(model);
}
Also used : JBPMProcessModel(org.kie.workbench.common.forms.jbpm.model.authoring.JBPMProcessModel) ArrayList(java.util.ArrayList) BusinessProcessFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl)

Example 19 with TaskFormModel

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

the class FormDefinitionGeneratorImpl method generateSelectedFormsForTasks.

private void generateSelectedFormsForTasks(Diagram diagram, String... taskIds) {
    try {
        final String idsRaw = Arrays.stream(taskIds).collect(Collectors.joining(","));
        LOGGER.finest("Generating form for tasks " + idsRaw);
        final Path path = diagram.getMetadata().getPath();
        org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
        ioService.startBatch(ioService.getFileSystem(nioPath.toUri()));
        final Definitions definitions = toDefinitions(diagram);
        for (String taskId : taskIds) {
            final TaskFormModel formModel = bpmnFormModelGenerator.generateTaskFormModel(definitions, taskId, path);
            createFormForModel(formModel, nioPath);
        }
    } catch (Exception ex) {
        LOGGER.severe("Error generating task forms");
        throw new RuntimeException(ex);
    } finally {
        ioService.endBatch();
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) Definitions(org.eclipse.bpmn2.Definitions) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) IOException(java.io.IOException)

Example 20 with TaskFormModel

use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel 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)

Aggregations

TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)21 Test (org.junit.Test)15 Matchers.anyString (org.mockito.Matchers.anyString)9 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 Definitions (org.eclipse.bpmn2.Definitions)4 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)4 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)4 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)4 Path (org.uberfire.backend.vfs.Path)4 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)3 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)3 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)3 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)3 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)3 IOException (java.io.IOException)2 List (java.util.List)2 Optional (java.util.Optional)2 Dependent (javax.enterprise.context.Dependent)2