Search in sources :

Example 1 with ConditionExpression

use of org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression 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 2 with ConditionExpression

use of org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression in project kie-wb-common by kiegroup.

the class ConditionalComboBoxFieldRendererTest method initWithDefinitionSet.

@Test
public void initWithDefinitionSet() throws Exception {
    resetMocks();
    SequenceFlow sequenceFlow = new SequenceFlow();
    SequenceFlowExecutionSet sequenceFlowExecutionSet = sequenceFlow.getExecutionSet();
    ConditionExpression conditionExpression = sequenceFlowExecutionSet.getConditionExpression();
    // static mock
    PowerMockito.mockStatic(ClientBindingUtils.class);
    BDDMockito.given(ClientBindingUtils.getProxiedValue(sequenceFlow, "executionSet")).willReturn(sequenceFlowExecutionSet);
    BDDMockito.given(ClientBindingUtils.getProxiedValue(sequenceFlowExecutionSet, "conditionExpression")).willReturn(conditionExpression);
    // instances mock
    when(conditionalComboBoxFieldDefinition.getRelatedField()).thenReturn("executionSet.conditionExpression");
    when(renderingContext.getModel()).thenReturn(null);
    when(renderingContext.getParentContext()).thenReturn(renderingContextParent);
    when(renderingContextParent.getModel()).thenReturn(sequenceFlow);
    when(adapterManager.forProperty()).thenReturn(Mockito.mock(PropertyAdapter.class));
    when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn("value");
    conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
    verify(conditionalComboBoxFieldRenderer, never()).setReadOnly(true);
    verify(conditionalComboBoxFieldRenderer, times(1)).setReadOnly(false);
    when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn("");
    conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
    verify(conditionalComboBoxFieldRenderer, times(1)).setReadOnly(true);
    when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn(null);
    conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
    verify(conditionalComboBoxFieldRenderer, atLeastOnce()).setReadOnly(true);
}
Also used : SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression) PropertyAdapter(org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with ConditionExpression

use of org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression in project kie-wb-common by kiegroup.

the class SequenceFlowConverter method convertEdge.

@Override
public Result<BpmnEdge> convertEdge(org.eclipse.bpmn2.SequenceFlow seq, Map<String, BpmnNode> nodes) {
    Edge<View<SequenceFlow>, Node> edge = factoryManager.newEdge(seq.getId(), SequenceFlow.class);
    SequenceFlow definition = edge.getContent().getDefinition();
    SequenceFlowPropertyReader p = propertyReaderFactory.of(seq);
    definition.setGeneral(new BPMNGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
    definition.setExecutionSet(new SequenceFlowExecutionSet(new Priority(p.getPriority()), new ConditionExpression(p.getConditionExpression())));
    return result(nodes, edge, p, "Sequence Flow ignored from " + p.getSourceId() + " to " + p.getTargetId(), MarshallingMessageKeys.sequenceFlowIgnored);
}
Also used : SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Priority(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.Priority) ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) Node(org.kie.workbench.common.stunner.core.graph.Node) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SequenceFlowPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.SequenceFlowPropertyReader) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Example 4 with ConditionExpression

use of org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression in project kie-wb-common by kiegroup.

the class EventPropertyReader method getConditionExpression.

public static ConditionExpression getConditionExpression(ConditionalEventDefinition conditionalEvent) {
    if (conditionalEvent.getCondition() instanceof FormalExpression) {
        FormalExpression formalExpression = (FormalExpression) conditionalEvent.getCondition();
        String language = Scripts.scriptLanguageFromUri(formalExpression.getLanguage(), Scripts.LANGUAGE.DROOLS.language());
        String script = formalExpression.getBody();
        return new ConditionExpression(new ScriptTypeValue(language, script));
    } else {
        return new ConditionExpression(new ScriptTypeValue(Scripts.LANGUAGE.DROOLS.language(), ""));
    }
}
Also used : ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression) FormalExpression(org.eclipse.bpmn2.FormalExpression) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Example 5 with ConditionExpression

use of org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression in project kie-wb-common by kiegroup.

the class BaseEventPropertyReaderTest method testGetConditionExpressionNotConfigured.

@Test
public void testGetConditionExpressionNotConfigured() {
    ConditionalEventDefinition eventDefinition = mock(ConditionalEventDefinition.class);
    assertEquals(new ConditionExpression(new ScriptTypeValue(Scripts.LANGUAGE.DROOLS.language(), "")), EventPropertyReader.getConditionExpression(eventDefinition));
}
Also used : ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression) ConditionalEventDefinition(org.eclipse.bpmn2.ConditionalEventDefinition) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue) Test(org.junit.Test)

Aggregations

ConditionExpression (org.kie.workbench.common.stunner.bpmn.definition.property.common.ConditionExpression)5 ScriptTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)3 Test (org.junit.Test)2 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)2 SequenceFlowExecutionSet (org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet)2 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)2 BoundaryEvent (org.eclipse.bpmn2.BoundaryEvent)1 CatchEvent (org.eclipse.bpmn2.CatchEvent)1 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)1 Event (org.eclipse.bpmn2.Event)1 FormalExpression (org.eclipse.bpmn2.FormalExpression)1 IntermediateCatchEvent (org.eclipse.bpmn2.IntermediateCatchEvent)1 Before (org.junit.Before)1 BoundaryEventPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BoundaryEventPropertyWriter)1 CatchEventPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.CatchEventPropertyWriter)1 FlatVariableScope (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.FlatVariableScope)1 PropertyWriterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)1 BpmnNode (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)1 SequenceFlowPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.SequenceFlowPropertyReader)1 BaseCatchingIntermediateEvent (org.kie.workbench.common.stunner.bpmn.definition.BaseCatchingIntermediateEvent)1