View Javadoc
1   /**
2    * 
3    */
4   package org.melati.poem.test;
5   
6   import java.math.BigDecimal;
7   
8   import org.melati.poem.BigDecimalPoemType;
9   import org.melati.poem.DoublePoemType;
10  import org.melati.poem.SQLPoemType;
11  
12  /**
13   * @author timp
14   * @since 21 Dec 2006
15   *
16   */
17  public class NotNullableSetBigDecimalPoemTypeTest extends SQLPoemTypeSpec<BigDecimal> {
18  
19    /**
20     * 
21     */
22    public NotNullableSetBigDecimalPoemTypeTest() {
23    }
24  
25    /**
26     * @param name
27     */
28    public NotNullableSetBigDecimalPoemTypeTest(String name) {
29      super(name);
30    }
31  
32    /**
33     * {@inheritDoc}
34     * @see org.melati.poem.test.SQLPoemTypeSpec#setObjectUnderTest()
35     */
36    void setObjectUnderTest() {
37      it = new BigDecimalPoemType(false, 22, 2);
38    }
39  
40    /**
41     * Test get total size. 
42     */
43    public void testGetTotalSize() {
44      assertEquals(24, ((BigDecimalPoemType)it).getTotalSize());
45    }
46    
47    /**
48     * Test full constructor. 
49     */
50    public void testWithPrecisionAndScale() {
51      BigDecimalPoemType itAlso = (BigDecimalPoemType)it;
52      assertEquals(it, itAlso.withPrecisionAndScale(itAlso.getPrecision(),itAlso.getScale()));
53      BigDecimalPoemType itClone = (BigDecimalPoemType) itAlso.withPrecisionAndScale(10,itAlso.getScale());
54      assertEquals(10, itClone.getPrecision());
55    }
56    /**
57     * Test method for {@link org.melati.poem.SQLType#quotedRaw(java.lang.Object)}.
58     */
59    public void testQuotedRaw() {
60      assertEquals(((SQLPoemType<BigDecimal>)it).sqlDefaultValue(getDb().getDbms()) , 
61          ((SQLPoemType<BigDecimal>)it).quotedRaw(((SQLPoemType<BigDecimal>)it).rawOfString(
62                  ((SQLPoemType<BigDecimal>)it).sqlDefaultValue(getDb().getDbms()))));
63  
64    }
65  
66    /**
67     * BigDecimals can represent Doubles.
68     */
69    public void testCanRepresentDoubles() { 
70      assertNull(it.canRepresent(DoublePoemType.it));
71      assertNotNull(it.canRepresent(new DoublePoemType(false)));
72    }
73    
74  }