Skip to content

Commit

Permalink
Refactor WorkflowControllerServiceIT to load test files dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Dec 18, 2023
1 parent f36b852 commit 5b8317c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public void shouldClose() throws Exception {
@Test
public void shouldCloseForProcessWithParallelTasks() throws Exception {
Task task = taskService.getById(19);
ProcessTestUtils.copyTestMetadataFile(task.getProcess().getId(), ProcessTestUtils.testFileChildProcessToKeep);

workflowService.close(task);
assertEquals("Task '" + task.getTitle() + "' was not closed!", TaskStatus.DONE, task.getProcessingStatus());
Expand All @@ -193,11 +194,14 @@ public void shouldCloseForProcessWithParallelTasks() throws Exception {
nextTask = taskService.getById(23);
assertEquals("Task '" + nextTask.getTitle() + "' was set up to open!", TaskStatus.LOCKED,
nextTask.getProcessingStatus());

ProcessTestUtils.removeTestProcess(task.getProcess().getId());
}

@Test
public void shouldCloseForInWorkProcessWithParallelTasks() throws Exception {
Task task = taskService.getById(25);
ProcessTestUtils.copyTestMetadataFile(task.getProcess().getId(), ProcessTestUtils.testFileChildProcessToKeep);

workflowService.close(task);
assertEquals("Task '" + task.getTitle() + "' was not closed!", TaskStatus.DONE, task.getProcessingStatus());
Expand All @@ -215,6 +219,7 @@ public void shouldCloseForInWorkProcessWithParallelTasks() throws Exception {
nextTask = taskService.getById(28);
assertEquals("Task '" + nextTask.getTitle() + "' was set up to open!", TaskStatus.LOCKED,
nextTask.getProcessingStatus());
ProcessTestUtils.removeTestProcess(task.getProcess().getId());
}

@Test
Expand Down Expand Up @@ -342,9 +347,10 @@ public void shouldCloseForProcessWithScriptParallelTasks() throws Exception {

@Test
public void shouldCloseForProcessWithSkippedTask() throws DataException, DAOException, IOException {
Process process = new Process();
process.setProcessBaseUri(URI.create("4"));
ServiceManager.getProcessService().save(process);
int processId = MockDatabase.insertTestProcess("Test process", 1, 1, 1);
Process process = ServiceManager.getProcessService().getById(processId);
process.getTasks().clear();
ProcessTestUtils.copyTestMetadataFile(processId, ProcessTestUtils.testFileForHierarchyParent);
WorkflowCondition workflowCondition = new WorkflowCondition("xpath", "/mets:nothing");
ServiceManager.getWorkflowConditionService().saveToDatabase(workflowCondition);
Task taskToClose = createAndSaveTask(TaskStatus.INWORK, 1, process, null);
Expand Down Expand Up @@ -380,7 +386,7 @@ public void shouldCloseForProcessWithSkippedTask() throws DataException, DAOExce
thirdTaskToSkip.getProcessingStatus());

process.getTasks().clear();
ServiceManager.getProcessService().remove(process);
ProcessTestUtils.removeTestProcess(processId);
}

private Task createAndSaveTask(TaskStatus taskStatus, int ordering, Process process,
Expand Down
4 changes: 2 additions & 2 deletions Kitodo/src/test/java/org/kitodo/utils/ProcessTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class ProcessTestUtils {
public static final String META_XML = "/meta.xml";
private static final int TEST_PROJECT_ID = 1;
private static final int TEST_TEMPLATE_ID = 1;
private static final String testFileForHierarchyParent = "multivalued_metadata.xml";
private static final String testFileChildProcessToKeep = "testMetadataForChildProcessToKeep.xml";
public static final String testFileForHierarchyParent = "multivalued_metadata.xml";
public static final String testFileChildProcessToKeep = "testMetadataForChildProcessToKeep.xml";
private static final String testFileChildProcessToRemove = "testMetadataForKitodoScript.xml";
private static final Map<String, String> hierarchyProcessTitlesAndFiles;
static {
Expand Down

0 comments on commit 5b8317c

Please sign in to comment.