use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl 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);
});
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl 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.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class ModelPropertiesGenerator method createModelProperty.
public static ModelProperty createModelProperty(String name, String className, boolean isMultiple, ClassLoader classLoader) {
if (FormModelPropertiesUtil.isBaseType(className)) {
// Dealing with basic type properties (String, Integer...)
return new ModelPropertyImpl(name, new TypeInfoImpl(className, isMultiple));
} else {
// Dealing with complex types.
if (FormModelPropertiesUtil.isListType(className)) {
// If className is a List let's create a model for Object...
return createModelProperty(name, Object.class.getName(), true);
}
try {
Class clazz = classLoader.loadClass(className);
TypeKind typeKind = clazz.isEnum() ? TypeKind.ENUM : TypeKind.OBJECT;
return new ModelPropertyImpl(name, new TypeInfoImpl(typeKind, className, isMultiple));
} catch (ClassNotFoundException e) {
logger.warn("Unable to create property '" + name + "' for class '" + className + "':", e);
}
}
return null;
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class FieldManagerTest method testCompatiblefields.
protected void testCompatiblefields(boolean addFieldType) {
for (Class clazz : basicTypesSupported) {
TypeInfo typeInfo = new TypeInfoImpl(clazz.isEnum() ? TypeKind.ENUM : TypeKind.BASE, clazz.getName(), false);
FieldDefinition fieldDefinition = fieldManager.getDefinitionByDataType(typeInfo);
Assertions.assertThat(fieldDefinition).isNotNull();
if (addFieldType) {
fieldDefinition.setStandaloneClassName(typeInfo.getClassName());
}
Collection<String> compatibles = fieldManager.getCompatibleFields(fieldDefinition);
Assertions.assertThat(compatibles).isNotNull().isNotEmpty();
}
}
use of org.kie.workbench.common.forms.model.impl.TypeInfoImpl in project kie-wb-common by kiegroup.
the class FieldManagerTest method testGetFieldByTypeInfo.
@Test
public void testGetFieldByTypeInfo() {
for (Class clazz : basicTypesSupported) {
TypeInfo typeInfo = new TypeInfoImpl(clazz.isEnum() ? TypeKind.ENUM : TypeKind.BASE, clazz.getName(), false);
checkFieldExists(typeInfo);
}
for (Class clazz : basicMultipleTypesSupported) {
TypeInfo typeInfo = new TypeInfoImpl(TypeKind.BASE, clazz.getName(), true);
checkFieldExists(typeInfo);
}
// check nested form
checkFieldExists(new TypeInfoImpl(TypeKind.OBJECT, Object.class.getName(), false));
// check multiple subform
checkFieldExists(new TypeInfoImpl(TypeKind.OBJECT, Object.class.getName(), true));
}
Aggregations