Skip to content

Commit

Permalink
[25826] Update FilesystemChangeTriggerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
col-panic committed Nov 6, 2024
1 parent 9d66782 commit f1b224c
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -71,12 +71,16 @@ public void onTemporaryDirectory() throws TaskException, IOException, Interrupte
Path createFile = Files.createTempFile(tempDirectory, "test", ".txt");
System.out.println(LocalDateTime.now() + " created " + createFile.toString());

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

List<ITask> result = AllTests.getTaskServiceTestUtil().getTasks(taskDescriptor);
assertEquals(1, result.size());
assertEquals(TaskState.COMPLETED, result.get(0).getState());
Awaitility.with().pollInterval(100, TimeUnit.MILLISECONDS).await().atMost(10, TimeUnit.SECONDS).until(c);
assertFalse(createFile.toFile().exists());

taskService.setActive(taskDescriptor, false);
assertFalse(taskService.getIncurredTasks().contains(taskDescriptor));
Expand All @@ -94,8 +98,7 @@ public void onTemporaryFile() throws TaskException, IOException, InterruptedExce
taskDescriptor.setOwner(AllTests.getOwner());
taskDescriptor.setRunContext(new HashMap<>());
taskDescriptor.setTriggerType(TaskTriggerType.FILESYSTEM_CHANGE);
taskDescriptor.setTriggerParameter(IIdentifiedRunnable.RunContextParameter.STRING_URL,
createFile.toString());
taskDescriptor.setTriggerParameter(IIdentifiedRunnable.RunContextParameter.STRING_URL, createFile.toString());
System.out.println(createFile.toString());
taskDescriptor.setTriggerParameter(TaskTriggerTypeParameter.FILESYSTEM_CHANGE.FILE_EXTENSION_FILTER, "pdf");
taskService.saveTaskDescriptor(taskDescriptor);
Expand All @@ -105,9 +108,4 @@ public void onTemporaryFile() throws TaskException, IOException, InterruptedExce
taskService.setActive(taskDescriptor, true);
}

@Test
public void handleActivateDeactivate() {

}

}

0 comments on commit f1b224c

Please sign in to comment.