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());
}
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());
}
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());
}
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());
}
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());
}
}
Aggregations