use of org.kie.workbench.common.stunner.bpmn.documentation.model.general.ProcessOverview in project kie-wb-common by kiegroup.
the class ClientBPMNDocumentationServiceTest method processDocumentation.
@Test
public void processDocumentation() {
final BPMNDocumentation bpmnDocumentation = tested.processDocumentation(diagram);
final ProcessOverview process = bpmnDocumentation.getProcess();
final General general = process.getGeneral();
assertEquals(PROCESS_PACKAGE, bpmnDocumentation.getModuleName());
assertEquals(PROCESS_DECRIPTION, general.getDescription());
assertNotEquals(PROCESS_DOCUMENTATION, general.getDocumentation());
// testing spaces on the value
assertEquals(PROCESS_DOCUMENTATION.replaceAll("\n", "<br/>"), general.getDocumentation());
assertEquals(PROCESS_UUID, general.getId());
assertEquals(PROCESS_IS_ADHOC.toString(), general.getIsAdhoc());
assertEquals(PROCESS_IS_EXECUTABLE.toString(), general.getIsExecutable());
assertEquals(PROCESS_NAME, general.getName());
assertEquals(PROCESS_PACKAGE, general.getPkg());
assertEquals(PROCESS_VERSION, general.getVersion());
final org.kie.workbench.common.stunner.bpmn.documentation.model.general.Imports importsDoc = process.getImports();
final org.kie.workbench.common.stunner.bpmn.documentation.model.general.Imports.DefaultImport[] defaultImportsDoc = importsDoc.getDefaultImports();
final org.kie.workbench.common.stunner.bpmn.documentation.model.general.Imports.WSDLImport[] wsdlImportsDoc = importsDoc.getWSDLImports();
assertEquals(EMPTY_VALUE, importsDoc.getDefaultImportsHidden());
assertEquals(EMPTY_VALUE, importsDoc.getWSDLImportsHidden());
assertEquals(EMPTY_VALUE, importsDoc.getImportsTableHidden());
assertEquals(HIDDEN, importsDoc.getNoImportsHidden());
assertEquals(3, importsDoc.getTotalDefaultImports(), 0);
assertEquals(4, importsDoc.getTotalWSDLImports(), 0);
assertEquals(defaultImportsDoc[0].getClassName(), CLASS_NAME + "1");
assertEquals(defaultImportsDoc[1].getClassName(), CLASS_NAME + "2");
assertEquals(defaultImportsDoc[2].getClassName(), CLASS_NAME + "3");
assertEquals(wsdlImportsDoc[0].getLocation(), LOCATION + "1");
assertEquals(wsdlImportsDoc[0].getNamespace(), NAMESPACE + "1");
assertEquals(wsdlImportsDoc[1].getLocation(), LOCATION + "2");
assertEquals(wsdlImportsDoc[1].getNamespace(), NAMESPACE + "2");
assertEquals(wsdlImportsDoc[2].getLocation(), LOCATION + "3");
assertEquals(wsdlImportsDoc[2].getNamespace(), NAMESPACE + "3");
assertEquals(wsdlImportsDoc[3].getLocation(), LOCATION + "4");
assertEquals(wsdlImportsDoc[3].getNamespace(), NAMESPACE + "4");
final ProcessVariablesTotal dataTotal = process.getDataTotal();
assertEquals(6, dataTotal.getTotal(), 0);
assertEquals(6, dataTotal.getTotalVariables(), 0);
// assert sorting based on the variables names
final ProcessVariablesTotal.VariableTriplets[] variables = dataTotal.getVariablesAsTriplets();
assertEquals("GL1", variables[0].getName());
assertEquals(String.class.getName(), variables[0].getType());
assertEquals("[]", variables[0].getTags());
assertEquals("GL2", variables[1].getName());
assertEquals(Boolean.class.getName(), variables[1].getType());
assertEquals("[]", variables[1].getTags());
assertEquals("PV1", variables[2].getName());
assertEquals(String.class.getName(), variables[2].getType());
assertEquals("[internal;input]", variables[2].getTags());
assertEquals("PV2", variables[3].getName());
assertEquals(Boolean.class.getName(), variables[3].getType());
assertEquals("[customTag;output]", variables[3].getTags());
assertEquals("SUBPV1", variables[4].getName());
assertEquals(String.class.getName(), variables[4].getType());
assertEquals("[internal]", variables[4].getTags());
assertEquals("SUBPV2", variables[5].getName());
assertEquals(Boolean.class.getName(), variables[5].getType());
assertEquals("[readonly;customTag]", variables[5].getTags());
final ElementTotal[] totals = bpmnDocumentation.getElementsDetails().getTotals();
assertEquals(2, totals.length);
// assert category order
// usertask
final ElementTotal activities = totals[0];
assertEquals(BPMNCategories.ACTIVITIES, activities.getType());
assertEquals(ICON_HTML, activities.getTypeIcon());
assertEquals(1, activities.getQuantity());
// subprocess
final ElementTotal subprocesses = totals[1];
assertEquals(BPMNCategories.SUB_PROCESSES, subprocesses.getType());
assertEquals(ICON_HTML, subprocesses.getTypeIcon());
assertEquals(1, subprocesses.getQuantity());
// assert elements order in the category
// usertask
final Element[] activitiesElements = activities.getElements();
final Element task = activitiesElements[0];
assertEquals(TASK_NAME, task.getTitle());
assertEquals(BPMNCategories.ACTIVITIES, task.getType());
assertEquals(ICON_HTML, task.getIcon());
assertEquals(TASK_NAME, task.getName());
// assert usertask properties sorted by name
final KeyValue[] taskProperties = task.getProperties();
assertProperty(taskProperties[0], ASSIGNEMNTS, ASSIGNEMNTS_CAPTION, userTask.getExecutionSet().getDescription());
assertProperty(taskProperties[1], TASK_DESCRIPTION, DESCRIPTION_CAPTION, userTask.getExecutionSet().getDescription());
assertProperty(taskProperties[2], TASK_DOCUMENTATION, DOCUMENTATION_CAPTION, userTask.getGeneral().getDocumentation());
assertProperty(taskProperties[3], TASK_GROUPID, GROUP_CAPTION, userTask.getExecutionSet().getGroupid());
assertProperty(taskProperties[4], TASK_PRIORITY, PRIORITY_CAPTION, userTask.getExecutionSet().getPriority());
assertProperty(taskProperties[5], TASK_SUBJECT, SUBJECT_CAPTION, userTask.getExecutionSet().getSubject());
// subprocess
final Element[] subprocessesElements = subprocesses.getElements();
final Element subprocess = subprocessesElements[0];
assertEquals(SUB_PROCESS_NAME, subprocess.getTitle());
assertEquals(BPMNCategories.SUB_PROCESSES, subprocess.getType());
assertEquals(ICON_HTML, subprocess.getIcon());
assertEquals(SUB_PROCESS_NAME, subprocess.getName());
// assert subprocess properties
final KeyValue[] subprocessProperties = subprocess.getProperties();
assertProperty(subprocessProperties[0], SUB_PROCESS_DOCUMENTATION, DOCUMENTATION_CAPTION, embeddedSubprocess.getGeneral().getDocumentation());
assertProperty(subprocessProperties[1], "false", ISASYNC_CAPTION, embeddedSubprocess.getExecutionSet().getIsAsync());
assertProperty(subprocessProperties[2], ON_ENTRY_ACTION, ON_ENTRY_CAPTION, embeddedSubprocess.getExecutionSet().getOnEntryAction());
assertProperty(subprocessProperties[3], ON_EXIT_ACTION, ON_EXIT_CAPTION, embeddedSubprocess.getExecutionSet().getOnEntryAction());
}
Aggregations