Skip to content

Commit

Permalink
Implement PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PHWaechtler committed Feb 14, 2025
1 parent 101f952 commit 0f20c65
Showing 1 changed file with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ public void testHistoricProcessInstanceQueryWithJobsRetrying() {
runtimeService.startProcessInstanceByKey("processWithJobsRetrying");

// then
assertEquals(0, queryWithJobsRetrying.count());
assertThat(queryWithJobsRetrying.count()).isZero();
assertThat(queryWithJobsRetrying.list()).isEmpty();

// when we have 1 instance with a job that has an exception and retries left
Expand All @@ -576,19 +576,42 @@ public void testHistoricProcessInstanceQueryWithJobsRetrying() {
executeFailingJob(failingJob);

// then
assertEquals(1, queryWithJobsRetrying.count());
assertEquals(1, queryWithJobsRetrying.list().size());
assertEquals(instanceWithRetryingJob.getId(), queryWithJobsRetrying.singleResult().getRootProcessInstanceId());
assertThat(queryWithJobsRetrying.count()).isEqualTo(1L);
assertThat(queryWithJobsRetrying.list()).hasSize(1);
assertThat(instanceWithRetryingJob.getId()).isEqualTo(queryWithJobsRetrying.singleResult().getId());

// when all retries are exhausted, so now the instance has a job with exception but no retries left
executeFailingJob(failingJob);
executeFailingJob(failingJob);

// then
assertEquals(0, queryWithJobsRetrying.count());
assertThat(queryWithJobsRetrying.count()).isZero();
assertThat(queryWithJobsRetrying.list()).isEmpty();
}

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/api/history/testInstancesWithJobsRetrying.bpmn20.xml" })
public void testHistoricProcessInstanceQueryWithJobsRetryingWithoutExceptionMessage() {
// given
HistoricProcessInstanceQuery queryWithJobsRetrying = historyService.createHistoricProcessInstanceQuery()
.withJobsRetrying();
Map<String, Object> vars = new HashMap<>();
vars.put("message", null);

ProcessInstance instanceWithRetryingJob = runtimeService.startProcessInstanceByKey("processWithJobsRetrying", vars);

// when
Job failingJob = managementService.createJobQuery()
.processInstanceId(instanceWithRetryingJob.getId())
.singleResult();
executeFailingJob(failingJob);

// then
assertThat(queryWithJobsRetrying.count()).isEqualTo(1L);
assertThat(queryWithJobsRetrying.list()).hasSize(1);
assertThat(instanceWithRetryingJob.getId()).isEqualTo(queryWithJobsRetrying.singleResult().getId());
}

@Test
@Deployment(resources = { "org/camunda/bpm/engine/test/history/oneAsyncTaskProcess.bpmn20.xml" })
public void testHistoricProcessInstanceQuery() {
Expand Down Expand Up @@ -2731,10 +2754,10 @@ protected void executeJobForProcessInstance(String processInstanceId) {
managementService.executeJob(job.getId());
}

private void executeFailingJob(Job job){
private void executeFailingJob(Job job) {
try {
managementService.executeJob(job.getId());
} catch(RuntimeException re) {
} catch (RuntimeException re) {
// Exception expected. Do nothing
}
}
Expand Down

0 comments on commit 0f20c65

Please sign in to comment.