Search in sources :

Example 1 with ScheduledJob

use of org.kie.kogito.jobs.service.model.ScheduledJob in project kogito-apps by kiegroup.

the class ScheduledJobAdapterTest method testToJobDetailsWithEmptyPayload.

@Test
void testToJobDetailsWithEmptyPayload() {
    ScheduledJob scheduledJob = ScheduledJob.builder().job(JobBuilder.builder().id(UUID.randomUUID().toString()).build()).build();
    JobDetails jobDetails = ScheduledJobAdapter.to(scheduledJob);
    assertThat(jobDetails.getPayload()).isNull();
}
Also used : ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) Test(org.junit.jupiter.api.Test)

Example 2 with ScheduledJob

use of org.kie.kogito.jobs.service.model.ScheduledJob in project kogito-apps by kiegroup.

the class ScheduledJobAdapterTest method testToScheduledJobWithEmptyPayload.

@Test
void testToScheduledJobWithEmptyPayload() {
    JobDetails jobDetails = JobDetails.builder().id(UUID.randomUUID().toString()).build();
    ScheduledJob scheduledJob = ScheduledJobAdapter.of(jobDetails);
    assertThat(scheduledJob.getProcessId()).isNull();
    assertThat(scheduledJob.getProcessInstanceId()).isNull();
    assertThat(scheduledJob.getRootProcessId()).isNull();
    assertThat(scheduledJob.getRootProcessInstanceId()).isNull();
}
Also used : ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) Test(org.junit.jupiter.api.Test)

Example 3 with ScheduledJob

use of org.kie.kogito.jobs.service.model.ScheduledJob in project kogito-apps by kiegroup.

the class ScheduledJobAdapterTest method testOfJobDetailsInterval.

@Test
void testOfJobDetailsInterval() {
    JobDetails jobDetails = getJobDetailsCommonBuilder().trigger(new IntervalTrigger(0, DateUtil.toDate(TIME), null, REPEAT_LIMIT, 0, INTERVAL, null, null)).build();
    ScheduledJob scheduledJob = ScheduledJobAdapter.of(jobDetails);
    assertScheduledJob(scheduledJob);
    assertThat(scheduledJob.getRepeatLimit()).isEqualTo(REPEAT_LIMIT);
    assertThat(scheduledJob.getRepeatInterval()).isEqualTo(INTERVAL);
}
Also used : ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) IntervalTrigger(org.kie.kogito.timer.impl.IntervalTrigger) Test(org.junit.jupiter.api.Test)

Example 4 with ScheduledJob

use of org.kie.kogito.jobs.service.model.ScheduledJob in project kogito-apps by kiegroup.

the class ScheduledJobAdapterTest method testToJobDetailsInterval.

@Test
void testToJobDetailsInterval() {
    JobBuilder jobBuilder = JobBuilder.builder().repeatLimit(REPEAT_LIMIT).repeatInterval(INTERVAL);
    ScheduledJob scheduledJob = getScheduledJobCommonBuilder(jobBuilder).build();
    JobDetails jobDetails = ScheduledJobAdapter.to(scheduledJob);
    assertJobDetails(jobDetails);
    assertThat(jobDetails.getTrigger()).isInstanceOf(IntervalTrigger.class);
    IntervalTrigger intervalTrigger = (IntervalTrigger) jobDetails.getTrigger();
    assertThat(intervalTrigger.getNextFireTime()).isEqualTo(DateUtil.toDate(TIME));
    assertThat(intervalTrigger.getRepeatLimit()).isEqualTo(REPEAT_LIMIT);
    assertThat(intervalTrigger.getPeriod()).isEqualTo(INTERVAL);
}
Also used : ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) JobBuilder(org.kie.kogito.jobs.api.JobBuilder) IntervalTrigger(org.kie.kogito.timer.impl.IntervalTrigger) Test(org.junit.jupiter.api.Test)

Example 5 with ScheduledJob

use of org.kie.kogito.jobs.service.model.ScheduledJob in project kogito-apps by kiegroup.

the class BaseJobResourceIT method executeTest.

@Test
void executeTest() throws Exception {
    final String id = "4";
    final Job job = getJob(id);
    create(jobToJson(job));
    final ScheduledJob scheduledJob = assertGetScheduledJob(id);
    assertEquals(scheduledJob.getId(), job.getId());
    assertEquals(0, scheduledJob.getRetries());
    assertEquals(JobStatus.SCHEDULED, scheduledJob.getStatus());
    assertNotNull(scheduledJob.getScheduledId());
}
Also used : ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) Job(org.kie.kogito.jobs.api.Job) ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) Test(org.junit.jupiter.api.Test)

Aggregations

ScheduledJob (org.kie.kogito.jobs.service.model.ScheduledJob)17 Test (org.junit.jupiter.api.Test)15 Job (org.kie.kogito.jobs.api.Job)9 IntervalTrigger (org.kie.kogito.timer.impl.IntervalTrigger)2 PointInTimeTrigger (org.kie.kogito.timer.impl.PointInTimeTrigger)2 JobBuilder (org.kie.kogito.jobs.api.JobBuilder)1