Skip to content

Commit

Permalink
fix: recurring tasks get correct default priority without data (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
geirsagberg committed Jan 17, 2025
1 parent 463b613 commit b0c5bb5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Class<T> getDataClass() {

@Override
public TaskInstance<T> instance(String id) {
return instanceBuilder(id).build();
return instanceBuilder(id).priority(getDefaultPriority()).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.github.kagkarlsson.scheduler.task;

import static org.junit.jupiter.api.Assertions.*;

import com.github.kagkarlsson.scheduler.task.helper.RecurringTask;
import com.github.kagkarlsson.scheduler.task.helper.Tasks;
import com.github.kagkarlsson.scheduler.task.schedule.Daily;
import java.time.LocalTime;
import org.junit.jupiter.api.Test;

class AbstractTaskTest {

@Test
void test_default_priority_with_data() {
RecurringTask<String> task =
Tasks.recurring("task", new Daily(LocalTime.MIDNIGHT), String.class)
.executeStateful((taskInstance, executionContext) -> "");

assertEquals(task.getDefaultPriority(), task.instance("id", "data").getPriority());
}

@Test
void test_default_priority_without_data() {
RecurringTask<Void> task =
Tasks.recurring("task", new Daily(LocalTime.MIDNIGHT))
.execute((taskInstance, executionContext) -> {});

assertEquals(task.getDefaultPriority(), task.instance("id").getPriority());
}
}

0 comments on commit b0c5bb5

Please sign in to comment.