Search in sources :

Example 1 with VariableDeclaration

use of org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration in project kie-wb-common by kiegroup.

the class InitializedVariableTest method testInputCustomVariable.

@Test
public void testInputCustomVariable() {
    VariableDeclaration declaration = new VariableDeclaration("Identifier", "type");
    InitializedVariable.InitializedInputVariable input = createCustomInput("parent", declaration, "#{expression}");
    assertTrue(input instanceof InitializedVariable.InputExpression);
    input = createCustomInput("parent", declaration, "constant");
    assertTrue(input instanceof InitializedVariable.InputConstant);
}
Also used : InputConstant(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable.InputConstant) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) VariableDeclaration(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration) Test(org.junit.Test)

Example 2 with VariableDeclaration

use of org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration in project kie-wb-common by kiegroup.

the class InitializedVariableTest method urlDecodeConstants.

@Test
public void urlDecodeConstants() throws UnsupportedEncodingException {
    String expected = "<<<#!!!#>>>";
    String encoded = URLEncoder.encode(expected, "UTF-8");
    VariableDeclaration variable = new VariableDeclaration("PARENT_ID", "Object");
    InputConstant c = (InputConstant) createCustomInput("PARENT", variable, encoded);
    Assignment assignment = c.getDataInputAssociation().getAssignment().get(0);
    FormalExpression to = (FormalExpression) assignment.getTo();
    assertEquals(Ids.dataInput("PARENT", "PARENT_ID"), to.getBody());
    FormalExpression from = (FormalExpression) assignment.getFrom();
    assertEquals(asCData(expected), from.getBody());
}
Also used : Assignment(org.eclipse.bpmn2.Assignment) VariableDeclaration(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration) InputConstant(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable.InputConstant) FormalExpression(org.eclipse.bpmn2.FormalExpression) Test(org.junit.Test)

Example 3 with VariableDeclaration

use of org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration in project kie-wb-common by kiegroup.

the class InitializedVariableTest method testGetDataOuput.

@Test
public void testGetDataOuput() {
    final VariableDeclaration varDeclaration = new VariableDeclaration("Data Output Test", "Boolean");
    final String TARGET_VAR = "BooleanTarget";
    final String DATA_OUTPUT_ID = "_Data-Output-TestOutputX";
    final String DATA_OUTPUT_NAME = "Data Output Test";
    final String DATA_OUTPUT_ASSOCIATION_ID = "Data Output Test";
    final String DATA_OUTPUT_ASSOCIATION_VALUE = "BooleanTarget";
    final String INIT_OUTPUT_VAR_ID = "Data-Output-Test";
    final String INIT_OUTPUT_VAR_TYPE = "Boolean";
    InitializedVariable.InitializedOutputVariable initializedOutputVar = new InitializedVariable.OutputVariableReference("", varScope, varDeclaration, TARGET_VAR, new HashSet<>());
    DataOutput dataOuput = initializedOutputVar.getDataOutput();
    DataOutputAssociation dataOutputAssociation = initializedOutputVar.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef = dataOutputAssociation.getSourceRef();
    DataOutput source = (DataOutput) sourceRef.get(0);
    PropertyImpl target = (PropertyImpl) dataOutputAssociation.getTargetRef();
    String dataOuputID = dataOuput.getId();
    String dataOutputName = dataOuput.getName();
    String dataOutputAssociationID = source.getName();
    String dataOutputAssocationValue = target.getId();
    String initVarID = initializedOutputVar.getIdentifier();
    String initVarType = initializedOutputVar.getType();
    assertEquals(dataOuputID, DATA_OUTPUT_ID);
    assertEquals(dataOutputName, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssocationValue, DATA_OUTPUT_ASSOCIATION_VALUE);
    assertEquals(initVarID, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType, INIT_OUTPUT_VAR_TYPE);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) VariableDeclaration(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) Test(org.junit.Test)

Example 4 with VariableDeclaration

use of org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration in project kie-wb-common by kiegroup.

the class InitializedVariableTest method testGetDataInput.

@Test
public void testGetDataInput() {
    final String SOURCE_VAR = "BooleanSource";
    final String DATA_INPUT_ID = "_Data-Input-TestInputX";
    final String DATA_INPUT_NAME = "Data Input Test";
    final String DATA_INPUT_ASSOCIATION_ID = "Data Input Test";
    final String DATA_INPUT_ASSOCIATION_VALUE = "BooleanSource";
    final String INIT_INPUT_VAR_ID = "Data-Input-Test";
    final String INIT_INPUT_VAR_TYPE = "Boolean";
    final VariableDeclaration varDeclaration = new VariableDeclaration("Data Input Test", "Boolean");
    InitializedVariable.InitializedInputVariable initializedInputVar = new InitializedVariable.InputVariableReference("", varScope, varDeclaration, SOURCE_VAR, new HashSet<>());
    DataInput dataInput = initializedInputVar.getDataInput();
    DataInputAssociation dataInputAssociation = initializedInputVar.getDataInputAssociation();
    List<ItemAwareElement> sourceRef = dataInputAssociation.getSourceRef();
    PropertyImpl source = (PropertyImpl) sourceRef.get(0);
    DataInput target = (DataInput) dataInputAssociation.getTargetRef();
    String dataInputId = dataInput.getId();
    String dataInputName = dataInput.getName();
    String dataInputAssociationID = target.getName();
    String dataInputAssociationValue = source.getId();
    String initVarID = initializedInputVar.getIdentifier();
    String initVarType = initializedInputVar.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 : DataInput(org.eclipse.bpmn2.DataInput) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) VariableDeclaration(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) DataInputAssociation(org.eclipse.bpmn2.DataInputAssociation) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 VariableDeclaration (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.VariableDeclaration)4 InitializedVariable (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable)3 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 PropertyImpl (org.eclipse.bpmn2.impl.PropertyImpl)2 InputConstant (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable.InputConstant)2 Assignment (org.eclipse.bpmn2.Assignment)1 DataInput (org.eclipse.bpmn2.DataInput)1 DataInputAssociation (org.eclipse.bpmn2.DataInputAssociation)1 DataOutput (org.eclipse.bpmn2.DataOutput)1 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)1 FormalExpression (org.eclipse.bpmn2.FormalExpression)1