use of org.folio.rest.jaxrs.model.DeleteJobExecutionsReq in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method testDeleteChangeManagerJobExecutionsSingleEntity.
@Test
public void testDeleteChangeManagerJobExecutionsSingleEntity() {
// given
String jsonFiles;
List<File> filesList;
try {
jsonFiles = TestUtil.readFileFromPath(FILES_PATH);
filesList = new ObjectMapper().readValue(jsonFiles, new TypeReference<>() {
});
} catch (IOException e) {
throw new RuntimeException(e);
}
List<File> limitedFilesList = filesList.stream().limit(1).collect(Collectors.toList());
String stubUserId = UUID.randomUUID().toString();
WireMock.stubFor(get(GET_USER_URL + stubUserId).willReturn(okJson(userResponse.toString())));
InitJobExecutionsRqDto requestDto = new InitJobExecutionsRqDto();
requestDto.getFiles().addAll(limitedFilesList);
requestDto.setUserId(stubUserId);
requestDto.setSourceType(InitJobExecutionsRqDto.SourceType.FILES);
// when
String parentJobExecutionId = RestAssured.given().spec(spec).body(JsonObject.mapFrom(requestDto).toString()).when().post(JOB_EXECUTION_PATH).then().statusCode(HttpStatus.SC_CREATED).extract().path("parentJobExecutionId");
DeleteJobExecutionsReq deleteJobExecutionsReq = new DeleteJobExecutionsReq().withIds(Arrays.asList(parentJobExecutionId));
RestAssured.given().spec(spec).body(deleteJobExecutionsReq).when().delete(JOB_EXECUTION_PATH).then().statusCode(HttpStatus.SC_OK).body("jobExecutionDetails.isDeleted.get(0)", is(true)).body("jobExecutionDetails.jobExecutionId.get(0)", is(parentJobExecutionId));
}
use of org.folio.rest.jaxrs.model.DeleteJobExecutionsReq in project mod-source-record-manager by folio-org.
the class ChangeManagerAPITest method testDeleteChangeManagerJobExecutionsMultipleIds.
@Test
public void testDeleteChangeManagerJobExecutionsMultipleIds() {
// given
String jsonFiles;
List<File> filesList;
try {
jsonFiles = TestUtil.readFileFromPath(FILES_PATH);
filesList = new ObjectMapper().readValue(jsonFiles, new TypeReference<>() {
});
} catch (IOException e) {
throw new RuntimeException(e);
}
List<File> limitedFilesList = filesList.stream().limit(1).collect(Collectors.toList());
String stubUserId = UUID.randomUUID().toString();
WireMock.stubFor(get(GET_USER_URL + stubUserId).willReturn(okJson(userResponse.toString())));
InitJobExecutionsRqDto requestDto = new InitJobExecutionsRqDto();
requestDto.getFiles().addAll(limitedFilesList);
requestDto.setUserId(stubUserId);
requestDto.setSourceType(InitJobExecutionsRqDto.SourceType.FILES);
// when
String parentJobExecutionId = RestAssured.given().spec(spec).body(JsonObject.mapFrom(requestDto).toString()).when().post(JOB_EXECUTION_PATH).then().statusCode(HttpStatus.SC_CREATED).extract().path("parentJobExecutionId");
// when
String parentJobExecutionId_2 = RestAssured.given().spec(spec).body(JsonObject.mapFrom(requestDto).toString()).when().post(JOB_EXECUTION_PATH).then().statusCode(HttpStatus.SC_CREATED).extract().path("parentJobExecutionId");
DeleteJobExecutionsReq deleteJobExecutionsReq = new DeleteJobExecutionsReq().withIds(Arrays.asList(parentJobExecutionId, parentJobExecutionId_2));
RestAssured.given().spec(spec).body(deleteJobExecutionsReq).when().delete(JOB_EXECUTION_PATH).then().statusCode(HttpStatus.SC_OK).body("jobExecutionDetails.jobExecutionId.get(0)", is(parentJobExecutionId)).body("jobExecutionDetails.isDeleted.get(0)", is(true)).body("jobExecutionDetails.jobExecutionId.get(1)", is(parentJobExecutionId_2)).body("jobExecutionDetails.isDeleted.get(1)", is(true));
}
Aggregations