Skip to content

Commit

Permalink
Add .listIdsPage() to support fetching ids in pages only
Browse files Browse the repository at this point in the history
  • Loading branch information
amporsim committed Dec 4, 2023
1 parent 949fbbb commit 784ce8a
Show file tree
Hide file tree
Showing 36 changed files with 295 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,30 @@ public void testQueryNoParams() {
public void testQueryByDeploymentId() {
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId1).list()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId1).listIds()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId1).listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId1).count()).isEqualTo(1);

assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId2).list()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId2).listIds()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId2).listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId2).count()).isEqualTo(1);

assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId3).list()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId3).listIds()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId3).listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId3).count()).isEqualTo(1);

assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId4).list()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId4).listIds()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId4).listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId(deploymentId4).count()).isEqualTo(1);
}

@Test
public void testQueryByInvalidDeploymentId() {
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId("invalid").list()).isEmpty();
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId("invalid").listIds()).isEmpty();
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId("invalid").listIdsPage(0, 10)).isEmpty();
assertThat(appRepositoryService.createAppDefinitionQuery().deploymentId("invalid").count()).isZero();
}

Expand Down Expand Up @@ -228,10 +233,12 @@ public void testQueryByAppDefinitionCategoryNotEquals() {
public void testQueryByAppDefinitionName() {
assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Test app").list()).hasSize(3);
assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Test app").listIds()).hasSize(3);
assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Test app").listIdsPage(0, 10)).hasSize(3);
assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Test app").count()).isEqualTo(3);

assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Full info app").list()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Full info app").listIds()).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Full info app").listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Full info app").count()).isEqualTo(1);

assertThat(appRepositoryService.createAppDefinitionQuery().appDefinitionName("Full info app").singleResult().getDeploymentId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,17 @@ public void deleteTestDeployments() {
public void testQueryNoParams() {
assertThat(appRepositoryService.createDeploymentQuery().list()).hasSize(2);
assertThat(appRepositoryService.createDeploymentQuery().listIds()).hasSize(2);
assertThat(appRepositoryService.createDeploymentQuery().listIdsPage(0, 10)).hasSize(2);
assertThat(appRepositoryService.createDeploymentQuery().count()).isEqualTo(2);

assertThat(appRepositoryService.createDeploymentQuery().list())
.extracting(AppDeployment::getId)
.containsExactlyInAnyOrder(deploymentId1, deploymentId2);
.extracting(AppDeployment::getId)
.containsExactlyInAnyOrder(deploymentId1, deploymentId2);

assertThat(appRepositoryService.createDeploymentQuery().listIds())
.containsExactlyInAnyOrder(deploymentId1, deploymentId2);
assertThat(appRepositoryService.createDeploymentQuery().listIdsPage(0, 10))
.containsExactlyInAnyOrder(deploymentId1, deploymentId2);
}

@Test
Expand All @@ -76,11 +79,13 @@ public void testQueryByDeploymentId() {
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId1).singleResult().getId()).isEqualTo(deploymentId1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId1).list()).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId1).listIds()).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId1).listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId1).count()).isEqualTo(1);

assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId2).singleResult()).isNotNull();
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId2).list()).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId2).listIds()).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId2).listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentId(deploymentId2).count()).isEqualTo(1);
}

Expand All @@ -89,13 +94,16 @@ public void testQueryByInvalidDeploymentId() {
assertThat(appRepositoryService.createDeploymentQuery().deploymentId("invalid").singleResult()).isNull();
assertThat(appRepositoryService.createDeploymentQuery().deploymentId("invalid").list()).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentId("invalid").listIds()).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentId("invalid").listIdsPage(0, 10)).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentId("invalid").count()).isZero();
}

@Test
public void testQueryByDeploymentIds() {
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Arrays.asList(deploymentId1, deploymentId2, "dummy")).list()).hasSize(2);
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Arrays.asList(deploymentId1, deploymentId2, "dummy")).listIds()).hasSize(2);
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Arrays.asList(deploymentId1, deploymentId2, "dummy")).listIdsPage(0, 10)).hasSize(
2);
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Arrays.asList(deploymentId2, "dummy")).singleResult()).isNotNull();
}

Expand All @@ -104,6 +112,7 @@ public void testQueryByInvalidDeploymentIds() {
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Collections.singletonList("invalid")).singleResult()).isNull();
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Collections.singletonList("invalid")).list()).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Collections.singletonList("invalid")).listIds()).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Collections.singletonList("invalid")).listIdsPage(0, 10)).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentIds(Collections.singletonList("invalid")).count()).isZero();
assertThatThrownBy(() -> appRepositoryService.createDeploymentQuery().deploymentIds(null))
.isInstanceOf(FlowableIllegalArgumentException.class)
Expand Down Expand Up @@ -131,11 +140,13 @@ public void testQueryByDeploymentNameLike() {
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("test%").singleResult().getId()).isEqualTo(deploymentId2);
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("test%").list()).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("test%").listIds()).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("test%").listIdsPage(0, 10)).hasSize(1);
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("test%").count()).isEqualTo(1);

assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("inval%").singleResult()).isNull();
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("inval%").list()).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("inval%").listIds()).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("inval%").listIdsPage(0, 10)).isEmpty();
assertThat(appRepositoryService.createDeploymentQuery().deploymentNameLike("inval%").count()).isZero();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,9 @@ public List<HistoricVariableInstance> listPage(int firstResult, int maxResults)
return wrappedHistoricVariableInstanceQuery.listPage(firstResult, maxResults);
}

