Search in sources :

Example 1 with ServiceProvider

use of javax.measure.spi.ServiceProvider in project uom-se by unitsofmeasurement.

the class QuantityFunctionsGroupTest method init.

@Before
public void init() {
    ServiceProvider provider = ServiceProvider.current();
    timeFactory = provider.getQuantityFactory(Time.class);
    minutes = timeFactory.create(BigDecimal.valueOf(15), Units.MINUTE);
    hours = timeFactory.create(BigDecimal.valueOf(18), Units.HOUR);
    day = timeFactory.create(BigDecimal.ONE, Units.DAY);
    seconds = timeFactory.create(BigDecimal.valueOf(100), Units.SECOND);
}
Also used : ServiceProvider(javax.measure.spi.ServiceProvider) Time(javax.measure.quantity.Time) Before(org.junit.Before)

Example 2 with ServiceProvider

use of javax.measure.spi.ServiceProvider in project uom-se by unitsofmeasurement.

the class QuantityFunctionsSortTest method init.

@Before
public void init() {
    ServiceProvider provider = ServiceProvider.current();
    timeFactory = provider.getQuantityFactory(Time.class);
    minutes = timeFactory.create(15, Units.MINUTE);
    hours = timeFactory.create(18, Units.HOUR);
    day = timeFactory.create(1, Units.DAY);
    seconds = timeFactory.create(100, Units.SECOND);
}
Also used : ServiceProvider(javax.measure.spi.ServiceProvider) Time(javax.measure.quantity.Time) Before(org.junit.Before)

Example 3 with ServiceProvider

use of javax.measure.spi.ServiceProvider in project indriya by unitsofmeasurement.

the class QuantityFunctionsSortTest method init.

@BeforeEach
public void init() {
    ServiceProvider provider = ServiceProvider.current();
    timeFactory = provider.getQuantityFactory(Time.class);
    minutes = timeFactory.create(15, Units.MINUTE);
    hours = timeFactory.create(18, Units.HOUR);
    day = timeFactory.create(1, Units.DAY);
    seconds = timeFactory.create(100, Units.SECOND);
}
Also used : ServiceProvider(javax.measure.spi.ServiceProvider) Time(javax.measure.quantity.Time) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ServiceProvider

use of javax.measure.spi.ServiceProvider in project sis by apache.

the class UnitServicesTest method testGetUnitFormat.

/**
 * Tests {@link UnitServices#getUnitFormat(String)}.
 */
@Test
public void testGetUnitFormat() {
    final ServiceProvider provider = ServiceProvider.current();
    final UnitFormat f = provider.getUnitFormatService().getUnitFormat("name");
    ((org.apache.sis.measure.UnitFormat) f).setLocale(Locale.US);
    assertEquals("CUBIC_METRE", "cubic meter", f.format(Units.CUBIC_METRE));
}
Also used : UnitFormat(javax.measure.format.UnitFormat) ServiceProvider(javax.measure.spi.ServiceProvider) Test(org.junit.Test)

Example 5 with ServiceProvider

use of javax.measure.spi.ServiceProvider in project sis by apache.

the class UnitServicesTest method testDefaultSystemOfUnits.

/**
 * Tests the default system of units.
 */
@Test
public void testDefaultSystemOfUnits() {
    final ServiceProvider provider = ServiceProvider.current();
    Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits().getUnits();
    assertTrue("METRE", units.contains(Units.METRE));
    assertTrue("KILOMETRE", units.contains(Units.KILOMETRE));
    assertTrue("CUBIC_METRE", units.contains(Units.CUBIC_METRE));
    assertTrue("METRES_PER_SECOND", units.contains(Units.METRES_PER_SECOND));
    assertTrue("KILOMETRES_PER_HOUR", units.contains(Units.KILOMETRES_PER_HOUR));
    assertTrue("NAUTICAL_MILE", units.contains(Units.NAUTICAL_MILE));
    assertTrue("STATUTE_MILE", units.contains(Units.STATUTE_MILE));
    assertTrue("DEGREE", units.contains(Units.DEGREE));
    assertTrue("RADIAN", units.contains(Units.RADIAN));
    assertTrue("GRAD", units.contains(Units.GRAD));
}
Also used : ServiceProvider(javax.measure.spi.ServiceProvider) Test(org.junit.Test)

Aggregations

ServiceProvider (javax.measure.spi.ServiceProvider)14 Time (javax.measure.quantity.Time)8 Test (org.junit.Test)6 Before (org.junit.Before)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 UnitFormat (javax.measure.format.UnitFormat)1