Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare 8.5 #818

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public class UserTaskConversion extends AbstractTypedConversion<UserTaskConverti
@Override
protected void convertTyped(DomElement element, UserTaskConvertible convertible) {
DomElement extensionElements = getExtensionElements(element);
if (convertible.isZeebeUserTask()) {
extensionElements.appendChild(createZeebeUserTask(element.getDocument()));
}
if (canAddFormDefinition(convertible)) {
extensionElements.appendChild(createFormDefinition(element.getDocument(), convertible));
}
Expand All @@ -22,6 +25,10 @@ protected void convertTyped(DomElement element, UserTaskConvertible convertible)
}
}

private DomElement createZeebeUserTask(DomDocument document) {
return document.createElement(ZEEBE, "userTask");
}

private DomElement createTaskSchedule(DomDocument document, UserTaskConvertible convertible) {
DomElement taskSchedule = document.createElement(ZEEBE, "taskSchedule");
taskSchedule.setAttribute("dueDate", convertible.getZeebeTaskSchedule().getDueDate());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.camunda.community.migration.converter.convertible;

public class UserTaskConvertible extends AbstractActivityConvertible {
private boolean zeebeUserTask;
private final ZeebeFormDefinition zeebeFormDefinition = new ZeebeFormDefinition();
private final ZeebeAssignmentDefinition zeebeAssignmentDefinition =
new ZeebeAssignmentDefinition();
Expand All @@ -18,6 +19,14 @@ public ZeebeAssignmentDefinition getZeebeAssignmentDefinition() {
return zeebeAssignmentDefinition;
}

public boolean isZeebeUserTask() {
return zeebeUserTask;
}

public void setZeebeUserTask(boolean zeebeUserTask) {
this.zeebeUserTask = zeebeUserTask;
}

public static class ZeebeFormDefinition {
private String formKey;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ public enum SemanticVersion {
_8_1("8.1"),
_8_2("8.2"),
_8_3("8.3"),
_8_4("8.4");
_8_4("8.4"),
_8_5("8.5");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.camunda.community.migration.converter.DomElementVisitorContext;
import org.camunda.community.migration.converter.message.MessageFactory;
import org.camunda.community.migration.converter.version.SemanticVersion;
import org.camunda.community.migration.converter.visitor.AbstractBpmnAttributeVisitor;

public class IsForCompensationVisitor extends AbstractBpmnAttributeVisitor {
Expand All @@ -12,7 +13,9 @@ public String attributeLocalName() {

@Override
protected void visitAttribute(DomElementVisitorContext context, String attribute) {
if (Boolean.parseBoolean(attribute)) {
if (Boolean.parseBoolean(attribute)
&& SemanticVersion.parse(context.getProperties().getPlatformVersion()).ordinal()
< SemanticVersion._8_5.ordinal()) {
context.addMessage(
MessageFactory.elementNotSupportedHint(
"Compensation Task", context.getProperties().getPlatformVersion()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,14 @@ protected Convertible createConvertible(DomElementVisitorContext context) {
protected SemanticVersion availableFrom(DomElementVisitorContext context) {
return SemanticVersion._8_0;
}

@Override
protected void postCreationVisitor(DomElementVisitorContext context) {
if (SemanticVersion.parse(context.getProperties().getPlatformVersion()).ordinal()
>= SemanticVersion._8_5.ordinal()) {
context.addConversion(UserTaskConvertible.class, c -> c.setZeebeUserTask(true));
} else {
context.addConversion(UserTaskConvertible.class, c -> c.setZeebeUserTask(false));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public String localName() {

@Override
protected SemanticVersion availableFrom(DomElementVisitorContext context) {
if (isNotEventSubProcessStartEvent(context.getElement())) {
return SemanticVersion._8_5;
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ zeebe-header.resource=resource
## Script format
zeebe-header.script-format=language
# Zeebe Meta Information
zeebe-platform.version=8.4
zeebe-platform.version=8.5
# Flags
## Enable Default Job Type usage
flag.default-job-type-enabled=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,4 +594,23 @@ void testMessageEventDefinitionOnThrowEvents() {
.getTextContent())
.isEqualTo("CatchEvent");
}

@Test
void testZeebeUserTask() {
BpmnModelInstance modelInstance = loadAndConvert("example-c7_2.bpmn");
DomElement userTask = modelInstance.getDocument().getElementById("Activity_1b9oq8z");
assertThat(userTask).isNotNull();
DomElement extensionElements =
userTask.getChildElementsByNameNs(BPMN, "extensionElements").get(0);
DomElement zeebeUserTask = extensionElements.getChildElementsByNameNs(ZEEBE, "userTask").get(0);
assertThat(zeebeUserTask).isNotNull();
}

@Test
void testZeebeUserTask_pre_8_5() {
BpmnModelInstance modelInstance = loadAndConvert("example-c7_2.bpmn", "8.4");
DomElement userTask = modelInstance.getDocument().getElementById("Activity_1b9oq8z");
assertThat(userTask).isNotNull();
assertThat(userTask.getChildElementsByNameNs(BPMN, "extensionElements")).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ Stream<DynamicTest> testCompensationEvents() {
return eventTypeTest(
"Compensation",
null,
isNotSupported(result, "CompensationThrowEvent", "Compensate Intermediate Throw Event"),
isSupported(result, "CompensationThrowEvent"),
null,
isNotSupported(result, "CompensationEndEndEvent", "Compensate End Event"),
isNotSupported(result, "CompensationAttachedBoundaryEvent", "Compensate Boundary Event"),
isSupported(result, "CompensationEndEndEvent"),
isSupported(result, "CompensationAttachedBoundaryEvent"),
null,
isNotSupported(
result,
Expand Down Expand Up @@ -253,8 +253,7 @@ Stream<DynamicTest> testMarkers() {
dynamicTest("Sequential Task", isSupported(result, "SequentialTask")),
dynamicTest(
"Loop Task", isNotSupported(result, "LoopTask", "Standard Loop Characteristics")),
dynamicTest(
"Compensation Task", isNotSupported(result, "CompensationTask", "Compensation Task")));
dynamicTest("Compensation Task", isSupported(result, "CompensationTask")));
}

@TestFactory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ public static BpmnModelInstance loadAndConvert(String bpmnFile) {
return modelInstance;
}

public static BpmnModelInstance loadAndConvert(String bpmnFile, String targetVersion) {
BpmnModelInstance modelInstance = loadModelInstance(bpmnFile);
BpmnConverter converter = BpmnConverterFactory.getInstance().get();
DefaultConverterProperties properties = new DefaultConverterProperties();
properties.setPlatformVersion(targetVersion);
converter.convert(modelInstance, ConverterPropertiesFactory.getInstance().merge(properties));
return modelInstance;
}

public static BpmnDiagramCheckResult loadAndCheck(String bpmnFile) {
ConverterProperties properties = ConverterPropertiesFactory.getInstance().get();
return loadAndCheckAgainstVersion(bpmnFile, properties.getPlatformVersion());
Expand Down
Loading