Changeset 1424 for trunk/test


Ignore:
Timestamp:
Jan 21, 2011, 4:30:04 PM (10 years ago)
Author:
robert@…
Message:

Improved querying and created a possibility to search for assays

Location:
trunk/test
Files:
4 added
4 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/dbnp/query/SearchTests.groovy

    r1415 r1424  
    11package dbnp.query
    22
     3import dbnp.studycapturing.RelTime
     4import dbnp.studycapturing.TemplateFieldType;
    35import grails.test.*
    46
     
    2022    protected void setUp() {
    2123        super.setUp()
     24                mockLogging( Search );
    2225    }
    2326
     
    2629    }
    2730
    28     void testSomething() {
     31    void testPrepare() {
     32                // Test prepare method for dates
     33                Date d = Date.parse( "yyyy-MM-dd", "1982-10-21" );
     34                assert !d.equals( Search.prepare( "21-10-1982", TemplateFieldType.DATE ) )
     35                assert !d.equals( Search.prepare( "21-10-82", TemplateFieldType.DATE ) )
     36                assert d.equals( Search.prepare( "1982-10-21 00:00:00", TemplateFieldType.DATE ) )
     37                assert d.equals( Search.prepare( "1982-10-21", TemplateFieldType.DATE ) )
     38               
     39                // Test prepare method for RelTime
     40                assertEquals new RelTime( 0 ), Search.prepare( "", TemplateFieldType.RELTIME )
     41                assertEquals new RelTime( 3600 ), Search.prepare( "1h", TemplateFieldType.RELTIME )
     42                assertEquals new RelTime( 3600 ), Search.prepare( "60m", TemplateFieldType.RELTIME )
     43                assertEquals new RelTime( 3600 ), Search.prepare( "3600", TemplateFieldType.RELTIME )
     44                assertEquals "abc", Search.prepare( "abc", TemplateFieldType.RELTIME )
     45               
     46                // Test prepare method for Double
     47                assertEquals new Double( 100.1 ), Search.prepare( "100.1", TemplateFieldType.DOUBLE )
     48                assertEquals new Double( 0.0 ), Search.prepare( "0", TemplateFieldType.DOUBLE )
     49                assertEquals new Double( 100.0 ), Search.prepare( "100", TemplateFieldType.DOUBLE )
     50                assertEquals new Double( -100.1 ), Search.prepare( "-100.1", TemplateFieldType.DOUBLE )
     51               
     52                // Test prepare method for Long
     53                assertEquals new Long( 100 ), Search.prepare( "100", TemplateFieldType.LONG )
     54                assertEquals new Long( 0 ), Search.prepare( "0", TemplateFieldType.LONG )
     55                assertEquals new Long( -100 ), Search.prepare( "-100", TemplateFieldType.LONG )
     56                assertEquals "3.8", Search.prepare( "3.8", TemplateFieldType.LONG )     // Can't be parsed into long
     57                assertEquals "4.2", Search.prepare( "4.2", TemplateFieldType.LONG )     // Can't be parsed into long
     58               
     59                // Test prepare method for Boolean
     60                assertEquals Boolean.TRUE, Search.prepare( "true", TemplateFieldType.BOOLEAN )
     61                assertEquals Boolean.FALSE, Search.prepare( "false", TemplateFieldType.BOOLEAN )
     62                assertEquals Boolean.FALSE, Search.prepare( "", TemplateFieldType.BOOLEAN )
     63                assertEquals Boolean.FALSE, Search.prepare( "test", TemplateFieldType.BOOLEAN )
     64    }
    2965
    30     }
    3166}
Note: See TracChangeset for help on using the changeset viewer.