From facc49a7991d702903950aa69744d84a84bbc016 Mon Sep 17 00:00:00 2001 From: slhafzjw Date: Fri, 6 Mar 2026 14:04:15 +0800 Subject: [PATCH] refactor(ActionScheduler): rename entry method into schedule --- .../action/dispatcher/ActionDispatcher.java | 2 +- .../dispatcher/executor/ActionExecutor.java | 2 +- .../dispatcher/scheduler/ActionScheduler.kt | 2 +- .../dispatcher/executor/ActionSchedulerTest.kt | 18 +++++++++--------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/ActionDispatcher.java b/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/ActionDispatcher.java index 88115ed0..a40d7261 100644 --- a/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/ActionDispatcher.java +++ b/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/ActionDispatcher.java @@ -53,7 +53,7 @@ public class ActionDispatcher extends PostRunningAbstractAgentModuleAbstract { } } actionExecutor.execute(new ActionExecutorInput(immediateActions)); - actionScheduler.execute(scheduledActions); + actionScheduler.schedule(scheduledActions); }); } diff --git a/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionExecutor.java b/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionExecutor.java index f0a287d5..26635a04 100644 --- a/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionExecutor.java +++ b/Partner-Core/src/main/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionExecutor.java @@ -144,7 +144,7 @@ public class ActionExecutor extends AbstractAgentModule.Sub) = schedulerScope.launch { + fun schedule(input: Set) = schedulerScope.launch { for (schedulableData in input) { log.debug("New data to schedule: {}", schedulableData) timeWheel.schedule(schedulableData) diff --git a/Partner-Core/src/test/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionSchedulerTest.kt b/Partner-Core/src/test/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionSchedulerTest.kt index e329e43b..a254ffd8 100644 --- a/Partner-Core/src/test/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionSchedulerTest.kt +++ b/Partner-Core/src/test/java/work/slhaf/partner/module/modules/action/dispatcher/executor/ActionSchedulerTest.kt @@ -93,7 +93,7 @@ class ActionSchedulerTest { val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default + CoroutineName("ActionSchedulerTest")) scope.launch { - actionScheduler.execute( + actionScheduler.schedule( setOf( buildAction(now.plusSeconds(5)), ) @@ -105,7 +105,7 @@ class ActionSchedulerTest { @Test fun `execute with null input should return null and no side effects`() { // 场景编号:1;路径:B1;目的:验证正常早退 - val result = actionScheduler.execute(null) + val result = actionScheduler.schedule(null) assertEquals(null, result) verify(actionCapability, Mockito.never()).putAction(any(ExecutableAction::class.java)) @@ -120,7 +120,7 @@ class ActionSchedulerTest { ZonedDateTime.now().plusHours(1).toString() ) - actionScheduler.execute(setOf(action)) + actionScheduler.schedule(setOf(action)) verify(actionCapability, times(1)).putAction(action) val timeWheel = timeWheel() @@ -136,7 +136,7 @@ class ActionSchedulerTest { type = Schedulable.ScheduleType.ONCE ) - actionScheduler.execute(setOf(action)) + actionScheduler.schedule(setOf(action)) verify(actionCapability, times(1)).putAction(action) val allScheduled = allScheduledActions(timeWheel()) @@ -151,7 +151,7 @@ class ActionSchedulerTest { type = Schedulable.ScheduleType.ONCE ) - actionScheduler.execute(setOf(action)) + actionScheduler.schedule(setOf(action)) val allScheduled = allScheduledActions(timeWheel()) assertFalse(allScheduled.contains(action)) @@ -166,7 +166,7 @@ class ActionSchedulerTest { scheduleContentOverride = "invalid-cron" ) - actionScheduler.execute(setOf(action)) + actionScheduler.schedule(setOf(action)) val allScheduled = allScheduledActions(timeWheel()) assertFalse(allScheduled.contains(action)) @@ -184,7 +184,7 @@ class ActionSchedulerTest { .putAction(action) assertThrows(RuntimeException::class.java) { - actionScheduler.execute(setOf(action)) + actionScheduler.schedule(setOf(action)) } } @@ -202,7 +202,7 @@ class ActionSchedulerTest { setCurrentHour(timeWheel, actionHour) setWheelState(timeWheel, "SLEEPING") - actionScheduler.execute(setOf(action)) + actionScheduler.schedule(setOf(action)) assertEquals("ACTIVE", wheelStateName(timeWheel)) } @@ -225,7 +225,7 @@ class ActionSchedulerTest { scheduleContentOverride = "invalid-cron" ) - actionScheduler.execute(setOf(ok, nonPrepare, invalid)) + actionScheduler.schedule(setOf(ok, nonPrepare, invalid)) verify(actionCapability, times(1)).putAction(ok) verify(actionCapability, times(1)).putAction(nonPrepare)