[TR064] Fix SAT warnings (#13873)

* Fix SAT warnings
* Fix markdown
* Properly annotate PhonebookProfileTest

Also-by: Wouter Born <github@maindrain.net>
Signed-off-by: Leo Siepel <leosiepel@gmail.com>
This commit is contained in:
lsiepel 2022-12-08 22:44:44 +01:00 committed by GitHub
parent 02398b14a3
commit 3e66cd1b33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 9 deletions

View File

@ -7,10 +7,12 @@ Even though textual configuration is possible, it is strongly recommended to use
## Supported Things ## Supported Things
Two Bridge things are supported: Two Bridge things are supported:
- `generic`: the internet gateway device itself (generic device) - `generic`: the internet gateway device itself (generic device)
- `fritzbox`: similar to `generic` with extensions for AVM FritzBox devices. - `fritzbox`: similar to `generic` with extensions for AVM FritzBox devices.
Two kind of Things are supported: Two kind of Things are supported:
- `subDevice`: a sub-device of the Bridge thing (e.g. a WAN interface) - `subDevice`: a sub-device of the Bridge thing (e.g. a WAN interface)
- `subDeviceLan`: a special type of sub-device that supports MAC-detection - `subDeviceLan`: a special type of sub-device that supports MAC-detection
@ -198,6 +200,7 @@ Example (use all phonebooks, match 5 digits from right):
val tr064Actions = getActions("tr064","tr064:fritzbox:2a28aee1ee") val tr064Actions = getActions("tr064","tr064:fritzbox:2a28aee1ee")
val result = tr064Actions.phonebookLookup("49157712341234", 5) val result = tr064Actions.phonebookLookup("49157712341234", 5)
``` ```
## A note on textual configuration ## A note on textual configuration
Textual configuration through a `.things` file is possible but, at present, strongly discouraged because it is significantly more error-prone Textual configuration through a `.things` file is possible but, at present, strongly discouraged because it is significantly more error-prone
@ -208,6 +211,7 @@ an automatic scan through the user interface first in order to extract the requi
needed subdevices). needed subdevices).
The definition of the bridge and of the subdevices things is the following The definition of the bridge and of the subdevices things is the following
``` ```
Bridge tr064:fritzbox:rootuid "Root label" @ "location" [ host="192.168.1.1", user="user", password="passwd", Bridge tr064:fritzbox:rootuid "Root label" @ "location" [ host="192.168.1.1", user="user", password="passwd",
phonebookInterval="0"]{ phonebookInterval="0"]{

View File

@ -63,7 +63,7 @@ public class Tr064PhonebookImpl implements Phonebook {
// in case there are multiple phone entries with same number -> name mapping, i.e. in phonebooks exported from // in case there are multiple phone entries with same number -> name mapping, i.e. in phonebooks exported from
// mobiles containing multiple accounts like: local, cloudprovider1, messenger1, messenger2,... // mobiles containing multiple accounts like: local, cloudprovider1, messenger1, messenger2,...
private String mergeSameContactNames(String nameA, String nameB) { private String mergeSameContactNames(String nameA, String nameB) {
if (nameA != null && nameA.equals(nameB)) { if (nameA.equals(nameB)) {
return nameA; return nameA;
} }
throw new IllegalStateException( throw new IllegalStateException(

View File

@ -12,11 +12,15 @@
*/ */
package org.openhab.binding.tr064.internal.soap; package org.openhab.binding.tr064.internal.soap;
import org.eclipse.jdt.annotation.NonNullByDefault;
/** /**
* The {@link CallListType} is used for post processing the retrieved call list * The {@link CallListType} is used for post processing the retrieved call list
* *
* @author Jan N. Klug - Initial contribution * @author Jan N. Klug - Initial contribution
*/ */
@NonNullByDefault
public enum CallListType { public enum CallListType {
MISSED_COUNT("2"), MISSED_COUNT("2"),
INBOUND_COUNT("1"), INBOUND_COUNT("1"),

View File

@ -103,11 +103,11 @@ public class SOAPValueConverter {
default: default:
} }
} else if (command instanceof StringType) { } else if (command instanceof StringType) {
if (dataType.equals("string")) { if ("string".equals(dataType)) {
return Optional.of(command.toString()); return Optional.of(command.toString());
} }
} else if (command instanceof OnOffType) { } else if (command instanceof OnOffType) {
if (dataType.equals("boolean")) { if ("boolean".equals(dataType)) {
return Optional.of(OnOffType.ON.equals(command) ? "1" : "0"); return Optional.of(OnOffType.ON.equals(command) ? "1" : "0");
} }
} }
@ -212,7 +212,7 @@ public class SOAPValueConverter {
private State processDecaDecibel(State state, Tr064ChannelConfig channelConfig) { private State processDecaDecibel(State state, Tr064ChannelConfig channelConfig) {
Float value = state.as(DecimalType.class).floatValue() / 10; Float value = state.as(DecimalType.class).floatValue() / 10;
return new QuantityType(value, Units.DECIBEL); return new QuantityType<>(value, Units.DECIBEL);
} }
/** /**

View File

@ -51,6 +51,7 @@ import org.openhab.core.util.UIDUtils;
*/ */
@ExtendWith(MockitoExtension.class) @ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT) @MockitoSettings(strictness = Strictness.LENIENT)
@NonNullByDefault
class PhonebookProfileTest { class PhonebookProfileTest {
private static final String INTERNAL_PHONE_NUMBER = "999"; private static final String INTERNAL_PHONE_NUMBER = "999";
@ -60,7 +61,6 @@ class PhonebookProfileTest {
private static final ThingUID THING_UID = new ThingUID(BINDING_ID, THING_TYPE_FRITZBOX.getId(), "test"); private static final ThingUID THING_UID = new ThingUID(BINDING_ID, THING_TYPE_FRITZBOX.getId(), "test");
private static final String MY_PHONEBOOK = UIDUtils.encode(THING_UID.getAsString()) + ":MyPhonebook"; private static final String MY_PHONEBOOK = UIDUtils.encode(THING_UID.getAsString()) + ":MyPhonebook";
@NonNullByDefault
public static class ParameterSet { public static class ParameterSet {
public final State state; public final State state;
public final State resultingState; public final State resultingState;
@ -101,11 +101,10 @@ class PhonebookProfileTest {
}); });
} }
private @Mock ProfileCallback mockCallback; private @Mock @NonNullByDefault({}) ProfileCallback mockCallback;
private @Mock ProfileContext mockContext; private @Mock @NonNullByDefault({}) ProfileContext mockContext;
private @Mock PhonebookProvider mockPhonebookProvider; private @Mock @NonNullByDefault({}) PhonebookProvider mockPhonebookProvider;
@NonNullByDefault
private final Phonebook phonebook = new Phonebook() { private final Phonebook phonebook = new Phonebook() {
@Override @Override
public Optional<String> lookupNumber(String number, int matchCount) { public Optional<String> lookupNumber(String number, int matchCount) {