root/trunk/test/unit/dbnp/studycapturing/AssayControllerTests.groovy @ 1559

Revision 1559, 1.9 KB (checked in by s.h.sikkema@…, 3 years ago)

Assay export functionality

  • Property svn:keywords set to Rev Author Date
RevLine 
[697]1package dbnp.studycapturing
2
3import grails.test.*
4
5/**
6 * AssayControllerTests Test
7 *
8 * @author  your email (+name?)
[1425]9 * @since       20101208
10 * @package     dbnp.studycapturing
[697]11 *
12 * Revision information:
13 * $Rev$
14 * $Author$
15 * $Date$
16 */
17class AssayControllerTests extends ControllerUnitTestCase {
18    protected void setUp() {
19        super.setUp()
[1445]20        mockDomain(Assay, [new Assay(id:1)])
[697]21    }
22
23    protected void tearDown() {
24        super.tearDown()
25    }
26
[1261]27    void testWrongAssayID() {
[1559]28        mockFlash.assayId = 3
[697]29
[1559]30        controller.compileExportData()
[1261]31
32        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
[1559]33        assertEquals 'Error message', 'No assay found with id: 3', mockFlash.errorMessage
[697]34    }
[1261]35
36    void testExceptionHandling() {
[1559]37        mockFlash.assayId = 1
[1445]38
39        controller.metaClass.'grailsApplication' = [
40                config: [modules: [metabolomics: [url: 'www.ab.com']]]
41        ]
42
[1425]43        controller.assayService = [
[1445]44
[1559]45                collectAssayData:               {a, b, c -> throw new Exception('msg1') },
46                convertColumnToRowStructure:    {a -> throw new Exception('msg2')},
47                exportRowWiseDataToExcelFile:   {a, b -> throw new Exception('msg3') }
[1445]48
[1425]49        ]
[1445]50
[1559]51        controller.compileExportData()
[1261]52
53        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
[1445]54        assertEquals 'Error message', 'msg1', mockFlash.errorMessage
[1261]55
[1559]56        controller.assayService.collectAssayData = {a, b, c -> true}
57        controller.compileExportData()
[1261]58
[1425]59        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
[1445]60        assertEquals 'Error message', 'msg2', mockFlash.errorMessage
[1261]61
[1559]62        controller.doExport()
63
64        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
65        assertEquals 'Error message', 'msg3', mockFlash.errorMessage
66
[1261]67    }
[1425]68
[697]69}
Note: See TracBrowser for help on using the browser.