[TR064] Fix SAT warnings ()

* 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
bundles/org.openhab.binding.tr064
README.md
src
main/java/org/openhab/binding/tr064/internal
test/java/org/openhab/binding/tr064/internal/phonebook

@ -7,10 +7,12 @@ Even though textual configuration is possible, it is strongly recommended to use
## Supported Things
Two Bridge things are supported:
- `generic`: the internet gateway device itself (generic device)
- `fritzbox`: similar to `generic` with extensions for AVM FritzBox devices.
Two kind of Things are supported:
- `subDevice`: a sub-device of the Bridge thing (e.g. a WAN interface)
- `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 result = tr064Actions.phonebookLookup("49157712341234", 5)
```
## 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
@ -208,6 +211,7 @@ an automatic scan through the user interface first in order to extract the requi
needed subdevices).
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",
phonebookInterval="0"]{

@ -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
// mobiles containing multiple accounts like: local, cloudprovider1, messenger1, messenger2,...
private String mergeSameContactNames(String nameA, String nameB) {
if (nameA != null && nameA.equals(nameB)) {
if (nameA.equals(nameB)) {
return nameA;
}
throw new IllegalStateException(

@ -12,11 +12,15 @@
*/
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
*
* @author Jan N. Klug - Initial contribution
*/
@NonNullByDefault
public enum CallListType {
MISSED_COUNT("2"),
INBOUND_COUNT("1"),

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

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