Search in sources :

Example 1 with FlatVariableScope

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope in project kie-wb-common by kiegroup.

the class AssociationsTest method marshallUnassignedDeclaration.

@Test
public void marshallUnassignedDeclaration() {
    String id = "PARENT";
    String decl = "||Foo:String||";
    StartEvent startEvent = bpmn2.createStartEvent();
    startEvent.setId(id);
    CatchEventPropertyWriter p = new CatchEventPropertyWriter(startEvent, new FlatVariableScope(), new HashSet<>());
    p.setAssignmentsInfo(new AssignmentsInfo(decl));
    assertEquals(1, p.getItemDefinitions().size());
    assertEquals(Ids.dataOutputItem(id, "Foo"), p.getItemDefinitions().get(0).getId());
    assertEquals("String", p.getItemDefinitions().get(0).getStructureRef());
    assertEquals(1, startEvent.getDataOutputs().size());
    assertEquals("Foo", startEvent.getDataOutputs().get(0).getName());
    assertEquals(0, startEvent.getDataOutputAssociation().size());
}
Also used : CatchEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) StartEvent(org.eclipse.bpmn2.StartEvent) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) Test(org.junit.Test) BPMNDiagramMarshallerBaseTest(org.kie.workbench.common.stunner.bpmn.backend.service.diagram.marshalling.BPMNDiagramMarshallerBaseTest)

Example 2 with FlatVariableScope

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope in project kie-wb-common by kiegroup.

the class IntermediateCatchEventConverterTest method setUp.

@Before
public void setUp() {
    Event boundaryEvent = bpmn2.createBoundaryEvent();
    boundaryEventPropertyWriter = spy(new BoundaryEventPropertyWriter((BoundaryEvent) spy(boundaryEvent), new FlatVariableScope(), new HashSet<>()));
    // when(boundaryEventPropertyWriter.getFlowElement()).thenReturn(spy(FlowElement.class));
    Event catchEvent = bpmn2.createIntermediateCatchEvent();
    catchEventPropertyWriter = spy(new CatchEventPropertyWriter((CatchEvent) spy(catchEvent), new FlatVariableScope(), new HashSet<>()));
    propertyWriterFactory = spy(PropertyWriterFactory.class);
    when(propertyWriterFactory.of(any(BoundaryEvent.class))).thenReturn(boundaryEventPropertyWriter);
    when(propertyWriterFactory.of(any(CatchEvent.class))).thenReturn(catchEventPropertyWriter);
    generalSet = new BPMNGeneralSet(NAME, DOCUMENTATION);
    assignmentsInfo = new AssignmentsInfo(ASSIGNMENTS_INFO);
    dataIOSet = new DataIOSet(assignmentsInfo);
    advancedData = new AdvancedData();
    slaDueDate = mock(SLADueDate.class);
    errorRef = mock(ErrorRef.class);
    signalRef = mock(SignalRef.class);
    linkRef = mock(LinkRef.class);
    timerSettingsValue = mock(TimerSettingsValue.class);
    timerSettings = new TimerSettings(timerSettingsValue);
    messageRef = mock(MessageRef.class);
    scriptTypeValue = mock(ScriptTypeValue.class);
    conditionExpression = new ConditionExpression(scriptTypeValue);
    escalationRef = mock(EscalationRef.class);
    tested = spy(new IntermediateCatchEventConverter(propertyWriterFactory));
}
Also used : SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) TimerSettings(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettings) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) TimerSettingsValue(org.kie.workbench.common.stunner.bpmn.definition.property.event.timer.TimerSettingsValue) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) CatchEvent(org.eclipse.bpmn2.CatchEvent) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) SLADueDate(org.kie.workbench.common.stunner.bpmn.definition.property.general.SLADueDate) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) CatchEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter) ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression) IntermediateCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateCompensationEvent) BaseCatchingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseCatchingIntermediateEvent) Event(org.eclipse.bpmn2.Event) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) CatchEvent(org.eclipse.bpmn2.CatchEvent) BoundaryEvent(org.eclipse.bpmn2.BoundaryEvent) IntermediateConditionalEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateConditionalEvent) IntermediateCatchEvent(org.eclipse.bpmn2.IntermediateCatchEvent) IntermediateEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEvent) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) ErrorRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.error.ErrorRef) EscalationRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.escalation.EscalationRef) BoundaryEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BoundaryEventPropertyWriter) LinkRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.link.LinkRef) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue) Before(org.junit.Before)

