-
Notifications
You must be signed in to change notification settings - Fork 780
Fix thing creation for nested Things from different ThingHandlerFactory #5410
Fix thing creation for nested Things from different ThingHandlerFactory #5410
Conversation
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.
Just to minor remarks, but it looks correct to me.
À propos: I vaguely remember us talking about a test-case which you wrote which proved the broken behavior - or do I mix something up? Did you maybe forget to commit it, or did I miss it anywhere?
// construct the thingUID up front: this will ensure that short notation things with reference to a bridge | ||
// do not end up with the bridge id in their id. | ||
things.forEach([thingId = thingId ?: constructThingUID.toString]) | ||
things.filter(typeof(ModelBridge)).forEach([val b = it; b.things.forEach[ |
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.
val b = it;
-> b |
Nevermind, all correct. Still, here you got me - how about giving both it
s some explicit names?
// for nested things in short notation, make sure the bridge id is part of the thing id. | ||
id = id ?: getThingUID(new ThingUID(b.id)).toString; | ||
]]) | ||
things + flattenModelThings(things.filter(typeof(ModelBridge)).map(b | b.things).flatten); |
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.
just personal preference, but here I think a return
would help readability
|
||
String model = | ||
''' | ||
Bridge Xhue:Xbridge:myBridge [ XipAddress = "1.2.3.4", XuserName = "123" ] { |
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.
Aaaaaahhh, TABS!!! 😱
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.
auto-formatter refuses to make all good, sorry :-(
Signed-off-by: Henning Treu <[email protected]>
Signed-off-by: Henning Treu <[email protected]>
Signed-off-by: Henning Treu <[email protected]>
@SJKA thanks for reminding me about the test case. I wrote one and apparently the fix is still incomplete. In case a bundle defines multiple HandlerFactories (which should be possible imho) it fails. And thus would fail for the reason this fix was made. |
* introduce BundleNameResolver Signed-off-by: Henning Treu <[email protected]>
03453aa
to
773fe06
Compare
@@ -0,0 +1,6 @@ | |||
package org.eclipse.smarthome.model.thing.internal.util; | |||
|
|||
public interface BundleNameResolver { |
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 do you need this additional interface? Wouldn't a making the getBundleName(...)
method protected be sufficient, so that it can be overridden in the test-case by like this?
new BundleNameResolver() {
@Override
protected String getBundleName(...) {
// ...
}
}
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.
done. I didn't like the solution either.
Signed-off-by: Henning Treu <[email protected]>
…ry (eclipse-archived#5410) * Refactor source directories and packages * flatten bridge models before creating things * Flatten thing models before handler creation * add test for multiple ThingHandlerFactories * introduce BundleNameResolver Signed-off-by: Henning Treu <[email protected]>
Fixes #5404.
The first commit is only a reorganisation of the tests into sane packages.