Search in sources :

Example 1 with Job

use of org.kie.kogito.index.model.Job in project kogito-apps by kiegroup.

the class JobEntityMapper method mapToModel.

@Override
public Job mapToModel(JobEntity entity) {
    if (entity == null) {
        return null;
    }
    Job job = new Job();
    job.setId(entity.getId());
    job.setProcessId(entity.getProcessId());
    job.setProcessInstanceId(entity.getProcessInstanceId());
    job.setRootProcessId(entity.getRootProcessId());
    job.setRootProcessInstanceId(entity.getRootProcessInstanceId());
    job.setExpirationTime(instantToZonedDateTime(entity.getExpirationTime()));
    job.setPriority(entity.getPriority());
    job.setCallbackEndpoint(entity.getCallbackEndpoint());
    job.setRepeatInterval(entity.getRepeatInterval());
    job.setRepeatLimit(entity.getRepeatLimit());
    job.setScheduledId(entity.getScheduledId());
    job.setRetries(entity.getRetries());
    job.setStatus(entity.getStatus());
    job.setLastUpdate(instantToZonedDateTime(entity.getLastUpdate()));
    job.setExecutionCounter(entity.getExecutionCounter());
    job.setEndpoint(entity.getEndpoint());
    job.setNodeInstanceId(entity.getNodeInstanceId());
    return job;
}
Also used : Job(org.kie.kogito.index.model.Job)

Example 2 with Job

use of org.kie.kogito.index.model.Job in project kogito-apps by kiegroup.

the class JobStorageIT method testJobEntity.

@Test
@Transactional
public void testJobEntity() {
    String jobId = UUID.randomUUID().toString();
    String processInstanceId = UUID.randomUUID().toString();
    Job job1 = TestUtils.createJob(jobId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "EXPECTED", 0L);
    Job job2 = TestUtils.createJob(jobId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "SCHEDULED", 1000L);
    testStorage(jobId, job1, job2);
}
Also used : Job(org.kie.kogito.index.model.Job) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Transactional(javax.transaction.Transactional)

Example 3 with Job

use of org.kie.kogito.index.model.Job in project kogito-apps by kiegroup.

the class JobEntityMapperTest method testMapToModel.

@Test
void testMapToModel() {
    Job result = jobEntityMapper.mapToModel(jobEntity);
    assertEquals(job, result);
}
Also used : Job(org.kie.kogito.index.model.Job) Test(org.junit.jupiter.api.Test)

Example 4 with Job

use of org.kie.kogito.index.model.Job in project kogito-apps by kiegroup.

the class JobEntityMapperTest method setup.

@BeforeAll
static void setup() {
    String testId = "testId";
    ZonedDateTime time = ZonedDateTime.now();
    String status = "ACTIVE";
    String processId = "testProcessId";
    String processInstanceId = "testProcessInstanceId";
    String rootProcessId = "testRootProcessId";
    String rootProcessInstanceId = "testRootProcessInstanceId";
    Integer priority = 79;
    String callbackEndpoint = "testCallbackEndpoint";
    Long repeatInterval = 70L;
    Integer repeatLimit = 89;
    String scheduledId = "testScheduleId";
    Integer retries = 25;
    Integer executionCounter = 17;
    job = new Job();
    job.setId(testId);
    job.setStatus(status);
    job.setLastUpdate(time);
    job.setProcessId(processId);
    job.setProcessInstanceId(processInstanceId);
    job.setRootProcessId(rootProcessId);
    job.setRootProcessInstanceId(rootProcessInstanceId);
    job.setExpirationTime(time);
    job.setPriority(priority);
    job.setCallbackEndpoint(callbackEndpoint);
    job.setRepeatInterval(repeatInterval);
    job.setRepeatLimit(repeatLimit);
    job.setScheduledId(scheduledId);
    job.setRetries(retries);
    job.setExecutionCounter(executionCounter);
    jobEntity = new JobEntity();
    jobEntity.setId(testId);
    jobEntity.setStatus(status);
    jobEntity.setLastUpdate(zonedDateTimeToInstant(time));
    jobEntity.setProcessId(processId);
    jobEntity.setProcessInstanceId(processInstanceId);
    jobEntity.setRootProcessId(rootProcessId);
    jobEntity.setRootProcessInstanceId(rootProcessInstanceId);
    jobEntity.setExpirationTime(zonedDateTimeToInstant(time));
    jobEntity.setPriority(priority);
    jobEntity.setCallbackEndpoint(callbackEndpoint);
    jobEntity.setRepeatInterval(repeatInterval);
    jobEntity.setRepeatLimit(repeatLimit);
    jobEntity.setScheduledId(scheduledId);
    jobEntity.setRetries(retries);
    jobEntity.setExecutionCounter(executionCounter);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Job(org.kie.kogito.index.model.Job) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with Job

use of org.kie.kogito.index.model.Job in project kogito-apps by kiegroup.

the class JobStorageIT method testCache.

@Test
void testCache() {
    String jobId = UUID.randomUUID().toString();
    String processInstanceId = UUID.randomUUID().toString();
    Job job1 = TestUtils.createJob(jobId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "EXPECTED", 0L);
    Job job2 = TestUtils.createJob(jobId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "SCHEDULED", 1000L);
    testStorage(storage, jobId, job1, job2);
}
Also used : Job(org.kie.kogito.index.model.Job) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Aggregations

Job (org.kie.kogito.index.model.Job)14 Test (org.junit.jupiter.api.Test)9 QuarkusTest (io.quarkus.test.junit.QuarkusTest)5 Handler (io.vertx.core.Handler)2 Transactional (javax.transaction.Transactional)2 JsonObject (io.vertx.core.json.JsonObject)1 ZonedDateTime (java.time.ZonedDateTime)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1