Example 3 with FlatVariableScope

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope in project kie-wb-common by kiegroup.

the class ParsedAssignmentsInfoTest method testCreateInitializedOutputVariablesDuplicates.

@Test
public void testCreateInitializedOutputVariablesDuplicates() {
    final String DATA_OUTPUT_ID = "_Data-TestOutputX";
    final String DATA_OUTPUT_NAME = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_ID = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_VALUE_1 = "BooleanTest";
    final String DATA_OUTPUT_ASSOCIATION_VALUE_2 = "BooleanTest2";
    final String INIT_OUTPUT_VAR_ID = "Data-Test";
    final String INIT_OUTPUT_VAR_TYPE = "Boolean";
    VariableScope variableScope = new FlatVariableScope();
    variableScope.declare("", "BooleanTest", "Boolean");
    variableScope.declare("", "BooleanTest2", "Boolean");
    List<InitializedVariable.InitializedOutputVariable> initializedOutputVariables = testedDuplicates.createInitializedOutputVariables("", variableScope, new HashSet<>());
    assertEquals(2, initializedOutputVariables.size());
    // Test first variable
    InitializedVariable.InitializedOutputVariable initializedOutputVariable1 = initializedOutputVariables.get(0);
    DataOutput dataOutput1 = initializedOutputVariable1.getDataOutput();
    DataOutputAssociation dataOutputAssociation1 = initializedOutputVariable1.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef1 = dataOutputAssociation1.getSourceRef();
    DataOutput source1 = (DataOutput) sourceRef1.get(0);
    PropertyImpl target1 = (PropertyImpl) dataOutputAssociation1.getTargetRef();
    String dataOutputID1 = dataOutput1.getId();
    String dataOutputName1 = dataOutput1.getName();
    String dataOutputAssociationID1 = source1.getName();
    String dataOutputAssociationValue1 = target1.getId();
    String initVarID1 = initializedOutputVariable1.getIdentifier();
    String initVarType1 = initializedOutputVariable1.getType();
    assertEquals(dataOutputID1, DATA_OUTPUT_ID);
    assertEquals(dataOutputName1, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID1, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssociationValue1, DATA_OUTPUT_ASSOCIATION_VALUE_1);
    assertEquals(initVarID1, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType1, INIT_OUTPUT_VAR_TYPE);
    // Test duplicate variable
    InitializedVariable.InitializedOutputVariable initializedOutputVariable2 = initializedOutputVariables.get(1);
    DataOutput dataOutput2 = initializedOutputVariable2.getDataOutput();
    DataOutputAssociation dataOutputAssociation2 = initializedOutputVariable2.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef2 = dataOutputAssociation2.getSourceRef();
    DataOutput source2 = (DataOutput) sourceRef2.get(0);
    PropertyImpl target2 = (PropertyImpl) dataOutputAssociation2.getTargetRef();
    String dataOutputID2 = dataOutput2.getId();
    String dataOutputName2 = dataOutput2.getName();
    String dataOutputAssociationID2 = source2.getName();
    String dataOutputAssociationValue2 = target2.getId();
    String initVarID2 = initializedOutputVariable2.getIdentifier();
    String initVarType2 = initializedOutputVariable2.getType();
    assertEquals(dataOutputID2, DATA_OUTPUT_ID);
    assertEquals(dataOutputName2, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID2, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssociationValue2, DATA_OUTPUT_ASSOCIATION_VALUE_2);
    assertEquals(initVarID2, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType2, INIT_OUTPUT_VAR_TYPE);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) VariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) Test(org.junit.Test)

Example 4 with FlatVariableScope

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope in project kie-wb-common by kiegroup.

the class IntermediateThrowEventConverterTest method setUp.

