Skip to content

Commit

Permalink
Ensure metadata available at startlevel 20 (openhab#3273)
Browse files Browse the repository at this point in the history
* Ensure metadata available at start-level 20

This makes the `MetadataRegistry` report when the elements of the `ManagedMetadataProvider` is available via a ready marker (like other registries).

Signed-off-by: Jan N. Klug <github@klug.nrw>
  • Loading branch information
J-N-K authored Jan 10, 2023
1 parent fd5b451 commit a09ad3d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
public class MetadataRegistryImpl extends AbstractRegistry<Metadata, MetadataKey, MetadataProvider>
implements MetadataRegistry {

public MetadataRegistryImpl() {
@Activate
public MetadataRegistryImpl(final @Reference ReadyService readyService) {
super(MetadataProvider.class);
super.setReadyService(readyService);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.openhab.core.items.ManagedMetadataProvider;
import org.openhab.core.items.Metadata;
import org.openhab.core.items.MetadataKey;
import org.openhab.core.service.ReadyService;
import org.openhab.core.types.CommandDescription;
import org.openhab.core.types.CommandOption;
import org.osgi.framework.BundleContext;
Expand All @@ -52,6 +53,7 @@ public class MetadataCommandDescriptionProviderTest {
private @Mock @NonNullByDefault({}) ManagedMetadataProvider managedProviderMock;

private @Mock @NonNullByDefault({}) MetadataRegistryImpl metadataRegistryMock;
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;
private @NonNullByDefault({}) MetadataCommandDescriptionProvider commandDescriptionProvider;

private @NonNullByDefault({}) ServiceListener providerTracker;
Expand All @@ -61,7 +63,7 @@ public class MetadataCommandDescriptionProviderTest {
public void setup() throws Exception {
when(bundleContextMock.getService(same(managedProviderRefMock))).thenReturn(managedProviderMock);

metadataRegistryMock = new MetadataRegistryImpl();
metadataRegistryMock = new MetadataRegistryImpl(readyServiceMock);
metadataRegistryMock.setManagedProvider(managedProviderMock);
metadataRegistryMock.activate(bundleContextMock);
metadataRegistryMock.waitForCompletedAsyncActivationTasks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.openhab.core.items.ManagedMetadataProvider;
import org.openhab.core.items.Metadata;
import org.openhab.core.items.MetadataKey;
import org.openhab.core.service.ReadyService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
Expand All @@ -44,6 +45,7 @@ public class MetadataRegistryImplTest {
private @Mock @NonNullByDefault({}) ServiceReference managedProviderRefMock;
private @Mock @NonNullByDefault({}) BundleContext bundleContextMock;
private @Mock @NonNullByDefault({}) ManagedMetadataProvider managedProviderMock;
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;

private @NonNullByDefault({}) MetadataRegistryImpl registry;
private @NonNullByDefault({}) ServiceListener providerTracker;
Expand All @@ -53,7 +55,7 @@ public class MetadataRegistryImplTest {
public void setup() throws Exception {
when(bundleContextMock.getService(same(managedProviderRefMock))).thenReturn(managedProviderMock);

registry = new MetadataRegistryImpl();
registry = new MetadataRegistryImpl(readyServiceMock);
registry.setManagedProvider(managedProviderMock);
registry.activate(bundleContextMock);
registry.waitForCompletedAsyncActivationTasks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openhab.core.items.ManagedMetadataProvider;
import org.openhab.core.items.Metadata;
import org.openhab.core.items.MetadataKey;
import org.openhab.core.service.ReadyService;
import org.openhab.core.types.StateDescriptionFragment;
import org.openhab.core.types.StateOption;
import org.osgi.framework.BundleContext;
Expand All @@ -53,6 +54,8 @@ public class MetadataStateDescriptionFragmentProviderTest {
private @Mock @NonNullByDefault({}) ManagedMetadataProvider managedProviderMock;

private @Mock @NonNullByDefault({}) MetadataRegistryImpl metadataRegistryMock;
private @Mock @NonNullByDefault({}) ReadyService readyServiceMock;

private @NonNullByDefault({}) MetadataStateDescriptionFragmentProvider stateDescriptionFragmentProvider;

private @NonNullByDefault({}) ServiceListener providerTracker;
Expand All @@ -62,7 +65,7 @@ public class MetadataStateDescriptionFragmentProviderTest {
public void setup() throws Exception {
when(bundleContextMock.getService(same(managedProviderRefMock))).thenReturn(managedProviderMock);

metadataRegistryMock = new MetadataRegistryImpl();
metadataRegistryMock = new MetadataRegistryImpl(readyServiceMock);
metadataRegistryMock.setManagedProvider(managedProviderMock);
metadataRegistryMock.activate(bundleContextMock);
metadataRegistryMock.waitForCompletedAsyncActivationTasks();
Expand Down

0 comments on commit a09ad3d

Please sign in to comment.