use of org.kie.kogito.jobs.api.Job in project kogito-runtimes by kiegroup.
the class ReactiveMessagingJobsService method scheduleProcessInstanceJob.
@Override
public String scheduleProcessInstanceJob(ProcessInstanceJobDescription description) {
Job job = buildCallbackPatternJob(description, buildCallbackURI(description, serviceUrl.toString()));
LOGGER.debug("scheduleProcessInstanceJob job: {}", job);
CreateProcessInstanceJobRequestEvent event = CreateProcessInstanceJobRequestEvent.builder().source(serviceUrl).job(job).processInstanceId(description.processInstanceId()).processId(description.processId()).rootProcessInstanceId(description.rootProcessInstanceId()).rootProcessId(description.rootProcessId()).kogitoAddons(KOGITO_ADDON).build();
emitEvent(event);
return job.getId();
}
use of org.kie.kogito.jobs.api.Job in project kogito-runtimes by kiegroup.
the class ReactiveMessagingJobsServiceTest method assertExpectedCreateProcessInstanceJobRequestEvent.
private void assertExpectedCreateProcessInstanceJobRequestEvent(CreateProcessInstanceJobRequestEvent event) {
assertThat(event).isNotNull();
assertThat(event.getProcessInstanceId()).isEqualTo(PROCESS_INSTANCE_ID);
assertThat(event.getProcessId()).isEqualTo(PROCESS_ID);
assertThat(event.getRootProcessInstanceId()).isEqualTo(ROOT_PROCESS_INSTANCE_ID);
assertThat(event.getRootProcessId()).isEqualTo(ROOT_PROCESS_ID);
assertThat(event.getSource()).isEqualTo(SERVICE_URI);
Job job = event.getData();
assertThat(job).isNotNull();
assertThat(job.getId()).isEqualTo(JOB_ID.encode());
assertThat(job.getExpirationTime()).isEqualTo(EXPIRATION_TIME.get());
assertThat(job.getRepeatLimit()).isZero();
assertThat(job.getRepeatInterval()).isNull();
assertThat(job.getPriority()).isEqualTo(PRIORITY);
assertThat(job.getCallbackEndpoint()).isEqualTo(CALLBACK_ENDPOINT);
assertThat(job.getProcessInstanceId()).isEqualTo(PROCESS_INSTANCE_ID);
assertThat(job.getProcessId()).isEqualTo(PROCESS_ID);
assertThat(job.getRootProcessInstanceId()).isEqualTo(ROOT_PROCESS_INSTANCE_ID);
assertThat(job.getRootProcessId()).isEqualTo(ROOT_PROCESS_ID);
}
use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.
the class BaseJobResourceIT method cancelRunningPeriodicJobTest.
@Test
// @Disabled("see https://issues.redhat.com/browse/KOGITO-1941")
void cancelRunningPeriodicJobTest() throws Exception {
final String id = UUID.randomUUID().toString();
int timeMillis = 1000;
final Job job = getJob(id, DateUtil.now().plus(timeMillis, ChronoUnit.MILLIS), 10, 500l);
create(jobToJson(job));
// check the job was created
assertGetScheduledJob(id);
// guarantee the job is running
await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
// assert executed at least once
ScheduledJob scheduledJob = assertGetScheduledJob(id);
assertThat(scheduledJob.getExecutionCounter()).isPositive();
// canceled the running job
assertCancelScheduledJob(id);
// assert the job was deleted from the api perspective
assertJobNotFound(id);
// ensure the job was indeed canceled on vertx
assertJobNotScheduledOnVertx(scheduledJob);
});
}
use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.
the class BaseJobResourceIT method create.
@Test
void create() throws Exception {
final Job job = getJob("1");
final ScheduledJob response = create(jobToJson(job)).statusCode(200).extract().as(ScheduledJob.class);
assertEquals(job, response);
}
use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.
the class BaseJobResourceIT method deleteAfterCreate.
@Test
void deleteAfterCreate() throws Exception {
final String id = "2";
final Job job = getJob(id);
create(jobToJson(job));
final ScheduledJob response = given().pathParam("id", id).when().delete(JobResource.JOBS_PATH + "/{id}").then().statusCode(200).contentType(ContentType.JSON).extract().as(ScheduledJob.class);
assertEquals(job, response);
}
Aggregations