@Before
public void setUp() {
    Event throwEvent = bpmn2.createIntermediateThrowEvent();
    throwEvent.setId("throwEventID");
    throwEventPropertyWriter = spy(new ThrowEventPropertyWriter((ThrowEvent) throwEvent, new FlatVariableScope(), new HashSet<>()));
    propertyWriterFactory = spy(PropertyWriterFactory.class);
    when(propertyWriterFactory.of(any(ThrowEvent.class))).thenReturn(throwEventPropertyWriter);
    generalSet = new BPMNGeneralSet(NAME, DOCUMENTATION);
    assignmentsInfo = new AssignmentsInfo(ASSIGNMENTS_INFO);
    dataIOSet = new DataIOSet(assignmentsInfo);
    advancedData = new AdvancedData();
    signalRef = mock(SignalRef.class);
    signalScope = mock(SignalScope.class);
    linkRef = mock(LinkRef.class);
    messageRef = mock(MessageRef.class);
    escalationRef = mock(EscalationRef.class);
    tested = spy(new IntermediateThrowEventConverter(propertyWriterFactory));
}
Also used : ThrowEvent(org.eclipse.bpmn2.ThrowEvent) SignalRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) MessageRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) AdvancedData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData) ThrowEvent(org.eclipse.bpmn2.ThrowEvent) BaseThrowingIntermediateEvent(org.kie.workbench.common.stunner.bpmn.definition.BaseThrowingIntermediateEvent) Event(org.eclipse.bpmn2.Event) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) SignalScope(org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalScope) EscalationRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.escalation.EscalationRef) ThrowEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ThrowEventPropertyWriter) LinkRef(org.kie.workbench.common.stunner.bpmn.definition.property.event.link.LinkRef) Before(org.junit.Before)

Example 5 with FlatVariableScope

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope in project kie-wb-common by kiegroup.

the class ParsedAssignmentsInfoTest method testCreateInitializedOutputVariables.

@Test
public void testCreateInitializedOutputVariables() {
    final String DATA_OUTPUT_ID = "_Data-TestOutputX";
    final String DATA_OUTPUT_NAME = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_ID = "Data Test";
    final String DATA_OUTPUT_ASSOCIATION_VALUE = "BooleanTest";
    final String INIT_OUTPUT_VAR_ID = "Data-Test";
    final String INIT_OUTPUT_VAR_TYPE = "Boolean";
    VariableScope variableScope = new FlatVariableScope();
    variableScope.declare("", "BooleanTest", "Boolean");
    List<InitializedVariable.InitializedOutputVariable> initializedOutputVariables = tested.createInitializedOutputVariables("", variableScope, new HashSet<>());
    assertEquals(1, initializedOutputVariables.size());
    InitializedVariable.InitializedOutputVariable initializedOutputVariable = initializedOutputVariables.get(0);
    DataOutput dataOutput = initializedOutputVariable.getDataOutput();
    DataOutputAssociation dataOutputAssociation = initializedOutputVariable.getDataOutputAssociation();
    List<ItemAwareElement> sourceRef = dataOutputAssociation.getSourceRef();
    DataOutput source = (DataOutput) sourceRef.get(0);
    PropertyImpl target = (PropertyImpl) dataOutputAssociation.getTargetRef();
    String dataOutputID = dataOutput.getId();
    String dataOutputName = dataOutput.getName();
    String dataOutputAssociationID = source.getName();
    String dataOutputAssociationValue = target.getId();
    String initVarID = initializedOutputVariable.getIdentifier();
    String initVarType = initializedOutputVariable.getType();
    assertEquals(dataOutputID, DATA_OUTPUT_ID);
    assertEquals(dataOutputName, DATA_OUTPUT_NAME);
    assertEquals(dataOutputAssociationID, DATA_OUTPUT_ASSOCIATION_ID);
    assertEquals(dataOutputAssociationValue, DATA_OUTPUT_ASSOCIATION_VALUE);
    assertEquals(initVarID, INIT_OUTPUT_VAR_ID);
    assertEquals(initVarType, INIT_OUTPUT_VAR_TYPE);
}
Also used : DataOutput(org.eclipse.bpmn2.DataOutput) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) PropertyImpl(org.eclipse.bpmn2.impl.PropertyImpl) InitializedVariable(org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) DataOutputAssociation(org.eclipse.bpmn2.DataOutputAssociation) VariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope) FlatVariableScope(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope) Test(org.junit.Test)

Aggregations

FlatVariableScope (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope)7 Test (org.junit.Test)5 InitializedVariable (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.InitializedVariable)4 VariableScope (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.VariableScope)4 DataOutput (org.eclipse.bpmn2.DataOutput)3 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)3 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)3 Event (org.eclipse.bpmn2.Event)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 PropertyImpl (org.eclipse.bpmn2.impl.PropertyImpl)2 Before (org.junit.Before)2 CatchEventPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter)2 PropertyWriterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)2 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)2 EscalationRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.escalation.EscalationRef)2 LinkRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.link.LinkRef)2 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)2 SignalRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.signal.SignalRef)2 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)2 AdvancedData (org.kie.workbench.common.stunner.bpmn.definition.property.variables.AdvancedData)2