source: trunk/test/unit/dbnp/studycapturing/AssayControllerTests.groovy @ 1559

Last change on this file since 1559 was 1559, checked in by s.h.sikkema@…, 12 years ago

Assay export functionality

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