use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.
the class BPMFinderServiceImpl method scannProcessesForType.
protected void scannProcessesForType(final Path path, final String extension, final GenerationConfig generationConfig) {
List<org.uberfire.java.nio.file.Path> nioPaths = new ArrayList<>();
nioPaths.add(Paths.convert(path));
Collection<FileUtils.ScanResult> processes = fileUtils.scan(ioService, nioPaths, extension, true);
processes.stream().map(scanResult -> parse(scanResult)).filter(definitions -> definitions != null && generationConfig.getPredicate().test(definitions)).forEach(definitions -> {
BusinessProcessFormModel processFormModel = bpmnFormModelGenerator.generateProcessFormModel(definitions.get(), path);
List<TaskFormModel> taskModels = bpmnFormModelGenerator.generateTaskFormModels(definitions.get(), path);
generationConfig.getConsumer().accept(new JBPMProcessModel(processFormModel, taskModels));
});
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.
the class MigrationToolTest method testProcessForm.
@Test
public void testProcessForm() throws IOException {
final FormDefinition processFormDef = getFormFromResources("formmodeler-migration.UpdateUserProfile-taskform");
checkFields(processFormDef, new HashMap<String, List<String>>() {
{
put("boolean", Arrays.asList("boolean (boolean)", "CheckBox", "boolean"));
put("cv", Arrays.asList("cv (cv)", "Document", "cv"));
put("float", Arrays.asList("float (float)", "DecimalBox", "float"));
put("integer", Arrays.asList("integer (integer)", "IntegerBox", "integer"));
put("string", Arrays.asList("string (string)", "TextBox", "string"));
put("person", Arrays.asList("person", "SubForm", "person"));
}
});
assertThat(((BusinessProcessFormModel) processFormDef.getModel()).getProcessName()).isEqualTo("UpdateUserProfile");
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImplTest method testGenerateAllForProcessWithAllPossibleProcessVariables.
@Test
public void testGenerateAllForProcessWithAllPossibleProcessVariables() {
final Map<String, String> EXPECTED_PROCESS_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);
put("list", Object.class.getName());
}
};
// generate all = generateProcessFormModel + generateTaskFormModels
BusinessProcessFormModel processFormModel = generator.generateProcessFormModel(processWithAllVariablesDefinitions, path);
assertProcessFormModelFieldsAreCorrect(processFormModel, PROCESS_WITH_ALL_VARIABLES_NAME);
assertJBPMVariablesAreCorrect(processFormModel, EXPECTED_PROCESS_VARIABLES);
List<TaskFormModel> taskFormModels = generator.generateTaskFormModels(processWithAllVariablesDefinitions, path);
// taskOnlyWithOutputs-taskform, emptyTask-taskform, taskOnlyWithInputs-taskform, taskWithDifferentInputsAndOutputs-taskform, taskWithTheSameInputsAndOutputs-taskform
final int EXPECTED_NUMBER_OF_HUMAN_TASKS = 5;
assertEquals("Forms should be generated for all human tasks including tasks in subprocesses and swimlanes", EXPECTED_NUMBER_OF_HUMAN_TASKS, taskFormModels.size());
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImplTest method testGenerateAllWithWrongTypes.
@Test
public void testGenerateAllWithWrongTypes() throws Exception {
when(projectClassLoader.loadClass(Mockito.<String>any())).thenAnswer(invocationOnMock -> getClass().getClassLoader().loadClass(invocationOnMock.getArguments()[0].toString()));
final Map<String, String> EXPECTED_PROPERTIES = new HashMap<String, String>() {
{
put("name", String.class.getName());
put("age", Integer.class.getName());
put("error", WorkItemHandlerRuntimeException.class.getName());
put("list", Object.class.getName());
}
};
BusinessProcessFormModel processFormModel = generator.generateProcessFormModel(processWithWrongTypes, path);
assertProcessFormModelFieldsAreCorrect(processFormModel, PROCESS_WITH_WRONG_TYPES);
Assertions.assertThat(processFormModel.getProperties()).isNotNull().isNotEmpty().hasSize(EXPECTED_PROPERTIES.size());
assertEquals(EXPECTED_PROPERTIES.size(), processFormModel.getProperties().size());
assertJBPMVariablesAreCorrect(processFormModel, EXPECTED_PROPERTIES);
List<TaskFormModel> taskFormModels = generator.generateTaskFormModels(processWithWrongTypes, path);
final int EXPECTED_NUMBER_OF_HUMAN_TASKS = 1;
Assertions.assertThat(taskFormModels).isNotNull().isNotEmpty().hasSize(EXPECTED_NUMBER_OF_HUMAN_TASKS);
TaskFormModel taskFormModel = taskFormModels.get(0);
Assertions.assertThat(taskFormModel.getProperties()).isNotNull().isNotEmpty().hasSize(EXPECTED_PROPERTIES.size());
assertJBPMVariablesAreCorrect(taskFormModel, EXPECTED_PROPERTIES);
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImplTest method testGenerateAllForProcessWithoutProcessVariables.
@Test
public void testGenerateAllForProcessWithoutProcessVariables() {
// generate all = generateProcessFormModel + generateTaskFormModels
BusinessProcessFormModel processFormModel = generator.generateProcessFormModel(processWithoutVariablesDefinitions, path);
assertProcessFormModelFieldsAreCorrect(processFormModel, PROCESS_WITHOUT_VARIABLES_NAME);
assertTrue(processFormModel.getProperties().isEmpty());
List<TaskFormModel> taskFormModels = generator.generateTaskFormModels(processWithoutVariablesDefinitions, path);
assertTrue(taskFormModels.isEmpty());
}
Aggregations