Search in sources :

Example 41 with DataInput

use of org.eclipse.bpmn2.DataInput in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testMarshallUserTaskAssignments.

@Test
public void testMarshallUserTaskAssignments() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_USERTASKASSIGNMENTS);
    // JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    assertNotNull(definitions);
    Process process = getProcess(definitions);
    assertNotNull(process);
    org.eclipse.bpmn2.UserTask userTask = (org.eclipse.bpmn2.UserTask) getNamedFlowElement(process, org.eclipse.bpmn2.UserTask.class, "Self Evaluation");
    assertNotNull(userTask);
    DataInput dataInput = getDataInput(userTask, "reason");
    // this fails because of type
    validateDataInputOrOutput(dataInput, "_reasonInputX", "com.test.Reason", "_reasonInputXItem");
    DataOutput dataOutput = getDataOutput(userTask, "performance");
    validateDataInputOrOutput(dataOutput, "_performanceOutputX", "Object", "_performanceOutputXItem");
    ItemAwareElement sourceRef = getDataInputAssociationSourceRef(userTask, "reason");
    assertNotNull(sourceRef);
    ItemAwareElement targetRef = getDataInputAssociationTargetRef(userTask, "_reasonInputX");
    assertNotNull(targetRef);
    sourceRef = getDataOutputAssociationSourceRef(userTask, "_performanceOutputX");
    assertNotNull(sourceRef);
    targetRef = getDataOutputAssociationTargetRef(userTask, "performance");
    assertNotNull(targetRef);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) Process(org.eclipse.bpmn2.Process) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) DataInput(org.eclipse.bpmn2.DataInput) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Test(org.junit.Test)

Example 42 with DataInput

use of org.eclipse.bpmn2.DataInput in project kie-wb-common by kiegroup.

the class ParsedAssignmentsInfoTest method testCreateInitializedInputVariables.

@Test
public void testCreateInitializedInputVariables() {
    final String DATA_INPUT_ID = "_Years-of-ServiceInputX";
    final String DATA_INPUT_NAME = "Years of Service";
    final String DATA_INPUT_ASSOCIATION_ID = "Years of Service";
    final String DATA_INPUT_ASSOCIATION_VALUE = "<![CDATA[35]]>";
    final String INIT_INPUT_VAR_ID = "Years-of-Service";
    final String INIT_INPUT_VAR_TYPE = "Integer";
    VariableScope variableScope = new FlatVariableScope();
    List<InitializedVariable.InitializedInputVariable> initializedInputVariables = tested.createInitializedInputVariables("", variableScope, new HashSet<>());
    assertEquals(1, initializedInputVariables.size());
    InitializedVariable.InitializedInputVariable initializedInputVariable = initializedInputVariables.get(0);
    DataInput dataInput = initializedInputVariable.getDataInput();
    DataInputAssociation dataInputAssociation = initializedInputVariable.getDataInputAssociation();
    DataInput target = (DataInput) dataInputAssociation.getTargetRef();
    List<Assignment> assignments = dataInputAssociation.getAssignment();
    Assignment assignment = assignments.get(0);
    FormalExpression from = (FormalExpression) assignment.getFrom();
    String dataInputID = dataInput.getId();
    String dataInputName = dataInput.getName();
    String dataInputAssociationID = target.getName();
    String dataInputAssociationValue = from.getBody();
    String initVarID = initializedInputVariable.getIdentifier();
    String initVarType = initializedInputVariable.getType();
    assertEquals(dataInputID, DATA_INPUT_ID);
    assertEquals(dataInputName, DATA_INPUT_NAME);
    assertEquals(dataInputAssociationID, DATA_INPUT_ASSOCIATION_ID);
    assertEquals(dataInputAssociationValue, DATA_INPUT_ASSOCIATION_VALUE);
    assertEquals(initVarID, INIT_INPUT_VAR_ID);
    assertEquals(initVarType, INIT_INPUT_VAR_TYPE);
}
Also used : FormalExpression(org.eclipse.bpmn2.FormalExpression) DataInput(org.eclipse.bpmn2.DataInput) Assignment(org.eclipse.bpmn2.Assignment) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) VariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Test(org.junit.Test)

Aggregations

DataInput (org.eclipse.bpmn2.DataInput)38 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)25 DataOutput (org.eclipse.bpmn2.DataOutput)17 FormalExpression (org.eclipse.bpmn2.FormalExpression)15 ArrayList (java.util.ArrayList)12 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)12 Assignment (org.eclipse.bpmn2.Assignment)11 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)11 Test (org.junit.Test)10 List (java.util.List)9 InputSet (org.eclipse.bpmn2.InputSet)9 InputOutputSpecification (org.eclipse.bpmn2.InputOutputSpecification)8 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)8 Parameter (bpsim.Parameter)5 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)5 Process (org.eclipse.bpmn2.Process)5 Property (org.eclipse.bpmn2.Property)5 NormalDistributionType (bpsim.NormalDistributionType)4 PoissonDistributionType (bpsim.PoissonDistributionType)4 TimeParameters (bpsim.TimeParameters)4