Skip to content

Commit

Permalink
Do not perform Cmmn Validation on already deployed models
Browse files Browse the repository at this point in the history
This aligns the CmmnDeployer with the BpmnDeployer
  • Loading branch information
filiphr authored and tijsrademakers committed Sep 25, 2024
1 parent 4523da9 commit 4d448b2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void deploy(EngineDeployment deployment, Map<String, Object> deploymentSe
for (EngineResource resource : deployment.getResources().values()) {
if (isCmmnResource(resource.getName())) {
LOGGER.debug("Processing CMMN resource {}", resource.getName());
parseResult.merge(cmmnParser.parse(new CmmnParseContextImpl(resource)));
parseResult.merge(cmmnParser.parse(new CmmnParseContextImpl(resource, deployment.isNew())));
}
}

Expand Down Expand Up @@ -407,9 +407,11 @@ public void setUsePrefixId(boolean usePrefixId) {
protected class CmmnParseContextImpl implements CmmnParseContext {

protected final EngineResource resource;
protected final boolean newDeployment;

public CmmnParseContextImpl(EngineResource resource) {
public CmmnParseContextImpl(EngineResource resource, boolean newDeployment) {
this.resource = resource;
this.newDeployment = newDeployment;
}

@Override
Expand All @@ -434,7 +436,8 @@ public boolean validateXml() {

@Override
public boolean validateCmmnModel() {
return validateXml();
// On redeploy, we assume it is validated at the first deploy
return newDeployment && validateXml();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.flowable.cmmn.engine.test.FlowableCmmnTestCase;
import org.flowable.cmmn.model.CmmnModel;
import org.flowable.cmmn.model.PlanItem;
import org.flowable.cmmn.validation.CaseValidator;
import org.flowable.cmmn.validation.CaseValidatorImpl;
import org.flowable.common.engine.api.FlowableException;
import org.flowable.common.engine.impl.persistence.deploy.DefaultDeploymentCache;
import org.flowable.common.engine.impl.persistence.deploy.DeploymentCache;
Expand Down Expand Up @@ -191,6 +193,39 @@ public void deployingCaseModelWithErrorsShouldFail() {
assertThat(cmmnRepositoryService.createCaseDefinitionQuery().list()).isEmpty();
}

@Test
public void alreadyDeployedCaseModelWithErrorsShouldNotFail() {
CaseValidator originalValidator = cmmnEngineConfiguration.getCaseValidator();

try {
// We disable all the validations so we can test this
cmmnEngineConfiguration.setCaseValidator(new CaseValidatorImpl());

org.flowable.cmmn.api.repository.CmmnDeployment cmmnDeployment = cmmnRepositoryService.createDeployment()
.addClasspathResource("org/flowable/cmmn/test/repository/DeploymentTest.testCaseDefinitionWithErrors.cmmn")
.deploy();
autoCleanupDeploymentIds.add(cmmnDeployment.getId());
CaseDefinition caseDefinition = cmmnRepositoryService.createCaseDefinitionQuery()
.caseDefinitionKey("myCase")
.singleResult();
assertThat(caseDefinition).isNotNull();

cmmnEngineConfiguration.setCaseValidator(originalValidator);

// remove it from the cache to force parsing it again
cmmnEngineConfiguration.getDeploymentManager()
.getCaseDefinitionCache()
.clear();

CmmnModel cmmnModel = cmmnRepositoryService.getCmmnModel(caseDefinition.getId());

assertThat(cmmnModel).isNotNull();

} finally {
cmmnEngineConfiguration.setCaseValidator(originalValidator);
}
}

@Test
public void deployingCaseModelWithWarningsShouldNotFail() {
org.flowable.cmmn.api.repository.CmmnDeployment deployment = null;
Expand Down

0 comments on commit 4d448b2

Please sign in to comment.