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

Upgrade Units of Measurement dependencies #10583

Merged
merged 1 commit into from
May 11, 2021
Merged

Conversation

wborn
Copy link
Member

@wborn wborn commented Apr 26, 2021

Depends on openhab/openhab-core#2319


  • Fix code/tests for upgrade
  • Resolve runbundles
  • Update Checkstyle ruleset for changed packages

* Fix code/tests for upgrade
* Resolve runbundles
* Update Checkstyle ruleset for changed packages

Signed-off-by: Wouter Born <github@maindrain.net>
Copy link
Contributor

@hmerk hmerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for itests/wemo

@kaikreuzer kaikreuzer removed the awaiting other PR Depends on another PR label May 10, 2021
@wborn wborn added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels May 10, 2021
@wborn
Copy link
Member Author

wborn commented May 10, 2021

This PR needs to be merged so other PR builds succeed again @openhab/add-ons-maintainers. ✔️

Copy link
Contributor

@ssalonen ssalonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of modbus as maintainer, small suggestion. Comments for modbus.e3dc

((QuantityType<?>) actualStateUpdateTowardsItem).getUnit());
assertEquals(((QuantityType<?>) expectedStateUpdateTowardsItem).toBigDecimal(),
((QuantityType<?>) actualStateUpdateTowardsItem).toBigDecimal());
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting to see the complicated equals check is no longer needed. I suppose it was remnant from time (during development) when I tried to make the profile support gain/offset for any QuantityType. This caused unexpected temperature unit errors like indicated in the comment above.

If the tests pass, it should be fine.

One change suggestion, can you remove now unnecessary conditional and the obsolete comment on "workaround"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary conditional

Which one do you think is unnecessary?

Copy link
Contributor

@ssalonen ssalonen May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wborn it now says

    // Workaround for errors like "java.lang.UnsupportedOperationException: °C is non-linear, cannot convert"
    if (expectedStateUpdateTowardsItem instanceof QuantityType<?>) {
        assertTrue(actualStateUpdateTowardsItem instanceof QuantityType<?>);
        assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
    } else {
        assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
    }

As you can see, both branches of conditional are effectively the same. Also, the comment does not apply anymore, you in fact were able to remove the "workaround"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK now I understand, I've created #10670 to clean it up. 👍

private <QU extends Quantity<QU>> QuantityType<QU> applyGainTowardsItem(QuantityType<Dimensionless> qtState,
QuantityType<QU> gainDelta) {
return (QuantityType<QU>) qtState.multiply(gainDelta);
return new QuantityType<>(qtState.toBigDecimal().multiply(gainDelta.toBigDecimal()), gainDelta.getUnit());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to be correct, tests should reveal any issues.

I am not fond of bypassing quantitytype-arithmetic since we lose many of the correctness guarantees from the uom lib. Having said this , in this particular case the change is isolated and allows to remove the unchecked cast.

assertEquals("14.0 W", b.gridPowerSupply.toString(), "Grid Supply");
assertEquals("0.0 W", b.gridPowerConsumpition.toString(), "Grid Consumption");
assertEquals("303.0 W", b.batteryPowerSupply.toString(), "Battery Supply");
assertEquals("-330 W", b.pvPowerSupply.toString(), "PV Supply");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not maintainer of modbus.e3dc but this seems like a harmless side effect of library change. I would not expect this to have negative side effects to non-test code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes toString values aren't the most future proof values to use in such comparisons.
They are easy to read and understand however. So that's why I opted for just updating them.

@kaikreuzer kaikreuzer merged commit c3a6aa5 into openhab:main May 11, 2021
@wborn wborn deleted the update-uom branch May 11, 2021 06:52
@wborn wborn added this to the 3.1 milestone May 11, 2021
computergeek1507 pushed a commit to computergeek1507/openhab-addons that referenced this pull request Jul 13, 2021
* Fix code/tests for upgrade
* Resolve runbundles
* Update Checkstyle ruleset for changed packages

Signed-off-by: Wouter Born <github@maindrain.net>
frederictobiasc pushed a commit to frederictobiasc/openhab-addons that referenced this pull request Oct 26, 2021
* Fix code/tests for upgrade
* Resolve runbundles
* Update Checkstyle ruleset for changed packages

Signed-off-by: Wouter Born <github@maindrain.net>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
* Fix code/tests for upgrade
* Resolve runbundles
* Update Checkstyle ruleset for changed packages

Signed-off-by: Wouter Born <github@maindrain.net>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
* Fix code/tests for upgrade
* Resolve runbundles
* Update Checkstyle ruleset for changed packages

Signed-off-by: Wouter Born <github@maindrain.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants