Search in sources :

Example 16 with StatusDto

use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method shouldNotUpdateStatusOfParentMultiple.

@Test
public void shouldNotUpdateStatusOfParentMultiple() {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(3);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(4));
    JobExecution parent = createdJobExecutions.stream().filter(jobExec -> jobExec.getSubordinationType().equals(JobExecution.SubordinationType.PARENT_MULTIPLE)).findFirst().get();
    StatusDto status = new StatusDto().withStatus(StatusDto.Status.PARSING_IN_PROGRESS);
    RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + parent.getId() + STATUS_PATH).then().statusCode(HttpStatus.SC_BAD_REQUEST);
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + parent.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(JobExecution.Status.PARENT.name())).body("uiStatus", is(JobExecution.UiStatus.PARENT.name()));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) StatusDto(org.folio.rest.jaxrs.model.StatusDto) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 17 with StatusDto

use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.

the class ChangeManagerAPITest method shouldUpdateStatusOfSingleParent.

@Test
public void shouldUpdateStatusOfSingleParent() {
    InitJobExecutionsRsDto response = constructAndPostInitJobExecutionRqDto(1);
    List<JobExecution> createdJobExecutions = response.getJobExecutions();
    assertThat(createdJobExecutions.size(), is(1));
    JobExecution jobExec = createdJobExecutions.get(0);
    StatusDto status = new StatusDto().withStatus(StatusDto.Status.PARSING_IN_PROGRESS);
    RestAssured.given().spec(spec).body(JsonObject.mapFrom(status).toString()).when().put(JOB_EXECUTION_PATH + jobExec.getId() + STATUS_PATH).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus()));
    RestAssured.given().spec(spec).when().get(JOB_EXECUTION_PATH + jobExec.getId()).then().statusCode(HttpStatus.SC_OK).body("status", is(status.getStatus().name())).body("uiStatus", is(Status.valueOf(status.getStatus().name()).getUiStatus()));
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) StatusDto(org.folio.rest.jaxrs.model.StatusDto) InitJobExecutionsRsDto(org.folio.rest.jaxrs.model.InitJobExecutionsRsDto) AbstractRestTest(org.folio.rest.impl.AbstractRestTest) Test(org.junit.Test)

Example 18 with StatusDto

use of org.folio.rest.jaxrs.model.StatusDto in project mod-source-record-manager by folio-org.

the class DataImportInitKafkaHandler method checkAndUpdateToInProgressState.

private Future<JobExecution> checkAndUpdateToInProgressState(String jobExecutionId, OkapiConnectionParams params) {
    return jobExecutionService.getJobExecutionById(jobExecutionId, params.getTenantId()).compose(jobExecutionOptional -> {
        if (jobExecutionOptional.isPresent()) {
            JobExecution jobExecution = jobExecutionOptional.get();
            if (jobExecution.getStatus() == JobExecution.Status.FILE_UPLOADED) {
                LOGGER.info("Moving from file uploaded to in progress state for jobExecutionId: {}", jobExecutionId);
                StatusDto statusDto = new StatusDto().withStatus(StatusDto.Status.PARSING_IN_PROGRESS);
                return jobExecutionService.updateJobExecutionStatus(jobExecutionId, statusDto, params);
            }
        }
        return Future.succeededFuture();
    });
}
Also used : JobExecution(org.folio.rest.jaxrs.model.JobExecution) StatusDto(org.folio.rest.jaxrs.model.StatusDto)

Aggregations

StatusDto (org.folio.rest.jaxrs.model.StatusDto)18 JobExecution (org.folio.rest.jaxrs.model.JobExecution)17 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)14 Test (org.junit.Test)14 InitJobExecutionsRsDto (org.folio.rest.jaxrs.model.InitJobExecutionsRsDto)10 Future (io.vertx.core.Future)8 JsonObject (io.vertx.core.json.JsonObject)7 UUID (java.util.UUID)7 OkapiConnectionParams (org.folio.dataimport.util.OkapiConnectionParams)7 JobProfileInfo (org.folio.rest.jaxrs.model.JobProfileInfo)7 Async (io.vertx.ext.unit.Async)6 Collections (java.util.Collections)6 RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)5 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)5 TestContext (io.vertx.ext.unit.TestContext)5 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)5 HashMap (java.util.HashMap)5 WireMock (com.github.tomakehurst.wiremock.client.WireMock)4 WireMock.created (com.github.tomakehurst.wiremock.client.WireMock.created)4 WireMock.get (com.github.tomakehurst.wiremock.client.WireMock.get)4