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

Last change on this file since 1430 was 1430, checked in by work@…, 9 years ago
  • set keyword expansion
  • Property svn:keywords set to Rev Author Date
File size: 1.4 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: 1430 $
14 * $Author: work@osx.eu $
15 * $Date: 2011-01-21 20:05:36 +0000 (vr, 21 jan 2011) $
16 */
17class AssayControllerTests extends ControllerUnitTestCase {
18    protected void setUp() {
19        super.setUp()
20    }
21
22    protected void tearDown() {
23        super.tearDown()
24    }
25
26    void testWrongAssayID() {
27        mockParams.assayId = 1
28
29        controller.exportAssayAsExcel()
30
31        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
32        assertEquals 'Error message', 'No assay found with id: 3.', mockFlash.errorMessage
33    }
34
35    void testExceptionHandling() {
36        controller.assayService = [
37                collectAssayData:{a, b -> throw new Exception('msg1')},
38                exportColumnWiseDataToExcelFile:{a, b -> throw new Exception('msg2')}
39        ]
40        controller.exportAssayAsExcel()
41
42        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
43        assertEquals 'Error message', 'java.lang.Exception: msg1', mockFlash.errorMessage
44
45        controller.assayService.collectAssayData = {a, b -> true}
46        controller.exportAssayAsExcel()
47
48        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
49        assertEquals 'Error message', 'java.lang.Exception: msg2', mockFlash.errorMessage
50
51    }
52
53}
Note: See TracBrowser for help on using the repository browser.