Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=org.ceskaexpedice
version=1.3-rc1
version=1.3-rc2
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,16 @@ public Response getProcess(@PathParam("processId") String processId) {
}

@GET
@Path("batch")
@Path("batch/{mainProcessId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getBatch(@PathParam("mainProcessId") String mainProcessId) {
Batch batch = processService.getBatch(mainProcessId);
JSONObject batchJson = ProcessServiceMapper.mapBatchToJson(batch);
return APIRestUtilities.jsonPayload(batchJson.toString());
}

@GET
@Path("batches")
@Produces(MediaType.APPLICATION_JSON)
public Response getBatches(
@QueryParam("offset") String offsetStr,
Expand Down
62 changes: 61 additions & 1 deletion process-manager/src/main/webapp/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ paths:
'404':
description: Process not found

/process/batch:
/process/batches:
get:
tags:
- Processes
Expand Down Expand Up @@ -817,6 +817,66 @@ paths:
description: Bad request - wrong parameters

/process/batch/{mainProcessId}:
get:
tags:
- Processes
summary: Returns the batch specified
description: Returns the batch specified
parameters:
- name: mainProcessId
in: path
required: true
description: Main process id
schema:
type: string
example: ed25ce29-2149-439d-85c4-cc5e516e3036
responses:
'200':
description: JSON representation of the batch
content:
application/json:
schema:
type: string
example: {
"owner" : "PePo",
"processes" : [ {
"owner" : "PePo",
"workerId" : "curatorWorker",
"processId" : "6853579d-15c1-4fb9-ad11-3e107141aedb",
"payload" : {
"surname" : "Po",
"name" : "Pe"
},
"profileId" : "testPlugin1-big",
"description" : "NewProcessName-PePo",
"pid" : 27204,
"started" : 1755262856918,
"finished" : 1755262857087,
"planned" : 1755262848459,
"batchId" : "6853579d-15c1-4fb9-ad11-3e107141aedb",
"status" : "FINISHED"
}, {
"owner" : "PePo",
"workerId" : "curatorWorker",
"processId" : "114a8406-1788-4cc5-bb04-89ca1a8ba9fe",
"payload" : { },
"profileId" : "testPlugin2",
"description" : "Sub process for the profile testPlugin2",
"pid" : 10900,
"started" : 1755262858373,
"finished" : 1755262858428,
"planned" : 1755262857057,
"batchId" : "6853579d-15c1-4fb9-ad11-3e107141aedb",
"status" : "FINISHED"
} ],
"mainProcessId" : "ed25ce29-2149-439d-85c4",
"started" : 1755262856918,
"finished" : 1755262857087,
"planned" : 1755262848459,
"status" : "FINISHED"
}
'404':
description: Process not found
delete:
tags:
- Processes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,34 @@ public void testGetProcess() throws JsonProcessingException {
verify(processServiceMock, times(2)).getProcess(any());
}

@Test
public void testGetBatch() {
Batch batch = new Batch();
batch.setMainProcessId(PROCESS1_ID);
batch.setStatus(ProcessState.WARNING);
ProcessInfo processInfo1 = new ProcessInfo();
processInfo1.setPlanned(new Date());
processInfo1.setProcessId(PROCESS1_ID);
processInfo1.setBatchId(PROCESS1_ID);
processInfo1.setStatus(ProcessState.FINISHED);
batch.getProcesses().add(processInfo1);
ProcessInfo processInfo2 = new ProcessInfo();
processInfo2.setProcessId(PROCESS2_ID);
processInfo2.setBatchId(PROCESS1_ID);
processInfo2.setStatus(ProcessState.WARNING);
batch.getProcesses().add(processInfo2);

when(processServiceMock.getBatch(eq(PROCESS1_ID))).thenReturn(batch);

Response response = target("process/batch/" + PROCESS1_ID).request().accept(MediaType.APPLICATION_JSON_TYPE).get();
Assertions.assertEquals(200, response.getStatus());
String json = response.readEntity(String.class);
JSONObject jsonObject = new JSONObject(json);
Assertions.assertEquals(PROCESS1_ID, jsonObject.getString("mainProcessId"));

verify(processServiceMock, times(1)).getBatch(eq(PROCESS1_ID));
}

@Test
public void testGetBatches() {
List<Batch> batches = new ArrayList<>();
Expand Down Expand Up @@ -138,7 +166,7 @@ public void testGetBatches() {
when(processServiceMock.countBatchHeaders(any())).thenReturn(2);
when(processServiceMock.getBatches(any(), eq(0), eq(10))).thenReturn(batches);

Response response = target("process/batch").request().accept(MediaType.APPLICATION_JSON_TYPE).get();
Response response = target("process/batches").request().accept(MediaType.APPLICATION_JSON_TYPE).get();
Assertions.assertEquals(200, response.getStatus());
String json = response.readEntity(String.class);
JSONObject jsonObject = new JSONObject(json);
Expand Down