Skip to content
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

Merged
merged 1 commit into from
Jul 20, 2024
Merged

Conversation

andrewfg
Copy link
Contributor

Fix tests.

Fixes #17104

Signed-off-by: AndrewFG software@whitebear.ch

Signed-off-by: AndrewFG <software@whitebear.ch>
@andrewfg andrewfg added the regression Regression that happened during the development of a release. Not shown on final release notes. label Jul 20, 2024
@andrewfg andrewfg requested a review from lolodomo July 20, 2024 11:26
@andrewfg andrewfg self-assigned this Jul 20, 2024
@andrewfg andrewfg requested a review from J-N-K as a code owner July 20, 2024 11:26
@@ -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));
Copy link
Member

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.

Copy link
Contributor Author

@andrewfg andrewfg Jul 20, 2024

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 ..

Copy link
Member

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.

Copy link
Contributor Author

@andrewfg andrewfg Jul 20, 2024

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)

@J-N-K J-N-K added bug An unexpected problem or unintended behavior of an add-on test labels Jul 20, 2024
@J-N-K J-N-K added this to the 4.3 milestone Jul 20, 2024
@J-N-K J-N-K merged commit 5fdb9fd into openhab:main Jul 20, 2024
5 checks passed
@andrewfg andrewfg deleted the deconz-fix-tests branch August 25, 2024 11:57
digitaldan pushed a commit to digitaldan/openhab-addons that referenced this pull request Aug 29, 2024
Signed-off-by: AndrewFG <software@whitebear.ch>
@jlaur jlaur removed the bug An unexpected problem or unintended behavior of an add-on label Sep 1, 2024
pgfeller pushed a commit to pgfeller/openhab-addons that referenced this pull request Sep 29, 2024
Signed-off-by: AndrewFG <software@whitebear.ch>
Signed-off-by: Patrik Gfeller <patrik.gfeller@proton.me>
joni1993 pushed a commit to joni1993/openhab-addons that referenced this pull request Oct 15, 2024
Signed-off-by: AndrewFG <software@whitebear.ch>
matchews pushed a commit to matchews/openhab-addons that referenced this pull request Oct 18, 2024
Signed-off-by: AndrewFG <software@whitebear.ch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression that happened during the development of a release. Not shown on final release notes. test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[deconz] Fails tests. Breaks CI build
3 participants