mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Java 21 language features (#4535)
* Java 21 language features * use getFirst and getLast methods * replace new Locale by Locale.of * replace Paths.get by Path.of * use ThreadLocalRandom.current().nextDouble() * add @Serial annotations Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
+1
-1
@@ -86,7 +86,7 @@ public abstract class MarketplaceBundleInstaller {
|
|||||||
"The local cache folder doesn't contain a single file: " + addonPath, null);
|
"The local cache folder doesn't contain a single file: " + addonPath, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (FileInputStream fileInputStream = new FileInputStream(bundleFiles.get(0).toFile())) {
|
try (FileInputStream fileInputStream = new FileInputStream(bundleFiles.getFirst().toFile())) {
|
||||||
Bundle bundle = bundleContext.installBundle(addonId, fileInputStream);
|
Bundle bundle = bundleContext.installBundle(addonId, fileInputStream);
|
||||||
try {
|
try {
|
||||||
bundle.start();
|
bundle.start();
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.addon.marketplace;
|
package org.openhab.core.addon.marketplace;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class MarketplaceHandlerException extends Exception {
|
public class MarketplaceHandlerException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -5652014141471618161L;
|
private static final long serialVersionUID = -5652014141471618161L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.addon.marketplace.internal.community;
|
package org.openhab.core.addon.marketplace.internal.community;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -32,6 +33,7 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
final class SerializedNameAnnotationIntrospector extends AnnotationIntrospector {
|
final class SerializedNameAnnotationIntrospector extends AnnotationIntrospector {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ public class AbstractRemoteAddonServiceTest {
|
|||||||
// check only the installed addon is present
|
// check only the installed addon is present
|
||||||
addons = addonService.getAddons(null);
|
addons = addonService.getAddons(null);
|
||||||
assertThat(addons, hasSize(1));
|
assertThat(addons, hasSize(1));
|
||||||
assertThat(addons.get(0).getUid(), is(getFullAddonId(TEST_ADDON)));
|
assertThat(addons.getFirst().getUid(), is(getFullAddonId(TEST_ADDON)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+5
-5
@@ -84,26 +84,26 @@ class AddonInfoListReaderTest {
|
|||||||
assertNotNull(addons);
|
assertNotNull(addons);
|
||||||
List<AddonInfo> addonsInfos = addons.getAddons();
|
List<AddonInfo> addonsInfos = addons.getAddons();
|
||||||
assertEquals(1, addonsInfos.size());
|
assertEquals(1, addonsInfos.size());
|
||||||
AddonInfo addon = addonsInfos.get(0);
|
AddonInfo addon = addonsInfos.getFirst();
|
||||||
assertNotNull(addon);
|
assertNotNull(addon);
|
||||||
List<AddonDiscoveryMethod> discoveryMethods = addon.getDiscoveryMethods();
|
List<AddonDiscoveryMethod> discoveryMethods = addon.getDiscoveryMethods();
|
||||||
assertNotNull(discoveryMethods);
|
assertNotNull(discoveryMethods);
|
||||||
assertEquals(2, discoveryMethods.size());
|
assertEquals(2, discoveryMethods.size());
|
||||||
|
|
||||||
AddonDiscoveryMethod method = discoveryMethods.get(0);
|
AddonDiscoveryMethod method = discoveryMethods.getFirst();
|
||||||
assertNotNull(method);
|
assertNotNull(method);
|
||||||
assertEquals("mdns", method.getServiceType());
|
assertEquals("mdns", method.getServiceType());
|
||||||
List<AddonParameter> parameters = method.getParameters();
|
List<AddonParameter> parameters = method.getParameters();
|
||||||
assertNotNull(parameters);
|
assertNotNull(parameters);
|
||||||
assertEquals(1, parameters.size());
|
assertEquals(1, parameters.size());
|
||||||
AddonParameter parameter = parameters.get(0);
|
AddonParameter parameter = parameters.getFirst();
|
||||||
assertNotNull(parameter);
|
assertNotNull(parameter);
|
||||||
assertEquals("mdnsServiceType", parameter.getName());
|
assertEquals("mdnsServiceType", parameter.getName());
|
||||||
assertEquals("_printer._tcp.local.", parameter.getValue());
|
assertEquals("_printer._tcp.local.", parameter.getValue());
|
||||||
List<AddonMatchProperty> matchProperties = method.getMatchProperties();
|
List<AddonMatchProperty> matchProperties = method.getMatchProperties();
|
||||||
assertNotNull(matchProperties);
|
assertNotNull(matchProperties);
|
||||||
assertEquals(2, matchProperties.size());
|
assertEquals(2, matchProperties.size());
|
||||||
AddonMatchProperty property = matchProperties.get(0);
|
AddonMatchProperty property = matchProperties.getFirst();
|
||||||
assertNotNull(property);
|
assertNotNull(property);
|
||||||
assertEquals("rp", property.getName());
|
assertEquals("rp", property.getName());
|
||||||
assertEquals(".*", property.getRegex());
|
assertEquals(".*", property.getRegex());
|
||||||
@@ -118,7 +118,7 @@ class AddonInfoListReaderTest {
|
|||||||
matchProperties = method.getMatchProperties();
|
matchProperties = method.getMatchProperties();
|
||||||
assertNotNull(matchProperties);
|
assertNotNull(matchProperties);
|
||||||
assertEquals(1, matchProperties.size());
|
assertEquals(1, matchProperties.size());
|
||||||
property = matchProperties.get(0);
|
property = matchProperties.getFirst();
|
||||||
assertNotNull(property);
|
assertNotNull(property);
|
||||||
assertEquals("modelName", property.getName());
|
assertEquals("modelName", property.getName());
|
||||||
assertEquals("Philips hue bridge", property.getRegex());
|
assertEquals("Philips hue bridge", property.getRegex());
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.audio;
|
package org.openhab.core.audio;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class AudioException extends Exception {
|
public class AudioException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.audio;
|
package org.openhab.core.audio;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class UnsupportedAudioFormatException extends AudioException {
|
public class UnsupportedAudioFormatException extends AudioException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.audio;
|
package org.openhab.core.audio;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class UnsupportedAudioStreamException extends AudioException {
|
public class UnsupportedAudioStreamException extends AudioException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+2
@@ -17,6 +17,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.io.Serial;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -72,6 +73,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class AudioServlet extends HttpServlet implements AudioHTTPServer {
|
public class AudioServlet extends HttpServlet implements AudioHTTPServer {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -3364664035854567854L;
|
private static final long serialVersionUID = -3364664035854567854L;
|
||||||
|
|
||||||
private static final List<String> WAV_MIME_TYPES = List.of("audio/wav", "audio/x-wav", "audio/vnd.wave");
|
private static final List<String> WAV_MIME_TYPES = List.of("audio/wav", "audio/x-wav", "audio/vnd.wave");
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ import static java.util.Comparator.comparing;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -138,7 +138,7 @@ public class MediaActionTypeProvider implements ModuleTypeProvider {
|
|||||||
*/
|
*/
|
||||||
private List<ParameterOption> getSoundOptions() {
|
private List<ParameterOption> getSoundOptions() {
|
||||||
List<ParameterOption> options = new ArrayList<>();
|
List<ParameterOption> options = new ArrayList<>();
|
||||||
File soundsDir = Paths.get(OpenHAB.getConfigFolder(), AudioManager.SOUND_DIR).toFile();
|
File soundsDir = Path.of(OpenHAB.getConfigFolder(), AudioManager.SOUND_DIR).toFile();
|
||||||
if (soundsDir.isDirectory()) {
|
if (soundsDir.isDirectory()) {
|
||||||
for (String fileName : soundsDir.list()) {
|
for (String fileName : soundsDir.list()) {
|
||||||
if (fileName.contains(".") && !fileName.startsWith(".")) {
|
if (fileName.contains(".") && !fileName.startsWith(".")) {
|
||||||
|
|||||||
+2
-2
@@ -42,7 +42,7 @@ public class ScriptEngineFactoryHelper {
|
|||||||
public static Map.@Nullable Entry<String, String> getParameterOption(ScriptEngineFactory engineFactory) {
|
public static Map.@Nullable Entry<String, String> getParameterOption(ScriptEngineFactory engineFactory) {
|
||||||
List<String> scriptTypes = engineFactory.getScriptTypes();
|
List<String> scriptTypes = engineFactory.getScriptTypes();
|
||||||
if (!scriptTypes.isEmpty()) {
|
if (!scriptTypes.isEmpty()) {
|
||||||
ScriptEngine scriptEngine = engineFactory.createScriptEngine(scriptTypes.get(0));
|
ScriptEngine scriptEngine = engineFactory.createScriptEngine(scriptTypes.getFirst());
|
||||||
if (scriptEngine != null) {
|
if (scriptEngine != null) {
|
||||||
Map.Entry<String, String> parameterOption = Map.entry(getPreferredMimeType(engineFactory),
|
Map.Entry<String, String> parameterOption = Map.entry(getPreferredMimeType(engineFactory),
|
||||||
getLanguageName(scriptEngine.getFactory()));
|
getLanguageName(scriptEngine.getFactory()));
|
||||||
@@ -66,7 +66,7 @@ public class ScriptEngineFactoryHelper {
|
|||||||
}
|
}
|
||||||
List<String> mimeTypes = new ArrayList<>(scriptTypes);
|
List<String> mimeTypes = new ArrayList<>(scriptTypes);
|
||||||
mimeTypes.removeIf(mimeType -> !mimeType.contains("application") || "application/python".equals(mimeType));
|
mimeTypes.removeIf(mimeType -> !mimeType.contains("application") || "application/python".equals(mimeType));
|
||||||
return mimeTypes.isEmpty() ? scriptTypes.get(0) : mimeTypes.get(0);
|
return mimeTypes.isEmpty() ? scriptTypes.getFirst() : mimeTypes.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLanguageName(javax.script.ScriptEngineFactory factory) {
|
public static String getLanguageName(javax.script.ScriptEngineFactory factory) {
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ public class ScriptEngineManagerImpl implements ScriptEngineManager {
|
|||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
if (!scriptTypes.isEmpty()) {
|
if (!scriptTypes.isEmpty()) {
|
||||||
ScriptEngine scriptEngine = engineFactory.createScriptEngine(scriptTypes.get(0));
|
ScriptEngine scriptEngine = engineFactory.createScriptEngine(scriptTypes.getFirst());
|
||||||
if (scriptEngine != null) {
|
if (scriptEngine != null) {
|
||||||
javax.script.ScriptEngineFactory factory = scriptEngine.getFactory();
|
javax.script.ScriptEngineFactory factory = scriptEngine.getFactory();
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|||||||
+2
-2
@@ -105,9 +105,9 @@ public abstract class AbstractScriptModuleHandler<T extends Module> extends Base
|
|||||||
Optional<ScriptEngine> engine = getScriptEngine();
|
Optional<ScriptEngine> engine = getScriptEngine();
|
||||||
if (engine.isPresent()) {
|
if (engine.isPresent()) {
|
||||||
ScriptEngine scriptEngine = engine.get();
|
ScriptEngine scriptEngine = engine.get();
|
||||||
if (scriptEngine instanceof Compilable) {
|
if (scriptEngine instanceof Compilable compilable) {
|
||||||
logger.debug("Pre-compiling script of rule with UID '{}'", ruleUID);
|
logger.debug("Pre-compiling script of rule with UID '{}'", ruleUID);
|
||||||
compiledScript = Optional.ofNullable(((Compilable) scriptEngine).compile(script));
|
compiledScript = Optional.ofNullable(compilable.compile(script));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -161,7 +161,7 @@ public class ScriptModuleTypeProvider extends AbstractProvider<ModuleType> imple
|
|||||||
public void unsetScriptEngineFactory(ScriptEngineFactory engineFactory) {
|
public void unsetScriptEngineFactory(ScriptEngineFactory engineFactory) {
|
||||||
List<String> scriptTypes = engineFactory.getScriptTypes();
|
List<String> scriptTypes = engineFactory.getScriptTypes();
|
||||||
if (!scriptTypes.isEmpty()) {
|
if (!scriptTypes.isEmpty()) {
|
||||||
ScriptEngine scriptEngine = engineFactory.createScriptEngine(scriptTypes.get(0));
|
ScriptEngine scriptEngine = engineFactory.createScriptEngine(scriptTypes.getFirst());
|
||||||
if (scriptEngine != null) {
|
if (scriptEngine != null) {
|
||||||
parameterOptions.remove(ScriptEngineFactoryHelper.getPreferredMimeType(engineFactory));
|
parameterOptions.remove(ScriptEngineFactoryHelper.getPreferredMimeType(engineFactory));
|
||||||
logger.trace("ParameterOptions: {}", parameterOptions);
|
logger.trace("ParameterOptions: {}", parameterOptions);
|
||||||
|
|||||||
+1
-1
@@ -126,7 +126,7 @@ public class AutomationCommandList extends AutomationCommand {
|
|||||||
}
|
}
|
||||||
if (getLocale) {
|
if (getLocale) {
|
||||||
String l = parameterValue;
|
String l = parameterValue;
|
||||||
locale = new Locale(l);
|
locale = Locale.of(l);
|
||||||
getLocale = false;
|
getLocale = false;
|
||||||
}
|
}
|
||||||
if (getId && getLocale) {
|
if (getId && getLocale) {
|
||||||
|
|||||||
+2
-2
@@ -339,7 +339,7 @@ public class Printer {
|
|||||||
if (list != null && !list.isEmpty()) {
|
if (list != null && !list.isEmpty()) {
|
||||||
for (Object element : list) {
|
for (Object element : list) {
|
||||||
if (element instanceof String string) {
|
if (element instanceof String string) {
|
||||||
res.add(Utils.getColumn(columnWidths[0], values.get(0)) + string);
|
res.add(Utils.getColumn(columnWidths[0], values.getFirst()) + string);
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
values.set(0, "");
|
values.set(0, "");
|
||||||
@@ -347,7 +347,7 @@ public class Printer {
|
|||||||
} else if (element instanceof Module module) {
|
} else if (element instanceof Module module) {
|
||||||
List<String> moduleRecords = getModuleRecords(module);
|
List<String> moduleRecords = getModuleRecords(module);
|
||||||
for (String elementRecord : moduleRecords) {
|
for (String elementRecord : moduleRecords) {
|
||||||
res.add(Utils.getColumn(columnWidths[0], values.get(0)) + elementRecord);
|
res.add(Utils.getColumn(columnWidths[0], values.getFirst()) + elementRecord);
|
||||||
if (isFirst) {
|
if (isFirst) {
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
values.set(0, "");
|
values.set(0, "");
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.automation.internal.module.exception;
|
package org.openhab.core.automation.internal.module.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,5 +24,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class UncomparableException extends Exception {
|
public class UncomparableException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 4891205711357448390L;
|
private static final long serialVersionUID = 4891205711357448390L;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -196,7 +196,7 @@ public class AnnotationActionModuleTypeProviderTest extends JavaTest {
|
|||||||
List<ParameterOption> parameterOptions = cdp.getOptions();
|
List<ParameterOption> parameterOptions = cdp.getOptions();
|
||||||
assertEquals(1, parameterOptions.size());
|
assertEquals(1, parameterOptions.size());
|
||||||
|
|
||||||
ParameterOption po = parameterOptions.get(0);
|
ParameterOption po = parameterOptions.getFirst();
|
||||||
assertEquals("conf2", po.getValue());
|
assertEquals("conf2", po.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -211,7 +211,7 @@ public class AnnotatedThingActionModuleTypeProviderTest extends JavaTest {
|
|||||||
List<ParameterOption> parameterOptions = cdp.getOptions();
|
List<ParameterOption> parameterOptions = cdp.getOptions();
|
||||||
assertEquals(1, parameterOptions.size());
|
assertEquals(1, parameterOptions.size());
|
||||||
|
|
||||||
ParameterOption po = parameterOptions.get(0);
|
ParameterOption po = parameterOptions.getFirst();
|
||||||
assertEquals("binding:thing-type:test2", po.getValue());
|
assertEquals("binding:thing-type:test2", po.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -208,7 +208,7 @@ public class ActionInputHelperTest {
|
|||||||
List<ConfigDescriptionParameter> params = helper
|
List<ConfigDescriptionParameter> params = helper
|
||||||
.mapActionInputsToConfigDescriptionParameters(List.of(input1, input2));
|
.mapActionInputsToConfigDescriptionParameters(List.of(input1, input2));
|
||||||
assertThat(params.size(), is(2));
|
assertThat(params.size(), is(2));
|
||||||
checkParameter(params.get(0), "Boolean", ConfigDescriptionParameter.Type.BOOLEAN, PARAM_LABEL,
|
checkParameter(params.getFirst(), "Boolean", ConfigDescriptionParameter.Type.BOOLEAN, PARAM_LABEL,
|
||||||
PARAM_DESCRIPTION, true, "false", null, null, null);
|
PARAM_DESCRIPTION, true, "false", null, null, null);
|
||||||
checkParameter(params.get(1), "String", ConfigDescriptionParameter.Type.TEXT, PARAM_LABEL, PARAM_DESCRIPTION,
|
checkParameter(params.get(1), "String", ConfigDescriptionParameter.Type.TEXT, PARAM_LABEL, PARAM_DESCRIPTION,
|
||||||
false, null, null, null, null);
|
false, null, null, null, null);
|
||||||
|
|||||||
+1
-1
@@ -262,7 +262,7 @@ public class ConfigUtil {
|
|||||||
for (final Object it : collection) {
|
for (final Object it : collection) {
|
||||||
final Object normalized = normalizeType(it, null);
|
final Object normalized = normalizeType(it, null);
|
||||||
lst.add(normalized);
|
lst.add(normalized);
|
||||||
if (normalized.getClass() != lst.get(0).getClass()) {
|
if (normalized.getClass() != lst.getFirst().getClass()) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Invalid configuration property. Heterogeneous collection value!");
|
"Invalid configuration property. Heterogeneous collection value!");
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.config.core.validation;
|
package org.openhab.core.config.core.validation;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -35,6 +36,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public final class ConfigValidationException extends RuntimeException {
|
public final class ConfigValidationException extends RuntimeException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(ConfigValidationException.class);
|
private final Logger logger = LoggerFactory.getLogger(ConfigValidationException.class);
|
||||||
|
|||||||
+2
-2
@@ -62,7 +62,7 @@ public class ConfigDescriptionBuilderTest {
|
|||||||
assertThat(configDescription.getUID(), is(CONFIG_URI));
|
assertThat(configDescription.getUID(), is(CONFIG_URI));
|
||||||
assertThat(configDescription.getParameterGroups(), hasSize(0));
|
assertThat(configDescription.getParameterGroups(), hasSize(0));
|
||||||
assertThat(configDescription.getParameters(), hasSize(1));
|
assertThat(configDescription.getParameters(), hasSize(1));
|
||||||
assertThat(configDescription.getParameters().get(0), is(PARAM1));
|
assertThat(configDescription.getParameters().getFirst(), is(PARAM1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -81,7 +81,7 @@ public class ConfigDescriptionBuilderTest {
|
|||||||
ConfigDescription configDescription = builder.withParameterGroup(GROUP1).build();
|
ConfigDescription configDescription = builder.withParameterGroup(GROUP1).build();
|
||||||
assertThat(configDescription.getUID(), is(CONFIG_URI));
|
assertThat(configDescription.getUID(), is(CONFIG_URI));
|
||||||
assertThat(configDescription.getParameterGroups(), hasSize(1));
|
assertThat(configDescription.getParameterGroups(), hasSize(1));
|
||||||
assertThat(configDescription.getParameterGroups().get(0), is(GROUP1));
|
assertThat(configDescription.getParameterGroups().getFirst(), is(GROUP1));
|
||||||
assertThat(configDescription.getParameters(), hasSize(0));
|
assertThat(configDescription.getParameters(), hasSize(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-13
@@ -121,9 +121,9 @@ public class ConfigDescriptionRegistryTest extends JavaTest {
|
|||||||
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(1));
|
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(1));
|
||||||
|
|
||||||
List<ConfigDescription> configDescriptions = new ArrayList<>(configDescriptionRegistry.getConfigDescriptions());
|
List<ConfigDescription> configDescriptions = new ArrayList<>(configDescriptionRegistry.getConfigDescriptions());
|
||||||
assertThat(configDescriptions.get(0).getUID(), is(equalTo(uriDummy)));
|
assertThat(configDescriptions.getFirst().getUID(), is(equalTo(uriDummy)));
|
||||||
assertThat(configDescriptions.get(0).toParametersMap().size(), is(1));
|
assertThat(configDescriptions.getFirst().toParametersMap().size(), is(1));
|
||||||
assertThat(configDescriptions.get(0).toParametersMap().get("param1"), notNullValue());
|
assertThat(configDescriptions.getFirst().toParametersMap().get("param1"), notNullValue());
|
||||||
|
|
||||||
configDescriptionRegistry.addConfigDescriptionProvider(configDescriptionProviderMock1);
|
configDescriptionRegistry.addConfigDescriptionProvider(configDescriptionProviderMock1);
|
||||||
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(2));
|
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(2));
|
||||||
@@ -146,11 +146,11 @@ public class ConfigDescriptionRegistryTest extends JavaTest {
|
|||||||
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(1));
|
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(1));
|
||||||
|
|
||||||
List<ConfigDescription> configDescriptions = new ArrayList<>(configDescriptionRegistry.getConfigDescriptions());
|
List<ConfigDescription> configDescriptions = new ArrayList<>(configDescriptionRegistry.getConfigDescriptions());
|
||||||
assertThat(configDescriptions.get(0).getUID(), is(equalTo(uriDummy)));
|
assertThat(configDescriptions.getFirst().getUID(), is(equalTo(uriDummy)));
|
||||||
|
|
||||||
assertThat(configDescriptions.get(0).getParameters().size(), is(2));
|
assertThat(configDescriptions.getFirst().getParameters().size(), is(2));
|
||||||
assertThat(configDescriptions.get(0).getParameters().get(0).getName(), is(equalTo("param1")));
|
assertThat(configDescriptions.getFirst().getParameters().getFirst().getName(), is(equalTo("param1")));
|
||||||
assertThat(configDescriptions.get(0).getParameters().get(1).getName(), is(equalTo("param2")));
|
assertThat(configDescriptions.getFirst().getParameters().get(1).getName(), is(equalTo("param2")));
|
||||||
|
|
||||||
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
||||||
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(1));
|
assertThat(configDescriptionRegistry.getConfigDescriptions().size(), is(1));
|
||||||
@@ -168,8 +168,8 @@ public class ConfigDescriptionRegistryTest extends JavaTest {
|
|||||||
configDescriptionRegistry.addConfigOptionProvider(configOptionsProviderMockAliased);
|
configDescriptionRegistry.addConfigOptionProvider(configOptionsProviderMockAliased);
|
||||||
|
|
||||||
ConfigDescription res = requireNonNull(configDescriptionRegistry.getConfigDescription(uriAliases));
|
ConfigDescription res = requireNonNull(configDescriptionRegistry.getConfigDescription(uriAliases));
|
||||||
assertThat(res.getParameters().get(0).getOptions().size(), is(1));
|
assertThat(res.getParameters().getFirst().getOptions().size(), is(1));
|
||||||
assertThat(res.getParameters().get(0).getOptions().get(0).getLabel(), is("Aliased"));
|
assertThat(res.getParameters().getFirst().getOptions().getFirst().getLabel(), is("Aliased"));
|
||||||
assertThat(res.getUID(), is(uriAliases));
|
assertThat(res.getUID(), is(uriAliases));
|
||||||
|
|
||||||
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
||||||
@@ -186,8 +186,8 @@ public class ConfigDescriptionRegistryTest extends JavaTest {
|
|||||||
configDescriptionRegistry.addConfigOptionProvider(configOptionsProviderMockAliased);
|
configDescriptionRegistry.addConfigOptionProvider(configOptionsProviderMockAliased);
|
||||||
|
|
||||||
ConfigDescription res = requireNonNull(configDescriptionRegistry.getConfigDescription(uriAliases));
|
ConfigDescription res = requireNonNull(configDescriptionRegistry.getConfigDescription(uriAliases));
|
||||||
assertThat(res.getParameters().get(0).getOptions().size(), is(1));
|
assertThat(res.getParameters().getFirst().getOptions().size(), is(1));
|
||||||
assertThat(res.getParameters().get(0).getOptions().get(0).getLabel(), is("Aliased"));
|
assertThat(res.getParameters().getFirst().getOptions().getFirst().getLabel(), is("Aliased"));
|
||||||
assertThat(res.getUID(), is(uriAliases));
|
assertThat(res.getUID(), is(uriAliases));
|
||||||
|
|
||||||
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
||||||
@@ -203,8 +203,8 @@ public class ConfigDescriptionRegistryTest extends JavaTest {
|
|||||||
configDescriptionRegistry.addConfigOptionProvider(configOptionsProviderMock);
|
configDescriptionRegistry.addConfigOptionProvider(configOptionsProviderMock);
|
||||||
|
|
||||||
ConfigDescription res = requireNonNull(configDescriptionRegistry.getConfigDescription(uriAliases));
|
ConfigDescription res = requireNonNull(configDescriptionRegistry.getConfigDescription(uriAliases));
|
||||||
assertThat(res.getParameters().get(0).getOptions().size(), is(1));
|
assertThat(res.getParameters().getFirst().getOptions().size(), is(1));
|
||||||
assertThat(res.getParameters().get(0).getOptions().get(0).getLabel(), is("Original"));
|
assertThat(res.getParameters().getFirst().getOptions().getFirst().getLabel(), is("Original"));
|
||||||
assertThat(res.getUID(), is(uriAliases));
|
assertThat(res.getUID(), is(uriAliases));
|
||||||
|
|
||||||
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
configDescriptionRegistry.removeConfigDescriptionProvider(configDescriptionProviderMock);
|
||||||
|
|||||||
+1
-1
@@ -119,7 +119,7 @@ public class ConfigurationTest {
|
|||||||
configuration.put("stringField", "someValue");
|
configuration.put("stringField", "someValue");
|
||||||
configuration.put("additionalField", "");
|
configuration.put("additionalField", "");
|
||||||
assertThat(props.get("stringField"), is(nullValue()));
|
assertThat(props.get("stringField"), is(nullValue()));
|
||||||
assertThat(values.get(0), is(nullValue()));
|
assertThat(values.getFirst(), is(nullValue()));
|
||||||
assertThat(values.get(1), is(nullValue()));
|
assertThat(values.get(1), is(nullValue()));
|
||||||
assertThat(values.size(), is(2));
|
assertThat(values.size(), is(2));
|
||||||
assertThat(keys.size(), is(2));
|
assertThat(keys.size(), is(2));
|
||||||
|
|||||||
+2
-2
@@ -85,7 +85,7 @@ class ConfigDescriptionDTOTest {
|
|||||||
.map(ConfigDescriptionDTOMapper.mapParameters(subject));
|
.map(ConfigDescriptionDTOMapper.mapParameters(subject));
|
||||||
assertThat(result, hasSize(1));
|
assertThat(result, hasSize(1));
|
||||||
|
|
||||||
ConfigDescriptionParameter parameter = result.get(0);
|
ConfigDescriptionParameter parameter = result.getFirst();
|
||||||
assertThat(parameter.getName(), is(PARAM_NAME));
|
assertThat(parameter.getName(), is(PARAM_NAME));
|
||||||
assertThat(parameter.getType(), is(Type.INTEGER));
|
assertThat(parameter.getType(), is(Type.INTEGER));
|
||||||
assertThat(parameter.isAdvanced(), is(true));
|
assertThat(parameter.isAdvanced(), is(true));
|
||||||
@@ -120,7 +120,7 @@ class ConfigDescriptionDTOTest {
|
|||||||
.mapParameterGroupsDTO(ConfigDescriptionDTOMapper.mapParameterGroups(subject));
|
.mapParameterGroupsDTO(ConfigDescriptionDTOMapper.mapParameterGroups(subject));
|
||||||
assertThat(result, hasSize(1));
|
assertThat(result, hasSize(1));
|
||||||
|
|
||||||
ConfigDescriptionParameterGroup parameterGroup = result.get(0);
|
ConfigDescriptionParameterGroup parameterGroup = result.getFirst();
|
||||||
assertThat(parameterGroup.getName(), is(PARAMETER_GROUP_NAME));
|
assertThat(parameterGroup.getName(), is(PARAMETER_GROUP_NAME));
|
||||||
assertThat(parameterGroup.isAdvanced(), is(true));
|
assertThat(parameterGroup.isAdvanced(), is(true));
|
||||||
assertThat(parameterGroup.getContext(), is(PARAMETER_GROUP_CONTEXT));
|
assertThat(parameterGroup.getContext(), is(PARAMETER_GROUP_CONTEXT));
|
||||||
|
|||||||
+5
-5
@@ -92,7 +92,7 @@ public class MetadataConfigDescriptionProviderImplTest extends JavaTest {
|
|||||||
assertEquals(URI_LIBERAL, desc.getUID());
|
assertEquals(URI_LIBERAL, desc.getUID());
|
||||||
assertEquals(1, desc.getParameters().size());
|
assertEquals(1, desc.getParameters().size());
|
||||||
|
|
||||||
ConfigDescriptionParameter param = desc.getParameters().get(0);
|
ConfigDescriptionParameter param = desc.getParameters().getFirst();
|
||||||
assertEquals("value", param.getName());
|
assertEquals("value", param.getName());
|
||||||
assertEquals("Liberal", param.getDescription());
|
assertEquals("Liberal", param.getDescription());
|
||||||
assertFalse(param.getLimitToOptions());
|
assertFalse(param.getLimitToOptions());
|
||||||
@@ -110,11 +110,11 @@ public class MetadataConfigDescriptionProviderImplTest extends JavaTest {
|
|||||||
assertEquals(URI_RESTRICTED, desc.getUID());
|
assertEquals(URI_RESTRICTED, desc.getUID());
|
||||||
assertEquals(1, desc.getParameters().size());
|
assertEquals(1, desc.getParameters().size());
|
||||||
|
|
||||||
ConfigDescriptionParameter param = desc.getParameters().get(0);
|
ConfigDescriptionParameter param = desc.getParameters().getFirst();
|
||||||
assertEquals("value", param.getName());
|
assertEquals("value", param.getName());
|
||||||
assertEquals("Restricted", param.getDescription());
|
assertEquals("Restricted", param.getDescription());
|
||||||
assertTrue(param.getLimitToOptions());
|
assertTrue(param.getLimitToOptions());
|
||||||
assertEquals("dimmer", param.getOptions().get(0).getValue());
|
assertEquals("dimmer", param.getOptions().getFirst().getValue());
|
||||||
assertEquals("switch", param.getOptions().get(1).getValue());
|
assertEquals("switch", param.getOptions().get(1).getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public class MetadataConfigDescriptionProviderImplTest extends JavaTest {
|
|||||||
assertEquals(URI_LIBERAL, desc.getUID());
|
assertEquals(URI_LIBERAL, desc.getUID());
|
||||||
assertEquals(1, desc.getParameters().size());
|
assertEquals(1, desc.getParameters().size());
|
||||||
|
|
||||||
ConfigDescriptionParameter param = desc.getParameters().get(0);
|
ConfigDescriptionParameter param = desc.getParameters().getFirst();
|
||||||
assertEquals("value", param.getName());
|
assertEquals("value", param.getName());
|
||||||
assertEquals("Liberal", param.getDescription());
|
assertEquals("Liberal", param.getDescription());
|
||||||
assertFalse(param.getLimitToOptions());
|
assertFalse(param.getLimitToOptions());
|
||||||
@@ -161,7 +161,7 @@ public class MetadataConfigDescriptionProviderImplTest extends JavaTest {
|
|||||||
assertEquals(URI_RESTRICTED_DIMMER, desc.getUID());
|
assertEquals(URI_RESTRICTED_DIMMER, desc.getUID());
|
||||||
assertEquals(2, desc.getParameters().size());
|
assertEquals(2, desc.getParameters().size());
|
||||||
|
|
||||||
ConfigDescriptionParameter paramWidth = desc.getParameters().get(0);
|
ConfigDescriptionParameter paramWidth = desc.getParameters().getFirst();
|
||||||
assertEquals("width", paramWidth.getName());
|
assertEquals("width", paramWidth.getName());
|
||||||
|
|
||||||
ConfigDescriptionParameter paramHeight = desc.getParameters().get(1);
|
ConfigDescriptionParameter paramHeight = desc.getParameters().get(1);
|
||||||
|
|||||||
+3
-3
@@ -47,8 +47,8 @@ public class ConfigStatusServiceTest extends JavaTest {
|
|||||||
private static final String ENTITY_ID1 = "entity1";
|
private static final String ENTITY_ID1 = "entity1";
|
||||||
private static final String ENTITY_ID2 = "entity2";
|
private static final String ENTITY_ID2 = "entity2";
|
||||||
|
|
||||||
private static final Locale LOCALE_DE = new Locale("de");
|
private static final Locale LOCALE_DE = Locale.of("de");
|
||||||
private static final Locale LOCALE_EN = new Locale("en");
|
private static final Locale LOCALE_EN = Locale.of("en");
|
||||||
|
|
||||||
private static final String PARAM1 = "param1";
|
private static final String PARAM1 = "param1";
|
||||||
private static final String PARAM2 = "param2";
|
private static final String PARAM2 = "param2";
|
||||||
@@ -108,7 +108,7 @@ public class ConfigStatusServiceTest extends JavaTest {
|
|||||||
MessageFormat.format(MSG3_EN, ARGS), PARAM3_MSG3.statusCode));
|
MessageFormat.format(MSG3_EN, ARGS), PARAM3_MSG3.statusCode));
|
||||||
|
|
||||||
LocaleProvider localeProvider = mock(LocaleProvider.class);
|
LocaleProvider localeProvider = mock(LocaleProvider.class);
|
||||||
when(localeProvider.getLocale()).thenReturn(new Locale("en", "US"));
|
when(localeProvider.getLocale()).thenReturn(Locale.of("en", "US"));
|
||||||
|
|
||||||
configStatusService = new ConfigStatusService(mock(EventPublisher.class), localeProvider,
|
configStatusService = new ConfigStatusService(mock(EventPublisher.class), localeProvider,
|
||||||
getTranslationProvider(), mock(BundleResolver.class));
|
getTranslationProvider(), mock(BundleResolver.class));
|
||||||
|
|||||||
+12
-11
@@ -88,17 +88,18 @@ public class XmlDocumentReaderTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void defaultSecurityProtectsAgainstRemoteCodeExecution() throws Exception {
|
public void defaultSecurityProtectsAgainstRemoteCodeExecution() throws Exception {
|
||||||
String xml = "<contact class='dynamic-proxy'>\n" //
|
String xml = """
|
||||||
+ " <interface>org.openhab.core.Contact</interface>\n"
|
<contact class='dynamic-proxy'>
|
||||||
+ " <handler class='java.beans.EventHandler'>\n" //
|
<interface>org.openhab.core.Contact</interface>
|
||||||
+ " <target class='java.lang.ProcessBuilder'>\n" //
|
<handler class='java.beans.EventHandler'>
|
||||||
+ " <command>\n" //
|
<target class='java.lang.ProcessBuilder'>
|
||||||
+ " <string>calc.exe</string>\n" //
|
<command>
|
||||||
+ " </command>\n" //
|
<string>calc.exe</string>
|
||||||
+ " </target>\n" //
|
</command>
|
||||||
+ " <action>start</action>\n" //
|
</target>
|
||||||
+ " </handler>\n" //
|
<action>start</action>
|
||||||
+ "</contact>";
|
</handler>
|
||||||
|
</contact>""";
|
||||||
|
|
||||||
assertThrows(ForbiddenClassException.class, () -> readXML(xml));
|
assertThrows(ForbiddenClassException.class, () -> readXML(xml));
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -114,7 +114,7 @@ public class UpnpAddonFinderTests {
|
|||||||
assertNotNull(upnpService);
|
assertNotNull(upnpService);
|
||||||
List<RemoteDevice> result = new ArrayList<>(upnpService.getRegistry().getRemoteDevices());
|
List<RemoteDevice> result = new ArrayList<>(upnpService.getRegistry().getRemoteDevices());
|
||||||
assertEquals(1, result.size());
|
assertEquals(1, result.size());
|
||||||
RemoteDevice device = result.get(0);
|
RemoteDevice device = result.getFirst();
|
||||||
assertEquals("manufacturer", device.getDetails().getManufacturerDetails().getManufacturer());
|
assertEquals("manufacturer", device.getDetails().getManufacturerDetails().getManufacturer());
|
||||||
assertEquals("serialNumber", device.getDetails().getSerialNumber());
|
assertEquals("serialNumber", device.getDetails().getSerialNumber());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -159,7 +159,7 @@ public class SddpDiscoveryService extends AbstractDiscoveryService
|
|||||||
if (!data.isBlank()) {
|
if (!data.isBlank()) {
|
||||||
List<String> lines = data.lines().toList();
|
List<String> lines = data.lines().toList();
|
||||||
if (lines.size() > 1) {
|
if (lines.size() > 1) {
|
||||||
String statement = lines.get(0).strip();
|
String statement = lines.getFirst().strip();
|
||||||
boolean offline = statement.startsWith(NOTIFY_OFFLINE_HEADER);
|
boolean offline = statement.startsWith(NOTIFY_OFFLINE_HEADER);
|
||||||
if (offline || statement.startsWith(NOTIFY_ALIVE_HEADER) || statement.startsWith(NOTIFY_IDENTIFY_HEADER)
|
if (offline || statement.startsWith(NOTIFY_ALIVE_HEADER) || statement.startsWith(NOTIFY_IDENTIFY_HEADER)
|
||||||
|| statement.startsWith(SEARCH_RESPONSE_HEADER)) {
|
|| statement.startsWith(SEARCH_RESPONSE_HEADER)) {
|
||||||
|
|||||||
+4
-5
@@ -18,7 +18,6 @@ import java.io.IOException;
|
|||||||
import java.nio.file.DirectoryStream;
|
import java.nio.file.DirectoryStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -127,7 +126,7 @@ public class SysfsUsbSerialScanner implements UsbSerialScanner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canPerformScans() {
|
public boolean canPerformScans() {
|
||||||
return isReadable(Paths.get(sysfsTtyDevicesDirectory)) && isReadable(Paths.get(devDirectory));
|
return isReadable(Path.of(sysfsTtyDevicesDirectory)) && isReadable(Path.of(devDirectory));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,10 +139,10 @@ public class SysfsUsbSerialScanner implements UsbSerialScanner {
|
|||||||
private Set<SerialPortInfo> getSerialPortInfos() throws IOException {
|
private Set<SerialPortInfo> getSerialPortInfos() throws IOException {
|
||||||
Set<SerialPortInfo> result = new HashSet<>();
|
Set<SerialPortInfo> result = new HashSet<>();
|
||||||
|
|
||||||
try (DirectoryStream<Path> sysfsTtyPaths = newDirectoryStream(Paths.get(sysfsTtyDevicesDirectory))) {
|
try (DirectoryStream<Path> sysfsTtyPaths = newDirectoryStream(Path.of(sysfsTtyDevicesDirectory))) {
|
||||||
for (Path sysfsTtyPath : sysfsTtyPaths) {
|
for (Path sysfsTtyPath : sysfsTtyPaths) {
|
||||||
String serialPortName = sysfsTtyPath.getFileName().toString();
|
String serialPortName = sysfsTtyPath.getFileName().toString();
|
||||||
Path devicePath = Paths.get(devDirectory).resolve(serialPortName);
|
Path devicePath = Path.of(devDirectory).resolve(serialPortName);
|
||||||
Path sysfsDevicePath = getRealDevicePath(sysfsTtyPath);
|
Path sysfsDevicePath = getRealDevicePath(sysfsTtyPath);
|
||||||
if (sysfsDevicePath != null && isReadable(devicePath) && isWritable(devicePath)) {
|
if (sysfsDevicePath != null && isReadable(devicePath) && isWritable(devicePath)) {
|
||||||
result.add(new SerialPortInfo(devicePath, sysfsDevicePath));
|
result.add(new SerialPortInfo(devicePath, sysfsDevicePath));
|
||||||
@@ -163,7 +162,7 @@ public class SysfsUsbSerialScanner implements UsbSerialScanner {
|
|||||||
String serialPortName = devicePath.getFileName().toString();
|
String serialPortName = devicePath.getFileName().toString();
|
||||||
// get the corresponding real sysinfo special dir :
|
// get the corresponding real sysinfo special dir :
|
||||||
Path sysfsDevicePath = getRealDevicePath(
|
Path sysfsDevicePath = getRealDevicePath(
|
||||||
Paths.get(sysfsTtyDevicesDirectory).resolve(serialPortName));
|
Path.of(sysfsTtyDevicesDirectory).resolve(serialPortName));
|
||||||
if (sysfsDevicePath != null && isReadable(devicePath) && isWritable(devicePath)) {
|
if (sysfsDevicePath != null && isReadable(devicePath) && isWritable(devicePath)) {
|
||||||
result.add(new SerialPortInfo(devLinkPath, sysfsDevicePath));
|
result.add(new SerialPortInfo(devLinkPath, sysfsDevicePath));
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -217,7 +217,7 @@ public class AutomaticInboxProcessor extends AbstractTypedEventSubscriber<ThingS
|
|||||||
if (results.size() == 1) {
|
if (results.size() == 1) {
|
||||||
logger.debug("Auto-ignoring the inbox entry for the representation value '{}'.", representationValue);
|
logger.debug("Auto-ignoring the inbox entry for the representation value '{}'.", representationValue);
|
||||||
|
|
||||||
inbox.setFlag(results.get(0).getThingUID(), DiscoveryResultFlag.IGNORED);
|
inbox.setFlag(results.getFirst().getThingUID(), DiscoveryResultFlag.IGNORED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,7 +255,7 @@ public class AutomaticInboxProcessor extends AbstractTypedEventSubscriber<ThingS
|
|||||||
if (results.size() == 1) {
|
if (results.size() == 1) {
|
||||||
logger.debug("Removing the ignored result from the inbox for the representation value '{}'.",
|
logger.debug("Removing the ignored result from the inbox for the representation value '{}'.",
|
||||||
representationValue);
|
representationValue);
|
||||||
inbox.remove(results.get(0).getThingUID());
|
inbox.remove(results.getFirst().getThingUID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -192,7 +192,7 @@ public final class PersistentInbox implements Inbox, DiscoveryListener, ThingReg
|
|||||||
if (newThingId != null && newThingId.contains(AbstractUID.SEPARATOR)) {
|
if (newThingId != null && newThingId.contains(AbstractUID.SEPARATOR)) {
|
||||||
throw new IllegalArgumentException("New Thing ID " + newThingId + " must not contain multiple segments");
|
throw new IllegalArgumentException("New Thing ID " + newThingId + " must not contain multiple segments");
|
||||||
}
|
}
|
||||||
DiscoveryResult result = results.get(0);
|
DiscoveryResult result = results.getFirst();
|
||||||
final Map<String, String> properties = new HashMap<>();
|
final Map<String, String> properties = new HashMap<>();
|
||||||
final Map<String, Object> configParams = new HashMap<>();
|
final Map<String, Object> configParams = new HashMap<>();
|
||||||
getPropsAndConfigParams(result, properties, configParams);
|
getPropsAndConfigParams(result, properties, configParams);
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ public class DiscoveryConsoleCommandExtension extends AbstractConsoleCommandExte
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.println(getUsages().get(0));
|
console.println(getUsages().getFirst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-12
@@ -81,7 +81,7 @@ public class InboxPredicatesTest {
|
|||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID1)).toList().size(), is(3));
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID1)).toList().size(), is(3));
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().get(0), is(equalTo(RESULTS.get(3))));
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).toList().getFirst(), is(equalTo(RESULTS.get(3))));
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.NEW)).toList()
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.NEW)).toList()
|
||||||
.size(), is(0));
|
.size(), is(0));
|
||||||
@@ -89,7 +89,7 @@ public class InboxPredicatesTest {
|
|||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
||||||
.toList().size(), is(1));
|
.toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
assertThat(RESULTS.stream().filter(forBinding(BINDING_ID2)).filter(withFlag(DiscoveryResultFlag.IGNORED))
|
||||||
.toList().get(0), is(equalTo(RESULTS.get(3))));
|
.toList().getFirst(), is(equalTo(RESULTS.get(3))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -97,27 +97,28 @@ public class InboxPredicatesTest {
|
|||||||
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID11)).toList().size(), is(2));
|
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID11)).toList().size(), is(2));
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().get(0),
|
assertThat(RESULTS.stream().filter(forThingTypeUID(THING_TYPE_UID12)).toList().getFirst(),
|
||||||
is(equalTo(RESULTS.get(2))));
|
is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForThingUID() {
|
public void testForThingUID() {
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().get(0), is(equalTo(RESULTS.get(0))));
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID11)).toList().getFirst(),
|
||||||
|
is(equalTo(RESULTS.getFirst())));
|
||||||
|
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).toList().size(), is(2));
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).toList().size(), is(2));
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList()
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList()
|
||||||
.size(), is(1));
|
.size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList()
|
assertThat(RESULTS.stream().filter(forThingUID(THING_UID12)).filter(forThingTypeUID(THING_TYPE_UID12)).toList()
|
||||||
.get(0), is(equalTo(RESULTS.get(2))));
|
.getFirst(), is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithFlag() {
|
public void testWithFlag() {
|
||||||
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList().size(), is(3));
|
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList().size(), is(3));
|
||||||
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().get(0),
|
assertThat(RESULTS.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList().getFirst(),
|
||||||
is(equalTo(RESULTS.get(3))));
|
is(equalTo(RESULTS.get(3))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,20 +134,20 @@ public class InboxPredicatesTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testWithRepresentationProperty() {
|
public void testWithRepresentationProperty() {
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().get(0),
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP1)).toList().getFirst(),
|
||||||
is(equalTo(RESULTS.get(0))));
|
is(equalTo(RESULTS.getFirst())));
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().get(0),
|
assertThat(RESULTS.stream().filter(withRepresentationProperty(PROP2)).toList().getFirst(),
|
||||||
is(equalTo(RESULTS.get(2))));
|
is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithRepresentationPropertyValue() {
|
public void testWithRepresentationPropertyValue() {
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().get(0),
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL1)).toList().getFirst(),
|
||||||
is(equalTo(RESULTS.get(0))));
|
is(equalTo(RESULTS.getFirst())));
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().size(), is(1));
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().size(), is(1));
|
||||||
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().get(0),
|
assertThat(RESULTS.stream().filter(withRepresentationPropertyValue(PROP_VAL2)).toList().getFirst(),
|
||||||
is(equalTo(RESULTS.get(2))));
|
is(equalTo(RESULTS.get(2))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-13
@@ -168,7 +168,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
// Then there is a discovery result which is NEW
|
// Then there is a discovery result which is NEW
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
// Now a thing with thing type THING_TYPE_UID3 goes online, with representation property value being also the
|
// Now a thing with thing type THING_TYPE_UID3 goes online, with representation property value being also the
|
||||||
// device id
|
// device id
|
||||||
@@ -181,7 +181,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
// Then there should still be the NEW discovery result, but no IGNORED discovery result
|
// Then there should still be the NEW discovery result, but no IGNORED discovery result
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID)));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
// Then there is a discovery result which is NEW
|
// Then there is a discovery result which is NEW
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID3)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -213,7 +213,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
|
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
when(thingRegistryMock.get(THING_UID)).thenReturn(thingMock);
|
when(thingRegistryMock.get(THING_UID)).thenReturn(thingMock);
|
||||||
when(thingStatusInfoChangedEventMock.getStatusInfo())
|
when(thingStatusInfoChangedEventMock.getStatusInfo())
|
||||||
@@ -225,7 +225,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -239,7 +239,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).build());
|
inbox.add(DiscoveryResultBuilder.create(THING_UID).withProperty(DEVICE_ID_KEY, DEVICE_ID).build());
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
when(thingMock.getProperties()).thenReturn(Map.of());
|
when(thingMock.getProperties()).thenReturn(Map.of());
|
||||||
when(thingStatusInfoChangedEventMock.getStatusInfo())
|
when(thingStatusInfoChangedEventMock.getStatusInfo())
|
||||||
@@ -266,7 +266,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -277,7 +277,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
inbox.setFlag(THING_UID, DiscoveryResultFlag.IGNORED);
|
inbox.setFlag(THING_UID, DiscoveryResultFlag.IGNORED);
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID)));
|
||||||
|
|
||||||
automaticInboxProcessor.removed(thingMock);
|
automaticInboxProcessor.removed(thingMock);
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
|
|
||||||
results = inbox.getAll();
|
results = inbox.getAll();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID3)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -312,7 +312,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
|
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.NEW)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID2)));
|
||||||
|
|
||||||
when(thingRegistryMock.get(THING_UID2)).thenReturn(thing2Mock);
|
when(thingRegistryMock.get(THING_UID2)).thenReturn(thing2Mock);
|
||||||
when(thingStatusInfoChangedEventMock.getStatusInfo())
|
when(thingStatusInfoChangedEventMock.getStatusInfo())
|
||||||
@@ -324,7 +324,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -342,7 +342,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
assertThat(results.size(), is(0));
|
assertThat(results.size(), is(0));
|
||||||
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -353,7 +353,7 @@ public class AutomaticInboxProcessorTest {
|
|||||||
inbox.setFlag(THING_UID2, DiscoveryResultFlag.IGNORED);
|
inbox.setFlag(THING_UID2, DiscoveryResultFlag.IGNORED);
|
||||||
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
List<DiscoveryResult> results = inbox.stream().filter(withFlag(DiscoveryResultFlag.IGNORED)).toList();
|
||||||
assertThat(results.size(), is(1));
|
assertThat(results.size(), is(1));
|
||||||
assertThat(results.get(0).getThingUID(), is(equalTo(THING_UID2)));
|
assertThat(results.getFirst().getThingUID(), is(equalTo(THING_UID2)));
|
||||||
|
|
||||||
automaticInboxProcessor.removed(thing2Mock);
|
automaticInboxProcessor.removed(thing2Mock);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -294,7 +294,7 @@ public class ConfigDispatcher {
|
|||||||
|
|
||||||
// configuration file contains a PID Marker
|
// configuration file contains a PID Marker
|
||||||
List<String> lines = Files.readAllLines(configFile.toPath(), StandardCharsets.UTF_8);
|
List<String> lines = Files.readAllLines(configFile.toPath(), StandardCharsets.UTF_8);
|
||||||
String exclusivePID = !lines.isEmpty() ? getPIDFromLine(lines.get(0)) : null;
|
String exclusivePID = !lines.isEmpty() ? getPIDFromLine(lines.getFirst()) : null;
|
||||||
if (exclusivePID != null) {
|
if (exclusivePID != null) {
|
||||||
if (exclusivePIDMap.contains(exclusivePID)) {
|
if (exclusivePIDMap.contains(exclusivePID)) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -41,7 +40,7 @@ public class InstanceUUIDTest {
|
|||||||
public void readFromPersistedFile() throws IOException {
|
public void readFromPersistedFile() throws IOException {
|
||||||
// we first need to remove the cached value
|
// we first need to remove the cached value
|
||||||
InstanceUUID.uuid = null;
|
InstanceUUID.uuid = null;
|
||||||
Path path = Paths.get(OpenHAB.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
Path path = Path.of(OpenHAB.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
||||||
Files.createDirectories(path.getParent());
|
Files.createDirectories(path.getParent());
|
||||||
Files.write(path, "123".getBytes());
|
Files.write(path, "123".getBytes());
|
||||||
String uuid = InstanceUUID.get();
|
String uuid = InstanceUUID.get();
|
||||||
@@ -52,7 +51,7 @@ public class InstanceUUIDTest {
|
|||||||
public void ignoreEmptyFile() throws IOException {
|
public void ignoreEmptyFile() throws IOException {
|
||||||
// we first need to remove the cached value
|
// we first need to remove the cached value
|
||||||
InstanceUUID.uuid = null;
|
InstanceUUID.uuid = null;
|
||||||
Path path = Paths.get(OpenHAB.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
Path path = Path.of(OpenHAB.getUserDataFolder(), InstanceUUID.UUID_FILE_NAME);
|
||||||
Files.createDirectories(path.getParent());
|
Files.createDirectories(path.getParent());
|
||||||
Files.write(path, "".getBytes());
|
Files.write(path, "".getBytes());
|
||||||
String uuid = InstanceUUID.get();
|
String uuid = InstanceUUID.get();
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.bin2json;
|
package org.openhab.core.io.bin2json;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +24,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ConversionException extends Exception {
|
public class ConversionException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public ConversionException() {
|
public ConversionException() {
|
||||||
|
|||||||
+4
-4
@@ -61,8 +61,8 @@ public class CompleterWrapperTest {
|
|||||||
|
|
||||||
completerWrapper.completeCandidates(session, commandLine, candidates);
|
completerWrapper.completeCandidates(session, commandLine, candidates);
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("command", candidates.get(0).value());
|
assertEquals("command", candidates.getFirst().value());
|
||||||
assertEquals("description", candidates.get(0).descr());
|
assertEquals("description", candidates.getFirst().descr());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -75,8 +75,8 @@ public class CompleterWrapperTest {
|
|||||||
|
|
||||||
completerWrapper.completeCandidates(session, commandLine, candidates);
|
completerWrapper.completeCandidates(session, commandLine, candidates);
|
||||||
assertEquals(2, candidates.size());
|
assertEquals(2, candidates.size());
|
||||||
assertEquals("command", candidates.get(0).value());
|
assertEquals("command", candidates.getFirst().value());
|
||||||
assertEquals("description", candidates.get(0).descr());
|
assertEquals("description", candidates.getFirst().descr());
|
||||||
|
|
||||||
assertEquals("openhab:command", candidates.get(1).value());
|
assertEquals("openhab:command", candidates.get(1).value());
|
||||||
assertEquals("description", candidates.get(1).descr());
|
assertEquals("description", candidates.get(1).descr());
|
||||||
|
|||||||
+9
-9
@@ -33,7 +33,7 @@ public class StringsCompleterTest {
|
|||||||
// positive match
|
// positive match
|
||||||
assertTrue(sc.complete(new String[] { "a" }, 0, 1, candidates));
|
assertTrue(sc.complete(new String[] { "a" }, 0, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("abc ", candidates.get(0));
|
assertEquals("abc ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
// negative match
|
// negative match
|
||||||
@@ -43,25 +43,25 @@ public class StringsCompleterTest {
|
|||||||
// case insensitive
|
// case insensitive
|
||||||
assertTrue(sc.complete(new String[] { "A" }, 0, 1, candidates));
|
assertTrue(sc.complete(new String[] { "A" }, 0, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("abc ", candidates.get(0));
|
assertEquals("abc ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
// second argument
|
// second argument
|
||||||
assertTrue(sc.complete(new String[] { "a", "d" }, 1, 1, candidates));
|
assertTrue(sc.complete(new String[] { "a", "d" }, 1, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("def ", candidates.get(0));
|
assertEquals("def ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
// cursor not at end of word (truncates rest)
|
// cursor not at end of word (truncates rest)
|
||||||
assertTrue(sc.complete(new String[] { "a", "dg" }, 1, 1, candidates));
|
assertTrue(sc.complete(new String[] { "a", "dg" }, 1, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("def ", candidates.get(0));
|
assertEquals("def ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
// first argument when second is present
|
// first argument when second is present
|
||||||
assertTrue(sc.complete(new String[] { "a", "d" }, 0, 1, candidates));
|
assertTrue(sc.complete(new String[] { "a", "d" }, 0, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("abc ", candidates.get(0));
|
assertEquals("abc ", candidates.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -77,7 +77,7 @@ public class StringsCompleterTest {
|
|||||||
|
|
||||||
assertTrue(sc.complete(new String[] { "AB" }, 0, 1, candidates));
|
assertTrue(sc.complete(new String[] { "AB" }, 0, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("ABc ", candidates.get(0));
|
assertEquals("ABc ", candidates.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -87,7 +87,7 @@ public class StringsCompleterTest {
|
|||||||
|
|
||||||
assertTrue(sc.complete(new String[] { "abcd" }, 0, 4, candidates));
|
assertTrue(sc.complete(new String[] { "abcd" }, 0, 4, candidates));
|
||||||
assertEquals(5, candidates.size());
|
assertEquals(5, candidates.size());
|
||||||
assertEquals("abcdd ", candidates.get(0));
|
assertEquals("abcdd ", candidates.getFirst());
|
||||||
assertEquals("abcde ", candidates.get(1));
|
assertEquals("abcde ", candidates.get(1));
|
||||||
assertEquals("abcdee ", candidates.get(2));
|
assertEquals("abcdee ", candidates.get(2));
|
||||||
assertEquals("abcdef ", candidates.get(3));
|
assertEquals("abcdef ", candidates.get(3));
|
||||||
@@ -96,13 +96,13 @@ public class StringsCompleterTest {
|
|||||||
|
|
||||||
assertTrue(sc.complete(new String[] { "abcde" }, 0, 5, candidates));
|
assertTrue(sc.complete(new String[] { "abcde" }, 0, 5, candidates));
|
||||||
assertEquals(3, candidates.size());
|
assertEquals(3, candidates.size());
|
||||||
assertEquals("abcde ", candidates.get(0));
|
assertEquals("abcde ", candidates.getFirst());
|
||||||
assertEquals("abcdee ", candidates.get(1));
|
assertEquals("abcdee ", candidates.get(1));
|
||||||
assertEquals("abcdef ", candidates.get(2));
|
assertEquals("abcdef ", candidates.get(2));
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
assertTrue(sc.complete(new String[] { "abcdee" }, 0, 6, candidates));
|
assertTrue(sc.complete(new String[] { "abcdee" }, 0, 6, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("abcdee ", candidates.get(0));
|
assertEquals("abcdee ", candidates.getFirst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -63,13 +63,13 @@ public class ItemConsoleCommandCompleterTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "It" }, 0, 2, candidates));
|
assertTrue(completer.complete(new String[] { "It" }, 0, 2, candidates));
|
||||||
assertEquals(2, candidates.size());
|
assertEquals(2, candidates.size());
|
||||||
assertEquals("Item1 ", candidates.get(0));
|
assertEquals("Item1 ", candidates.getFirst());
|
||||||
assertEquals("Item2 ", candidates.get(1));
|
assertEquals("Item2 ", candidates.get(1));
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "JI" }, 0, 2, candidates));
|
assertTrue(completer.complete(new String[] { "JI" }, 0, 2, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("JItem1 ", candidates.get(0));
|
assertEquals("JItem1 ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
// case sensitive
|
// case sensitive
|
||||||
@@ -98,7 +98,7 @@ public class ItemConsoleCommandCompleterTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "Item1", "" }, 1, 0, candidates));
|
assertTrue(completer.complete(new String[] { "Item1", "" }, 1, 0, candidates));
|
||||||
assertEquals(3, candidates.size());
|
assertEquals(3, candidates.size());
|
||||||
assertEquals("OFF ", candidates.get(0));
|
assertEquals("OFF ", candidates.getFirst());
|
||||||
assertEquals("ON ", candidates.get(1));
|
assertEquals("ON ", candidates.get(1));
|
||||||
assertEquals("REFRESH ", candidates.get(2));
|
assertEquals("REFRESH ", candidates.get(2));
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
@@ -106,7 +106,7 @@ public class ItemConsoleCommandCompleterTest {
|
|||||||
// case insensitive
|
// case insensitive
|
||||||
assertTrue(completer.complete(new String[] { "Item1", "o" }, 1, 1, candidates));
|
assertTrue(completer.complete(new String[] { "Item1", "o" }, 1, 1, candidates));
|
||||||
assertEquals(2, candidates.size());
|
assertEquals(2, candidates.size());
|
||||||
assertEquals("OFF ", candidates.get(0));
|
assertEquals("OFF ", candidates.getFirst());
|
||||||
assertEquals("ON ", candidates.get(1));
|
assertEquals("ON ", candidates.get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ public class ItemConsoleCommandCompleterTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "Item1", "" }, 1, 0, candidates));
|
assertTrue(completer.complete(new String[] { "Item1", "" }, 1, 0, candidates));
|
||||||
assertEquals(4, candidates.size());
|
assertEquals(4, candidates.size());
|
||||||
assertEquals("NULL ", candidates.get(0));
|
assertEquals("NULL ", candidates.getFirst());
|
||||||
assertEquals("OFF ", candidates.get(1));
|
assertEquals("OFF ", candidates.get(1));
|
||||||
assertEquals("ON ", candidates.get(2));
|
assertEquals("ON ", candidates.get(2));
|
||||||
assertEquals("UNDEF ", candidates.get(3));
|
assertEquals("UNDEF ", candidates.get(3));
|
||||||
@@ -132,7 +132,7 @@ public class ItemConsoleCommandCompleterTest {
|
|||||||
// case insensitive
|
// case insensitive
|
||||||
assertTrue(completer.complete(new String[] { "Item1", "o" }, 1, 1, candidates));
|
assertTrue(completer.complete(new String[] { "Item1", "o" }, 1, 1, candidates));
|
||||||
assertEquals(2, candidates.size());
|
assertEquals(2, candidates.size());
|
||||||
assertEquals("OFF ", candidates.get(0));
|
assertEquals("OFF ", candidates.getFirst());
|
||||||
assertEquals("ON ", candidates.get(1));
|
assertEquals("ON ", candidates.get(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -52,7 +52,7 @@ public class ItemConsoleCommandExtensionTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "" }, 0, 0, candidates));
|
assertTrue(completer.complete(new String[] { "" }, 0, 0, candidates));
|
||||||
assertEquals(5, candidates.size());
|
assertEquals(5, candidates.size());
|
||||||
assertEquals("addTag ", candidates.get(0));
|
assertEquals("addTag ", candidates.getFirst());
|
||||||
assertEquals("clear ", candidates.get(1));
|
assertEquals("clear ", candidates.get(1));
|
||||||
assertEquals("list ", candidates.get(2));
|
assertEquals("list ", candidates.get(2));
|
||||||
assertEquals("remove ", candidates.get(3));
|
assertEquals("remove ", candidates.get(3));
|
||||||
@@ -61,7 +61,7 @@ public class ItemConsoleCommandExtensionTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "A", "Item1" }, 0, 1, candidates));
|
assertTrue(completer.complete(new String[] { "A", "Item1" }, 0, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("addTag ", candidates.get(0));
|
assertEquals("addTag ", candidates.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -75,17 +75,17 @@ public class ItemConsoleCommandExtensionTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "addTag", "I" }, 0, 6, candidates));
|
assertTrue(completer.complete(new String[] { "addTag", "I" }, 0, 6, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("addTag ", candidates.get(0));
|
assertEquals("addTag ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "addTag", "I" }, 1, 1, candidates));
|
assertTrue(completer.complete(new String[] { "addTag", "I" }, 1, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("Item1 ", candidates.get(0));
|
assertEquals("Item1 ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "rmTag", "I" }, 1, 1, candidates));
|
assertTrue(completer.complete(new String[] { "rmTag", "I" }, 1, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("Item1 ", candidates.get(0));
|
assertEquals("Item1 ", candidates.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -96,12 +96,12 @@ public class ItemConsoleCommandExtensionTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "remove", "I" }, 0, 6, candidates));
|
assertTrue(completer.complete(new String[] { "remove", "I" }, 0, 6, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("remove ", candidates.get(0));
|
assertEquals("remove ", candidates.getFirst());
|
||||||
candidates.clear();
|
candidates.clear();
|
||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "remove", "I" }, 1, 1, candidates));
|
assertTrue(completer.complete(new String[] { "remove", "I" }, 1, 1, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("Item2 ", candidates.get(0));
|
assertEquals("Item2 ", candidates.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -135,6 +135,6 @@ public class ItemConsoleCommandExtensionTest {
|
|||||||
|
|
||||||
assertTrue(completer.complete(new String[] { "rmTag", "Item3", "" }, 2, 0, candidates));
|
assertTrue(completer.complete(new String[] { "rmTag", "Item3", "" }, 2, 0, candidates));
|
||||||
assertEquals(1, candidates.size());
|
assertEquals(1, candidates.size());
|
||||||
assertEquals("Tag1 ", candidates.get(0));
|
assertEquals("Tag1 ", candidates.getFirst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -14,6 +14,7 @@ package org.openhab.core.io.http.auth.internal;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.Serial;
|
||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -51,6 +52,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public abstract class AbstractAuthPageServlet extends HttpServlet {
|
public abstract class AbstractAuthPageServlet extends HttpServlet {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 5340598701104679840L;
|
private static final long serialVersionUID = 5340598701104679840L;
|
||||||
|
|
||||||
private static final String MESSAGES_BUNDLE_NAME = "messages";
|
private static final String MESSAGES_BUNDLE_NAME = "messages";
|
||||||
|
|||||||
+2
@@ -13,6 +13,7 @@
|
|||||||
package org.openhab.core.io.http.auth.internal;
|
package org.openhab.core.io.http.auth.internal;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -62,6 +63,7 @@ public class AuthorizePageServlet extends AbstractAuthPageServlet {
|
|||||||
|
|
||||||
public static final String SERVLET_PATH = "/auth";
|
public static final String SERVLET_PATH = "/auth";
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 5340598701104679843L;
|
private static final long serialVersionUID = 5340598701104679843L;
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(AuthorizePageServlet.class);
|
private final Logger logger = LoggerFactory.getLogger(AuthorizePageServlet.class);
|
||||||
|
|||||||
+2
@@ -13,6 +13,7 @@
|
|||||||
package org.openhab.core.io.http.auth.internal;
|
package org.openhab.core.io.http.auth.internal;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.Servlet;
|
import javax.servlet.Servlet;
|
||||||
@@ -48,6 +49,7 @@ public class ChangePasswordPageServlet extends AbstractAuthPageServlet {
|
|||||||
|
|
||||||
public static final String SERVLET_PATH = "/changePassword";
|
public static final String SERVLET_PATH = "/changePassword";
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 5340598701104679843L;
|
private static final long serialVersionUID = 5340598701104679843L;
|
||||||
|
|
||||||
@Activate
|
@Activate
|
||||||
|
|||||||
+2
@@ -13,6 +13,7 @@
|
|||||||
package org.openhab.core.io.http.auth.internal;
|
package org.openhab.core.io.http.auth.internal;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.Servlet;
|
import javax.servlet.Servlet;
|
||||||
@@ -46,6 +47,7 @@ import org.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPatte
|
|||||||
@HttpWhiteboardServletPattern(CreateAPITokenPageServlet.SERVLET_PATH + "/*")
|
@HttpWhiteboardServletPattern(CreateAPITokenPageServlet.SERVLET_PATH + "/*")
|
||||||
public class CreateAPITokenPageServlet extends AbstractAuthPageServlet {
|
public class CreateAPITokenPageServlet extends AbstractAuthPageServlet {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 5340598701104679843L;
|
private static final long serialVersionUID = 5340598701104679843L;
|
||||||
public static final String SERVLET_PATH = "/createApiToken";
|
public static final String SERVLET_PATH = "/createApiToken";
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -69,7 +69,7 @@ public class ThingStateMetricTest {
|
|||||||
|
|
||||||
List<Meter> meters = meterRegistry.getMeters();
|
List<Meter> meters = meterRegistry.getMeters();
|
||||||
assertEquals(1, meters.size());
|
assertEquals(1, meters.size());
|
||||||
assertEquals(strThingUid, meters.get(0).getId().getTag("thing"));
|
assertEquals(strThingUid, meters.getFirst().getId().getTag("thing"));
|
||||||
|
|
||||||
// Still only one meter registered after receiving an event
|
// Still only one meter registered after receiving an event
|
||||||
ThingStatusInfo thingStatusInfo = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
|
ThingStatusInfo thingStatusInfo = new ThingStatusInfo(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);
|
||||||
@@ -77,7 +77,7 @@ public class ThingStateMetricTest {
|
|||||||
|
|
||||||
meters = meterRegistry.getMeters();
|
meters = meterRegistry.getMeters();
|
||||||
assertEquals(1, meters.size());
|
assertEquals(1, meters.size());
|
||||||
assertEquals(strThingUid, meters.get(0).getId().getTag("thing"));
|
assertEquals(strThingUid, meters.getFirst().getId().getTag("thing"));
|
||||||
|
|
||||||
// Now another one is added
|
// Now another one is added
|
||||||
thingStateMetric.receive(ThingEventFactory.createStatusInfoEvent(thingUid2, thingStatusInfo));
|
thingStateMetric.receive(ThingEventFactory.createStatusInfoEvent(thingUid2, thingStatusInfo));
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.net.http;
|
package org.openhab.core.io.net.http;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -23,6 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class HttpClientInitializationException extends RuntimeException {
|
public class HttpClientInitializationException extends RuntimeException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -3187938868560212413L;
|
private static final long serialVersionUID = -3187938868560212413L;
|
||||||
|
|
||||||
public HttpClientInitializationException(String message, @Nullable Throwable cause) {
|
public HttpClientInitializationException(String message, @Nullable Throwable cause) {
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -84,7 +84,7 @@ public class JwtHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RsaJsonWebKey loadOrGenerateKey() throws JoseException, IOException {
|
private RsaJsonWebKey loadOrGenerateKey() throws JoseException, IOException {
|
||||||
try (final BufferedReader reader = Files.newBufferedReader(Paths.get(KEY_FILE_PATH))) {
|
try (final BufferedReader reader = Files.newBufferedReader(Path.of(KEY_FILE_PATH))) {
|
||||||
return (RsaJsonWebKey) JsonWebKey.Factory.newJwk(reader.readLine());
|
return (RsaJsonWebKey) JsonWebKey.Factory.newJwk(reader.readLine());
|
||||||
} catch (IOException | JoseException e) {
|
} catch (IOException | JoseException e) {
|
||||||
RsaJsonWebKey key = generateNewKey();
|
RsaJsonWebKey key = generateNewKey();
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.rest.auth.internal;
|
package org.openhab.core.io.rest.auth.internal;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.openhab.core.auth.AuthenticationException;
|
import org.openhab.core.auth.AuthenticationException;
|
||||||
|
|
||||||
@@ -26,6 +28,7 @@ import org.openhab.core.auth.AuthenticationException;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TokenEndpointException extends AuthenticationException {
|
public class TokenEndpointException extends AuthenticationException {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 610324537843397832L;
|
private static final long serialVersionUID = 610324537843397832L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -179,7 +179,7 @@ public class ItemChannelLinkResource implements RESTResource {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
if (!links.isEmpty()) {
|
if (!links.isEmpty()) {
|
||||||
return JSONResponse.createResponse(Status.OK, links.get(0), null);
|
return JSONResponse.createResponse(Status.OK, links.getFirst(), null);
|
||||||
}
|
}
|
||||||
return JSONResponse.createErrorResponse(Status.NOT_FOUND,
|
return JSONResponse.createErrorResponse(Status.NOT_FOUND,
|
||||||
"No link found for item '" + itemName + "' + and channelUID '" + channelUid + "'");
|
"No link found for item '" + itemName + "' + and channelUID '" + channelUid + "'");
|
||||||
|
|||||||
+3
-3
@@ -174,7 +174,7 @@ public class ConfigurableServiceResource implements RESTResource {
|
|||||||
+ "=*))";
|
+ "=*))";
|
||||||
List<ConfigurableServiceDTO> services = getServicesByFilter(filter, locale);
|
List<ConfigurableServiceDTO> services = getServicesByFilter(filter, locale);
|
||||||
if (services.size() == 1) {
|
if (services.size() == 1) {
|
||||||
return services.get(0);
|
return services.getFirst();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -391,9 +391,9 @@ public class ConfigurableServiceResource implements RESTResource {
|
|||||||
case 0:
|
case 0:
|
||||||
return "";
|
return "";
|
||||||
case 1:
|
case 1:
|
||||||
return pids.get(0);
|
return pids.getFirst();
|
||||||
default: // multiple entries
|
default: // multiple entries
|
||||||
final String first = pids.get(0);
|
final String first = pids.getFirst();
|
||||||
boolean differences = false;
|
boolean differences = false;
|
||||||
for (int i = 1; i < pids.size(); ++i) {
|
for (int i = 1; i < pids.size(); ++i) {
|
||||||
if (!first.equals(pids.get(i))) {
|
if (!first.equals(pids.get(i))) {
|
||||||
|
|||||||
+3
-3
@@ -49,7 +49,7 @@ public class EnrichedConfigDescriptionDTOMapperTest {
|
|||||||
ConfigDescriptionDTO cddto = EnrichedConfigDescriptionDTOMapper.map(configDescription);
|
ConfigDescriptionDTO cddto = EnrichedConfigDescriptionDTOMapper.map(configDescription);
|
||||||
assertThat(cddto.parameters, hasSize(1));
|
assertThat(cddto.parameters, hasSize(1));
|
||||||
|
|
||||||
ConfigDescriptionParameterDTO cdpdto = cddto.parameters.get(0);
|
ConfigDescriptionParameterDTO cdpdto = cddto.parameters.getFirst();
|
||||||
assertThat(cdpdto, instanceOf(EnrichedConfigDescriptionParameterDTO.class));
|
assertThat(cdpdto, instanceOf(EnrichedConfigDescriptionParameterDTO.class));
|
||||||
assertThat(cdpdto.defaultValue, is(nullValue()));
|
assertThat(cdpdto.defaultValue, is(nullValue()));
|
||||||
EnrichedConfigDescriptionParameterDTO ecdpdto = (EnrichedConfigDescriptionParameterDTO) cdpdto;
|
EnrichedConfigDescriptionParameterDTO ecdpdto = (EnrichedConfigDescriptionParameterDTO) cdpdto;
|
||||||
@@ -66,7 +66,7 @@ public class EnrichedConfigDescriptionDTOMapperTest {
|
|||||||
ConfigDescriptionDTO cddto = EnrichedConfigDescriptionDTOMapper.map(configDescription);
|
ConfigDescriptionDTO cddto = EnrichedConfigDescriptionDTOMapper.map(configDescription);
|
||||||
assertThat(cddto.parameters, hasSize(1));
|
assertThat(cddto.parameters, hasSize(1));
|
||||||
|
|
||||||
ConfigDescriptionParameterDTO cdpdto = cddto.parameters.get(0);
|
ConfigDescriptionParameterDTO cdpdto = cddto.parameters.getFirst();
|
||||||
assertThat(cdpdto, instanceOf(EnrichedConfigDescriptionParameterDTO.class));
|
assertThat(cdpdto, instanceOf(EnrichedConfigDescriptionParameterDTO.class));
|
||||||
assertThat(cdpdto.defaultValue, is(CONFIG_PARAMETER_DEFAULT_VALUE));
|
assertThat(cdpdto.defaultValue, is(CONFIG_PARAMETER_DEFAULT_VALUE));
|
||||||
EnrichedConfigDescriptionParameterDTO ecdpdto = (EnrichedConfigDescriptionParameterDTO) cdpdto;
|
EnrichedConfigDescriptionParameterDTO ecdpdto = (EnrichedConfigDescriptionParameterDTO) cdpdto;
|
||||||
@@ -84,7 +84,7 @@ public class EnrichedConfigDescriptionDTOMapperTest {
|
|||||||
ConfigDescriptionDTO cddto = EnrichedConfigDescriptionDTOMapper.map(configDescription);
|
ConfigDescriptionDTO cddto = EnrichedConfigDescriptionDTOMapper.map(configDescription);
|
||||||
assertThat(cddto.parameters, hasSize(1));
|
assertThat(cddto.parameters, hasSize(1));
|
||||||
|
|
||||||
ConfigDescriptionParameterDTO cdpdto = cddto.parameters.get(0);
|
ConfigDescriptionParameterDTO cdpdto = cddto.parameters.getFirst();
|
||||||
assertThat(cdpdto, instanceOf(EnrichedConfigDescriptionParameterDTO.class));
|
assertThat(cdpdto, instanceOf(EnrichedConfigDescriptionParameterDTO.class));
|
||||||
assertThat(cdpdto.defaultValue, is(CONFIG_PARAMETER_DEFAULT_VALUE));
|
assertThat(cdpdto.defaultValue, is(CONFIG_PARAMETER_DEFAULT_VALUE));
|
||||||
EnrichedConfigDescriptionParameterDTO ecdpdto = (EnrichedConfigDescriptionParameterDTO) cdpdto;
|
EnrichedConfigDescriptionParameterDTO ecdpdto = (EnrichedConfigDescriptionParameterDTO) cdpdto;
|
||||||
|
|||||||
+1
-1
@@ -127,7 +127,7 @@ public class PersistenceResourceTest {
|
|||||||
|
|
||||||
// since we added binary state type elements, all except the first have to be repeated but with the timestamp of
|
// since we added binary state type elements, all except the first have to be repeated but with the timestamp of
|
||||||
// the following item
|
// the following item
|
||||||
HistoryDataBean item0 = dto.data.get(0);
|
HistoryDataBean item0 = dto.data.getFirst();
|
||||||
HistoryDataBean item1 = dto.data.get(1);
|
HistoryDataBean item1 = dto.data.get(1);
|
||||||
|
|
||||||
assertEquals(item0.state, item1.state);
|
assertEquals(item0.state, item1.state);
|
||||||
|
|||||||
+2
-2
@@ -94,9 +94,9 @@ public class EnrichedThingDTOMapperTest {
|
|||||||
|
|
||||||
private void assertChannels(EnrichedThingDTO enrichedThingDTO) {
|
private void assertChannels(EnrichedThingDTO enrichedThingDTO) {
|
||||||
assertThat(enrichedThingDTO.channels, hasSize(2));
|
assertThat(enrichedThingDTO.channels, hasSize(2));
|
||||||
assertThat(enrichedThingDTO.channels.get(0), is(instanceOf(EnrichedChannelDTO.class)));
|
assertThat(enrichedThingDTO.channels.getFirst(), is(instanceOf(EnrichedChannelDTO.class)));
|
||||||
|
|
||||||
EnrichedChannelDTO channel1 = enrichedThingDTO.channels.get(0);
|
EnrichedChannelDTO channel1 = enrichedThingDTO.channels.getFirst();
|
||||||
assertThat(channel1.linkedItems, hasSize(2));
|
assertThat(channel1.linkedItems, hasSize(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -299,9 +299,9 @@ public class SitemapSubscriptionService implements ModelRepositoryChangeListener
|
|||||||
// subscribing to whole sitemap --> get items for all subpages as well
|
// subscribing to whole sitemap --> get items for all subpages as well
|
||||||
LinkedList<Widget> childrenQueue = new LinkedList<>(widgets);
|
LinkedList<Widget> childrenQueue = new LinkedList<>(widgets);
|
||||||
while (!childrenQueue.isEmpty()) {
|
while (!childrenQueue.isEmpty()) {
|
||||||
Widget child = childrenQueue.remove(0);
|
Widget child = childrenQueue.removeFirst();
|
||||||
if (child instanceof LinkableWidget) {
|
if (child instanceof LinkableWidget widget) {
|
||||||
List<Widget> subWidgets = itemUIRegistry.getChildren((LinkableWidget) child);
|
List<Widget> subWidgets = itemUIRegistry.getChildren(widget);
|
||||||
widgets.addAll(subWidgets);
|
widgets.addAll(subWidgets);
|
||||||
childrenQueue.addAll(subWidgets);
|
childrenQueue.addAll(subWidgets);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-14
@@ -358,18 +358,18 @@ public class SitemapResourceTest extends JavaTest {
|
|||||||
assertThat(pageDTO.widgets, notNullValue());
|
assertThat(pageDTO.widgets, notNullValue());
|
||||||
assertThat((Collection<?>) pageDTO.widgets, hasSize(3));
|
assertThat((Collection<?>) pageDTO.widgets, hasSize(3));
|
||||||
|
|
||||||
assertThat(pageDTO.widgets.get(0).widgetId, is(WIDGET1_ID));
|
assertThat(pageDTO.widgets.getFirst().widgetId, is(WIDGET1_ID));
|
||||||
assertThat(pageDTO.widgets.get(0).label, is(WIDGET1_LABEL));
|
assertThat(pageDTO.widgets.getFirst().label, is(WIDGET1_LABEL));
|
||||||
assertThat(pageDTO.widgets.get(0).labelSource, is("SITEMAP_WIDGET"));
|
assertThat(pageDTO.widgets.getFirst().labelSource, is("SITEMAP_WIDGET"));
|
||||||
assertThat(pageDTO.widgets.get(0).labelcolor, is("GREEN"));
|
assertThat(pageDTO.widgets.getFirst().labelcolor, is("GREEN"));
|
||||||
assertThat(pageDTO.widgets.get(0).valuecolor, is("BLUE"));
|
assertThat(pageDTO.widgets.getFirst().valuecolor, is("BLUE"));
|
||||||
assertThat(pageDTO.widgets.get(0).iconcolor, is("ORANGE"));
|
assertThat(pageDTO.widgets.getFirst().iconcolor, is("ORANGE"));
|
||||||
assertThat(pageDTO.widgets.get(0).icon, is(WIDGET1_ICON));
|
assertThat(pageDTO.widgets.getFirst().icon, is(WIDGET1_ICON));
|
||||||
assertThat(pageDTO.widgets.get(0).staticIcon, is(true));
|
assertThat(pageDTO.widgets.getFirst().staticIcon, is(true));
|
||||||
assertThat(pageDTO.widgets.get(0).state, nullValue());
|
assertThat(pageDTO.widgets.getFirst().state, nullValue());
|
||||||
assertThat(pageDTO.widgets.get(0).item, notNullValue());
|
assertThat(pageDTO.widgets.getFirst().item, notNullValue());
|
||||||
assertThat(pageDTO.widgets.get(0).item.name, is(ITEM_NAME));
|
assertThat(pageDTO.widgets.getFirst().item.name, is(ITEM_NAME));
|
||||||
assertThat(pageDTO.widgets.get(0).item.state, is("50"));
|
assertThat(pageDTO.widgets.getFirst().item.state, is("50"));
|
||||||
|
|
||||||
assertThat(pageDTO.widgets.get(1).widgetId, is(WIDGET2_ID));
|
assertThat(pageDTO.widgets.get(1).widgetId, is(WIDGET2_ID));
|
||||||
assertThat(pageDTO.widgets.get(1).label, is(ITEM_LABEL));
|
assertThat(pageDTO.widgets.get(1).label, is(ITEM_LABEL));
|
||||||
@@ -399,7 +399,7 @@ public class SitemapResourceTest extends JavaTest {
|
|||||||
|
|
||||||
private void configureItemUIRegistryWithSubpages(State state1, State state2, State state3)
|
private void configureItemUIRegistryWithSubpages(State state1, State state2, State state3)
|
||||||
throws ItemNotFoundException {
|
throws ItemNotFoundException {
|
||||||
Group group1 = (Group) widgets.get(0);
|
Group group1 = (Group) widgets.getFirst();
|
||||||
Group group2 = (Group) widgets.get(4);
|
Group group2 = (Group) widgets.get(4);
|
||||||
|
|
||||||
when(itemUIRegistryMock.getChildren(defaultSitemapMock)).thenReturn(new BasicEList<>(List.of(group1, group2)));
|
when(itemUIRegistryMock.getChildren(defaultSitemapMock)).thenReturn(new BasicEList<>(List.of(group1, group2)));
|
||||||
@@ -441,7 +441,7 @@ public class SitemapResourceTest extends JavaTest {
|
|||||||
|
|
||||||
private void configureWidgetStatesPage1(State state1, State state2) {
|
private void configureWidgetStatesPage1(State state1, State state2) {
|
||||||
EList<Widget> mainpageWidgets = new BasicEList<>(widgets.subList(1, 4));
|
EList<Widget> mainpageWidgets = new BasicEList<>(widgets.subList(1, 4));
|
||||||
Widget w1 = mainpageWidgets.get(0);
|
Widget w1 = mainpageWidgets.getFirst();
|
||||||
configureItemUIRegistryForWidget(w1, WIDGET1_ID, WIDGET1_ICON, WIDGET1_LABEL, WidgetLabelSource.SITEMAP_WIDGET,
|
configureItemUIRegistryForWidget(w1, WIDGET1_ID, WIDGET1_ICON, WIDGET1_LABEL, WidgetLabelSource.SITEMAP_WIDGET,
|
||||||
true, "GREEN", "BLUE", "ORANGE", state1);
|
true, "GREEN", "BLUE", "ORANGE", state1);
|
||||||
|
|
||||||
|
|||||||
+15
-15
@@ -62,9 +62,9 @@ public class SseUtilTest {
|
|||||||
List<String> regexes = SseUtil
|
List<String> regexes = SseUtil
|
||||||
.convertToRegex("openhab/*/test/test/test/test, openhab/test/*/test/test/test, openhab/*,qivicon/*");
|
.convertToRegex("openhab/*/test/test/test/test, openhab/test/*/test/test/test, openhab/*,qivicon/*");
|
||||||
|
|
||||||
assertThat("openhab/test/test/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/test/test/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/asdf/test/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/asdf/test/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/asdf/ASDF/test/test/test".matches(regexes.get(0)), is(false));
|
assertThat("openhab/asdf/ASDF/test/test/test".matches(regexes.getFirst()), is(false));
|
||||||
|
|
||||||
assertThat("openhab/test/test/test/test/test".matches(regexes.get(1)), is(true));
|
assertThat("openhab/test/test/test/test/test".matches(regexes.get(1)), is(true));
|
||||||
assertThat("openhab/asdf/test/test/test/test".matches(regexes.get(1)), is(false));
|
assertThat("openhab/asdf/test/test/test/test".matches(regexes.get(1)), is(false));
|
||||||
@@ -83,9 +83,9 @@ public class SseUtilTest {
|
|||||||
public void testMoreFilterMatchers() {
|
public void testMoreFilterMatchers() {
|
||||||
List<String> regexes = SseUtil.convertToRegex(", *, openhab/items/*/added, openhab/items/*/*");
|
List<String> regexes = SseUtil.convertToRegex(", *, openhab/items/*/added, openhab/items/*/*");
|
||||||
|
|
||||||
assertThat("openhab/test/test/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/test/test/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/asdf/test/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/asdf/test/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/asdf/ASDF/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/asdf/ASDF/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
|
|
||||||
assertThat("openhab/test/test/test/test/test".matches(regexes.get(1)), is(false));
|
assertThat("openhab/test/test/test/test/test".matches(regexes.get(1)), is(false));
|
||||||
assertThat("openhab/items/anyitem/added".matches(regexes.get(1)), is(true));
|
assertThat("openhab/items/anyitem/added".matches(regexes.get(1)), is(true));
|
||||||
@@ -101,20 +101,20 @@ public class SseUtilTest {
|
|||||||
public void testEvenMoreFilterMatchers() {
|
public void testEvenMoreFilterMatchers() {
|
||||||
List<String> regexes = SseUtil.convertToRegex("");
|
List<String> regexes = SseUtil.convertToRegex("");
|
||||||
|
|
||||||
assertThat("openhab/test/test/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/test/test/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/asdf/test/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/asdf/test/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/asdf/ASDF/test/test/test".matches(regexes.get(0)), is(true));
|
assertThat("openhab/asdf/ASDF/test/test/test".matches(regexes.getFirst()), is(true));
|
||||||
|
|
||||||
regexes = SseUtil.convertToRegex("*/added");
|
regexes = SseUtil.convertToRegex("*/added");
|
||||||
assertThat("openhab/items/anyitem/added".matches(regexes.get(0)), is(true));
|
assertThat("openhab/items/anyitem/added".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/items/anyitem/removed".matches(regexes.get(0)), is(false));
|
assertThat("openhab/items/anyitem/removed".matches(regexes.getFirst()), is(false));
|
||||||
|
|
||||||
regexes = SseUtil.convertToRegex("*added");
|
regexes = SseUtil.convertToRegex("*added");
|
||||||
assertThat("openhab/items/anyitem/added".matches(regexes.get(0)), is(true));
|
assertThat("openhab/items/anyitem/added".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/items/anyitem/removed".matches(regexes.get(0)), is(false));
|
assertThat("openhab/items/anyitem/removed".matches(regexes.getFirst()), is(false));
|
||||||
|
|
||||||
regexes = SseUtil.convertToRegex("openhab/items/*/state");
|
regexes = SseUtil.convertToRegex("openhab/items/*/state");
|
||||||
assertThat("openhab/items/anyitem/state".matches(regexes.get(0)), is(true));
|
assertThat("openhab/items/anyitem/state".matches(regexes.getFirst()), is(true));
|
||||||
assertThat("openhab/items/anyitem/statechanged".matches(regexes.get(0)), is(false));
|
assertThat("openhab/items/anyitem/statechanged".matches(regexes.getFirst()), is(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -52,9 +52,9 @@ public class LocaleServiceImpl implements LocaleService {
|
|||||||
split = acceptLanguageHttpHeader.split("-");
|
split = acceptLanguageHttpHeader.split("-");
|
||||||
}
|
}
|
||||||
if (split.length == 2) {
|
if (split.length == 2) {
|
||||||
locale = new Locale(split[0], split[1]);
|
locale = Locale.of(split[0], split[1]);
|
||||||
} else {
|
} else {
|
||||||
locale = new Locale(split[0]);
|
locale = Locale.of(split[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return locale;
|
return locale;
|
||||||
|
|||||||
+1
-1
@@ -157,7 +157,7 @@ public class CorsFilter implements ContainerResponseFilter {
|
|||||||
if (values == null || values.isEmpty()) {
|
if (values == null || values.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return values.get(0);
|
return values.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -129,6 +129,6 @@ public class ProxyFilter implements ContainerRequestFilter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return values.get(0);
|
return values.getFirst();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@@ -139,7 +140,7 @@ public class JSONResponseTest {
|
|||||||
private List<BigDecimal> getRandoms() {
|
private List<BigDecimal> getRandoms() {
|
||||||
List<BigDecimal> randoms = new ArrayList<>();
|
List<BigDecimal> randoms = new ArrayList<>();
|
||||||
for (int i = 0; i < 100000; i++) {
|
for (int i = 0; i < 100000; i++) {
|
||||||
randoms.add(new BigDecimal(Math.random()));
|
randoms.add(new BigDecimal(ThreadLocalRandom.current().nextDouble()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return randoms;
|
return randoms;
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.exception;
|
package org.openhab.core.io.transport.modbus.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
import org.openhab.core.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
|
import org.openhab.core.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
|
||||||
@@ -25,6 +27,7 @@ import org.openhab.core.io.transport.modbus.endpoint.ModbusSlaveEndpoint;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusConnectionException extends ModbusTransportException {
|
public class ModbusConnectionException extends ModbusTransportException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -6171226761518661925L;
|
private static final long serialVersionUID = -6171226761518661925L;
|
||||||
private ModbusSlaveEndpoint endpoint;
|
private ModbusSlaveEndpoint endpoint;
|
||||||
|
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.exception;
|
package org.openhab.core.io.transport.modbus.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -153,6 +154,7 @@ public abstract class ModbusSlaveErrorResponseException extends ModbusTransportE
|
|||||||
public static final int GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND = KnownExceptionCode.GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND
|
public static final int GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND = KnownExceptionCode.GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND
|
||||||
.getExceptionCode();
|
.getExceptionCode();
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -1435199498550990487L;
|
private static final long serialVersionUID = -1435199498550990487L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.exception;
|
package org.openhab.core.io.transport.modbus.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,5 +25,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusSlaveIOException extends ModbusTransportException {
|
public class ModbusSlaveIOException extends ModbusTransportException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -8568199166837844463L;
|
private static final long serialVersionUID = -8568199166837844463L;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.exception;
|
package org.openhab.core.io.transport.modbus.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,5 +25,6 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusTransportException extends Exception {
|
public class ModbusTransportException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1684767401685843339L;
|
private static final long serialVersionUID = 1684767401685843339L;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.exception;
|
package org.openhab.core.io.transport.modbus.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusUnexpectedResponseFunctionCodeException extends ModbusTransportException {
|
public class ModbusUnexpectedResponseFunctionCodeException extends ModbusTransportException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1109165449703638949L;
|
private static final long serialVersionUID = 1109165449703638949L;
|
||||||
private int requestFunctionCode;
|
private int requestFunctionCode;
|
||||||
private int responseFunctionCode;
|
private int responseFunctionCode;
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.exception;
|
package org.openhab.core.io.transport.modbus.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusUnexpectedResponseSizeException extends ModbusTransportException {
|
public class ModbusUnexpectedResponseSizeException extends ModbusTransportException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 2460907938819984483L;
|
private static final long serialVersionUID = 2460907938819984483L;
|
||||||
private int requestSize;
|
private int requestSize;
|
||||||
private int responseSize;
|
private int responseSize;
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.exception;
|
package org.openhab.core.io.transport.modbus.exception;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusUnexpectedTransactionIdException extends ModbusTransportException {
|
public class ModbusUnexpectedTransactionIdException extends ModbusTransportException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -2453232634024813933L;
|
private static final long serialVersionUID = -2453232634024813933L;
|
||||||
private int requestId;
|
private int requestId;
|
||||||
private int responseId;
|
private int responseId;
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.modbus.internal;
|
package org.openhab.core.io.transport.modbus.internal;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@@ -30,6 +31,7 @@ import net.wimpi.modbus.ModbusSlaveException;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusSlaveErrorResponseExceptionImpl extends ModbusSlaveErrorResponseException {
|
public class ModbusSlaveErrorResponseExceptionImpl extends ModbusSlaveErrorResponseException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 6334580162425192133L;
|
private static final long serialVersionUID = 6334580162425192133L;
|
||||||
private int rawCode;
|
private int rawCode;
|
||||||
private Optional<KnownExceptionCode> exceptionCode;
|
private Optional<KnownExceptionCode> exceptionCode;
|
||||||
|
|||||||
+2
@@ -13,6 +13,7 @@
|
|||||||
package org.openhab.core.io.transport.modbus.internal;
|
package org.openhab.core.io.transport.modbus.internal;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
@@ -29,6 +30,7 @@ import net.wimpi.modbus.ModbusIOException;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class ModbusSlaveIOExceptionImpl extends ModbusSlaveIOException {
|
public class ModbusSlaveIOExceptionImpl extends ModbusSlaveIOException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -8910463902857643468L;
|
private static final long serialVersionUID = -8910463902857643468L;
|
||||||
private Exception error;
|
private Exception error;
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -440,7 +440,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
assertThat(response.getFunctionCode(), is(equalTo(15)));
|
assertThat(response.getFunctionCode(), is(equalTo(15)));
|
||||||
|
|
||||||
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
||||||
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().getFirst();
|
||||||
assertThat(request.getFunctionCode(), is(equalTo(15)));
|
assertThat(request.getFunctionCode(), is(equalTo(15)));
|
||||||
assertThat(((WriteMultipleCoilsRequest) request).getReference(), is(equalTo(3)));
|
assertThat(((WriteMultipleCoilsRequest) request).getReference(), is(equalTo(3)));
|
||||||
assertThat(((WriteMultipleCoilsRequest) request).getBitCount(), is(equalTo(bits.size())));
|
assertThat(((WriteMultipleCoilsRequest) request).getBitCount(), is(equalTo(bits.size())));
|
||||||
@@ -481,7 +481,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString());
|
assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString());
|
||||||
|
|
||||||
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
||||||
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().getFirst();
|
||||||
assertThat(request.getFunctionCode(), is(equalTo(15)));
|
assertThat(request.getFunctionCode(), is(equalTo(15)));
|
||||||
assertThat(((WriteMultipleCoilsRequest) request).getReference(), is(equalTo(3)));
|
assertThat(((WriteMultipleCoilsRequest) request).getReference(), is(equalTo(3)));
|
||||||
assertThat(((WriteMultipleCoilsRequest) request).getBitCount(), is(equalTo(bits.size())));
|
assertThat(((WriteMultipleCoilsRequest) request).getBitCount(), is(equalTo(bits.size())));
|
||||||
@@ -520,7 +520,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
assertThat(response.getFunctionCode(), is(equalTo(5)));
|
assertThat(response.getFunctionCode(), is(equalTo(5)));
|
||||||
|
|
||||||
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
||||||
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().getFirst();
|
||||||
assertThat(request.getFunctionCode(), is(equalTo(5)));
|
assertThat(request.getFunctionCode(), is(equalTo(5)));
|
||||||
assertThat(((WriteCoilRequest) request).getReference(), is(equalTo(3)));
|
assertThat(((WriteCoilRequest) request).getReference(), is(equalTo(3)));
|
||||||
assertThat(((WriteCoilRequest) request).getCoil(), is(equalTo(true)));
|
assertThat(((WriteCoilRequest) request).getCoil(), is(equalTo(true)));
|
||||||
@@ -558,7 +558,7 @@ public class SmokeTest extends IntegrationTestSupport {
|
|||||||
assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString());
|
assertInstanceOf(ModbusSlaveErrorResponseException.class, lastError.get(), lastError.toString());
|
||||||
|
|
||||||
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
assertThat(modbustRequestCaptor.getAllReturnValues().size(), is(equalTo(1)));
|
||||||
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().get(0);
|
ModbusRequest request = modbustRequestCaptor.getAllReturnValues().getFirst();
|
||||||
assertThat(request.getFunctionCode(), is(equalTo(5)));
|
assertThat(request.getFunctionCode(), is(equalTo(5)));
|
||||||
assertThat(((WriteCoilRequest) request).getReference(), is(equalTo(300)));
|
assertThat(((WriteCoilRequest) request).getReference(), is(equalTo(300)));
|
||||||
assertThat(((WriteCoilRequest) request).getCoil(), is(equalTo(true)));
|
assertThat(((WriteCoilRequest) request).getCoil(), is(equalTo(true)));
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.mqtt;
|
package org.openhab.core.io.transport.mqtt;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -23,6 +25,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class MqttException extends Exception {
|
public class MqttException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 301L;
|
private static final long serialVersionUID = 301L;
|
||||||
private Throwable cause;
|
private Throwable cause;
|
||||||
|
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.serial;
|
package org.openhab.core.io.transport.serial;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +24,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class PortInUseException extends Exception {
|
public class PortInUseException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -2709480420743139383L;
|
private static final long serialVersionUID = -2709480420743139383L;
|
||||||
|
|
||||||
public PortInUseException(String message, Exception cause) {
|
public PortInUseException(String message, Exception cause) {
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.transport.serial;
|
package org.openhab.core.io.transport.serial;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,6 +24,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class UnsupportedCommOperationException extends Exception {
|
public class UnsupportedCommOperationException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public UnsupportedCommOperationException() {
|
public UnsupportedCommOperationException() {
|
||||||
|
|||||||
+2
@@ -13,6 +13,7 @@
|
|||||||
package org.openhab.core.io.websocket;
|
package org.openhab.core.io.websocket;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -65,6 +66,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
@HttpWhiteboardServletPattern(CommonWebSocketServlet.SERVLET_PATH + "/*")
|
@HttpWhiteboardServletPattern(CommonWebSocketServlet.SERVLET_PATH + "/*")
|
||||||
@Component(immediate = true, service = { Servlet.class })
|
@Component(immediate = true, service = { Servlet.class })
|
||||||
public class CommonWebSocketServlet extends WebSocketServlet {
|
public class CommonWebSocketServlet extends WebSocketServlet {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final String SEC_WEBSOCKET_PROTOCOL_HEADER = "Sec-WebSocket-Protocol";
|
public static final String SEC_WEBSOCKET_PROTOCOL_HEADER = "Sec-WebSocket-Protocol";
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.io.websocket.event;
|
package org.openhab.core.io.websocket.event;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +23,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class EventProcessingException extends Exception {
|
public class EventProcessingException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public EventProcessingException(String message) {
|
public EventProcessingException(String message) {
|
||||||
|
|||||||
+1
-2
@@ -18,7 +18,6 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -283,7 +282,7 @@ public class FeatureInstaller implements ConfigurationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setOnlineRepoUrl() {
|
private void setOnlineRepoUrl() {
|
||||||
Path versionFilePath = Paths.get(OpenHAB.getUserDataFolder(), "etc", "version.properties");
|
Path versionFilePath = Path.of(OpenHAB.getUserDataFolder(), "etc", "version.properties");
|
||||||
try (BufferedReader reader = Files.newBufferedReader(versionFilePath)) {
|
try (BufferedReader reader = Files.newBufferedReader(versionFilePath)) {
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
prop.load(reader);
|
prop.load(reader);
|
||||||
|
|||||||
+2
-2
@@ -81,7 +81,7 @@ public class ModelRepositoryImpl implements ModelRepository {
|
|||||||
Resource resource = getResource(name);
|
Resource resource = getResource(name);
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
if (!resource.getContents().isEmpty()) {
|
if (!resource.getContents().isEmpty()) {
|
||||||
return resource.getContents().get(0);
|
return resource.getContents().getFirst();
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Configuration model '{}' is either empty or cannot be parsed correctly!", name);
|
logger.warn("Configuration model '{}' is either empty or cannot be parsed correctly!", name);
|
||||||
resourceSet.getResources().remove(resource);
|
resourceSet.getResources().remove(resource);
|
||||||
@@ -274,7 +274,7 @@ public class ModelRepositoryImpl implements ModelRepository {
|
|||||||
// Check for validation errors, but log them only
|
// Check for validation errors, but log them only
|
||||||
try {
|
try {
|
||||||
final org.eclipse.emf.common.util.Diagnostic diagnostic = safeEmf
|
final org.eclipse.emf.common.util.Diagnostic diagnostic = safeEmf
|
||||||
.call(() -> Diagnostician.INSTANCE.validate(resource.getContents().get(0)));
|
.call(() -> Diagnostician.INSTANCE.validate(resource.getContents().getFirst()));
|
||||||
for (org.eclipse.emf.common.util.Diagnostic d : diagnostic.getChildren()) {
|
for (org.eclipse.emf.common.util.Diagnostic d : diagnostic.getChildren()) {
|
||||||
warnings.add(d.getMessage());
|
warnings.add(d.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -29,7 +29,6 @@ import java.io.IOException;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Dictionary;
|
import java.util.Dictionary;
|
||||||
@@ -253,7 +252,7 @@ public class FolderObserverTest extends JavaTest {
|
|||||||
configProps.put(subdir, "");
|
configProps.put(subdir, "");
|
||||||
folderObserver.activate(contextMock);
|
folderObserver.activate(contextMock);
|
||||||
|
|
||||||
File file = new File(WATCHED_DIRECTORY, Paths.get(subdir, "MockFileInNoExtSubDir.txt").toString());
|
File file = new File(WATCHED_DIRECTORY, Path.of(subdir, "MockFileInNoExtSubDir.txt").toString());
|
||||||
Files.writeString(file.toPath(), INITIAL_FILE_CONTENT, StandardCharsets.UTF_8, StandardOpenOption.CREATE);
|
Files.writeString(file.toPath(), INITIAL_FILE_CONTENT, StandardCharsets.UTF_8, StandardOpenOption.CREATE);
|
||||||
waitForAssert(() -> assertThat(file.exists(), is(true)));
|
waitForAssert(() -> assertThat(file.exists(), is(true)));
|
||||||
|
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.model.item;
|
package org.openhab.core.model.item;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This exception is used by {@link BindingConfigReader} instances if parsing configurations fails
|
* This exception is used by {@link BindingConfigReader} instances if parsing configurations fails
|
||||||
*
|
*
|
||||||
@@ -19,6 +21,7 @@ package org.openhab.core.model.item;
|
|||||||
*/
|
*/
|
||||||
public class BindingConfigParseException extends Exception {
|
public class BindingConfigParseException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1434607160082879845L;
|
private static final long serialVersionUID = 1434607160082879845L;
|
||||||
|
|
||||||
public BindingConfigParseException(String msg) {
|
public BindingConfigParseException(String msg) {
|
||||||
|
|||||||
+1
-1
@@ -354,7 +354,7 @@ public class GenericItemProvider extends AbstractProvider<Item>
|
|||||||
// Single valued lists get unwrapped to just their one value for
|
// Single valued lists get unwrapped to just their one value for
|
||||||
// backwards compatibility
|
// backwards compatibility
|
||||||
if (value instanceof List listValue && listValue.size() == 1) {
|
if (value instanceof List listValue && listValue.size() == 1) {
|
||||||
value = listValue.get(0);
|
value = listValue.getFirst();
|
||||||
}
|
}
|
||||||
configuration.put(p.getKey(), value);
|
configuration.put(p.getKey(), value);
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-3
@@ -16,7 +16,6 @@ import java.io.File;
|
|||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
|
||||||
|
|
||||||
import org.eclipse.emf.common.util.URI;
|
import org.eclipse.emf.common.util.URI;
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
@@ -50,7 +49,7 @@ public class MappingUriExtensions extends UriExtensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String calcServerLocation(String configFolder) {
|
protected String calcServerLocation(String configFolder) {
|
||||||
Path configPath = Paths.get(configFolder);
|
Path configPath = Path.of(configFolder);
|
||||||
Path absoluteConfigPath = configPath.toAbsolutePath();
|
Path absoluteConfigPath = configPath.toAbsolutePath();
|
||||||
java.net.URI configPathURI = absoluteConfigPath.toUri();
|
java.net.URI configPathURI = absoluteConfigPath.toUri();
|
||||||
return removeTrailingSlash(configPathURI.toString());
|
return removeTrailingSlash(configPathURI.toString());
|
||||||
@@ -184,6 +183,6 @@ public class MappingUriExtensions extends UriExtensions {
|
|||||||
// output new: file:///d/
|
// output new: file:///d/
|
||||||
|
|
||||||
// We use this method now to keep the old behavior.
|
// We use this method now to keep the old behavior.
|
||||||
return Paths.get(uri).toUri().toString();
|
return Path.of(uri).toUri().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.model.rule.scoping;
|
package org.openhab.core.model.rule.scoping;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.eclipse.xtext.common.types.access.impl.Primitives;
|
import org.eclipse.xtext.common.types.access.impl.Primitives;
|
||||||
@@ -36,6 +37,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
@Component
|
@Component
|
||||||
public class RulesClassCache extends HashMap<String, Class<?>> {
|
public class RulesClassCache extends HashMap<String, Class<?>> {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static RulesClassCache instance;
|
private static RulesClassCache instance;
|
||||||
|
|||||||
+5
-3
@@ -16,6 +16,7 @@ import java.io.IOException;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
import org.eclipse.emf.common.util.EList;
|
import org.eclipse.emf.common.util.EList;
|
||||||
import org.eclipse.emf.common.util.URI;
|
import org.eclipse.emf.common.util.URI;
|
||||||
@@ -143,9 +144,9 @@ public class ScriptEngineImpl implements ScriptEngine, ModelParser {
|
|||||||
|
|
||||||
EList<EObject> contents = resource.getContents();
|
EList<EObject> contents = resource.getContents();
|
||||||
if (!contents.isEmpty()) {
|
if (!contents.isEmpty()) {
|
||||||
Iterable<Issue> validationErrors = getValidationErrors(contents.get(0));
|
Iterable<Issue> validationErrors = getValidationErrors(contents.getFirst());
|
||||||
if (!validationErrors.iterator().hasNext()) {
|
if (!validationErrors.iterator().hasNext()) {
|
||||||
return (XExpression) contents.get(0);
|
return (XExpression) contents.getFirst();
|
||||||
} else {
|
} else {
|
||||||
deleteResource(resource);
|
deleteResource(resource);
|
||||||
throw new ScriptParsingException("Failed to parse expression (due to managed ValidationError/s)",
|
throw new ScriptParsingException("Failed to parse expression (due to managed ValidationError/s)",
|
||||||
@@ -162,7 +163,8 @@ public class ScriptEngineImpl implements ScriptEngine, ModelParser {
|
|||||||
final int MAX_TRIES = 1000;
|
final int MAX_TRIES = 1000;
|
||||||
for (int i = 0; i < MAX_TRIES; i++) {
|
for (int i = 0; i < MAX_TRIES; i++) {
|
||||||
// NOTE: The "filename extension" (".script") must match the file.extensions in the *.mwe2
|
// NOTE: The "filename extension" (".script") must match the file.extensions in the *.mwe2
|
||||||
URI syntheticUri = URI.createURI(name + Math.random() + "." + Script.SCRIPT_FILEEXT);
|
URI syntheticUri = URI
|
||||||
|
.createURI(name + ThreadLocalRandom.current().nextDouble() + "." + Script.SCRIPT_FILEEXT);
|
||||||
if (resourceSet.getResource(syntheticUri, false) == null) {
|
if (resourceSet.getResource(syntheticUri, false) == null) {
|
||||||
return syntheticUri;
|
return syntheticUri;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.model.script.actions;
|
package org.openhab.core.model.script.actions;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
|
||||||
@@ -24,6 +26,7 @@ import org.eclipse.jdt.annotation.Nullable;
|
|||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TransformationException extends Exception {
|
public class TransformationException extends Exception {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -1L;
|
private static final long serialVersionUID = -1L;
|
||||||
|
|
||||||
public TransformationException(@Nullable String message) {
|
public TransformationException(@Nullable String message) {
|
||||||
|
|||||||
+4
-4
@@ -325,9 +325,9 @@ public class Voice {
|
|||||||
String[] split = locale.split("-");
|
String[] split = locale.split("-");
|
||||||
Locale loc;
|
Locale loc;
|
||||||
if (split.length == 2) {
|
if (split.length == 2) {
|
||||||
loc = new Locale(split[0], split[1]);
|
loc = Locale.of(split[0], split[1]);
|
||||||
} else {
|
} else {
|
||||||
loc = new Locale(split[0]);
|
loc = Locale.of(split[0]);
|
||||||
}
|
}
|
||||||
dialogContextBuilder.withLocale(loc);
|
dialogContextBuilder.withLocale(loc);
|
||||||
}
|
}
|
||||||
@@ -453,9 +453,9 @@ public class Voice {
|
|||||||
Locale loc;
|
Locale loc;
|
||||||
String[] split = locale.split("-");
|
String[] split = locale.split("-");
|
||||||
if (split.length == 2) {
|
if (split.length == 2) {
|
||||||
loc = new Locale(split[0], split[1]);
|
loc = Locale.of(split[0], split[1]);
|
||||||
} else {
|
} else {
|
||||||
loc = new Locale(split[0]);
|
loc = Locale.of(split[0]);
|
||||||
}
|
}
|
||||||
dialogContextBuilder.withLocale(loc);
|
dialogContextBuilder.withLocale(loc);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.model.script.engine;
|
package org.openhab.core.model.script.engine;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -22,6 +23,7 @@ import java.util.List;
|
|||||||
* @author Kai Kreuzer - Initial contribution
|
* @author Kai Kreuzer - Initial contribution
|
||||||
*/
|
*/
|
||||||
public abstract class ScriptException extends Exception {
|
public abstract class ScriptException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -4155948282895039148L;
|
private static final long serialVersionUID = -4155948282895039148L;
|
||||||
|
|
||||||
private String scriptText;
|
private String scriptText;
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.model.script.engine;
|
package org.openhab.core.model.script.engine;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception that is thrown on errors during script execution.
|
* Exception that is thrown on errors during script execution.
|
||||||
*
|
*
|
||||||
@@ -19,6 +21,7 @@ package org.openhab.core.model.script.engine;
|
|||||||
*/
|
*/
|
||||||
public class ScriptExecutionException extends ScriptException {
|
public class ScriptExecutionException extends ScriptException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 149490362444673405L;
|
private static final long serialVersionUID = 149490362444673405L;
|
||||||
|
|
||||||
public ScriptExecutionException(final String message, final int line, final int column, final int length) {
|
public ScriptExecutionException(final String message, final int line, final int column, final int length) {
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.model.script.engine;
|
package org.openhab.core.model.script.engine;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
|
import org.eclipse.emf.ecore.resource.Resource.Diagnostic;
|
||||||
@@ -26,6 +27,7 @@ import org.eclipse.xtext.validation.Issue;
|
|||||||
*/
|
*/
|
||||||
public class ScriptParsingException extends ScriptException {
|
public class ScriptParsingException extends ScriptException {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -3784970293118871807L;
|
private static final long serialVersionUID = -3784970293118871807L;
|
||||||
|
|
||||||
public ScriptParsingException(String message, String scriptAsString) {
|
public ScriptParsingException(String message, String scriptAsString) {
|
||||||
|
|||||||
+2
-2
@@ -30,8 +30,8 @@ public class ThingSyntacticSequencerExtension extends ThingSyntacticSequencer {
|
|||||||
@Override
|
@Override
|
||||||
protected void emit_ModelThing_ThingKeyword_0_q(EObject semanticObject, ISynNavigable transition,
|
protected void emit_ModelThing_ThingKeyword_0_q(EObject semanticObject, ISynNavigable transition,
|
||||||
List<INode> nodes) {
|
List<INode> nodes) {
|
||||||
ILeafNode node = nodes != null && nodes.size() == 1 && nodes.get(0) instanceof ILeafNode
|
ILeafNode node = nodes != null && nodes.size() == 1 && nodes.getFirst() instanceof ILeafNode
|
||||||
? (ILeafNode) nodes.get(0)
|
? (ILeafNode) nodes.getFirst()
|
||||||
: null;
|
: null;
|
||||||
Keyword keyword = grammarAccess.getModelThingAccess().getThingKeyword_0();
|
Keyword keyword = grammarAccess.getModelThingAccess().getThingKeyword_0();
|
||||||
acceptUnassignedKeyword(keyword, keyword.getValue(), node);
|
acceptUnassignedKeyword(keyword, keyword.getValue(), node);
|
||||||
|
|||||||
+3
-3
@@ -157,7 +157,7 @@ public class YamlModelRepositoryImplTest {
|
|||||||
assertThat(arguments, hasSize(4));
|
assertThat(arguments, hasSize(4));
|
||||||
|
|
||||||
// added originally
|
// added originally
|
||||||
assertThat(arguments.get(0), containsInAnyOrder(new FirstTypeDTO("First", "First original"),
|
assertThat(arguments.getFirst(), containsInAnyOrder(new FirstTypeDTO("First", "First original"),
|
||||||
new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original")));
|
new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original")));
|
||||||
// added by update
|
// added by update
|
||||||
assertThat(arguments.get(1), contains(new FirstTypeDTO("Fourth", "Fourth original")));
|
assertThat(arguments.get(1), contains(new FirstTypeDTO("Fourth", "Fourth original")));
|
||||||
@@ -185,10 +185,10 @@ public class YamlModelRepositoryImplTest {
|
|||||||
assertThat(arguments, hasSize(2));
|
assertThat(arguments, hasSize(2));
|
||||||
|
|
||||||
// all are added
|
// all are added
|
||||||
assertThat(arguments.get(0), containsInAnyOrder(new FirstTypeDTO("First", "First original"),
|
assertThat(arguments.getFirst(), containsInAnyOrder(new FirstTypeDTO("First", "First original"),
|
||||||
new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original")));
|
new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original")));
|
||||||
// all are removed
|
// all are removed
|
||||||
assertThat(arguments.get(0), containsInAnyOrder(new FirstTypeDTO("First", "First original"),
|
assertThat(arguments.getFirst(), containsInAnyOrder(new FirstTypeDTO("First", "First original"),
|
||||||
new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original")));
|
new FirstTypeDTO("Second", "Second original"), new FirstTypeDTO("Third", "Third original")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-4
@@ -2681,20 +2681,19 @@ public class PersistenceExtensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add HistoricItem at begin
|
// add HistoricItem at begin
|
||||||
if (betweenItemsList.isEmpty() || !betweenItemsList.get(0).getTimestamp().equals(begin)) {
|
if (betweenItemsList.isEmpty() || !betweenItemsList.getFirst().getTimestamp().equals(begin)) {
|
||||||
HistoricItem first = beginTime.equals(now) ? historicItemOrCurrentState(item, null)
|
HistoricItem first = beginTime.equals(now) ? historicItemOrCurrentState(item, null)
|
||||||
: internalPersistedState(item, beginTime, serviceId);
|
: internalPersistedState(item, beginTime, serviceId);
|
||||||
if (first != null) {
|
if (first != null) {
|
||||||
first = new RetimedHistoricItem(first, beginTime);
|
first = new RetimedHistoricItem(first, beginTime);
|
||||||
}
|
}
|
||||||
if (first != null) {
|
if (first != null) {
|
||||||
betweenItemsList.add(0, first);
|
betweenItemsList.addFirst(first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add HistoricItem at end
|
// add HistoricItem at end
|
||||||
if (betweenItemsList.isEmpty()
|
if (betweenItemsList.isEmpty() || !betweenItemsList.getLast().getTimestamp().equals(end)) {
|
||||||
|| !betweenItemsList.get(betweenItemsList.size() - 1).getTimestamp().equals(end)) {
|
|
||||||
HistoricItem last = endTime.equals(now) ? historicItemOrCurrentState(item, null)
|
HistoricItem last = endTime.equals(now) ? historicItemOrCurrentState(item, null)
|
||||||
: internalPersistedState(item, endTime, serviceId);
|
: internalPersistedState(item, endTime, serviceId);
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
|
|||||||
+4
-4
@@ -415,7 +415,7 @@ public class PersistenceManagerTest {
|
|||||||
assertThat(filterCriteria.getEndDate(), is(time4.atZone(ZoneId.systemDefault())));
|
assertThat(filterCriteria.getEndDate(), is(time4.atZone(ZoneId.systemDefault())));
|
||||||
|
|
||||||
// verify restore future is not cancelled
|
// verify restore future is not cancelled
|
||||||
verify(futures.get(0), never()).cancel(anyBoolean());
|
verify(futures.getFirst(), never()).cancel(anyBoolean());
|
||||||
|
|
||||||
// verify new values are stored
|
// verify new values are stored
|
||||||
inOrder.verify(service, times(2)).store(any(Item.class), any(ZonedDateTime.class), any(State.class));
|
inOrder.verify(service, times(2)).store(any(Item.class), any(ZonedDateTime.class), any(State.class));
|
||||||
@@ -430,7 +430,7 @@ public class PersistenceManagerTest {
|
|||||||
manager.timeSeriesUpdated(TEST_ITEM, timeSeries3);
|
manager.timeSeriesUpdated(TEST_ITEM, timeSeries3);
|
||||||
// verify old restore future is cancelled
|
// verify old restore future is cancelled
|
||||||
inOrder.verify(service, times(1)).store(any(Item.class), any(ZonedDateTime.class), any(State.class));
|
inOrder.verify(service, times(1)).store(any(Item.class), any(ZonedDateTime.class), any(State.class));
|
||||||
verify(futures.get(0)).cancel(true);
|
verify(futures.getFirst()).cancel(true);
|
||||||
|
|
||||||
// verify new restore future is properly created
|
// verify new restore future is properly created
|
||||||
inOrder.verify(schedulerMock).at(any(SchedulerRunnable.class), eq(time5));
|
inOrder.verify(schedulerMock).at(any(SchedulerRunnable.class), eq(time5));
|
||||||
@@ -452,8 +452,8 @@ public class PersistenceManagerTest {
|
|||||||
verify(readyServiceMock, timeout(1000)).markReady(any());
|
verify(readyServiceMock, timeout(1000)).markReady(any());
|
||||||
List<SchedulerRunnable> runnables = runnableCaptor.getAllValues();
|
List<SchedulerRunnable> runnables = runnableCaptor.getAllValues();
|
||||||
assertThat(runnables.size(), is(2));
|
assertThat(runnables.size(), is(2));
|
||||||
runnables.get(0).run();
|
runnables.getFirst().run();
|
||||||
runnables.get(0).run();
|
runnables.getFirst().run();
|
||||||
runnables.get(1).run();
|
runnables.get(1).run();
|
||||||
runnables.get(1).run();
|
runnables.get(1).run();
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -164,7 +164,7 @@ public class SemanticsMetadataProvider extends AbstractProvider<Metadata>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Entry<List<Class<? extends Tag>>, String> relation : propertyRelations.entrySet()) {
|
for (Entry<List<Class<? extends Tag>>, String> relation : propertyRelations.entrySet()) {
|
||||||
Class<? extends Tag> entityClass = relation.getKey().get(0);
|
Class<? extends Tag> entityClass = relation.getKey().getFirst();
|
||||||
if (entityClass.isAssignableFrom(type)) {
|
if (entityClass.isAssignableFrom(type)) {
|
||||||
Class<? extends Property> p = SemanticTags.getProperty(item);
|
Class<? extends Property> p = SemanticTags.getProperty(item);
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
@@ -211,7 +211,7 @@ public class SemanticsMetadataProvider extends AbstractProvider<Metadata>
|
|||||||
}
|
}
|
||||||
for (Entry<List<Class<? extends Tag>>, String> relation : parentRelations.entrySet()) {
|
for (Entry<List<Class<? extends Tag>>, String> relation : parentRelations.entrySet()) {
|
||||||
List<Class<? extends Tag>> relClasses = relation.getKey();
|
List<Class<? extends Tag>> relClasses = relation.getKey();
|
||||||
Class<? extends Tag> entityClass = relClasses.get(0);
|
Class<? extends Tag> entityClass = relClasses.getFirst();
|
||||||
Class<? extends Tag> parentClass = relClasses.get(1);
|
Class<? extends Tag> parentClass = relClasses.get(1);
|
||||||
// process relations of locations
|
// process relations of locations
|
||||||
if (entityClass.isAssignableFrom(type)) {
|
if (entityClass.isAssignableFrom(type)) {
|
||||||
@@ -236,7 +236,7 @@ public class SemanticsMetadataProvider extends AbstractProvider<Metadata>
|
|||||||
}
|
}
|
||||||
for (Entry<List<Class<? extends Tag>>, String> relation : memberRelations.entrySet()) {
|
for (Entry<List<Class<? extends Tag>>, String> relation : memberRelations.entrySet()) {
|
||||||
List<Class<? extends Tag>> relClasses = relation.getKey();
|
List<Class<? extends Tag>> relClasses = relation.getKey();
|
||||||
Class<? extends Tag> entityClass = relClasses.get(0);
|
Class<? extends Tag> entityClass = relClasses.getFirst();
|
||||||
Class<? extends Tag> parentClass = relClasses.get(1);
|
Class<? extends Tag> parentClass = relClasses.get(1);
|
||||||
// process relations of locations
|
// process relations of locations
|
||||||
if (entityClass.isAssignableFrom(type)) {
|
if (entityClass.isAssignableFrom(type)) {
|
||||||
|
|||||||
+9
-9
@@ -160,7 +160,7 @@ public class SemanticsServiceImplTest {
|
|||||||
public void testGetLabelAndSynonyms() {
|
public void testGetLabelAndSynonyms() {
|
||||||
List<String> result = service.getLabelAndSynonyms(bathroomTagClass, Locale.ENGLISH);
|
List<String> result = service.getLabelAndSynonyms(bathroomTagClass, Locale.ENGLISH);
|
||||||
assertEquals(6, result.size());
|
assertEquals(6, result.size());
|
||||||
assertEquals("bathroom", result.get(0));
|
assertEquals("bathroom", result.getFirst());
|
||||||
assertEquals("bathrooms", result.get(1));
|
assertEquals("bathrooms", result.get(1));
|
||||||
assertEquals("bath", result.get(2));
|
assertEquals("bath", result.get(2));
|
||||||
assertEquals("baths", result.get(3));
|
assertEquals("baths", result.get(3));
|
||||||
@@ -169,14 +169,14 @@ public class SemanticsServiceImplTest {
|
|||||||
|
|
||||||
result = service.getLabelAndSynonyms(cleaningRobotTagClass, Locale.FRENCH);
|
result = service.getLabelAndSynonyms(cleaningRobotTagClass, Locale.FRENCH);
|
||||||
assertEquals(4, result.size());
|
assertEquals(4, result.size());
|
||||||
assertEquals("robot de nettoyage", result.get(0));
|
assertEquals("robot de nettoyage", result.getFirst());
|
||||||
assertEquals("robos de nettoyage", result.get(1));
|
assertEquals("robos de nettoyage", result.get(1));
|
||||||
assertEquals("robot aspirateur", result.get(2));
|
assertEquals("robot aspirateur", result.get(2));
|
||||||
assertEquals("robots aspirateur", result.get(3));
|
assertEquals("robots aspirateur", result.get(3));
|
||||||
|
|
||||||
result = service.getLabelAndSynonyms(userLocationTagClass, Locale.ENGLISH);
|
result = service.getLabelAndSynonyms(userLocationTagClass, Locale.ENGLISH);
|
||||||
assertEquals(4, result.size());
|
assertEquals(4, result.size());
|
||||||
assertEquals("custom label", result.get(0));
|
assertEquals("custom label", result.getFirst());
|
||||||
assertEquals("synonym1", result.get(1));
|
assertEquals("synonym1", result.get(1));
|
||||||
assertEquals("synonym2", result.get(2));
|
assertEquals("synonym2", result.get(2));
|
||||||
assertEquals("synonym with space", result.get(3));
|
assertEquals("synonym with space", result.get(3));
|
||||||
@@ -204,28 +204,28 @@ public class SemanticsServiceImplTest {
|
|||||||
public void testGetByLabelOrSynonym() {
|
public void testGetByLabelOrSynonym() {
|
||||||
List<Class<? extends Tag>> tags = service.getByLabelOrSynonym("BATHROOM", Locale.ENGLISH);
|
List<Class<? extends Tag>> tags = service.getByLabelOrSynonym("BATHROOM", Locale.ENGLISH);
|
||||||
assertEquals(1, tags.size());
|
assertEquals(1, tags.size());
|
||||||
assertEquals(bathroomTagClass, tags.get(0));
|
assertEquals(bathroomTagClass, tags.getFirst());
|
||||||
tags = service.getByLabelOrSynonym("POWDER Rooms", Locale.ENGLISH);
|
tags = service.getByLabelOrSynonym("POWDER Rooms", Locale.ENGLISH);
|
||||||
assertEquals(1, tags.size());
|
assertEquals(1, tags.size());
|
||||||
assertEquals(bathroomTagClass, tags.get(0));
|
assertEquals(bathroomTagClass, tags.getFirst());
|
||||||
tags = service.getByLabelOrSynonym("other bath", Locale.ENGLISH);
|
tags = service.getByLabelOrSynonym("other bath", Locale.ENGLISH);
|
||||||
assertTrue(tags.isEmpty());
|
assertTrue(tags.isEmpty());
|
||||||
|
|
||||||
tags = service.getByLabelOrSynonym("ROBOT de nettoyage", Locale.FRENCH);
|
tags = service.getByLabelOrSynonym("ROBOT de nettoyage", Locale.FRENCH);
|
||||||
assertEquals(1, tags.size());
|
assertEquals(1, tags.size());
|
||||||
assertEquals(cleaningRobotTagClass, tags.get(0));
|
assertEquals(cleaningRobotTagClass, tags.getFirst());
|
||||||
tags = service.getByLabelOrSynonym("ROBOTS aspirateur", Locale.FRENCH);
|
tags = service.getByLabelOrSynonym("ROBOTS aspirateur", Locale.FRENCH);
|
||||||
assertEquals(1, tags.size());
|
assertEquals(1, tags.size());
|
||||||
assertEquals(cleaningRobotTagClass, tags.get(0));
|
assertEquals(cleaningRobotTagClass, tags.getFirst());
|
||||||
tags = service.getByLabelOrSynonym("Robot cuiseur", Locale.FRENCH);
|
tags = service.getByLabelOrSynonym("Robot cuiseur", Locale.FRENCH);
|
||||||
assertTrue(tags.isEmpty());
|
assertTrue(tags.isEmpty());
|
||||||
|
|
||||||
tags = service.getByLabelOrSynonym("CUSTOM label", Locale.ENGLISH);
|
tags = service.getByLabelOrSynonym("CUSTOM label", Locale.ENGLISH);
|
||||||
assertEquals(1, tags.size());
|
assertEquals(1, tags.size());
|
||||||
assertEquals(userLocationTagClass, tags.get(0));
|
assertEquals(userLocationTagClass, tags.getFirst());
|
||||||
tags = service.getByLabelOrSynonym("Synonym with space", Locale.ENGLISH);
|
tags = service.getByLabelOrSynonym("Synonym with space", Locale.ENGLISH);
|
||||||
assertEquals(1, tags.size());
|
assertEquals(1, tags.size());
|
||||||
assertEquals(userLocationTagClass, tags.get(0));
|
assertEquals(userLocationTagClass, tags.getFirst());
|
||||||
tags = service.getByLabelOrSynonym("wrong label", Locale.ENGLISH);
|
tags = service.getByLabelOrSynonym("wrong label", Locale.ENGLISH);
|
||||||
assertTrue(tags.isEmpty());
|
assertTrue(tags.isEmpty());
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -12,6 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.openhab.core.storage.json.internal.migration;
|
package org.openhab.core.storage.json.internal.migration;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,6 +23,7 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
|
|||||||
*/
|
*/
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class TypeMigrationException extends Exception {
|
public class TypeMigrationException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public TypeMigrationException(String message) {
|
public TypeMigrationException(String message) {
|
||||||
|
|||||||
+2
-2
@@ -132,10 +132,10 @@ public class JsonStorageTest extends JavaTest {
|
|||||||
assertEquals(0, ((BigDecimal) dummy.configuration.get("testInt")).scale());
|
assertEquals(0, ((BigDecimal) dummy.configuration.get("testInt")).scale());
|
||||||
assertEquals(0, ((BigDecimal) dummy.configuration.get("testLong")).scale());
|
assertEquals(0, ((BigDecimal) dummy.configuration.get("testLong")).scale());
|
||||||
assertEquals(0, ((BigDecimal) dummy.configuration.get("testBigDecimal")).scale());
|
assertEquals(0, ((BigDecimal) dummy.configuration.get("testBigDecimal")).scale());
|
||||||
assertEquals(0, ((List<BigDecimal>) dummy.configuration.get("multiInt")).get(0).scale());
|
assertEquals(0, ((List<BigDecimal>) dummy.configuration.get("multiInt")).getFirst().scale());
|
||||||
assertEquals(0, ((List<BigDecimal>) dummy.configuration.get("multiInt")).get(1).scale());
|
assertEquals(0, ((List<BigDecimal>) dummy.configuration.get("multiInt")).get(1).scale());
|
||||||
assertEquals(0, ((List<BigDecimal>) dummy.configuration.get("multiInt")).get(2).scale());
|
assertEquals(0, ((List<BigDecimal>) dummy.configuration.get("multiInt")).get(2).scale());
|
||||||
assertEquals(0, ((BigDecimal) dummy.channels.get(0).configuration.get("testChildLong")).scale());
|
assertEquals(0, ((BigDecimal) dummy.channels.getFirst().configuration.get("testChildLong")).scale());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user