use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImplTest method testCorrectTaskFormModelIsGeneratedForTaskThatContainsOnlyInputs.
@Test
public void testCorrectTaskFormModelIsGeneratedForTaskThatContainsOnlyInputs() {
final String TASK_ID = "_9F3A7665-E7EF-4DC2-94F1-F9D20A38547E", TASK_NAME = "taskOnlyWithInputs";
TaskFormModel taskFormModel = generator.generateTaskFormModel(processWithAllVariablesDefinitions, TASK_ID, path);
assertTaskFormModelIsCorrect(taskFormModel, PROCESS_WITH_ALL_VARIABLES_ID, TASK_NAME);
assertJBPMVariablesAreCorrect(taskFormModel, EXPECTED_INPUT_VARIABLES);
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImpl method generateTaskFormModels.
@Override
public List<TaskFormModel> generateTaskFormModels(Definitions source, Path path) {
Process process = getProcess(source);
final ClassLoader projectClassLoader = projectClassLoaderHelper.getModuleClassLoader(moduleService.resolveModule(path));
if (process != null) {
ProcessTaskFormsGenerationResult result = readUserTaskFormVariables(process);
return result.getAllTaskFormVariables().stream().filter(taskFormVariables -> {
if (!taskFormVariables.isValid()) {
logger.warn(generateErrorMessage(taskFormVariables));
return false;
}
return true;
}).map(taskFormVariables -> taskFormVariables.toFormModel(variable -> createModelProperty(variable, projectClassLoader))).collect(Collectors.toList());
}
return Collections.emptyList();
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.
the class FormGenerationWithSynchronizationTest method testAddModelProperties.
@Test
public void testAddModelProperties() {
List<ModelProperty> modelProperties = new ArrayList<>();
modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(AGE_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(MARRIED_PROPERTY, new TypeInfoImpl(Boolean.class.getName())));
modelProperties.add(new ModelPropertyImpl(ADDRESS_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(JOB_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(HOBBIES_PROPERTY, new TypeInfoImpl(String.class.getName())));
newFormModel = new TaskFormModel(PROCESS_ID, TASK_NAME, modelProperties);
FormGenerationResult generationResult = service.generateForms(newFormModel, source);
assertNotNull(generationResult);
assertNotNull(generationResult.getRootForm());
FormDefinition formDefinition = generationResult.getRootForm();
assertEquals(newFormModel, formDefinition.getModel());
assertEquals(ALL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(AGE_PROPERTY);
assertEquals(field.getStandaloneClassName(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(MARRIED_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Boolean.class.getName());
assertTrue(field instanceof CheckBoxFieldDefinition);
field = formDefinition.getFieldByBinding(ADDRESS_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(JOB_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(HOBBIES_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.
the class FormGenerationWithSynchronizationTest method testModelPropertiesConflict.
@Test
public void testModelPropertiesConflict() {
List<ModelProperty> modelProperties = new ArrayList<>();
modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(AGE_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(MARRIED_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(ADDRESS_PROPERTY, new TypeInfoImpl(Boolean.class.getName())));
newFormModel = new TaskFormModel(PROCESS_ID, TASK_NAME, modelProperties);
FormGenerationResult generationResult = service.generateForms(newFormModel, source);
assertNotNull(generationResult);
assertNotNull(generationResult.getRootForm());
FormDefinition formDefinition = generationResult.getRootForm();
assertEquals(newFormModel, formDefinition.getModel());
assertEquals(ORIGINAL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(AGE_PROPERTY);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(MARRIED_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(ADDRESS_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Boolean.class.getName());
assertTrue(field instanceof CheckBoxFieldDefinition);
}
use of org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel in project kie-wb-common by kiegroup.
the class BPMNFormModelGeneratorImplTest method testGenerateAllTaskFormModelForTasksWithSharedForm.
@Test
public void testGenerateAllTaskFormModelForTasksWithSharedForm() {
final String TASK_NAME = "task";
final int EXPECTED_MODELS = 2;
List<TaskFormModel> generatedModels = generator.generateTaskFormModels(processWithSharedForms, path);
assertNotNull(generatedModels);
assertEquals(EXPECTED_MODELS, generatedModels.size());
for (TaskFormModel formModel : generatedModels) {
assertNotNull(formModel);
assertEquals(PROCESS_WITH_SHARED_FORMS_ID, formModel.getProcessId());
assertNotNull(formModel.getProperties());
assertFalse(formModel.getProperties().isEmpty());
if (formModel.getFormName().equals(TASK_NAME + BPMNVariableUtils.TASK_FORM_SUFFIX)) {
checkExpectedMergedFormVariables(formModel);
}
}
}
Aggregations