javax.measure.quantity.Energy Java Examples
The following examples show how to use
javax.measure.quantity.Energy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UnitUtilsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetDimensionName() { assertThat(UnitUtils.getDimensionName(SIUnits.CELSIUS), is(Temperature.class.getSimpleName())); assertThat(UnitUtils.getDimensionName(SmartHomeUnits.KILOWATT_HOUR), is(Energy.class.getSimpleName())); assertThat(UnitUtils.getDimensionName(SmartHomeUnits.WATT), is(Power.class.getSimpleName())); assertThat(UnitUtils.getDimensionName(MetricPrefix.MEGA(SmartHomeUnits.KILOWATT_HOUR)), is(Energy.class.getSimpleName())); Unit<?> unit = UnitUtils.parseUnit("°F"); assertNotNull(unit); assertThat(UnitUtils.getDimensionName(unit), is(Temperature.class.getSimpleName())); unit = UnitUtils.parseUnit("m"); assertNotNull(unit); assertThat(UnitUtils.getDimensionName(unit), is(Length.class.getSimpleName())); }
Example #2
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testKVarUnitSymbol() { assertThat(SmartHomeUnits.KILOVAR.toString(), is("kvar")); assertThat(SmartHomeUnits.KILOVAR_HOUR.toString(), is("kvarh")); Quantity<Power> kvar = Quantities.getQuantity(BigDecimal.TEN, MetricPrefix.KILO(SmartHomeUnits.VAR)); assertThat(kvar.getUnit().toString(), is("kvar")); Quantity<Energy> kvarh = Quantities.getQuantity(BigDecimal.TEN, MetricPrefix.KILO(SmartHomeUnits.VAR_HOUR)); assertThat(kvarh.getUnit().toString(), is("kvarh")); }
Example #3
Source File: SmartHomeUnitsTest.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
@Test public void testVoltAmpereUnitSymbol() { assertThat(SmartHomeUnits.VOLT_AMPERE.toString(), is("VA")); assertThat(SmartHomeUnits.VOLT_AMPERE.getSymbol(), is("VA")); assertThat(SmartHomeUnits.VOLT_AMPERE_HOUR.toString(), is("VAh")); Quantity<Power> kVA = Quantities.getQuantity(BigDecimal.TEN, MetricPrefix.KILO(SmartHomeUnits.VOLT_AMPERE)); assertThat(kVA.getUnit().toString(), is("kVA")); Quantity<Energy> kVAh = Quantities.getQuantity(BigDecimal.TEN, MetricPrefix.KILO(SmartHomeUnits.VOLT_AMPERE_HOUR)); assertThat(kVAh.getUnit().toString(), is("kVAh")); }
Example #4
Source File: UnitUtilsTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
@Test public void testGetDimensionName() { assertThat(UnitUtils.getDimensionName(SIUnits.CELSIUS), is(Temperature.class.getSimpleName())); assertThat(UnitUtils.getDimensionName(SmartHomeUnits.KILOWATT_HOUR), is(Energy.class.getSimpleName())); assertThat(UnitUtils.getDimensionName(SmartHomeUnits.WATT), is(Power.class.getSimpleName())); assertThat(UnitUtils.getDimensionName(MetricPrefix.MEGA(SmartHomeUnits.KILOWATT_HOUR)), is(Energy.class.getSimpleName())); Unit<?> unit = UnitUtils.parseUnit("°F"); assertNotNull(unit); assertThat(UnitUtils.getDimensionName(unit), is(Temperature.class.getSimpleName())); unit = UnitUtils.parseUnit("m"); assertNotNull(unit); assertThat(UnitUtils.getDimensionName(unit), is(Length.class.getSimpleName())); }
Example #5
Source File: QuantityTypeTest.java From openhab-core with Eclipse Public License 2.0 | 4 votes |
@Test public void testEnergyUnits() { QuantityType<Energy> energy = new QuantityType<>("28800 J"); assertEquals("0.008 kWh", energy.toUnit("kWh").toString()); assertEquals("28800 Ws", energy.toUnit("Ws").toString()); }
Example #6
Source File: QuantityTypeTest.java From openhab-core with Eclipse Public License 2.0 | 4 votes |
@Test public void testMWh() { QuantityType<Energy> energy = new QuantityType<>("1 MWh"); assertEquals("1000000 Wh", energy.toUnit("Wh").toString()); }
Example #7
Source File: QuantityTypeTest.java From smarthome with Eclipse Public License 2.0 | 4 votes |
@Test public void testEnergyUnits() { QuantityType<Energy> energy = new QuantityType<>("28800 J"); assertEquals("0.008 kWh", energy.toUnit("kWh").toString()); assertEquals("28800 Ws", energy.toUnit("Ws").toString()); }