protected internal virtual void waitForExecutedJobWithRetriesLeft(int retriesLeft, string jobId) { JobQuery jobQuery = managementService.createJobQuery(); if (!string.ReferenceEquals(jobId, null)) { jobQuery.jobId(jobId); } Job job = jobQuery.singleResult(); try { managementService.executeJob(job.Id); } catch (Exception) { } // update job job = jobQuery.singleResult(); if (job.Retries != retriesLeft) { waitForExecutedJobWithRetriesLeft(retriesLeft, jobId); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Deployment public void testFailingTimeCycle() public virtual void testFailingTimeCycle() { // given runtimeService.startProcessInstanceByKey("process"); JobQuery failedJobQuery = managementService.createJobQuery(); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(1, jobQuery.count()); string jobId = jobQuery.singleResult().Id; failedJobQuery.jobId(jobId); // when (1) try { managementService.executeJob(jobId); fail(); } catch (Exception) { // expected } // then (1) Job failedJob = failedJobQuery.singleResult(); assertEquals(2, failedJob.Retries); // a new timer job has been created assertEquals(2, jobQuery.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); // when (2) try { managementService.executeJob(jobId); } catch (Exception) { // expected } // then (2) failedJob = failedJobQuery.singleResult(); assertEquals(1, failedJob.Retries); // there are still two jobs assertEquals(2, jobQuery.count()); assertEquals(1, managementService.createJobQuery().withException().count()); assertEquals(0, managementService.createJobQuery().noRetriesLeft().count()); assertEquals(2, managementService.createJobQuery().withRetriesLeft().count()); }