Search in sources :

Example 1 with Mass

use of javax.measure.quantity.Mass in project uom-se by unitsofmeasurement.

the class MeasurementTest method testOf.

@Test
public void testOf() {
    Instant instant = Instant.now();
    Measurement<Mass> measurement = Measurement.of(Quantities.getQuantity(15, KILOGRAM), instant);
    assertEquals(Quantities.getQuantity(15, KILOGRAM), measurement.getQuantity());
    assertEquals(instant, measurement.getInstant());
    assertEquals(instant.toEpochMilli(), measurement.getTimestamp());
}
Also used : Mass(javax.measure.quantity.Mass) Instant(java.time.Instant) Test(org.junit.Test)

Example 2 with Mass

use of javax.measure.quantity.Mass in project indriya by unitsofmeasurement.

the class MeasurementTest method testOf.

@Test
public void testOf() {
    Instant instant = Instant.now();
    Measurement<Mass> measurement = Measurement.of(Quantities.getQuantity(15, KILOGRAM), instant);
    assertEquals(Quantities.getQuantity(15, KILOGRAM), measurement.getQuantity());
    assertEquals(instant, measurement.getInstant());
    assertEquals(instant.toEpochMilli(), measurement.getTimestamp());
}
Also used : Mass(javax.measure.quantity.Mass) Instant(java.time.Instant) Test(org.junit.jupiter.api.Test)

Example 3 with Mass

use of javax.measure.quantity.Mass in project indriya by unitsofmeasurement.

the class PrefixTest method testNestedOperationsShouldBeSame.

@Test
@Disabled("This is research for https://github.com/unitsofmeasurement/uom-se/issues/164")
public void testNestedOperationsShouldBeSame() {
    Unit<Mass> m1 = MICRO(GRAM);
    Unit<Mass> m2 = GRAM.divide(1000).divide(1000);
    UnitConverter c1 = m1.getConverterTo(m2);
    List steps1 = c1.getConversionSteps();
    UnitConverter c2 = m2.getConverterTo(m1);
    List steps2 = c2.getConversionSteps();
    assertEquals(c1, c2);
    assertEquals(m1, m2);
}
Also used : Mass(javax.measure.quantity.Mass) UnitConverter(javax.measure.UnitConverter) List(java.util.List) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 4 with Mass

use of javax.measure.quantity.Mass in project indriya by unitsofmeasurement.

the class PrefixTest method testNestedOperationsNotTheSame.

@Test
public void testNestedOperationsNotTheSame() {
    Unit<Mass> m1 = MICRO(GRAM);
    Unit<Mass> m2 = GRAM.divide(1000).divide(2000);
    UnitConverter c1 = m1.getConverterTo(m2);
    List steps1 = c1.getConversionSteps();
    UnitConverter c2 = m2.getConverterTo(m1);
    List steps2 = c2.getConversionSteps();
    assertNotEquals(c1, c2);
    assertNotEquals(m1, m2);
}
Also used : Mass(javax.measure.quantity.Mass) UnitConverter(javax.measure.UnitConverter) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 5 with Mass

use of javax.measure.quantity.Mass in project uom-se by unitsofmeasurement.

the class PrefixTest method testNestedOperationsShouldBeSame.

@Test
@Ignore("This is research for https://github.com/unitsofmeasurement/uom-se/issues/164")
public void testNestedOperationsShouldBeSame() {
    Unit<Mass> m1 = MICRO(GRAM);
    Unit<Mass> m2 = GRAM.divide(1000).divide(1000);
    UnitConverter c1 = m1.getConverterTo(m2);
    List steps1 = c1.getConversionSteps();
    UnitConverter c2 = m2.getConverterTo(m1);
    List steps2 = c2.getConversionSteps();
    assertEquals(c1, c2);
    assertEquals(m1, m2);
}
Also used : Mass(javax.measure.quantity.Mass) UnitConverter(javax.measure.UnitConverter) List(java.util.List) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Mass (javax.measure.quantity.Mass)6 List (java.util.List)4 UnitConverter (javax.measure.UnitConverter)4 Test (org.junit.Test)3 Test (org.junit.jupiter.api.Test)3 Instant (java.time.Instant)2 Ignore (org.junit.Ignore)1 Disabled (org.junit.jupiter.api.Disabled)1