Java Code Examples for javax.measure.spi.SystemOfUnitsService#getSystemOfUnits()

The following examples show how to use javax.measure.spi.SystemOfUnitsService#getSystemOfUnits() . 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: SystemOfUnitsServiceTest.java    From uom-systems with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
// TODO consolidate asserts
public void testUnitSystemServiceAlias() {
	final ServiceProvider cldrProvider = ServiceProvider.of("Unicode");
	assertNotNull(cldrProvider);
	final SystemOfUnitsService cldrService = cldrProvider.getSystemOfUnitsService();
	assertNotNull(cldrService);
	assertEquals("systems.uom.unicode.spi.CLDRSystemService", cldrService.getClass().getName());
	SystemOfUnits system = cldrService.getSystemOfUnits("CLDR");
	assertNotNull(system);
	assertEquals("systems.uom.unicode.CLDR", system.getClass().getName());
	assertEquals("Unicode CLDR", system.getName());
	assertNotNull(system.getUnits());
	assertEquals(NUM_OF_UNITS_CLDR, system.getUnits().size());
	SystemOfUnits system2 = cldrService.getSystemOfUnits("Unicode");
	assertEquals(system, system2);
}
 
Example 2
Source File: SystemOfUnitsServiceTest.java    From uom-systems with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
// TODO consolidate asserts
public void testCommonUnitSystemServiceAlias() {
	final ServiceProvider commonProvider = ServiceProvider.of("Common");
	assertNotNull(commonProvider);
	final SystemOfUnitsService commonService = commonProvider.getSystemOfUnitsService();
	assertNotNull(commonService);
	assertEquals(COMMON_SERVICE_CLASSNAME, commonService.getClass().getName());
	SystemOfUnits system = commonService.getSystemOfUnits("USCustomary");
	assertNotNull(system);
	assertEquals("systems.uom.common.USCustomary", system.getClass().getName());
	assertEquals("United States Customary Units", system.getName());
	assertNotNull(system.getUnits());
	assertEquals(NUM_OF_UNITS_US, system.getUnits().size());
	SystemOfUnits system2 = commonService.getSystemOfUnits("US");
	assertEquals(system, system2);

	system = commonService.getSystemOfUnits("CGS");
	assertNotNull(system);
	assertEquals("Centimetre–gram–second System of Units", system.getName());
	system2 = commonService.getSystemOfUnits("Centimetre–gram–second");
	assertEquals(system, system2);
	assertEquals(NUM_OF_UNITS_CGS, system.getUnits().size());
}
 
Example 3
Source File: SystemOfUnitsServiceTest.java    From uom-systems with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testCLDRUnitSystemService() {
	final ServiceProvider cldrProvider = ServiceProvider.of("Unicode");
	assertNotNull(cldrProvider);
	final SystemOfUnitsService cldrService = cldrProvider.getSystemOfUnitsService();
	assertNotNull(cldrService);
	assertEquals("systems.uom.unicode.spi.CLDRSystemService", cldrService.getClass().getName());
	SystemOfUnits system = cldrService.getSystemOfUnits();
	assertNotNull(system);
	assertEquals("systems.uom.unicode.CLDR", system.getClass().getName());
	assertEquals("Unicode CLDR", system.getName());
	assertNotNull(system.getUnits());
	assertEquals(NUM_OF_UNITS_CLDR, system.getUnits().size());
}
 
Example 4
Source File: SystemOfUnitsServiceTest.java    From uom-systems with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testCommonUnitSystemService() {
	final ServiceProvider commonProvider = ServiceProvider.of("Common");
	assertNotNull(commonProvider);
	final SystemOfUnitsService commonService = commonProvider.getSystemOfUnitsService();
	assertNotNull(commonService);
	assertEquals("systems.uom.common.spi.CommonSystemService", commonService.getClass().getName());
	SystemOfUnits system = commonService.getSystemOfUnits();
	assertNotNull(system);
	assertEquals("systems.uom.common.USCustomary", system.getClass().getName());
	assertEquals("United States Customary Units", system.getName());
	assertNotNull(system.getUnits());
	assertEquals(NUM_OF_UNITS_US, system.getUnits().size());
}