Search in sources :

Example 6 with Job

use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.

the class BaseJobResourceIT method getAfterCreate.

@Test
void getAfterCreate() throws Exception {
    final String id = "3";
    final Job job = getJob(id);
    create(jobToJson(job));
    assertGetScheduledJob(id);
}
Also used : Job(org.kie.kogito.jobs.api.Job) ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) Test(org.junit.jupiter.api.Test)

Example 7 with Job

use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.

the class BaseJobResourceIT method patchInvalidAttributesTest.

@Test
void patchInvalidAttributesTest() throws Exception {
    final String id = UUID.randomUUID().toString();
    final Job job = getJob(id);
    create(jobToJson(job));
    final String newCallbackEndpoint = "http://localhost/newcallback";
    Job toPatch = JobBuilder.builder().callbackEndpoint(newCallbackEndpoint).build();
    assertPatch(id, toPatch, 500);
    toPatch = JobBuilder.builder().processId(UUID.randomUUID().toString()).build();
    assertPatch(id, toPatch, 500);
    toPatch = JobBuilder.builder().rootProcessId(UUID.randomUUID().toString()).build();
    assertPatch(id, toPatch, 500);
    toPatch = JobBuilder.builder().rootProcessInstanceId(UUID.randomUUID().toString()).build();
    assertPatch(id, toPatch, 500);
    toPatch = JobBuilder.builder().processInstanceId(UUID.randomUUID().toString()).build();
    assertPatch(id, toPatch, 500);
    toPatch = JobBuilder.builder().priority(10).build();
    assertPatch(id, toPatch, 500);
    toPatch = JobBuilder.builder().repeatLimit(1).repeatInterval(1l).build();
    assertPatch(id, toPatch, 200);
}
Also used : Job(org.kie.kogito.jobs.api.Job) ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) Test(org.junit.jupiter.api.Test)

Example 8 with Job

use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.

the class BaseJobResourceIT method patchInvalidIdPathTest.

@Test
void patchInvalidIdPathTest() throws Exception {
    final String id = UUID.randomUUID().toString();
    final Job job = getJob(id);
    create(jobToJson(job));
    Job toPatch = JobBuilder.builder().expirationTime(DateUtil.now()).build();
    // not found id on path
    assertPatch("invalid", toPatch, 404);
    // different id on the job object from path id
    toPatch = JobBuilder.builder().id("differentId").build();
    assertPatch(id, toPatch, 500);
}
Also used : Job(org.kie.kogito.jobs.api.Job) ScheduledJob(org.kie.kogito.jobs.service.model.ScheduledJob) Test(org.junit.jupiter.api.Test)

Example 9 with Job

use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.

the class BaseKeycloakJobServiceIT method getAfterCreate.

@Test
void getAfterCreate() throws Exception {
    final String id = "3";
    final Job job = getJob(id);
    createJob(jobToJson(job), getAccessToken("jdoe"), OK_CODE);
    given().pathParam("id", id).when().get(JobResource.JOBS_PATH + "/{id}").then().statusCode(FORBIDDEN_CODE);
    given().auth().oauth2(getAccessToken("alice")).pathParam("id", id).when().get(JobResource.JOBS_PATH + "/{id}").then().statusCode(UNAUTHORIZED_CODE);
    final ScheduledJob scheduledJob = given().auth().oauth2(getAccessToken("jdoe")).pathParam("id", id).when().get(JobResource.JOBS_PATH + "/{id}").then().statusCode(OK_CODE).contentType(ContentType.JSON).assertThat().extract().as(ScheduledJob.class);
    assertEquals(scheduledJob.getId(), job.getId());
}
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)

Example 10 with Job

use of org.kie.kogito.jobs.api.Job in project kogito-apps by kiegroup.

the class BaseKeycloakJobServiceIT method create.

@Test
void create() throws Exception {
    final Job job = getJob("1");
    createJob(jobToJson(job), getAccessToken("alice"), UNAUTHORIZED_CODE);
    createJob(jobToJson(job), "", FORBIDDEN_CODE);
    final ScheduledJob response = createJob(jobToJson(job), getAccessToken("jdoe"), OK_CODE).extract().as(ScheduledJob.class);
    assertEquals(job, response);
}
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

Job (org.kie.kogito.jobs.api.Job)30 Test (org.junit.jupiter.api.Test)23 ScheduledJob (org.kie.kogito.jobs.service.model.ScheduledJob)13 CreateProcessInstanceJobRequestEvent (org.kie.kogito.jobs.api.event.CreateProcessInstanceJobRequestEvent)8 ZonedDateTime (java.time.ZonedDateTime)4 JobDetails (org.kie.kogito.jobs.service.model.job.JobDetails)3 Timeout (org.junit.jupiter.api.Timeout)2 ProcessInstanceJobDescription (org.kie.kogito.jobs.ProcessInstanceJobDescription)2 TimerJobId (org.kie.kogito.jobs.TimerJobId)2 JobServiceException (org.kie.kogito.jobs.service.exception.JobServiceException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 CloudEvent (io.cloudevents.CloudEvent)1 CloudEventData (io.cloudevents.CloudEventData)1 AsyncResult (io.vertx.core.AsyncResult)1 Handler (io.vertx.core.Handler)1 Buffer (io.vertx.core.buffer.Buffer)1 HttpResponse (io.vertx.ext.web.client.HttpResponse)1 IOException (java.io.IOException)1 URI (java.net.URI)1 JobCallbackResourceDef.buildCallbackPatternJob (org.kie.kogito.jobs.api.JobCallbackResourceDef.buildCallbackPatternJob)1