Search in sources :

Example 1 with ProcessVariablesTotal

use of org.kie.workbench.common.stunner.bpmn.documentation.model.general.ProcessVariablesTotal 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());
}
Also used : KeyValue(org.kie.workbench.common.stunner.core.client.util.js.KeyValue) IsElement(org.jboss.errai.common.client.api.IsElement) Element(org.kie.workbench.common.stunner.bpmn.documentation.model.element.Element) ProcessOverview(org.kie.workbench.common.stunner.bpmn.documentation.model.general.ProcessOverview) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ElementTotal(org.kie.workbench.common.stunner.bpmn.documentation.model.element.ElementTotal) DefaultImport(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.DefaultImport) General(org.kie.workbench.common.stunner.bpmn.documentation.model.general.General) BPMNDocumentation(org.kie.workbench.common.stunner.bpmn.documentation.model.BPMNDocumentation) WSDLImport(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.WSDLImport) ProcessVariablesTotal(org.kie.workbench.common.stunner.bpmn.documentation.model.general.ProcessVariablesTotal) Test(org.junit.Test)

Aggregations

IsElement (org.jboss.errai.common.client.api.IsElement)1 Test (org.junit.Test)1 DefaultImport (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.DefaultImport)1 WSDLImport (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.WSDLImport)1 BPMNDocumentation (org.kie.workbench.common.stunner.bpmn.documentation.model.BPMNDocumentation)1 Element (org.kie.workbench.common.stunner.bpmn.documentation.model.element.Element)1 ElementTotal (org.kie.workbench.common.stunner.bpmn.documentation.model.element.ElementTotal)1 General (org.kie.workbench.common.stunner.bpmn.documentation.model.general.General)1 ProcessOverview (org.kie.workbench.common.stunner.bpmn.documentation.model.general.ProcessOverview)1 ProcessVariablesTotal (org.kie.workbench.common.stunner.bpmn.documentation.model.general.ProcessVariablesTotal)1 KeyValue (org.kie.workbench.common.stunner.core.client.util.js.KeyValue)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1