@Override
public List<String> listIdsPage(int firstResult, int maxResults) {
return wrappedHistoricVariableInstanceQuery.listIdsPage(firstResult, maxResults);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,9 @@ public List<VariableInstance> listPage(int firstResult, int maxResults) {
return wrappedVariableInstanceQuery.listPage(firstResult, maxResults);
}

@Override
public List<String> listIdsPage(int firstResult, int maxResults) {
return wrappedVariableInstanceQuery.listIdsPage(firstResult, maxResults);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ public List<GenericEventListenerInstance> listPage(int firstResult, int maxResul
return convertPlanItemInstances(innerQuery.listPage(firstResult, maxResults));
}

@Override
public List<String> listIdsPage(int firstResult, int maxResults) {
return innerQuery.listIdsPage(firstResult, maxResults);
}

protected List<GenericEventListenerInstance> convertPlanItemInstances(List<PlanItemInstance> instances) {
if (instances == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ public List<SignalEventListenerInstance> listPage(int firstResult, int maxResult
return convertPlanItemInstances(innerQuery.listPage(firstResult, maxResults));
}

@Override
public List<String> listIdsPage(int firstResult, int maxResults) {
return innerQuery.listIdsPage(firstResult, maxResults);
}

protected List<SignalEventListenerInstance> convertPlanItemInstances(List<PlanItemInstance> instances) {
if (instances == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public List<UserEventListenerInstance> listPage(int firstResult, int maxResults)
return convertPlanItemInstances(innerQuery.listPage(firstResult, maxResults));
}

@Override
public List<String> listIdsPage(int firstResult, int maxResults) {
return innerQuery.listIdsPage(firstResult, maxResults);
}

protected List<UserEventListenerInstance> convertPlanItemInstances(List<PlanItemInstance> instances) {
if (instances == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public void testByCaseDefinitionId() {
if (CmmnHistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, cmmnEngineConfiguration)) {
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().list()).hasSize(20);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().listIds()).hasSize(20);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().listIdsPage(0, 100)).hasSize(20);
}
}

Expand All @@ -65,6 +66,8 @@ public void testByCaseInstanceId() {
if (CmmnHistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, cmmnEngineConfiguration)) {
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstanceId).list()).hasSize(4);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstanceId).listIds()).hasSize(4);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceCaseInstanceId(caseInstanceId).listIdsPage(0, 10)).hasSize(
4);
}
}
}
Expand All @@ -79,6 +82,8 @@ public void testByStageInstanceId() {
.singleResult();
assertThat(planItemInstance).isNotNull();
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceStageInstanceId(planItemInstance.getId()).listIds()).hasSize(2);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceStageInstanceId(planItemInstance.getId())
.listIdsPage(0, 10)).hasSize(2);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceStageInstanceId(planItemInstance.getId()).count()).isEqualTo(2);
}
}
Expand All @@ -91,6 +96,7 @@ public void testByPlanItemInstanceId() {
List<HistoricPlanItemInstance> planItemInstances = cmmnHistoryService.createHistoricPlanItemInstanceQuery().list();
for (HistoricPlanItemInstance planItemInstance : planItemInstances) {
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceId(planItemInstance.getId()).listIds()).hasSize(1);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceId(planItemInstance.getId()).listIdsPage(0, 10)).hasSize(1);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceId(planItemInstance.getId()).count()).isEqualTo(1);
}
}
Expand All @@ -102,6 +108,7 @@ public void testByElementId() {

if (CmmnHistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, cmmnEngineConfiguration)) {
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceElementId("planItem3").listIds()).hasSize(4);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceElementId("planItem3").listIdsPage(0, 10)).hasSize(4);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceElementId("planItem3").list()).hasSize(4);
}
}
Expand All @@ -112,6 +119,7 @@ public void testByName() {

if (CmmnHistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, cmmnEngineConfiguration)) {
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceName("B").listIds()).hasSize(9);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceName("B").listIdsPage(0, 10)).hasSize(9);
assertThat(cmmnHistoryService.createHistoricPlanItemInstanceQuery().planItemInstanceName("B").list()).hasSize(9);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void testQueryByNoCriteria() {
.extracting(ExternalWorkerJob::getScopeId)
.containsOnly(caseInstance.getId());
assertThat(query.listIds()).hasSize(2);
assertThat(query.listIdsPage(0, 10)).hasSize(2);
}

@Test
Expand All @@ -72,19 +73,22 @@ public void testQueryByCaseInstanceId() {
.extracting(ExternalWorkerJob::getScopeId)
.containsOnly(caseInstance1.getId());
assertThat(query.listIds()).hasSize(2);
assertThat(query.listIdsPage(0, 10)).hasSize(2);

query = cmmnManagementService.createExternalWorkerJobQuery().caseInstanceId(caseInstance2.getId());
assertThat(query.count()).isEqualTo(2);
assertThat(query.list())
.extracting(ExternalWorkerJob::getScopeId)
.containsOnly(caseInstance2.getId());
assertThat(query.listIds()).hasSize(2);
assertThat(query.listIdsPage(0, 10)).hasSize(2);

query = cmmnManagementService.createExternalWorkerJobQuery().caseInstanceId("invalid");
assertThat(query.count()).isZero();
assertThat(query.list()).isEmpty();
assertThat(query.singleResult()).isNull();
assertThat(query.listIds()).isEmpty();
assertThat(query.listIdsPage(0, 10)).isEmpty();
}

@Test
Expand All @@ -106,6 +110,7 @@ public void testQueryByCaseDefinitionId() {
assertThat(query.count()).isZero();
assertThat(query.list()).isEmpty();
assertThat(query.listIds()).isEmpty();
assertThat(query.listIdsPage(0, 10)).isEmpty();
assertThat(query.singleResult()).isNull();
}

Expand Down
Loading

0 comments on commit 784ce8a

Please sign in to comment.