/** * Helper method which creates a <code>MutableUnitType</code> which can be used for testing. * * @return a mutable unit type. */ private MutableQuantityValue createMutableUnitTypeForTestingEquals() { MutableQuantityValue mutableQuantityValue = new MutableQuantityValueImpl(); NumberValueImpl numberValue = new MutableNumberValueImpl(); mutableQuantityValue.setMagnitudeValue(numberValue); UnitValueImpl unitValue = new ImmutableUnitValueImpl(); mutableQuantityValue.setUnitValue(unitValue); return mutableQuantityValue; }
/** This tests the getMagnitudeValueAsNumber method. */ public void testGetMagnitudeValueAsNumber() { MutableQuantityValue mutableQuantityValue = new MutableQuantityValueImpl(); NumberValueImpl numberValue = new MutableNumberValueImpl(); numberValue.setValue(new Double(10)); mutableQuantityValue.setMagnitudeValue(numberValue); UnitValue unitValue = QuantityUnits.CENTIMETERS; mutableQuantityValue.setUnitValue(unitValue); Number expectedResultInMillimeters = new Double(100); Number result = mutableQuantityValue.getMagnitudeAsNumber(QuantityUnits.MILLIMETERS); assertEquals("CM to MM Conversion failure", expectedResultInMillimeters, result); // todo add tests for other conversions }