mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Create ready markers for YAML providers (#5605)
yaml=items yaml=pages yaml=rules yaml=ruletemplates yaml=tags yaml=sitemaps yaml=things yaml=widgets Related to #5602 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
+26
-1
@@ -52,6 +52,8 @@ import org.openhab.core.model.yaml.internal.semantics.YamlSemanticTagDTO;
|
||||
import org.openhab.core.model.yaml.internal.sitemaps.YamlSitemapDTO;
|
||||
import org.openhab.core.model.yaml.internal.things.YamlThingDTO;
|
||||
import org.openhab.core.model.yaml.internal.widgets.YamlWidgetDTO;
|
||||
import org.openhab.core.service.ReadyMarker;
|
||||
import org.openhab.core.service.ReadyService;
|
||||
import org.openhab.core.service.WatchService;
|
||||
import org.openhab.core.service.WatchService.Kind;
|
||||
import org.osgi.service.component.annotations.Activate;
|
||||
@@ -119,6 +121,7 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
private final WatchService watchService;
|
||||
private final Path mainWatchPath;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ReadyService readyService;
|
||||
|
||||
private final Map<String, List<YamlModelListener<?>>> elementListeners = new ConcurrentHashMap<>();
|
||||
// all model nodes, ordered by model name (full path as string) and type
|
||||
@@ -126,10 +129,12 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
|
||||
private final Map<String, List<YamlElement>> elementsToGenerate = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean allFilesVisited;
|
||||
private int counter;
|
||||
|
||||
@Activate
|
||||
public YamlModelRepositoryImpl(@Reference(target = WatchService.CONFIG_WATCHER_FILTER) WatchService watchService) {
|
||||
public YamlModelRepositoryImpl(@Reference(target = WatchService.CONFIG_WATCHER_FILTER) WatchService watchService,
|
||||
final @Reference ReadyService readyService) {
|
||||
YAMLFactory yamlFactory = YAMLFactory.builder() //
|
||||
.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER) // omit "---" at file start
|
||||
.disable(YAMLGenerator.Feature.SPLIT_LINES) // do not split long lines
|
||||
@@ -148,6 +153,8 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
|
||||
this.watchService = watchService;
|
||||
this.mainWatchPath = watchService.getWatchPath();
|
||||
this.readyService = readyService;
|
||||
this.allFilesVisited = false;
|
||||
|
||||
watchService.registerListener(this, WATCHED_PATHS);
|
||||
|
||||
@@ -190,6 +197,14 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
this.allFilesVisited = true;
|
||||
|
||||
KNOWN_ELEMENTS.forEach(elementName -> {
|
||||
if (!getElementListeners(elementName).isEmpty()) {
|
||||
markReady(elementName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Deactivate
|
||||
@@ -415,6 +430,10 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
logger.info("YAML model {}: {}", modelName, warning);
|
||||
});
|
||||
});
|
||||
|
||||
if (allFilesVisited) {
|
||||
markReady(elementName);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeYamlModelListener(YamlModelListener<? extends YamlElement> listener) {
|
||||
@@ -425,6 +444,12 @@ public class YamlModelRepositoryImpl implements WatchService.WatchEventListener,
|
||||
});
|
||||
}
|
||||
|
||||
private void markReady(String elementName) {
|
||||
ReadyMarker marker = new ReadyMarker("yaml", elementName.toLowerCase());
|
||||
logger.debug("Create ready marker {}", marker);
|
||||
readyService.markReady(marker);
|
||||
}
|
||||
|
||||
private void checkElementNames(String modelName, YamlModelWrapper model, List<String> warnings) {
|
||||
Set<String> elementListenerNames = elementListeners.keySet();
|
||||
if (elementListenerNames.containsAll(KNOWN_ELEMENTS)) {
|
||||
|
||||
+18
-16
@@ -50,6 +50,7 @@ import org.openhab.core.model.yaml.YamlModelListener;
|
||||
import org.openhab.core.model.yaml.internal.items.YamlItemDTO;
|
||||
import org.openhab.core.model.yaml.test.FirstTypeDTO;
|
||||
import org.openhab.core.model.yaml.test.SecondTypeDTO;
|
||||
import org.openhab.core.service.ReadyService;
|
||||
import org.openhab.core.service.WatchService;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
@@ -70,6 +71,7 @@ public class YamlModelRepositoryImplTest {
|
||||
private static final Path MODEL_PATH = Path.of(MODEL_NAME);
|
||||
|
||||
private @Mock @NonNullByDefault({}) WatchService watchServiceMock;
|
||||
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;
|
||||
private @TempDir @NonNullByDefault({}) Path watchPath;
|
||||
private @NonNullByDefault({}) Path fullModelPath;
|
||||
|
||||
@@ -101,7 +103,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testFileAddedAfterListeners() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
modelRepository.addYamlModelListener(secondTypeListener1);
|
||||
modelRepository.addYamlModelListener(secondTypeListener2);
|
||||
@@ -142,7 +144,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testFileAddedBeforeListeners() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
|
||||
@@ -182,7 +184,7 @@ public class YamlModelRepositoryImplTest {
|
||||
|
||||
@Test
|
||||
public void testFileUpdated() throws IOException {
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileUpdatePost.yaml"), fullModelPath);
|
||||
@@ -219,7 +221,7 @@ public class YamlModelRepositoryImplTest {
|
||||
"modelFileUpdateRemovedVersion.yaml" //
|
||||
})
|
||||
public void testFileRemovedElements(String file) throws IOException {
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileUpdatePost.yaml"), fullModelPath);
|
||||
@@ -240,7 +242,7 @@ public class YamlModelRepositoryImplTest {
|
||||
|
||||
@Test
|
||||
public void testFileRemoved() throws IOException {
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
|
||||
@@ -269,7 +271,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testAddElementToModel() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("modifyModelInitialContent.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
modelRepository.addYamlModelListener(secondTypeListener1);
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
@@ -307,7 +309,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testUpdateElementInModel() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("modifyModelInitialContent.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
|
||||
@@ -334,7 +336,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testRemoveElementFromModel() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("modifyModelInitialContent.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
|
||||
FirstTypeDTO removed = new FirstTypeDTO("element1", "description1");
|
||||
@@ -361,7 +363,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testReadOnlyModelNotUpdated() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
|
||||
FirstTypeDTO added = new FirstTypeDTO("element3", "description3");
|
||||
@@ -388,7 +390,7 @@ public class YamlModelRepositoryImplTest {
|
||||
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
@@ -411,7 +413,7 @@ public class YamlModelRepositoryImplTest {
|
||||
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
@@ -434,7 +436,7 @@ public class YamlModelRepositoryImplTest {
|
||||
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(firstTypeListener);
|
||||
|
||||
modelRepository.processWatchEvent(WatchService.Kind.CREATE, fullModelPath);
|
||||
@@ -455,7 +457,7 @@ public class YamlModelRepositoryImplTest {
|
||||
|
||||
Files.copy(SOURCE_PATH.resolve("modelFileAddedOrRemoved.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(secondTypeListener1);
|
||||
modelRepository.addYamlModelListener(secondTypeListener2);
|
||||
|
||||
@@ -478,7 +480,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testObjectFormMetadataLoadingAndGeneration() throws IOException {
|
||||
Files.copy(SOURCE_PATH_ITEMS.resolve("itemWithObjectFormMetadata.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
YamlModelListener<YamlItemDTO> itemListener = mock(YamlModelListener.class);
|
||||
@@ -522,7 +524,7 @@ public class YamlModelRepositoryImplTest {
|
||||
@Test
|
||||
public void testShortFormMetadataLoadingAndGeneration() throws IOException {
|
||||
Files.copy(SOURCE_PATH_ITEMS.resolve("itemWithShortFormMetadata.yaml"), fullModelPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
YamlModelListener<YamlItemDTO> itemListener = mock(YamlModelListener.class);
|
||||
@@ -566,7 +568,7 @@ public class YamlModelRepositoryImplTest {
|
||||
public void testMixedFormMetadataLoadingAndGeneration() throws IOException {
|
||||
Files.copy(SOURCE_PATH_ITEMS.resolve("itemWithMixedFormMetadata.yaml"), fullModelPath);
|
||||
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
YamlModelListener<YamlItemDTO> itemListener = mock(YamlModelListener.class);
|
||||
|
||||
+8
-6
@@ -54,6 +54,7 @@ import org.openhab.core.config.core.FilterCriteria;
|
||||
import org.openhab.core.config.core.ParameterOption;
|
||||
import org.openhab.core.model.yaml.YamlModelUtils;
|
||||
import org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl;
|
||||
import org.openhab.core.service.ReadyService;
|
||||
import org.openhab.core.service.WatchService;
|
||||
|
||||
/**
|
||||
@@ -70,6 +71,7 @@ public class YamlRuleProviderTest {
|
||||
private static final Path RULES_PATH = Path.of(RULES_NAME);
|
||||
|
||||
private @Mock @NonNullByDefault({}) WatchService watchServiceMock;
|
||||
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;
|
||||
private @TempDir @NonNullByDefault({}) Path watchPath;
|
||||
private @NonNullByDefault({}) Path rulesPath;
|
||||
|
||||
@@ -82,7 +84,7 @@ public class YamlRuleProviderTest {
|
||||
@Test
|
||||
public void yamlModelListenerTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("BasicRule.yaml"), rulesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleProvider ruleProvider = new YamlRuleProvider();
|
||||
TestRuleChangeListener ruleListener = new TestRuleChangeListener();
|
||||
ruleProvider.addProviderChangeListener(ruleListener);
|
||||
@@ -109,7 +111,7 @@ public class YamlRuleProviderTest {
|
||||
@Test
|
||||
public void emptyRuleTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("EmptyRule.yaml"), rulesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleProvider ruleProvider = new YamlRuleProvider();
|
||||
TestRuleChangeListener ruleListener = new TestRuleChangeListener();
|
||||
ruleProvider.addProviderChangeListener(ruleListener);
|
||||
@@ -122,7 +124,7 @@ public class YamlRuleProviderTest {
|
||||
@Test
|
||||
public void basicRuleTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("BasicRule.yaml"), rulesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleProvider ruleProvider = new YamlRuleProvider();
|
||||
TestRuleChangeListener ruleListener = new TestRuleChangeListener();
|
||||
ruleProvider.addProviderChangeListener(ruleListener);
|
||||
@@ -202,7 +204,7 @@ public class YamlRuleProviderTest {
|
||||
@Test
|
||||
public void mixedRulesTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("MixedRules.yaml"), rulesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleProvider ruleProvider = new YamlRuleProvider();
|
||||
TestRuleChangeListener ruleListener = new TestRuleChangeListener();
|
||||
ruleProvider.addProviderChangeListener(ruleListener);
|
||||
@@ -436,7 +438,7 @@ public class YamlRuleProviderTest {
|
||||
@Test
|
||||
public void fullRuleTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("FullRule.yaml"), rulesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleProvider ruleProvider = new YamlRuleProvider();
|
||||
TestRuleChangeListener ruleListener = new TestRuleChangeListener();
|
||||
ruleProvider.addProviderChangeListener(ruleListener);
|
||||
@@ -631,7 +633,7 @@ public class YamlRuleProviderTest {
|
||||
@Test
|
||||
public void createIsolatedModelWithRuleTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("BasicRule.yaml"), rulesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleProvider ruleProvider = new YamlRuleProvider();
|
||||
TestRuleChangeListener ruleListener = new TestRuleChangeListener();
|
||||
ruleProvider.addProviderChangeListener(ruleListener);
|
||||
|
||||
+6
-4
@@ -52,6 +52,7 @@ import org.openhab.core.config.core.FilterCriteria;
|
||||
import org.openhab.core.config.core.ParameterOption;
|
||||
import org.openhab.core.model.yaml.YamlModelUtils;
|
||||
import org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl;
|
||||
import org.openhab.core.service.ReadyService;
|
||||
import org.openhab.core.service.WatchService;
|
||||
|
||||
/**
|
||||
@@ -68,6 +69,7 @@ public class YamlRuleTemplateProviderTest {
|
||||
private static final Path TEMPLATES_PATH = Path.of(TEMPLATES_NAME);
|
||||
|
||||
private @Mock @NonNullByDefault({}) WatchService watchServiceMock;
|
||||
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;
|
||||
private @TempDir @NonNullByDefault({}) Path watchPath;
|
||||
private @NonNullByDefault({}) Path templatesPath;
|
||||
|
||||
@@ -80,7 +82,7 @@ public class YamlRuleTemplateProviderTest {
|
||||
@Test
|
||||
public void yamlModelListenerTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("BasicRuleTemplate.yaml"), templatesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleTemplateProvider templateProvider = new YamlRuleTemplateProvider();
|
||||
TestRuleTemplateChangeListener templateListener = new TestRuleTemplateChangeListener();
|
||||
templateProvider.addProviderChangeListener(templateListener);
|
||||
@@ -104,7 +106,7 @@ public class YamlRuleTemplateProviderTest {
|
||||
@Test
|
||||
public void basicRuleTemplateTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("BasicRuleTemplate.yaml"), templatesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleTemplateProvider ruleTemplateProvider = new YamlRuleTemplateProvider();
|
||||
TestRuleTemplateChangeListener templateListener = new TestRuleTemplateChangeListener();
|
||||
ruleTemplateProvider.addProviderChangeListener(templateListener);
|
||||
@@ -202,7 +204,7 @@ public class YamlRuleTemplateProviderTest {
|
||||
@Test
|
||||
public void fullRuleTemplateTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("FullRuleTemplate.yaml"), templatesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleTemplateProvider ruleTemplateProvider = new YamlRuleTemplateProvider();
|
||||
TestRuleTemplateChangeListener templateListener = new TestRuleTemplateChangeListener();
|
||||
ruleTemplateProvider.addProviderChangeListener(templateListener);
|
||||
@@ -389,7 +391,7 @@ public class YamlRuleTemplateProviderTest {
|
||||
@Test
|
||||
public void createIsolatedModelWithRuleTemplateTest() throws IOException {
|
||||
Files.copy(SOURCE_PATH.resolve("BasicRuleTemplate.yaml"), templatesPath);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
YamlModelRepositoryImpl modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
YamlRuleTemplateProvider templateProvider = new YamlRuleTemplateProvider();
|
||||
TestRuleTemplateChangeListener templateListener = new TestRuleTemplateChangeListener();
|
||||
templateProvider.addProviderChangeListener(templateListener);
|
||||
|
||||
+3
-1
@@ -40,6 +40,7 @@ import org.openhab.core.common.registry.ProviderChangeListener;
|
||||
import org.openhab.core.model.yaml.YamlElement;
|
||||
import org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl;
|
||||
import org.openhab.core.semantics.SemanticTag;
|
||||
import org.openhab.core.service.ReadyService;
|
||||
import org.openhab.core.service.WatchService;
|
||||
|
||||
/**
|
||||
@@ -56,6 +57,7 @@ public class YamlSemanticTagProviderTest {
|
||||
private static final Path MODEL_PATH = Path.of(MODEL_NAME);
|
||||
|
||||
private @Mock @NonNullByDefault({}) WatchService watchServiceMock;
|
||||
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;
|
||||
|
||||
private @NonNullByDefault({}) YamlModelRepositoryImpl modelRepository;
|
||||
private @NonNullByDefault({}) YamlSemanticTagProvider semanticTagProvider;
|
||||
@@ -75,7 +77,7 @@ public class YamlSemanticTagProviderTest {
|
||||
semanticTagProvider = new YamlSemanticTagProvider();
|
||||
semanticTagProvider.addProviderChangeListener(semanticTagListener);
|
||||
|
||||
modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(semanticTagProvider);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -43,6 +43,7 @@ import org.openhab.core.common.registry.Provider;
|
||||
import org.openhab.core.common.registry.ProviderChangeListener;
|
||||
import org.openhab.core.model.yaml.YamlModelUtils;
|
||||
import org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl;
|
||||
import org.openhab.core.service.ReadyService;
|
||||
import org.openhab.core.service.WatchService;
|
||||
import org.openhab.core.sitemap.Button;
|
||||
import org.openhab.core.sitemap.Buttongrid;
|
||||
@@ -105,6 +106,7 @@ public class YamlSitemapProviderTest {
|
||||
private static final Path MODEL_PATH = Path.of(MODEL_NAME);
|
||||
|
||||
private @Mock @NonNullByDefault({}) WatchService watchServiceMock;
|
||||
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;
|
||||
private @TempDir @NonNullByDefault({}) Path watchPath;
|
||||
private @NonNullByDefault({}) Path fullModelPath;
|
||||
|
||||
@@ -198,7 +200,7 @@ public class YamlSitemapProviderTest {
|
||||
sitemapListener = new TestSitemapChangeListener();
|
||||
sitemapProvider.addProviderChangeListener(sitemapListener);
|
||||
|
||||
modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(sitemapProvider);
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -60,6 +60,7 @@ import org.openhab.core.i18n.LocaleProvider;
|
||||
import org.openhab.core.model.yaml.YamlModelUtils;
|
||||
import org.openhab.core.model.yaml.internal.YamlModelRepositoryImpl;
|
||||
import org.openhab.core.service.ReadyMarker;
|
||||
import org.openhab.core.service.ReadyService;
|
||||
import org.openhab.core.service.WatchService;
|
||||
import org.openhab.core.thing.Bridge;
|
||||
import org.openhab.core.thing.Channel;
|
||||
@@ -129,6 +130,7 @@ public class YamlThingProviderTest {
|
||||
private static final ThingUID NTP_THING_UID = new ThingUID(NTP_THING_TYPE_UID, "local");
|
||||
|
||||
private @Mock @NonNullByDefault({}) WatchService watchServiceMock;
|
||||
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;
|
||||
private @TempDir @NonNullByDefault({}) Path watchPath;
|
||||
private @NonNullByDefault({}) Path fullModelPath;
|
||||
|
||||
@@ -236,7 +238,7 @@ public class YamlThingProviderTest {
|
||||
thingListener = new TestThingChangeListener();
|
||||
thingProvider.addProviderChangeListener(thingListener);
|
||||
|
||||
modelRepository = new YamlModelRepositoryImpl(watchServiceMock);
|
||||
modelRepository = new YamlModelRepositoryImpl(watchServiceMock, readyServiceMock);
|
||||
modelRepository.addYamlModelListener(thingProvider);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user