Skip to content

Commit

Permalink
Update TaskServiceTest
Browse files Browse the repository at this point in the history
  • Loading branch information
col-panic committed Aug 8, 2024
1 parent 070f69b commit b2d6fda
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ch.elexis.core.tasks.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
Expand Down Expand Up @@ -146,7 +147,6 @@ public void reloadOnTaskDescriptorChangeDeleted() throws TaskException {
*/
@Test
public void triggerCron() throws TaskException, IOException {

IIdentifiedRunnable rwcDeleteFile = taskService
.instantiateRunnableById(IdentifiedRunnableIdConstants.DELETEFILE);
Path createFile = Files.createTempFile(tempDirectory, "test", "txt");
Expand All @@ -161,11 +161,15 @@ public void triggerCron() throws TaskException, IOException {
taskDescriptor.setTriggerParameter(TaskTriggerTypeParameter.CRON.SCHEMA, "0/5 * * * * ?");
taskService.setActive(taskDescriptor, true);

Callable<Boolean> c = () -> !createFile.toFile().exists();

Awaitility.await().atMost(30, TimeUnit.SECONDS).until(c);
Optional<ITask> execution = taskService.findLatestExecution(taskDescriptor);
assertEquals(TaskState.COMPLETED, execution.get().getState());
Callable<Boolean> c = () -> {
Optional<ITask> execution = taskService.findLatestExecution(taskDescriptor);
if (execution.isPresent()) {
return TaskState.COMPLETED == execution.get().getState();
}
return false;
};
Awaitility.with().pollInterval(100, TimeUnit.MILLISECONDS).await().atMost(10, TimeUnit.SECONDS).until(c);
assertFalse(createFile.toFile().exists());
}

/**
Expand Down

0 comments on commit b2d6fda

Please sign in to comment.