Upgrade Units of Measurement dependencies (#10583)

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

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-05-11 08:31:03 +02:00
committed by GitHub
parent 0fd9c4c1f8
commit c3a6aa5814
24 changed files with 178 additions and 91 deletions

View File

@@ -231,10 +231,9 @@ public class ModbusGainOffsetProfile<Q extends Quantity<Q>> implements StateProf
* When the conversion is towards the handler (towardsItem=false), unit will be ONE
*
*/
@SuppressWarnings("unchecked") // Safe cast since QU = Dimensionless * QU
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());
}
private QuantityType<Dimensionless> applyGainTowardsHandler(QuantityType<?> qtState, QuantityType<?> gainDelta) {

View File

@@ -172,10 +172,7 @@ public class ModbusGainOffsetProfileTest {
// Workaround for errors like "java.lang.UnsupportedOperationException: °C is non-linear, cannot convert"
if (expectedStateUpdateTowardsItem instanceof QuantityType<?>) {
assertTrue(actualStateUpdateTowardsItem instanceof QuantityType<?>);
assertEquals(((QuantityType<?>) expectedStateUpdateTowardsItem).getUnit(),
((QuantityType<?>) actualStateUpdateTowardsItem).getUnit());
assertEquals(((QuantityType<?>) expectedStateUpdateTowardsItem).toBigDecimal(),
((QuantityType<?>) actualStateUpdateTowardsItem).toBigDecimal());
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
} else {
assertEquals(expectedStateUpdateTowardsItem, actualStateUpdateTowardsItem);
}