Search in sources :

Example 6 with ServiceProvider

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

the class UnitServicesTest method testGetAvailableFormatNames.

/**
 * Tests {@link UnitServices#getAvailableFormatNames()}.
 */
@Test
public void testGetAvailableFormatNames() {
    final ServiceProvider provider = ServiceProvider.current();
    assertSetEquals(Arrays.asList("SYMBOL", "UCUM", "NAME"), provider.getUnitFormatService().getAvailableFormatNames());
}
Also used : ServiceProvider(javax.measure.spi.ServiceProvider) Test(org.junit.Test)

Example 7 with ServiceProvider

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

the class UnitServicesTest method testAccepted.

/**
 * Tests the "SI + accepted" system of units.
 */
@Test
public void testAccepted() {
    final ServiceProvider provider = ServiceProvider.current();
    Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("SI + accepted").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));
    assertFalse("NAUTICAL_MILE", units.contains(Units.NAUTICAL_MILE));
    assertFalse("STATUTE_MILE", units.contains(Units.STATUTE_MILE));
    assertTrue("DEGREE", units.contains(Units.DEGREE));
    assertTrue("RADIAN", units.contains(Units.RADIAN));
    assertFalse("GRAD", units.contains(Units.GRAD));
}
Also used : ServiceProvider(javax.measure.spi.ServiceProvider) Test(org.junit.Test)

Example 8 with ServiceProvider

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

the class UnitServicesTest method testSI.

/**
 * Tests the "SI" system of units.
 */
@Test
public void testSI() {
    final ServiceProvider provider = ServiceProvider.current();
    Set<? extends Unit<?>> units = provider.getSystemOfUnitsService().getSystemOfUnits("SI").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));
    assertFalse("KILOMETRES_PER_HOUR", units.contains(Units.KILOMETRES_PER_HOUR));
    assertFalse("NAUTICAL_MILE", units.contains(Units.NAUTICAL_MILE));
    assertFalse("STATUTE_MILE", units.contains(Units.STATUTE_MILE));
    assertFalse("DEGREE", units.contains(Units.DEGREE));
    assertTrue("RADIAN", units.contains(Units.RADIAN));
    assertFalse("GRAD", units.contains(Units.GRAD));
}
Also used : ServiceProvider(javax.measure.spi.ServiceProvider) Test(org.junit.Test)

Example 9 with ServiceProvider

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

the class UnitServicesTest method testImperial.

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

Example 10 with ServiceProvider

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

the class QuantityFunctionsFilterTest method init.

@BeforeEach
public void init() {
    ServiceProvider factoryService = ServiceProvider.current();
    timeFactory = factoryService.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)

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