Search in sources :

Example 11 with JobRecord

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);
}
Also used : JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) Test(org.junit.Test)

Example 12 with JobRecord

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);
}
Also used : JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) Test(org.junit.Test)

Example 13 with JobRecord

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);
}
Also used : JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) Test(org.junit.Test)

Example 14 with JobRecord

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;
}
Also used : JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord)

Example 15 with 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);
}
Also used : JobRecord(io.camunda.zeebe.protocol.impl.record.value.job.JobRecord) Test(org.junit.Test)

Aggregations

JobRecord (io.camunda.zeebe.protocol.impl.record.value.job.JobRecord)183 Test (org.junit.Test)96 GatewayTest (io.camunda.zeebe.gateway.api.util.GatewayTest)15 BrokerResponse (io.camunda.zeebe.gateway.impl.broker.response.BrokerResponse)9 LongValue (io.camunda.zeebe.msgpack.value.LongValue)9 CompleteJobResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobResponse)8 IncidentRecord (io.camunda.zeebe.protocol.impl.record.value.incident.IncidentRecord)8 DirectBuffer (org.agrona.DirectBuffer)8 RecordMetadata (io.camunda.zeebe.protocol.impl.record.RecordMetadata)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)7 BrokerCompleteJobRequest (io.camunda.zeebe.gateway.impl.broker.request.BrokerCompleteJobRequest)6 CompleteJobRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.CompleteJobRequest)6 JobState (io.camunda.zeebe.engine.state.immutable.JobState)5 State (io.camunda.zeebe.engine.state.immutable.JobState.State)5 ActivateJobsResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivateJobsResponse)5 ActivatedJob (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.ActivatedJob)5 FailJobResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.FailJobResponse)5 UpdateJobRetriesResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.UpdateJobRetriesResponse)5 DeploymentRecord (io.camunda.zeebe.protocol.impl.record.value.deployment.DeploymentRecord)5 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)5