Search in sources :

Example 1 with CamundaVariableTransitionEvent

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method sentryTransformWithMultipleVariableEvent.

@Test
public void sentryTransformWithMultipleVariableEvent() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    CamundaVariableTransitionEvent transitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    transitionEvent.setTextContent("create");
    CamundaVariableTransitionEvent additionalTransitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    additionalTransitionEvent.setTextContent("delete");
    variableOnPart.setVariableName("aVariable");
    CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
    // then
    assertNotNull(sentryDeclaration);
    List<CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.getVariableOnParts();
    assertNotNull(variableOnParts);
    assertFalse(variableOnParts.isEmpty());
    assertEquals(1, variableOnParts.size());
    CmmnVariableOnPartDeclaration transformedVariableOnPart = variableOnParts.get(0);
    assertEquals("aVariable", transformedVariableOnPart.getVariableName());
    // when there are multiple variable events then, only first variable event is considered.
    assertEquals(VariableTransition.create.name(), transformedVariableOnPart.getVariableEvent());
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) CmmnSentryDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration) CmmnVariableOnPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration) CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) CamundaVariableTransitionEvent(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent) Test(org.junit.Test)

Example 2 with CamundaVariableTransitionEvent

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method sentryTransformShouldFailWithInvalidVariableEvent.

@Test
public void sentryTransformShouldFailWithInvalidVariableEvent() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    CamundaVariableTransitionEvent transitionEvent = createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    transitionEvent.setTextContent("invalid");
    variableOnPart.setVariableName("aVariable");
    thrown.expect(CmmnTransformException.class);
    thrown.expectMessage("The variableOnPart of the sentry with id 'aSentry' must have one valid variable event.");
    sentryHandler.handleElement(sentry, context);
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) CamundaVariableTransitionEvent(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent) Test(org.junit.Test)

Example 3 with CamundaVariableTransitionEvent

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent in project camunda-cmmn-model by camunda.

the class CamundaVariableOnPartImpl method setVariableEvent.

public void setVariableEvent(VariableTransition variableTransition) {
    CamundaVariableTransitionEvent child = camundaVariableEventChild.getChild(this);
    child.setValue(variableTransition);
}
Also used : CamundaVariableTransitionEvent(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent)

Example 4 with CamundaVariableTransitionEvent

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent in project camunda-cmmn-model by camunda.

the class CamundaVariableTransitionEventImpl method registerType.

public static void registerType(ModelBuilder modelBuilder) {
    ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(CamundaVariableTransitionEvent.class, CAMUNDA_ELEMENT_VARIABLE_EVENT).namespaceUri(CAMUNDA_NS).instanceProvider(new ModelTypeInstanceProvider<CamundaVariableTransitionEvent>() {

        public CamundaVariableTransitionEvent newInstance(ModelTypeInstanceContext instanceContext) {
            return new CamundaVariableTransitionEventImpl(instanceContext);
        }
    });
    typeBuilder.build();
}
Also used : ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) CamundaVariableTransitionEvent(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Aggregations

CamundaVariableTransitionEvent (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent)4 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)2 CamundaVariableOnPart (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart)2 Test (org.junit.Test)2 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)1 CmmnVariableOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1