javax.measure.quantity.Volume Java Examples
The following examples show how to use
javax.measure.quantity.Volume.
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: UnitsTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests getting a unit for a given quantity type. */ @Test public void testGetForQuantity() { assertSame("Length", Units.METRE, Units.get(Length.class)); assertSame("Mass", Units.KILOGRAM, Units.get(Mass.class)); assertSame("Time", Units.SECOND, Units.get(Time.class)); assertSame("Temperature", Units.KELVIN, Units.get(Temperature.class)); assertSame("Area", Units.SQUARE_METRE, Units.get(Area.class)); assertSame("Volume", Units.CUBIC_METRE, Units.get(Volume.class)); assertSame("Speed", Units.METRES_PER_SECOND, Units.get(Speed.class)); assertSame("LuminousIntensity", Units.CANDELA, Units.get(LuminousIntensity.class)); assertSame("LuminousFlux", Units.LUMEN, Units.get(LuminousFlux.class)); assertSame("SolidAngle", Units.STERADIAN, Units.get(SolidAngle.class)); assertSame("Angle", Units.RADIAN, Units.get(Angle.class)); assertSame("Dimensionless", Units.UNITY, Units.get(Dimensionless.class)); }
Example #2
Source File: WaterTankUnitTest.java From tutorials with MIT License | 6 votes |
@Test public void givenQuantity_whenGetUnitAndConvertValue_thenSuccess() { WaterTank waterTank = new WaterTank(); waterTank.setCapacityMeasure(Quantities.getQuantity(9.2, LITRE)); assertEquals(LITRE, waterTank.getCapacityMeasure().getUnit()); Quantity<Volume> waterCapacity = waterTank.getCapacityMeasure(); double volumeInLitre = waterCapacity.getValue().doubleValue(); assertEquals(9.2, volumeInLitre, 0.0f); double volumeInMilliLitre = waterCapacity.to(MetricPrefix.MILLI(LITRE)).getValue().doubleValue(); assertEquals(9200.0, volumeInMilliLitre, 0.0f); // compilation error // volumeInMilliLitre = waterCapacity.to(MetricPrefix.MILLI(KILOGRAM)); Unit<Length> Kilometer = MetricPrefix.KILO(METRE); // compilation error // Unit<Length> Centimeter = MetricPrefix.CENTI(LITRE); }
Example #3
Source File: UCUMTest.java From uom-systems with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testLiterToDm3() { final Quantity<Volume> oneLiter = Quantities.getQuantity(1, LITER); final Quantity<Volume> oneDm3 = Quantities.getQuantity(1, LITER_DM3); assertEquals(1, oneLiter.to(LITER_DM3).getValue()); //assertEquals(oneLiter, oneDm3); }
Example #4
Source File: ConventionalUnitTest.java From sis with Apache License 2.0 | 5 votes |
/** * Verifies that the given units derived from litres ({@code u1}) is equivalent to the given units derived * from cubic metres ({@code u2}). The conversion between those two units is expected to be identity. */ private static void assertEquivalent(final String s1, final Unit<Volume> u1, final String s2, final Unit<Volume> u2) throws IncommensurableException { assertEquals("unit1.symbol", s1, u1.getSymbol()); assertEquals("unit2.symbol", s2, u2.getSymbol()); assertTrue("getConverterTo(…).isIdentity", u1.getConverterTo(u2).isIdentity()); assertTrue("getConverterTo(…).isIdentity", u2.getConverterTo(u1).isIdentity()); assertTrue("getConverterTo(…).isIdentity", u1.getConverterToAny(u2).isIdentity()); assertTrue("getConverterTo(…).isIdentity", u2.getConverterToAny(u1).isIdentity()); }
Example #5
Source File: ConventionalUnitTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests conversion between litres and cubic metres. */ @Test @DependsOnMethod("testVolumeEquivalences") public void testVolumeConversions() { final Unit<Volume> l = Units.LITRE; final Unit<Volume> cl = Units.LITRE.divide(100); final Unit<Volume> ml = Units.LITRE.divide(1000); final Unit<Volume> cm3 = Units.CUBIC_METRE.divide(1E+06); assertEquals("4 L to ml", 4000, l.getConverterTo(ml) .convert(4), STRICT); assertEquals("4 cL to cm³", 40, cl.getConverterTo(cm3).convert(4), STRICT); }
Example #6
Source File: UCUMTest.java From uom-systems with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testStToDm3() { final Quantity<Volume> oneLiter = Quantities.getQuantity(1, STERE); assertEquals(1000, oneLiter.to(LITER_DM3).getValue()); }
Example #7
Source File: UCUMTest.java From uom-systems with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testStToLiter() { final Quantity<Volume> oneLiter = Quantities.getQuantity(1, STERE); assertEquals(1000, oneLiter.to(LITER).getValue()); }
Example #8
Source File: UnitFormatPrefixTest.java From uom-systems with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Test public void testKibiLiter() { Unit<Volume> v1 = KIBI(LITER); assertEquals("KiL", FORMAT_PRINT.format(v1)); }
Example #9
Source File: WaterTank.java From tutorials with MIT License | 4 votes |
public void setCapacityMeasure(Quantity<Volume> capacityMeasure) { this.capacityMeasure = capacityMeasure; }
Example #10
Source File: WaterTank.java From tutorials with MIT License | 4 votes |
public Quantity<Volume> getCapacityMeasure() { return capacityMeasure; }