Changeset 1445 for trunk/test


Ignore:
Timestamp:
Jan 27, 2011, 1:43:36 PM (10 years ago)
Author:
s.h.sikkema@…
Message:

Rudimentary assay export functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/dbnp/studycapturing/AssayControllerTests.groovy

    r1430 r1445  
    1818    protected void setUp() {
    1919        super.setUp()
     20        mockDomain(Assay, [new Assay(id:1)])
    2021    }
    2122
     
    2526
    2627    void testWrongAssayID() {
    27         mockParams.assayId = 1
     28        mockParams.assayId = 3
    2829
    2930        controller.exportAssayAsExcel()
     
    3435
    3536    void testExceptionHandling() {
     37        mockParams.assayId = 1
     38
     39        controller.metaClass.'grailsApplication' = [
     40                config: [modules: [metabolomics: [url: 'www.ab.com']]]
     41        ]
     42
    3643        controller.assayService = [
    37                 collectAssayData:{a, b -> throw new Exception('msg1')},
    38                 exportColumnWiseDataToExcelFile:{a, b -> throw new Exception('msg2')}
     44
     45                collectAssayData:                   {a, b -> def e = new Exception('msga'); e.metaClass.cause = new Exception('msg1'); throw e },
     46                exportColumnWiseDataToExcelFile:    {a, b -> def e = new Exception('msgb'); e.metaClass.cause = new Exception('msg2'); throw e }
     47
    3948        ]
     49
    4050        controller.exportAssayAsExcel()
    4151
    4252        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
    43         assertEquals 'Error message', 'java.lang.Exception: msg1', mockFlash.errorMessage
     53        assertEquals 'Error message', 'msg1', mockFlash.errorMessage
    4454
    4555        controller.assayService.collectAssayData = {a, b -> true}
     
    4757
    4858        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
    49         assertEquals 'Error message', 'java.lang.Exception: msg2', mockFlash.errorMessage
     59        assertEquals 'Error message', 'msg2', mockFlash.errorMessage
    5060
    5161    }
Note: See TracChangeset for help on using the changeset viewer.