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());
}
}
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);
}
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);
}
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();
}
}
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);
}
}
Aggregations