use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by camunda.
the class JobStateTest method shouldTimeoutJob.
@Test
public void shouldTimeoutJob() {
// given
final long key = 1L;
final JobRecord jobRecord = newJobRecord();
// when
jobState.create(key, jobRecord);
jobState.activate(key, jobRecord);
jobState.timeout(key, jobRecord);
// then
assertThat(jobState.exists(key)).isTrue();
assertJobState(key, State.ACTIVATABLE);
assertJobRecordIsEqualTo(jobState.getJob(key), jobRecord);
assertListedAsActivatable(key, jobRecord.getTypeBuffer());
refuteListedAsTimedOut(key, jobRecord.getDeadline() + 1);
refuteListedAsBackOff(key, jobRecord.getRecurringTime() + 1 + 1);
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by camunda.
the class JobStateTest method shouldThrowErrorActivatableJob.
@Test
public void shouldThrowErrorActivatableJob() {
// given
final long key = 1L;
final JobRecord jobRecord = newJobRecord();
// when
jobState.create(key, jobRecord);
jobState.throwError(key, jobRecord);
// then
assertThat(jobState.exists(key)).isTrue();
assertJobState(key, State.ERROR_THROWN);
assertJobRecordIsEqualTo(jobState.getJob(key), jobRecord);
refuteListedAsActivatable(key, jobRecord.getTypeBuffer());
refuteListedAsTimedOut(key, jobRecord.getDeadline() + 1);
refuteListedAsBackOff(key, jobRecord.getRecurringTime() + 1 + 1);
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by camunda.
the class JobStateTest method shouldCancelFailedJob.
@Test
public void shouldCancelFailedJob() {
// given
final long key = 1L;
final JobRecord jobRecord = newJobRecord();
// when
jobState.create(key, jobRecord);
jobState.activate(key, jobRecord);
jobState.fail(key, jobRecord.setRetries(0));
jobState.cancel(key, jobRecord);
// then
assertThat(jobState.exists(key)).isFalse();
assertThat(jobState.isInState(key, State.NOT_FOUND)).isTrue();
assertThat(jobState.getJob(key)).isNull();
refuteListedAsActivatable(key, jobRecord.getTypeBuffer());
refuteListedAsTimedOut(key, jobRecord.getDeadline() + 1);
refuteListedAsBackOff(key, jobRecord.getRecurringTime() + 1 + 1);
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by camunda.
the class JobStateTest method newJobRecord.
private JobRecord newJobRecord() {
final JobRecord jobRecord = new JobRecord();
jobRecord.setRetries(2);
jobRecord.setDeadline(256L);
jobRecord.setType("test");
return jobRecord;
}
use of io.camunda.zeebe.protocol.impl.record.value.job.JobRecord in project zeebe by camunda.
the class JobStateTest method shouldCancelActivatableJob.
@Test
public void shouldCancelActivatableJob() {
// given
final long key = 1L;
final JobRecord jobRecord = newJobRecord();
// when
jobState.create(key, jobRecord);
jobState.cancel(key, jobRecord);
// then
assertThat(jobState.exists(key)).isFalse();
assertThat(jobState.isInState(key, State.NOT_FOUND)).isTrue();
assertThat(jobState.getJob(key)).isNull();
refuteListedAsActivatable(key, jobRecord.getTypeBuffer());
refuteListedAsTimedOut(key, jobRecord.getDeadline() + 1);
refuteListedAsBackOff(key, jobRecord.getRecurringTime() + 1 + 1);
}
Aggregations