Skip to content

Commit

Permalink
add pre- and post upgrade expressions to migration builder (#3871)
Browse files Browse the repository at this point in the history
  • Loading branch information
vzickner authored Apr 12, 2024
1 parent f502b07 commit f10aa6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public CaseInstanceMigrationBuilder fromCaseInstanceMigrationDocument(CaseInstan
this.caseInstanceMigrationDocumentDocumentBuilder.addWaitingForRepetitionPlanItemDefinitionMappings(caseInstanceMigrationDocument.getWaitingForRepetitionPlanItemDefinitionMappings());
this.caseInstanceMigrationDocumentDocumentBuilder.addRemoveWaitingForRepetitionPlanItemDefinitionMappings(caseInstanceMigrationDocument.getRemoveWaitingForRepetitionPlanItemDefinitionMappings());
this.caseInstanceMigrationDocumentDocumentBuilder.addCaseInstanceVariables(caseInstanceMigrationDocument.getCaseInstanceVariables());
this.caseInstanceMigrationDocumentDocumentBuilder.preUpgradeExpression(caseInstanceMigrationDocument.getPreUpgradeExpression());
this.caseInstanceMigrationDocumentDocumentBuilder.postUpgradeExpression(caseInstanceMigrationDocument.getPostUpgradeExpression());
return this;
}

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

package org.flowable.cmmn.test.migration;

import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.flowable.cmmn.converter.CmmnXmlConstants.ELEMENT_STAGE;
Expand All @@ -27,6 +28,7 @@
import org.flowable.cmmn.api.history.HistoricMilestoneInstance;
import org.flowable.cmmn.api.history.HistoricPlanItemInstance;
import org.flowable.cmmn.api.migration.ActivatePlanItemDefinitionMapping;
import org.flowable.cmmn.api.migration.CaseInstanceMigrationDocument;
import org.flowable.cmmn.api.migration.ChangePlanItemIdMapping;
import org.flowable.cmmn.api.migration.ChangePlanItemIdWithDefinitionIdMapping;
import org.flowable.cmmn.api.migration.PlanItemDefinitionMappingBuilder;
Expand All @@ -38,6 +40,7 @@
import org.flowable.cmmn.api.runtime.PlanItemInstance;
import org.flowable.cmmn.api.runtime.PlanItemInstanceState;
import org.flowable.cmmn.api.runtime.UserEventListenerInstance;
import org.flowable.cmmn.engine.impl.migration.CaseInstanceMigrationDocumentConverter;
import org.flowable.cmmn.engine.impl.persistence.entity.SentryPartInstanceEntity;
import org.flowable.cmmn.engine.test.impl.CmmnHistoryTestHelper;
import org.flowable.common.engine.api.FlowableException;
Expand Down Expand Up @@ -5847,6 +5850,32 @@ void withCaseTaskWhichWillBeTerminated() {
assertThat(subcaseInstances).isEqualTo(0);
}

@Test
void testCaseInstanceMigrationDocument() {
String documentAsJson = this.cmmnMigrationService.createCaseInstanceMigrationBuilder()
.addTerminatePlanItemDefinitionMapping(
PlanItemDefinitionMappingBuilder.createTerminatePlanItemDefinitionMappingFor("terminateId", "${terminateCondition}"))
.addMoveToAvailablePlanItemDefinitionMapping(
PlanItemDefinitionMappingBuilder.createMoveToAvailablePlanItemDefinitionMappingFor("availableId", "${availableCondition}"))
.addWaitingForRepetitionPlanItemDefinitionMapping(
PlanItemDefinitionMappingBuilder.createWaitingForRepetitionPlanItemDefinitionMappingFor("repetitionId", "${repetitionCondition}"))
.removeWaitingForRepetitionPlanItemDefinitionMapping(
PlanItemDefinitionMappingBuilder.createRemoveWaitingForRepetitionPlanItemDefinitionMappingFor("removeRepetitionId",
"${removeRepetitionCondition}"))
.addActivatePlanItemDefinitionMapping(
PlanItemDefinitionMappingBuilder.createActivatePlanItemDefinitionMappingFor("activateId", "${activateCondition}"))
.withPreUpgradeExpression("${preExpression}")
.withPostUpgradeExpression("${postExpression}")
.getCaseInstanceMigrationDocument()
.asJsonString();
CaseInstanceMigrationDocument caseInstanceMigrationDocumentFromString = CaseInstanceMigrationDocumentConverter.convertFromJson(documentAsJson);
String documentAsJsonConverted = this.cmmnMigrationService.createCaseInstanceMigrationBuilderFromCaseInstanceMigrationDocument(
caseInstanceMigrationDocumentFromString)
.getCaseInstanceMigrationDocument()
.asJsonString();
assertThatJson(documentAsJsonConverted).isEqualTo(documentAsJson);
}

protected class CustomTenantProvider implements DefaultTenantProvider {

@Override
Expand Down

0 comments on commit f10aa6c

Please sign in to comment.