From 892450bb4e1d47c268726c5a2620805595d872c1 Mon Sep 17 00:00:00 2001 From: Alexander Falkenstern Date: Fri, 31 May 2024 10:11:51 +0200 Subject: [PATCH] [systeminfo] Rename Systeminfo* to SystemInfo* (#16823) Signed-off-by: Alexander Falkenstern Signed-off-by: Ciprian Pascu --- .../org.openhab.binding.systeminfo/pom.xml | 2 +- ...s.java => SystemInfoBindingConstants.java} | 4 +- ...ory.java => SystemInfoHandlerFactory.java} | 26 +-- ....java => SystemInfoThingTypeProvider.java} | 14 +- ...e.java => SystemInfoDiscoveryService.java} | 14 +- ...nfoHandler.java => SystemInfoHandler.java} | 38 ++-- ...SHISysteminfo.java => OSHISystemInfo.java} | 18 +- ...nterface.java => SystemInfoInterface.java} | 8 +- .../pom.xml | 2 +- ...oOSGiTest.java => SystemInfoOSGiTest.java} | 174 +++++++++--------- 10 files changed, 149 insertions(+), 151 deletions(-) rename bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/{SysteminfoBindingConstants.java => SystemInfoBindingConstants.java} (99%) rename bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/{SysteminfoHandlerFactory.java => SystemInfoHandlerFactory.java} (76%) rename bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/{SysteminfoThingTypeProvider.java => SystemInfoThingTypeProvider.java} (97%) rename bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/{SysteminfoDiscoveryService.java => SystemInfoDiscoveryService.java} (86%) rename bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/{SysteminfoHandler.java => SystemInfoHandler.java} (97%) rename bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/{OSHISysteminfo.java => OSHISystemInfo.java} (98%) rename bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/{SysteminfoInterface.java => SystemInfoInterface.java} (98%) rename itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/{SysteminfoOSGiTest.java => SystemInfoOSGiTest.java} (89%) diff --git a/bundles/org.openhab.binding.systeminfo/pom.xml b/bundles/org.openhab.binding.systeminfo/pom.xml index 6e8f2d00c90d7..2e16481931654 100644 --- a/bundles/org.openhab.binding.systeminfo/pom.xml +++ b/bundles/org.openhab.binding.systeminfo/pom.xml @@ -12,7 +12,7 @@ org.openhab.binding.systeminfo - openHAB Add-ons :: Bundles :: Systeminfo Binding + openHAB Add-ons :: Bundles :: SystemInfo Binding diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoBindingConstants.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoBindingConstants.java similarity index 99% rename from bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoBindingConstants.java rename to bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoBindingConstants.java index ebe6c7ac83dea..71a2e8df2e23e 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoBindingConstants.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoBindingConstants.java @@ -16,7 +16,7 @@ import org.openhab.core.thing.ThingTypeUID; /** - * The {@link SysteminfoBindingConstants} class defines common constants, which are + * The {@link SystemInfoBindingConstants} class defines common constants, which are * used across the whole binding. * * @author Svilen Valkanov - Initial contribution @@ -24,7 +24,7 @@ * @author Mark Herwege - Processor frequency channels */ @NonNullByDefault -public class SysteminfoBindingConstants { +public class SystemInfoBindingConstants { public static final String BINDING_ID = "systeminfo"; diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoHandlerFactory.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoHandlerFactory.java similarity index 76% rename from bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoHandlerFactory.java rename to bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoHandlerFactory.java index ded9260601982..0b4db4c74c75d 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoHandlerFactory.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoHandlerFactory.java @@ -12,12 +12,12 @@ */ package org.openhab.binding.systeminfo.internal; -import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.*; +import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler; -import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface; +import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler; +import org.openhab.binding.systeminfo.internal.model.SystemInfoInterface; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.binding.BaseThingHandlerFactory; @@ -27,19 +27,19 @@ import org.osgi.service.component.annotations.Reference; /** - * The {@link SysteminfoHandlerFactory} is responsible for creating things and thing + * The {@link SystemInfoHandlerFactory} is responsible for creating things and thing * handlers. * * @author Svilen Valkanov - Initial contribution - * @author Lyubomir Papazov - Pass systeminfo service to the SysteminfoHandler constructor + * @author Lyubomir Papazov - Pass systeminfo service to the SystemInfoHandler constructor * @author Wouter Born - Add null annotations * @author Mark Herwege - Add dynamic creation of extra channels */ @NonNullByDefault @Component(service = ThingHandlerFactory.class, configurationPid = "binding.systeminfo") -public class SysteminfoHandlerFactory extends BaseThingHandlerFactory { - private @NonNullByDefault({}) SysteminfoInterface systeminfo; - private @NonNullByDefault({}) SysteminfoThingTypeProvider thingTypeProvider; +public class SystemInfoHandlerFactory extends BaseThingHandlerFactory { + private @NonNullByDefault({}) SystemInfoInterface systeminfo; + private @NonNullByDefault({}) SystemInfoThingTypeProvider thingTypeProvider; @Override public boolean supportsThingType(ThingTypeUID thingTypeUID) { @@ -58,26 +58,26 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { thingTypeProvider.storeChannelsConfig(thing); // Save the current channels configs, will be restored // after thing type change. } - return new SysteminfoHandler(thing, thingTypeProvider, systeminfo); + return new SystemInfoHandler(thing, thingTypeProvider, systeminfo); } return null; } @Reference - public void bindSystemInfo(SysteminfoInterface systeminfo) { + public void bindSystemInfo(SystemInfoInterface systeminfo) { this.systeminfo = systeminfo; } - public void unbindSystemInfo(SysteminfoInterface systeminfo) { + public void unbindSystemInfo(SystemInfoInterface systeminfo) { this.systeminfo = null; } @Reference - public void setSysteminfoThingTypeProvider(SysteminfoThingTypeProvider thingTypeProvider) { + public void setSystemInfoThingTypeProvider(SystemInfoThingTypeProvider thingTypeProvider) { this.thingTypeProvider = thingTypeProvider; } - public void unsetSysteminfoThingTypeProvider(SysteminfoThingTypeProvider thingTypeProvider) { + public void unsetSystemInfoThingTypeProvider(SystemInfoThingTypeProvider thingTypeProvider) { this.thingTypeProvider = null; } } diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoThingTypeProvider.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoThingTypeProvider.java similarity index 97% rename from bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoThingTypeProvider.java rename to bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoThingTypeProvider.java index 20ab103161b76..93da1c148059a 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SysteminfoThingTypeProvider.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/SystemInfoThingTypeProvider.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.systeminfo.internal; -import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.*; +import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*; import java.net.URI; import java.util.Collections; @@ -51,17 +51,17 @@ /** * Extended channels can be auto discovered and added to newly created groups in the - * {@link org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler}. The - * thing needs to be updated to add the groups. The `SysteminfoThingTypeProvider` OSGi service gives access to the + * {@link org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler}. The + * thing needs to be updated to add the groups. The `SystemInfoThingTypeProvider` OSGi service gives access to the * `ThingTypeRegistry` and serves the updated `ThingType`. * * @author Mark Herwege - Initial contribution * */ @NonNullByDefault -@Component(service = { SysteminfoThingTypeProvider.class, ThingTypeProvider.class }) -public class SysteminfoThingTypeProvider extends AbstractStorageBasedTypeProvider { - private final Logger logger = LoggerFactory.getLogger(SysteminfoThingTypeProvider.class); +@Component(service = { SystemInfoThingTypeProvider.class, ThingTypeProvider.class }) +public class SystemInfoThingTypeProvider extends AbstractStorageBasedTypeProvider { + private final Logger logger = LoggerFactory.getLogger(SystemInfoThingTypeProvider.class); private final ThingTypeRegistry thingTypeRegistry; private final ChannelGroupTypeRegistry channelGroupTypeRegistry; @@ -70,7 +70,7 @@ public class SysteminfoThingTypeProvider extends AbstractStorageBasedTypeProvide private final Map> thingChannelsConfig = new HashMap<>(); @Activate - public SysteminfoThingTypeProvider(@Reference ThingTypeRegistry thingTypeRegistry, + public SystemInfoThingTypeProvider(@Reference ThingTypeRegistry thingTypeRegistry, @Reference ChannelGroupTypeRegistry channelGroupTypeRegistry, @Reference ChannelTypeRegistry channelTypeRegistry, @Reference StorageService storageService) { super(storageService); diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SysteminfoDiscoveryService.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SystemInfoDiscoveryService.java similarity index 86% rename from bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SysteminfoDiscoveryService.java rename to bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SystemInfoDiscoveryService.java index b2c90cfad9bd9..93a73f40e4636 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SysteminfoDiscoveryService.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/discovery/SystemInfoDiscoveryService.java @@ -12,14 +12,13 @@ */ package org.openhab.binding.systeminfo.internal.discovery; -import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.THING_TYPE_COMPUTER; +import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.THING_TYPE_COMPUTER; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants; import org.openhab.core.config.discovery.AbstractDiscoveryService; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultBuilder; @@ -31,7 +30,7 @@ import org.slf4j.LoggerFactory; /** - * Discovery service implementation for the Systeminfo binding. It creates {@link DiscoveryResult} with + * Discovery service implementation for the SystemInfo binding. It creates {@link DiscoveryResult} with * {@link #DEFAULT_THING_LABEL}. The discovered Thing will have id - the hostname or {@link #DEFAULT_THING_ID}' * * @author Svilen Valkanov - Initial contribution @@ -39,11 +38,11 @@ */ @NonNullByDefault @Component(service = DiscoveryService.class, configurationPid = "discovery.systeminfo") -public class SysteminfoDiscoveryService extends AbstractDiscoveryService { +public class SystemInfoDiscoveryService extends AbstractDiscoveryService { public static final String DEFAULT_THING_ID = "unknown"; public static final String DEFAULT_THING_LABEL = "Local computer"; - private final Logger logger = LoggerFactory.getLogger(SysteminfoDiscoveryService.class); + private final Logger logger = LoggerFactory.getLogger(SystemInfoDiscoveryService.class); private static final Set SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COMPUTER); @@ -51,7 +50,7 @@ public class SysteminfoDiscoveryService extends AbstractDiscoveryService { private static final String THING_UID_VALID_CHARS = "A-Za-z0-9_-"; private static final String HOST_NAME_SEPERATOR = "_"; - public SysteminfoDiscoveryService() { + public SystemInfoDiscoveryService() { super(SUPPORTED_THING_TYPES_UIDS, DISCOVERY_TIME_SECONDS); } @@ -74,8 +73,7 @@ protected void startScan() { DEFAULT_THING_ID); } - ThingTypeUID computerType = SysteminfoBindingConstants.THING_TYPE_COMPUTER; - ThingUID computer = new ThingUID(computerType, hostname); + ThingUID computer = new ThingUID(THING_TYPE_COMPUTER, hostname); thingDiscovered(DiscoveryResultBuilder.create(computer).withLabel(DEFAULT_THING_LABEL).build()); } diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SysteminfoHandler.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SystemInfoHandler.java similarity index 97% rename from bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SysteminfoHandler.java rename to bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SystemInfoHandler.java index eb6fccc30c205..366ee9405c817 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SysteminfoHandler.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/handler/SystemInfoHandler.java @@ -12,7 +12,7 @@ */ package org.openhab.binding.systeminfo.internal.handler; -import static org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants.*; +import static org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants.*; import java.math.BigDecimal; import java.util.ArrayList; @@ -27,9 +27,9 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.systeminfo.internal.SysteminfoThingTypeProvider; +import org.openhab.binding.systeminfo.internal.SystemInfoThingTypeProvider; import org.openhab.binding.systeminfo.internal.model.DeviceNotFoundException; -import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface; +import org.openhab.binding.systeminfo.internal.model.SystemInfoInterface; import org.openhab.core.cache.ExpiringCache; import org.openhab.core.cache.ExpiringCacheMap; import org.openhab.core.config.core.Configuration; @@ -55,7 +55,7 @@ import org.slf4j.LoggerFactory; /** - * The {@link SysteminfoHandler} is responsible for providing real time information about the system + * The {@link SystemInfoHandler} is responsible for providing real time information about the system * (CPU, Memory, Storage, Display and others). * * @author Svilen Valkanov - Initial contribution @@ -65,7 +65,7 @@ * @author Mark Herwege - Processor frequency channels */ @NonNullByDefault -public class SysteminfoHandler extends BaseThingHandler { +public class SystemInfoHandler extends BaseThingHandler { /** * Refresh interval for {@link #highPriorityChannels} in seconds. */ @@ -109,9 +109,9 @@ public class SysteminfoHandler extends BaseThingHandler { */ public final String idExtString; - public final SysteminfoThingTypeProvider thingTypeProvider; + public final SystemInfoThingTypeProvider thingTypeProvider; - private SysteminfoInterface systeminfo; + private SystemInfoInterface systeminfo; private @Nullable ScheduledFuture highPriorityTasks; private @Nullable ScheduledFuture mediumPriorityTasks; @@ -128,10 +128,10 @@ public class SysteminfoHandler extends BaseThingHandler { private ExpiringCacheMap processLoadCache = new ExpiringCacheMap<>( MIN_PROCESS_LOAD_REFRESH_INTERVAL_MS); - private final Logger logger = LoggerFactory.getLogger(SysteminfoHandler.class); + private final Logger logger = LoggerFactory.getLogger(SystemInfoHandler.class); - public SysteminfoHandler(Thing thing, SysteminfoThingTypeProvider thingTypeProvider, - SysteminfoInterface systeminfo) { + public SystemInfoHandler(Thing thing, SystemInfoThingTypeProvider thingTypeProvider, + SystemInfoInterface systeminfo) { super(thing); this.thingTypeProvider = thingTypeProvider; this.systeminfo = systeminfo; @@ -145,7 +145,7 @@ public void initialize() { thing.getThingTypeUID().getId()); restoreChannelsConfig(); // After a thing type change, previous channel configs will have been stored, and will // be restored here. - if (instantiateSysteminfoLibrary() && isConfigurationValid() && updateProperties()) { + if (instantiateSystemInfoLibrary() && isConfigurationValid() && updateProperties()) { if (!addDynamicChannels()) { // If there are new channel groups, the thing will get recreated with a new // thing type and this handler will be disposed. Therefore do not do anything // further here. @@ -165,13 +165,13 @@ public void handleRemoval() { super.handleRemoval(); } - private boolean instantiateSysteminfoLibrary() { + private boolean instantiateSystemInfoLibrary() { try { - systeminfo.initializeSysteminfo(); - logger.debug("Systeminfo implementation is instantiated!"); + systeminfo.initializeSystemInfo(); + logger.debug("SystemInfo implementation is instantiated!"); return true; } catch (Exception e) { - logger.warn("Cannot instantiate Systeminfo object!", e); + logger.warn("Cannot instantiate SystemInfo object!", e); return false; } } @@ -428,9 +428,9 @@ public Set getLowPriorityChannels() { } /** - * This method gets the information for specific channel through the {@link SysteminfoInterface}. It uses the - * channel ID to call the correct method from the {@link SysteminfoInterface} with deviceIndex parameter (in case of - * multiple devices, for reference see {@link #getDeviceIndex(String)}}) + * This method gets the information for specific channel through the {@link SystemInfoInterface}. It uses the + * channel ID to call the correct method from the {@link SystemInfoInterface} with deviceIndex parameter (in case of + * multiple devices, for reference see {@link SystemInfoHandler#getDeviceIndex(ChannelUID)}}) * * @param channelUID the UID of the channel * @return State object or null, if there is no information for the device with this index @@ -662,7 +662,7 @@ private State getInfoForChannel(ChannelUID channelUID) { * first will have deviceIndex=0, the second deviceIndex=1 ant etc). * When no device index is specified, default value of 0 (first device in the list) is returned. * - * @param channelID the ID of the channel + * @param channelUID the ID of the channel * @return natural number (number >=0) */ private int getDeviceIndex(ChannelUID channelUID) { diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISystemInfo.java similarity index 98% rename from bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java rename to bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISystemInfo.java index 2277d59e26ced..a88c20890fb1e 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISysteminfo.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/OSHISystemInfo.java @@ -52,12 +52,12 @@ import oshi.util.EdidUtil; /** - * This implementation of {@link SysteminfoInterface} is using the open source library OSHI to provide system + * This implementation of {@link SystemInfoInterface} is using the open source library OSHI to provide system * information. OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java. * * @author Svilen Valkanov - Initial contribution * @author Lyubomir Papazov - Move the initialization logic that could potentially take long time to the - * initializeSysteminfo method + * initializeSystemInfo method * @author Christoph Weitkamp - Update to OSHI 3.13.0 - Replaced deprecated method * CentralProcessor#getSystemSerialNumber() * @author Wouter Born - Update to OSHI 4.0.0 and add null annotations @@ -68,10 +68,10 @@ * @see OSHI GitHub repository */ @NonNullByDefault -@Component(service = SysteminfoInterface.class) -public class OSHISysteminfo implements SysteminfoInterface { +@Component(service = SystemInfoInterface.class) +public class OSHISystemInfo implements SystemInfoInterface { - private final Logger logger = LoggerFactory.getLogger(OSHISysteminfo.class); + private final Logger logger = LoggerFactory.getLogger(OSHISystemInfo.class); private @NonNullByDefault({}) HardwareAbstractionLayer hal; @@ -101,13 +101,13 @@ public class OSHISysteminfo implements SysteminfoInterface { * Some of the methods used in this constructor execute native code and require execute permissions * */ - public OSHISysteminfo() { - logger.debug("OSHISysteminfo service is created"); + public OSHISystemInfo() { + logger.debug("OSHISystemInfo service is created"); } @Override - public void initializeSysteminfo() { - logger.debug("OSHISysteminfo service starts initializing"); + public void initializeSystemInfo() { + logger.debug("OSHISystemInfo service starts initializing"); SystemInfo systemInfo = new SystemInfo(); hal = systemInfo.getHardware(); diff --git a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/SysteminfoInterface.java b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/SystemInfoInterface.java similarity index 98% rename from bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/SysteminfoInterface.java rename to bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/SystemInfoInterface.java index 8873ee3243eb4..4f4ebea6e75ff 100644 --- a/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/SysteminfoInterface.java +++ b/bundles/org.openhab.binding.systeminfo/src/main/java/org/openhab/binding/systeminfo/internal/model/SystemInfoInterface.java @@ -26,7 +26,7 @@ import org.openhab.core.library.types.StringType; /** - * {@link SysteminfoInterface} defines the methods needed to provide this binding with the required system information. + * {@link SystemInfoInterface} defines the methods needed to provide this binding with the required system information. * * @author Svilen Valkanov - Initial contribution * @author Wouter Born - Add null annotations @@ -35,12 +35,12 @@ * @author Mark Herwege - Processor frequency channels */ @NonNullByDefault -public interface SysteminfoInterface { +public interface SystemInfoInterface { /** - * Initialize logic for the Systeminfo implementation + * Initialize logic for the SystemInfo implementation */ - void initializeSysteminfo(); + void initializeSystemInfo(); // Operating system info /** diff --git a/itests/org.openhab.binding.systeminfo.tests/pom.xml b/itests/org.openhab.binding.systeminfo.tests/pom.xml index b4b418f4e1397..9ae612e6dbbfa 100644 --- a/itests/org.openhab.binding.systeminfo.tests/pom.xml +++ b/itests/org.openhab.binding.systeminfo.tests/pom.xml @@ -12,7 +12,7 @@ org.openhab.binding.systeminfo.tests - openHAB Add-ons :: Integration Tests :: Systeminfo Binding Tests + openHAB Add-ons :: Integration Tests :: SystemInfo Binding Tests diff --git a/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java b/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SystemInfoOSGiTest.java similarity index 89% rename from itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java rename to itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SystemInfoOSGiTest.java index 0c8394732d3aa..012350f0063a7 100644 --- a/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SysteminfoOSGiTest.java +++ b/itests/org.openhab.binding.systeminfo.tests/src/main/java/org/openhab/binding/systeminfo/test/SystemInfoOSGiTest.java @@ -39,13 +39,13 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.junit.jupiter.MockitoSettings; import org.mockito.quality.Strictness; -import org.openhab.binding.systeminfo.internal.SysteminfoBindingConstants; -import org.openhab.binding.systeminfo.internal.SysteminfoHandlerFactory; -import org.openhab.binding.systeminfo.internal.discovery.SysteminfoDiscoveryService; -import org.openhab.binding.systeminfo.internal.handler.SysteminfoHandler; +import org.openhab.binding.systeminfo.internal.SystemInfoBindingConstants; +import org.openhab.binding.systeminfo.internal.SystemInfoHandlerFactory; +import org.openhab.binding.systeminfo.internal.discovery.SystemInfoDiscoveryService; +import org.openhab.binding.systeminfo.internal.handler.SystemInfoHandler; import org.openhab.binding.systeminfo.internal.model.DeviceNotFoundException; -import org.openhab.binding.systeminfo.internal.model.OSHISysteminfo; -import org.openhab.binding.systeminfo.internal.model.SysteminfoInterface; +import org.openhab.binding.systeminfo.internal.model.OSHISystemInfo; +import org.openhab.binding.systeminfo.internal.model.SystemInfoInterface; import org.openhab.core.config.core.Configuration; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryService; @@ -88,7 +88,7 @@ import org.openhab.core.types.UnDefType; /** - * OSGi tests for the {@link SysteminfoHandler} + * OSGi tests for the {@link SystemInfoHandler} * * @author Svilen Valkanov - Initial contribution * @author Lyubomir Papazov - Created a mock systeminfo object. This way, access to the user's OS will not be required, @@ -99,13 +99,13 @@ @NonNullByDefault @ExtendWith(MockitoExtension.class) @MockitoSettings(strictness = Strictness.LENIENT) -public class SysteminfoOSGiTest extends JavaOSGiTest { +public class SystemInfoOSGiTest extends JavaOSGiTest { private static final String DEFAULT_TEST_THING_NAME = "work"; private static final String DEFAULT_TEST_ITEM_NAME = "test"; private static final String DEFAULT_CHANNEL_TEST_PRIORITY = "High"; private static final int DEFAULT_CHANNEL_PID = -1; - private static final String DEFAULT_TEST_CHANNEL_ID = SysteminfoBindingConstants.CHANNEL_CPU_LOAD; + private static final String DEFAULT_TEST_CHANNEL_ID = SystemInfoBindingConstants.CHANNEL_CPU_LOAD; private static final int DEFAULT_DEVICE_INDEX = 0; /** @@ -122,8 +122,8 @@ public class SysteminfoOSGiTest extends JavaOSGiTest { private @Nullable Thing systeminfoThing; private @Nullable GenericItem testItem; - private @Mock @NonNullByDefault({}) OSHISysteminfo mockedSystemInfo; - private @NonNullByDefault({}) SysteminfoHandlerFactory systeminfoHandlerFactory; + private @Mock @NonNullByDefault({}) OSHISystemInfo mockedSystemInfo; + private @NonNullByDefault({}) SystemInfoHandlerFactory systeminfoHandlerFactory; private @NonNullByDefault({}) ThingRegistry thingRegistry; private @NonNullByDefault({}) ItemRegistry itemRegistry; private @NonNullByDefault({}) ManagedThingProvider managedThingProvider; @@ -136,7 +136,7 @@ public void setUp() { volatileStorageService = new VolatileStorageService(); registerService(volatileStorageService); - // Preparing the mock with OS properties, that are used in the initialize method of SysteminfoHandler + // Preparing the mock with OS properties, that are used in the initialize method of SystemInfoHandler // Make this lenient because the assertInvalidThingConfigurationValuesAreHandled test does not require them lenient().when(mockedSystemInfo.getCpuLogicalCores()).thenReturn(new DecimalType(1)); lenient().when(mockedSystemInfo.getCpuPhysicalCores()).thenReturn(new DecimalType(1)); @@ -154,14 +154,14 @@ public void setUp() { registerService(mockedSystemInfo); waitForAssert(() -> { - systeminfoHandlerFactory = getService(ThingHandlerFactory.class, SysteminfoHandlerFactory.class); + systeminfoHandlerFactory = getService(ThingHandlerFactory.class, SystemInfoHandlerFactory.class); assertThat(systeminfoHandlerFactory, is(notNullValue())); }); if (systeminfoHandlerFactory != null) { // Unbind oshiSystemInfo service and bind the mock service to make the systeminfo binding tests independent // of the external OSHI library - SysteminfoInterface oshiSystemInfo = getService(SysteminfoInterface.class); + SystemInfoInterface oshiSystemInfo = getService(SystemInfoInterface.class); if (oshiSystemInfo != null) { systeminfoHandlerFactory.unbindSystemInfo(oshiSystemInfo); } @@ -218,9 +218,9 @@ public void tearDown() { private void initializeThingWithChannelAndPID(String channelID, String acceptedItemType, int pid) { Configuration thingConfig = new Configuration(); - thingConfig.put(SysteminfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, + thingConfig.put(SystemInfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, new BigDecimal(DEFAULT_TEST_INTERVAL_HIGH)); - thingConfig.put(SysteminfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, + thingConfig.put(SystemInfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, new BigDecimal(DEFAULT_TEST_INTERVAL_MEDIUM)); String priority = DEFAULT_CHANNEL_TEST_PRIORITY; @@ -229,9 +229,9 @@ private void initializeThingWithChannelAndPID(String channelID, String acceptedI private void initializeThingWithChannelAndPriority(String channelID, String acceptedItemType, String priority) { Configuration thingConfig = new Configuration(); - thingConfig.put(SysteminfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, + thingConfig.put(SystemInfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, new BigDecimal(DEFAULT_TEST_INTERVAL_HIGH)); - thingConfig.put(SysteminfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, + thingConfig.put(SystemInfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, new BigDecimal(DEFAULT_TEST_INTERVAL_MEDIUM)); int pid = DEFAULT_CHANNEL_PID; @@ -249,9 +249,9 @@ private void initializeThingWithConfiguration(Configuration config) { private void initializeThingWithChannel(String channelID, String acceptedItemType) { Configuration thingConfig = new Configuration(); - thingConfig.put(SysteminfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, + thingConfig.put(SystemInfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, new BigDecimal(DEFAULT_TEST_INTERVAL_HIGH)); - thingConfig.put(SysteminfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, + thingConfig.put(SystemInfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, new BigDecimal(DEFAULT_TEST_INTERVAL_MEDIUM)); String priority = DEFAULT_CHANNEL_TEST_PRIORITY; @@ -261,7 +261,7 @@ private void initializeThingWithChannel(String channelID, String acceptedItemTyp private void initializeThing(Configuration thingConfiguration, String channelID, String acceptedItemType, String priority, int pid) { - ThingTypeUID thingTypeUID = SysteminfoBindingConstants.THING_TYPE_COMPUTER; + ThingTypeUID thingTypeUID = SystemInfoBindingConstants.THING_TYPE_COMPUTER; ThingUID thingUID = new ThingUID(thingTypeUID, DEFAULT_TEST_THING_NAME); ChannelUID channelUID = new ChannelUID(thingUID, channelID); @@ -269,7 +269,7 @@ private void initializeThing(Configuration thingConfiguration, String channelID, if ("load1".equals(channelTypeId) || "load5".equals(channelTypeId) || "load15".equals(channelTypeId)) { channelTypeId = "loadAverage"; } - ChannelTypeUID channelTypeUID = new ChannelTypeUID(SysteminfoBindingConstants.BINDING_ID, channelTypeId); + ChannelTypeUID channelTypeUID = new ChannelTypeUID(SystemInfoBindingConstants.BINDING_ID, channelTypeId); Configuration channelConfig = new Configuration(); channelConfig.put("priority", priority); channelConfig.put("pid", new BigDecimal(pid)); @@ -287,7 +287,7 @@ private void initializeThing(Configuration thingConfiguration, String channelID, managedThingProvider.add(thing); waitForAssert(() -> { - SysteminfoHandler handler = (SysteminfoHandler) thing.getHandler(); + SystemInfoHandler handler = (SystemInfoHandler) thing.getHandler(); assertThat(handler, is(notNullValue())); }); @@ -310,9 +310,9 @@ private void assertItemState(String acceptedItemType, String itemName, String pr assertThat("Thing status detail is " + thingStatusDetail + " with description " + description, thing.getStatus(), is(equalTo(ThingStatus.ONLINE))); }); - // The binding starts all refresh tasks in SysteminfoHandler.scheduleUpdates() after this delay ! + // The binding starts all refresh tasks in SystemInfoHandler.scheduleUpdates() after this delay ! try { - sleep(SysteminfoHandler.WAIT_TIME_CHANNEL_ITEM_LINK_INIT * 1000); + sleep(SystemInfoHandler.WAIT_TIME_CHANNEL_ITEM_LINK_INIT * 1000); } catch (InterruptedException e) { throw new AssertionError("Interrupted while sleeping"); } @@ -361,10 +361,10 @@ public void assertInvalidThingConfigurationValuesAreHandled() { // invalid value - must be positive int refreshIntervalHigh = -5; - configuration.put(SysteminfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, new BigDecimal(refreshIntervalHigh)); + configuration.put(SystemInfoBindingConstants.HIGH_PRIORITY_REFRESH_TIME, new BigDecimal(refreshIntervalHigh)); int refreshIntervalMedium = 3; - configuration.put(SysteminfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, + configuration.put(SystemInfoBindingConstants.MEDIUM_PRIORITY_REFRESH_TIME, new BigDecimal(refreshIntervalMedium)); initializeThingWithConfiguration(configuration); @@ -406,7 +406,7 @@ public void assertStateOfSecondDeviceIsUpdated() { @Test public void assertChannelCpuMaxFreq() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_MAXFREQ; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_MAXFREQ; String acceptedItemType = "Number:Frequency"; QuantityType mockedCpuMaxFreqValue = new QuantityType<>(2500, Units.HERTZ); @@ -418,7 +418,7 @@ public void assertChannelCpuMaxFreq() { @Test public void assertChannelCpuFreq() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_FREQ; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_FREQ; String acceptedItemType = "Number:Frequency"; QuantityType mockedCpuFreqValue = new QuantityType<>(2500, Units.HERTZ); @@ -430,7 +430,7 @@ public void assertChannelCpuFreq() { @Test public void assertChannelCpuLoadIsUpdated() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_LOAD; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_LOAD; String acceptedItemType = "Number"; PercentType mockedCpuLoadValue = new PercentType(9); @@ -442,7 +442,7 @@ public void assertChannelCpuLoadIsUpdated() { @Test public void assertChannelCpuLoad1IsUpdated() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_LOAD_1; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_LOAD_1; String acceptedItemType = "Number"; DecimalType mockedCpuLoad1Value = new DecimalType(1.1); @@ -454,7 +454,7 @@ public void assertChannelCpuLoad1IsUpdated() { @Test public void assertChannelCpuLoad5IsUpdated() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_LOAD_5; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_LOAD_5; String acceptedItemType = "Number"; DecimalType mockedCpuLoad5Value = new DecimalType(5.5); @@ -466,7 +466,7 @@ public void assertChannelCpuLoad5IsUpdated() { @Test public void assertChannelCpuLoad15IsUpdated() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_LOAD_15; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_LOAD_15; String acceptedItemType = "Number"; DecimalType mockedCpuLoad15Value = new DecimalType(15.15); @@ -478,7 +478,7 @@ public void assertChannelCpuLoad15IsUpdated() { @Test public void assertChannelCpuThreadsIsUpdated() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_THREADS; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_THREADS; String acceptedItemType = "Number"; DecimalType mockedCpuThreadsValue = new DecimalType(16); @@ -490,7 +490,7 @@ public void assertChannelCpuThreadsIsUpdated() { @Test public void assertChannelCpuUptimeIsUpdated() { - String channnelID = SysteminfoBindingConstants.CHANNEL_CPU_UPTIME; + String channnelID = SystemInfoBindingConstants.CHANNEL_CPU_UPTIME; String acceptedItemType = "Number:Time"; QuantityType