Skip to content

Commit 5b8317c

Browse files
committed
Refactor WorkflowControllerServiceIT to load test files dynamically
1 parent f36b852 commit 5b8317c

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Kitodo/src/test/java/org/kitodo/production/services/workflow/WorkflowControllerServiceIT.java

+10-4
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public void shouldClose() throws Exception {
171171
@Test
172172
public void shouldCloseForProcessWithParallelTasks() throws Exception {
173173
Task task = taskService.getById(19);
174+
ProcessTestUtils.copyTestMetadataFile(task.getProcess().getId(), ProcessTestUtils.testFileChildProcessToKeep);
174175

175176
workflowService.close(task);
176177
assertEquals("Task '" + task.getTitle() + "' was not closed!", TaskStatus.DONE, task.getProcessingStatus());
@@ -193,11 +194,14 @@ public void shouldCloseForProcessWithParallelTasks() throws Exception {
193194
nextTask = taskService.getById(23);
194195
assertEquals("Task '" + nextTask.getTitle() + "' was set up to open!", TaskStatus.LOCKED,
195196
nextTask.getProcessingStatus());
197+
198+
ProcessTestUtils.removeTestProcess(task.getProcess().getId());
196199
}
197200

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

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

220225
@Test
@@ -342,9 +347,10 @@ public void shouldCloseForProcessWithScriptParallelTasks() throws Exception {
342347

343348
@Test
344349
public void shouldCloseForProcessWithSkippedTask() throws DataException, DAOException, IOException {
345-
Process process = new Process();
346-
process.setProcessBaseUri(URI.create("4"));
347-
ServiceManager.getProcessService().save(process);
350+
int processId = MockDatabase.insertTestProcess("Test process", 1, 1, 1);
351+
Process process = ServiceManager.getProcessService().getById(processId);
352+
process.getTasks().clear();
353+
ProcessTestUtils.copyTestMetadataFile(processId, ProcessTestUtils.testFileForHierarchyParent);
348354
WorkflowCondition workflowCondition = new WorkflowCondition("xpath", "/mets:nothing");
349355
ServiceManager.getWorkflowConditionService().saveToDatabase(workflowCondition);
350356
Task taskToClose = createAndSaveTask(TaskStatus.INWORK, 1, process, null);
@@ -380,7 +386,7 @@ public void shouldCloseForProcessWithSkippedTask() throws DataException, DAOExce
380386
thirdTaskToSkip.getProcessingStatus());
381387

382388
process.getTasks().clear();
383-
ServiceManager.getProcessService().remove(process);
389+
ProcessTestUtils.removeTestProcess(processId);
384390
}
385391

386392
private Task createAndSaveTask(TaskStatus taskStatus, int ordering, Process process,

Kitodo/src/test/java/org/kitodo/utils/ProcessTestUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public class ProcessTestUtils {
4848
public static final String META_XML = "/meta.xml";
4949
private static final int TEST_PROJECT_ID = 1;
5050
private static final int TEST_TEMPLATE_ID = 1;
51-
private static final String testFileForHierarchyParent = "multivalued_metadata.xml";
52-
private static final String testFileChildProcessToKeep = "testMetadataForChildProcessToKeep.xml";
51+
public static final String testFileForHierarchyParent = "multivalued_metadata.xml";
52+
public static final String testFileChildProcessToKeep = "testMetadataForChildProcessToKeep.xml";
5353
private static final String testFileChildProcessToRemove = "testMetadataForKitodoScript.xml";
5454
private static final Map<String, String> hierarchyProcessTitlesAndFiles;
5555
static {

0 commit comments

Comments
 (0)