use of io.camunda.zeebe.protocol.record.value.JobRecordValue in project zeebe-process-test by camunda.
the class RecordStreamLogger method logJobRecordValue.
private String logJobRecordValue(final Record<?> record) {
final JobRecordValue value = (JobRecordValue) record.getValue();
final StringJoiner joiner = new StringJoiner(", ", "", "");
// These fields are empty for commands
if (record.getRecordType().equals(RecordType.EVENT)) {
joiner.add(String.format("(Element id: %s)", value.getElementId()));
joiner.add(String.format("(Job type: %s)", value.getType()));
joiner.add(logVariables(value.getVariables()));
}
return joiner.toString();
}
use of io.camunda.zeebe.protocol.record.value.JobRecordValue in project zeebe-exporter-protobuf by camunda-community-hub.
the class RecordTransformTest method shouldTransformJob.
@Test
public void shouldTransformJob() {
// given
final JobRecordValue jobRecordValue = mockJobRecordValue();
final Record<JobRecordValue> mockedRecord = mockRecord(jobRecordValue, ValueType.JOB, JobIntent.CREATED);
// when
final Schema.JobRecord jobRecord = (Schema.JobRecord) RecordTransformer.toProtobufMessage(mockedRecord);
// then
assertMetadata(jobRecord.getMetadata(), "JOB", "CREATED");
assertJobRecord(jobRecord);
}
use of io.camunda.zeebe.protocol.record.value.JobRecordValue in project zeebe by camunda.
the class ActivatableJobsNotificationTests method shouldNotifyWhenFailedJobsResolved.
@Test
public void shouldNotifyWhenFailedJobsResolved() {
// given
createProcessInstanceAndJobs(1);
final Record<JobBatchRecordValue> jobs = activateJobs(1);
final JobRecordValue job = jobs.getValue().getJobs().get(0);
ENGINE.job().withType(taskType).ofInstance(job.getProcessInstanceKey()).fail();
// when
ENGINE.job().ofInstance(job.getProcessInstanceKey()).withType(taskType).withRetries(1).updateRetries();
ENGINE.incident().ofInstance(job.getProcessInstanceKey()).resolve();
// then
Mockito.verify(JOB_AVAILABLE_CALLBACK, times(2)).accept(taskType);
}
use of io.camunda.zeebe.protocol.record.value.JobRecordValue in project zeebe by camunda.
the class ActivateJobsTest method shouldFetchFullJobRecordFromProcess.
@Test
public void shouldFetchFullJobRecordFromProcess() {
// given
final ControlledActorClock clock = ENGINE.getClock();
clock.pinCurrentTime();
final String worker = "testWorker";
final Duration timeout = Duration.ofMinutes(4);
ENGINE.deployment().withXmlResource(PROCESS_ID + ".bpmn", MODEL_SUPPLIER.apply(taskType)).deploy();
createProcessInstances(1, "{'foo':'bar'}");
final Record<JobRecordValue> jobRecord = jobRecords(JobIntent.CREATED).withType(taskType).getFirst();
// when
final Record<JobBatchRecordValue> jobActivatedRecord = ENGINE.jobs().withType(taskType).byWorker(worker).withTimeout(timeout.toMillis()).withMaxJobsToActivate(1).activate();
final JobRecordValue jobActivated = jobActivatedRecord.getValue().getJobs().get(0);
final Record<JobBatchRecordValue> jobActivate = RecordingExporter.jobBatchRecords().withType(taskType).withIntent(JobBatchIntent.ACTIVATE).getFirst();
// then
assertThat(jobActivated).hasType(taskType).hasWorker(worker).hasRetries(3).hasDeadline(jobActivate.getTimestamp() + timeout.toMillis());
assertThat(jobActivated.getVariables()).containsExactly(entry("foo", "bar"));
final JobRecordValue jobRecordValue = jobRecord.getValue();
assertThat(jobActivated.getProcessInstanceKey()).isEqualTo(jobRecordValue.getProcessInstanceKey());
assertThat(jobActivated).hasBpmnProcessId(jobRecordValue.getBpmnProcessId()).hasProcessDefinitionVersion(jobRecordValue.getProcessDefinitionVersion()).hasProcessDefinitionKey(jobRecordValue.getProcessDefinitionKey()).hasElementId(jobRecordValue.getElementId()).hasElementInstanceKey(jobRecordValue.getElementInstanceKey());
assertThat(jobActivated.getCustomHeaders()).isEqualTo(jobRecordValue.getCustomHeaders());
}
use of io.camunda.zeebe.protocol.record.value.JobRecordValue in project zeebe by camunda.
the class ActivateJobsTest method shouldActivateSingleJob.
@Test
public void shouldActivateSingleJob() {
// given
ENGINE.deployment().withXmlResource(PROCESS_ID + ".bpmn", MODEL_SUPPLIER.apply(taskType)).deploy();
final long firstInstanceKey = createProcessInstances(3, "{'foo':'bar'}").get(0);
final long expectedJobKey = jobRecords(JobIntent.CREATED).withType(taskType).filter(r -> r.getValue().getProcessInstanceKey() == firstInstanceKey).getFirst().getKey();
final String worker = "myTestWorker";
final Duration timeout = Duration.ofMinutes(12);
// when
final Record<JobBatchRecordValue> batchRecord = ENGINE.jobs().withType(taskType).byWorker(worker).withTimeout(timeout.toMillis()).withMaxJobsToActivate(1).activate();
final List<JobRecordValue> jobs = batchRecord.getValue().getJobs();
final List<Long> jobKeys = batchRecord.getValue().getJobKeys();
// then
assertThat(batchRecord.getIntent()).isEqualTo(JobBatchIntent.ACTIVATED);
assertThat(jobKeys).hasSize(1);
assertThat(jobs).hasSize(1);
assertThat(jobKeys.get(0)).isEqualTo(expectedJobKey);
assertThat(jobs.get(0)).hasRetries(3).hasWorker(worker).hasType(taskType);
assertThat(jobs.get(0).getVariables()).containsExactly(entry("foo", "bar"));
final var activatedJobBatch = getActivatedJobBatch();
final var jobRecordValue = activatedJobBatch.getJobs().get(0);
final var jobKey = activatedJobBatch.getJobKeys().get(0);
assertThat(jobKey).isEqualTo(expectedJobKey);
assertThat(jobRecordValue).hasRetries(3).hasWorker(worker);
}
Aggregations