### Question:
Variable { public BigDecimal asNumber() { BigDecimal bd = null; if (value != null) { if (value instanceof String) { try { bd = new BigDecimal((String)value); } catch (NumberFormatException nfe) { } } else if (value instanceof BigDecimal) { bd = (BigDecimal)value; } } return bd; } Variable(Object theValue); Object asObject(); Boolean asBoolean(); boolean asBool(); double asDouble(); int asInt(); BigDecimal asNumber(); String asString(); Timestamp asTimestamp(); String toString();  }### Answer:
@Test public void testAsNumber() throws Exception { assertNull("expected null", new Variable(null).asNumber()); Variable var = new Variable(new BigDecimal("3.14159")); assertEquals("wrong value", new BigDecimal("3.14159"), var.asNumber()); var = new Variable("3.14159"); assertEquals("wrong value", new BigDecimal("3.14159"), var.asNumber()); assertNull("asBoolean", var.asBoolean()); assertNotNull("asNumber", var.asNumber()); assertNotNull("asString", var.asString()); assertNull("asTimestamp", var.asTimestamp()); assertEquals("asBool", false, var.asBool()); assertEquals("asDouble", Double.valueOf(3.14159), Double.valueOf(var.asDouble())); assertEquals("asInt", 3, var.asInt()); }