-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[deconz] Fix tests. Fix #17104 #17108
Conversation
Signed-off-by: AndrewFG <software@whitebear.ch>
@@ -92,6 +94,7 @@ public void discoveryTest() throws IOException { | |||
Mockito.doAnswer(answer -> CompletableFuture.completedFuture(Optional.of(bridgeFullState))).when(bridgeHandler) | |||
.getBridgeFullState(); | |||
ThingDiscoveryService discoveryService = new ThingDiscoveryService(); | |||
discoveryService.modified(Map.of(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY, false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about that, because that is not the default setting. Maybe removing discoveryService.startScan()
and relying on the background discovery would be an approach that is closer to a production system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I can change it.
.. but on a side note, it seems to me that the Junit test is not really a test of the binding code, but rather of the OH core ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? It ensures that the discovery code creates a DiscoveryResult
for every device in the input JSON. I would say that this is binding code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.. but in any case, removing the startScan()
also fails the Junit test (see below) .. so evidently we cannot 'rely on the background discovery' -- of the three options i) foreground scan with no background, ii) background with no foreground, or iii) both background and foreground, it seems to me that i) (my solution) is the most controlled test and therefore the one most likely to pass properly.
[ERROR] Failures:
[ERROR] DeconzTest.discoveryTest:100
Wanted but not invoked:
discoveryListener.thingDiscovered(
<any>,
<any>
);
-> at org.openhab.binding.deconz.DeconzTest.discoveryTest(DeconzTest.java:100)
However, there was exactly 1 interaction with this mock:
discoveryListener.removeOlderResults(
org.openhab.binding.deconz.internal.discovery.ThingDiscoveryService@329a1f8d,
0L,
[deconz:colorcontrol, deconz:dimmablelight, deconz:powersensor, deconz:consumptionsensor, deconz:moisturesensor, deconz:waterleakagesensor, deconz:onofflight, deconz:switch, deconz:vibrationsensor, deconz:openclosesensor, deconz:humiditysensor, deconz:colortemperaturelight, deconz:extendedcolorlight, deconz:windowcovering, deconz:airqualitysensor, deconz:lightsensor, deconz:batterysensor, deconz:pressuresensor, deconz:presencesensor, deconz:alarmsensor, deconz:colorlight, deconz:doorlock, deconz:firesensor, deconz:temperaturesensor, deconz:carbonmonoxidesensor, deconz:daylightsensor, deconz:warningdevice, deconz:thermostat],
null
);
-> at org.openhab.core.config.discovery.AbstractDiscoveryService.removeOlderResults(AbstractDiscoveryService.java:330)
Signed-off-by: AndrewFG <software@whitebear.ch>
Signed-off-by: AndrewFG <software@whitebear.ch> Signed-off-by: Patrik Gfeller <patrik.gfeller@proton.me>
Signed-off-by: AndrewFG <software@whitebear.ch>
Signed-off-by: AndrewFG <software@whitebear.ch>
Fix tests.
Fixes #17104
Signed-off-by: AndrewFG software@whitebear.ch