use of org.kie.workbench.common.forms.model.impl.ModelPropertyImpl in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorServiceTest method checkSimpleVariableForms.
protected void checkSimpleVariableForms() {
List<ModelProperty> properties = new ArrayList<>();
properties.add(new ModelPropertyImpl(TEXT_VARIABLE, new TypeInfoImpl(String.class.getName())));
properties.add(new ModelPropertyImpl(INTEGER_VARIABLE, new TypeInfoImpl(Integer.class.getName())));
properties.add(new ModelPropertyImpl(DOUBLE_VARIABLE, new TypeInfoImpl(Double.class.getName())));
properties.add(new ModelPropertyImpl(BOOLEAN_VARIABLE, new TypeInfoImpl(Boolean.class.getName())));
properties.add(new ModelPropertyImpl(DATE_VARIABLE, new TypeInfoImpl(Date.class.getName())));
BusinessProcessFormModel model = new BusinessProcessFormModel(PROCESS_ID, PROCESS_ID, properties);
FormGenerationResult result = service.generateForms(model, source);
assertNotNull(result);
assertNotNull(result.getRootForm());
assertTrue(result.getNestedForms().isEmpty());
checkRootForm(model, result, properties);
}
use of org.kie.workbench.common.forms.model.impl.ModelPropertyImpl in project kie-wb-common by kiegroup.
the class AbstractBPMNFormGeneratorServiceTest method launchNestedFormsTest.
protected FormGenerationResult launchNestedFormsTest() {
List<ModelProperty> variableList = new ArrayList<>();
variableList.add(new ModelPropertyImpl(EXPENSE_VARIABLE, new TypeInfoImpl(TypeKind.OBJECT, Expense.class.getName(), false)));
variableList.add(new ModelPropertyImpl(TEXT_VARIABLE, new TypeInfoImpl(String.class.getName())));
BusinessProcessFormModel model = new BusinessProcessFormModel(PROCESS_ID, PROCESS_ID, variableList);
FormGenerationResult result = service.generateForms(model, source);
assertNotNull(result);
assertNotNull(result.getRootForm());
checkRootForm(model, result, variableList);
return result;
}
use of org.kie.workbench.common.forms.model.impl.ModelPropertyImpl 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.model.impl.ModelPropertyImpl 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.model.impl.ModelPropertyImpl in project kie-wb-common by kiegroup.
the class BPMNFormGenerationTest method testSimpleVariables.
@Test
public void testSimpleVariables() {
List<ModelProperty> variables = new ArrayList<>();
variables.add(new ModelPropertyImpl("employee", new TypeInfoImpl(String.class.getName())));
variables.add(new ModelPropertyImpl("manager", new TypeInfoImpl(String.class.getName())));
variables.add(new ModelPropertyImpl("performance", new TypeInfoImpl(Integer.class.getName())));
variables.add(new ModelPropertyImpl("approved", new TypeInfoImpl(Boolean.class.getName())));
model = getModel(getModelId(), variables);
Collection<FormDefinition> forms = getModelForms(model, classLoader);
try {
verify(classLoader, never()).loadClass(anyString());
} catch (ClassNotFoundException e) {
fail("We shouldn't be here: " + e.getMessage());
}
assertNotNull("There should one form", forms);
assertEquals("There should one form", 1, forms.size());
FormDefinition form = forms.iterator().next();
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getId());
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getName());
assertEquals(form.getModel(), model);
assertEquals("There should be 4 fields", 4, form.getFields().size());
variables.forEach(variable -> {
FieldDefinition field = form.getFieldByBinding(variable.getName());
assertFieldStatus(field, variable);
});
}
Aggregations