[shelly] Add unit test coverage (#18794)

* Add coverage for BLU things
* Use existing ThingTypeUID constants
* Remove misplaced annotation

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
pull/18173/merge
Jacob Laursen 2025-06-13 23:01:39 +02:00 committed by GitHub
parent 4a9af7110c
commit 9843c4ad8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 13 deletions

View File

@ -48,8 +48,6 @@ import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.reactivex.annotations.NonNull;
/**
* The {@link ShellyHandlerFactory} is responsible for creating things and thing handlers.
*
@ -156,7 +154,7 @@ public class ShellyHandlerFactory extends BaseThingHandlerFactory {
* Remove handler of things.
*/
@Override
protected synchronized void removeHandler(@NonNull ThingHandler thingHandler) {
protected synchronized void removeHandler(ThingHandler thingHandler) {
if (thingHandler instanceof ShellyBaseHandler shellyBaseHandler) {
shellyBaseHandler.stop();
String uid = thingHandler.getThing().getUID().getAsString();

View File

@ -202,16 +202,10 @@ public class ShellyThingCreatorTest {
@Test
void getThingUIDReturnsThingTypeMatchingServiceName() {
Set<ThingTypeUID> excludedThingTypeUids = Set.of(THING_TYPE_SHELLYBLUDW, THING_TYPE_SHELLYBLUMOTION,
THING_TYPE_SHELLYBLUHT, THING_TYPE_SHELLYBLUGW, THING_TYPE_SHELLYBLUBUTTON, THING_TYPE_SHELLY2_RELAY,
THING_TYPE_SHELLY2_ROLLER, THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY25_RELAY,
new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUSHTG3_STR),
new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUS2PM_RELAY_STR),
new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUS2PM_ROLLER_STR),
new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPRO2_RELAY_STR),
new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPRO2PM_ROLLER_STR),
new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPRO2PM_RELAY_STR),
new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYRGBW2_COLOR_STR));
Set<ThingTypeUID> excludedThingTypeUids = Set.of(THING_TYPE_SHELLY2_RELAY, THING_TYPE_SHELLY2_ROLLER,
THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY25_RELAY, THING_TYPE_SHELLYPLUSHTG3,
THING_TYPE_SHELLYPLUS2PM_RELAY, THING_TYPE_SHELLYPLUS2PM_ROLLER, THING_TYPE_SHELLYPRO2_RELAY,
THING_TYPE_SHELLYPRO2PM_ROLLER, THING_TYPE_SHELLYPRO2PM_RELAY, THING_TYPE_SHELLYRGBW2_COLOR);
for (ThingTypeUID supportedThingTypeUid : SUPPORTED_THING_TYPES_UIDS.stream()
.filter(uid -> !excludedThingTypeUids.contains(uid)).toList()) {