Skip to content

Commit

Permalink
Expose filtering by caseDefinitionIds
Browse files Browse the repository at this point in the history
  • Loading branch information
amporsim committed Sep 12, 2023
1 parent 2a6445e commit 255824f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public interface CaseInstanceQuery extends Query<CaseInstanceQuery, CaseInstance
CaseInstanceQuery caseDefinitionKey(String caseDefinitionKey);
CaseInstanceQuery caseDefinitionKeys(Set<String> caseDefinitionKeys);
CaseInstanceQuery caseDefinitionId(String caseDefinitionId);
CaseInstanceQuery caseDefinitionIds(Set<String> caseDefinitionIds);
CaseInstanceQuery caseDefinitionCategory(String caseDefinitionCategory);
CaseInstanceQuery caseDefinitionName(String caseDefinitionName);
CaseInstanceQuery caseDefinitionVersion(Integer caseDefinitionVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ public CaseInstanceQueryImpl caseDefinitionId(String caseDefinitionId) {
return this;
}

@Override
public CaseInstanceQueryImpl caseDefinitionIds(Set<String> caseDefinitionIds) {
if (caseDefinitionIds == null) {
throw new FlowableIllegalArgumentException("Case definition ids is null");
}

if (inOrStatement) {
this.currentOrQueryObject.caseDefinitionIds = caseDefinitionIds;
} else {
this.caseDefinitionIds = caseDefinitionIds;
}
return this;
}

@Override
public CaseInstanceQueryImpl caseDefinitionKey(String caseDefinitionKey) {
if (caseDefinitionKey == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void createCase() {
this.deploymentId = addDeploymentForAutoCleanup(cmmnRepositoryService.createDeployment()
.addClasspathResource("org/flowable/cmmn/test/runtime/CaseTaskTest.testBasicBlocking.cmmn")
.addClasspathResource("org/flowable/cmmn/test/runtime/oneTaskCase.cmmn")
.addClasspathResource("org/flowable/cmmn/test/runtime/oneHumanTaskCase.cmmn")
.deploy());

cmmnRuntimeService.createCaseInstanceBuilder()
Expand Down Expand Up @@ -206,6 +207,39 @@ public void getCaseInstanceByCaseDefinitionId() {
.singleResult().getId()).isEqualTo(caseInstance.getId());
}

@Test
public void getCaseInstanceByCaseDefinitionIds() {
CaseInstance caseInstance1 = cmmnRuntimeService.createCaseInstanceBuilder()
.caseDefinitionKey("oneTaskCase")
.start();

CaseInstance caseInstance2 = cmmnRuntimeService.createCaseInstanceBuilder()
.caseDefinitionKey("oneHumanTaskCase")
.start();

assertThat(cmmnRuntimeService.createCaseInstanceQuery()
.caseDefinitionIds(Set.of(caseInstance1.getCaseDefinitionId(), caseInstance2.getCaseDefinitionId()))
.list())
.extracting(CaseInstance::getId)
.containsExactlyInAnyOrder(caseInstance1.getId(), caseInstance2.getId());

assertThat(cmmnRuntimeService.createCaseInstanceQuery()
.caseDefinitionIds(Set.of(caseInstance1.getCaseDefinitionId(), caseInstance2.getCaseDefinitionId()))
.caseInstanceId(caseInstance1.getId())
.list())
.extracting(CaseInstance::getId)
.containsExactlyInAnyOrder(caseInstance1.getId());

assertThat(cmmnRuntimeService.createCaseInstanceQuery()
.or()
.caseDefinitionIds(Set.of(caseInstance1.getCaseDefinitionId(), caseInstance2.getCaseDefinitionId()))
.caseInstanceId("undefinedId")
.endOr()
.list())
.extracting(CaseInstance::getId)
.containsExactlyInAnyOrder(caseInstance1.getId(), caseInstance2.getId());
}

@Test
public void getCaseInstanceByCaseDefinitionVersion() {
cmmnRuntimeService.createCaseInstanceBuilder()
Expand Down

0 comments on commit 255824f

Please sign in to comment.