Search in sources :

Example 6 with CamundaVariableOnPart

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

the class SentryHandlerTest method sentryTransformShouldFailWithMissingVariableName.

@Test
public void sentryTransformShouldFailWithMissingVariableName() {
    // given
    ExtensionElements extensionElements = createElement(sentry, "extensionElements", ExtensionElements.class);
    CamundaVariableOnPart variableOnPart = createElement(extensionElements, null, CamundaVariableOnPart.class);
    createElement(variableOnPart, null, CamundaVariableTransitionEvent.class);
    variableOnPart.setVariableEvent(VariableTransition.create);
    thrown.expect(CmmnTransformException.class);
    thrown.expectMessage("The variableOnPart of the sentry with id 'aSentry' must have variable name.");
    sentryHandler.handleElement(sentry, context);
}
Also used : ExtensionElements(org.camunda.bpm.model.cmmn.instance.ExtensionElements) CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) Test(org.junit.Test)

Example 7 with CamundaVariableOnPart

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart 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 8 with CamundaVariableOnPart

use of org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart 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 9 with CamundaVariableOnPart

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

the class CamundaVariableOnPartImpl method registerType.

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

        public CamundaVariableOnPart newInstance(ModelTypeInstanceContext instanceContext) {
            return new CamundaVariableOnPartImpl(instanceContext);
        }
    });
    camundaVariableNameAttribute = typeBuilder.stringAttribute(CAMUNDA_ATTRIBUTE_VARIABLE_NAME).namespace(CAMUNDA_NS).build();
    SequenceBuilder sequenceBuilder = typeBuilder.sequence();
    camundaVariableEventChild = sequenceBuilder.element(CamundaVariableTransitionEvent.class).build();
    typeBuilder.build();
}
Also used : SequenceBuilder(org.camunda.bpm.model.xml.type.child.SequenceBuilder) CamundaVariableOnPart(org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart) ModelElementTypeBuilder(org.camunda.bpm.model.xml.type.ModelElementTypeBuilder) ModelTypeInstanceContext(org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)

Aggregations

CamundaVariableOnPart (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableOnPart)9 ExtensionElements (org.camunda.bpm.model.cmmn.instance.ExtensionElements)7 Test (org.junit.Test)7 CmmnSentryDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration)5 CmmnVariableOnPartDeclaration (org.camunda.bpm.engine.impl.cmmn.model.CmmnVariableOnPartDeclaration)4 CamundaVariableTransitionEvent (org.camunda.bpm.model.cmmn.instance.camunda.CamundaVariableTransitionEvent)2 CmmnActivity (org.camunda.bpm.engine.impl.cmmn.model.CmmnActivity)1 CaseFileItemOnPart (org.camunda.bpm.model.cmmn.instance.CaseFileItemOnPart)1 IfPart (org.camunda.bpm.model.cmmn.instance.IfPart)1 OnPart (org.camunda.bpm.model.cmmn.instance.OnPart)1 PlanItemOnPart (org.camunda.bpm.model.cmmn.instance.PlanItemOnPart)1 ModelTypeInstanceContext (org.camunda.bpm.model.xml.impl.instance.ModelTypeInstanceContext)1 ModelElementTypeBuilder (org.camunda.bpm.model.xml.type.ModelElementTypeBuilder)1 SequenceBuilder (org.camunda.bpm.model.xml.type.child.SequenceBuilder)1