Search in sources :

Example 1 with CmmnVariableOnPartDeclaration

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method sentryTransformWithSameVariableOnPartTwice.

@Test
public void sentryTransformWithSameVariableOnPartTwice() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    variableOnPart.setVariableEvent(VariableTransition.create);
    variableOnPart.setVariableName("aVariable");
    CamundaVariableOnPart additionalVariableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(additionalVariableOnPart, null, CamundaVariableTransitionEvent.class);
    additionalVariableOnPart.setVariableEvent(VariableTransition.create);
    additionalVariableOnPart.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());
}
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) Test(org.junit.Test)

Example 2 with CmmnVariableOnPartDeclaration

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration 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 3 with CmmnVariableOnPartDeclaration

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method sentryTransformWithMultipleVariableOnPart.

@Test
public void sentryTransformWithMultipleVariableOnPart() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    variableOnPart.setVariableEvent(VariableTransition.create);
    variableOnPart.setVariableName("aVariable");
    CamundaVariableOnPart additionalVariableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(additionalVariableOnPart, null, CamundaVariableTransitionEvent.class);
    additionalVariableOnPart.setVariableEvent(VariableTransition.update);
    additionalVariableOnPart.setVariableName("bVariable");
    CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
    // then
    assertNotNull(sentryDeclaration);
    List<CmmnVariableOnPartDeclaration> variableOnParts = sentryDeclaration.getVariableOnParts();
    assertNotNull(variableOnParts);
    assertFalse(variableOnParts.isEmpty());
    assertEquals(2, variableOnParts.size());
}
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) Test(org.junit.Test)

Example 4 with CmmnVariableOnPartDeclaration

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration in project camunda-bpm-platform by camunda.

the class SentryHandlerTest method sentryTransformWithVariableOnPart.

// variableOnParts
@Test
public void sentryTransformWithVariableOnPart() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    variableOnPart.setVariableEvent(VariableTransition.create);
    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());
    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) Test(org.junit.Test)

Example 5 with CmmnVariableOnPartDeclaration

use of org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration in project camunda-bpm-platform by camunda.

the class SentryHandler method initializeVariableOnPart.

protected void initializeVariableOnPart(CamundaVariableOnPart variableOnPart, CmmnSentryDeclaration sentryDeclaration, CmmnHandlerContext context) {
    VariableTransition variableTransition;
    try {
        variableTransition = variableOnPart.getVariableEvent();
    } catch (IllegalArgumentException illegalArgumentexception) {
        throw LOG.nonMatchingVariableEvents(sentryDeclaration.getId());
    } catch (NullPointerException nullPointerException) {
        throw LOG.nonMatchingVariableEvents(sentryDeclaration.getId());
    }
    String variableName = variableOnPart.getVariableName();
    String variableEventName = variableTransition.name();
    if (variableName != null) {
        if (!sentryDeclaration.hasVariableOnPart(variableEventName, variableName)) {
            CmmnVariableOnPartDeclaration variableOnPartDeclaration = new CmmnVariableOnPartDeclaration();
            variableOnPartDeclaration.setVariableEvent(variableEventName);
            variableOnPartDeclaration.setVariableName(variableName);
            sentryDeclaration.addVariableOnParts(variableOnPartDeclaration);
        }
    } else {
        throw LOG.emptyVariableName(sentryDeclaration.getId());
    }
}
Also used : CmmnVariableOnPartDeclaration(org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration) VariableTransition(org.camunda.bpm.model.cmmn.VariableTransition)

Aggregations

CmmnVariableOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration)6 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)5 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)4 CamundaVariableOnPart (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart)4 Test (org.junit.Test)4 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)1 CmmnIfPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnIfPartDeclaration)1 CmmnOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnOnPartDeclaration)1 VariableTransition (org.camunda.bpm.model.cmmn.VariableTransition)1 CamundaVariableTransitionEvent (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent)1