From b2d6fda51b3535bdd597d887f91801df5f3e7f25 Mon Sep 17 00:00:00 2001 From: Marco Descher Date: Thu, 8 Aug 2024 10:15:44 +0200 Subject: [PATCH] Update TaskServiceTest --- .../elexis/core/tasks/test/TaskServiceTest.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/ch.elexis.core.tasks.test/src/ch/elexis/core/tasks/test/TaskServiceTest.java b/tests/ch.elexis.core.tasks.test/src/ch/elexis/core/tasks/test/TaskServiceTest.java index 4dbb5f8699..248ae20b36 100644 --- a/tests/ch.elexis.core.tasks.test/src/ch/elexis/core/tasks/test/TaskServiceTest.java +++ b/tests/ch.elexis.core.tasks.test/src/ch/elexis/core/tasks/test/TaskServiceTest.java @@ -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; @@ -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"); @@ -161,11 +161,15 @@ public void triggerCron() throws TaskException, IOException { taskDescriptor.setTriggerParameter(TaskTriggerTypeParameter.CRON.SCHEMA, "0/5 * * * * ?"); taskService.setActive(taskDescriptor, true); - Callable c = () -> !createFile.toFile().exists(); - - Awaitility.await().atMost(30, TimeUnit.SECONDS).until(c); - Optional execution = taskService.findLatestExecution(taskDescriptor); - assertEquals(TaskState.COMPLETED, execution.get().getState()); + Callable c = () -> { + Optional 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()); } /**