mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-25 11:45:49 +01:00
Ephemeris: consider the default weekend dayset (#4253)
Fix openhab/openhab-addons#16812 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
4b4f25d31b
commit
a5a7eee9a8
@ -107,6 +107,9 @@ public class EphemerisManagerImpl implements EphemerisManager, ConfigOptionProvi
|
||||
this.localeProvider = localeProvider;
|
||||
bundle = bundleContext.getBundle();
|
||||
|
||||
// Default weekend dayset
|
||||
addDayset(CONFIG_DAYSET_WEEKEND, List.of(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY));
|
||||
|
||||
try (InputStream stream = bundle.getResource(JOLLYDAY_COUNTRY_DESCRIPTIONS).openStream()) {
|
||||
final Properties properties = new Properties();
|
||||
properties.load(stream);
|
||||
|
@ -15,8 +15,7 @@ package org.openhab.core.automation.integration.test;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
@ -148,8 +147,7 @@ public class RuleSimulationTest extends JavaOSGiTest {
|
||||
List<RuleExecution> executions = ruleEngine.simulateRuleExecutions(from, until).toList();
|
||||
|
||||
// Every rule fires twice a week. We simulate for two weeks so we expect 12 executions
|
||||
// TODO: must be 12, but Ephemeris Condition is not yet evaluated in test, because dayset is not configured.
|
||||
assertEquals(8, executions.size());
|
||||
assertEquals(12, executions.size());
|
||||
|
||||
Iterator<RuleExecution> it = executions.iterator();
|
||||
|
||||
@ -159,16 +157,16 @@ public class RuleSimulationTest extends JavaOSGiTest {
|
||||
checkExecution(it.next(), cronRuleWithTimeOfDayCondition, 6, 10, 30);
|
||||
checkExecution(it.next(), timeOfDayTriggerWithDayOfWeekCondition, 6, 16, 00);
|
||||
checkExecution(it.next(), cronRuleWithTimeOfDayCondition, 8, 10, 30);
|
||||
// checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 9, 10, 00);
|
||||
// checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 10, 10, 00);
|
||||
checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 9, 10, 00);
|
||||
checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 10, 10, 00);
|
||||
|
||||
// Second week
|
||||
checkExecution(it.next(), timeOfDayTriggerWithDayOfWeekCondition, 11, 16, 00);
|
||||
checkExecution(it.next(), cronRuleWithTimeOfDayCondition, 13, 10, 30);
|
||||
checkExecution(it.next(), timeOfDayTriggerWithDayOfWeekCondition, 13, 16, 00);
|
||||
checkExecution(it.next(), cronRuleWithTimeOfDayCondition, 15, 10, 30);
|
||||
// checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 16, 10, 00);
|
||||
// checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 17, 10, 00);
|
||||
checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 16, 10, 00);
|
||||
checkExecution(it.next(), timeOfDayTriggerWithEphemerisCondition, 17, 10, 00);
|
||||
assertFalse(it.hasNext());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user