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

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

Using moduleCommunicationService now to fetch measurement data from module

  • Property svn:keywords set to Rev Author Date
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$
14 * $Author$
15 * $Date$
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        mockParams.assayId = 3
29
30        controller.exportAssayAsExcel()
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        mockParams.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 -> throw new Exception('msg1') },
46                exportColumnWiseDataToExcelFile:    {a, b -> throw new Exception('msg2') }
47
48        ]
49
50        controller.exportAssayAsExcel()
51
52        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
53        assertEquals 'Error message', 'msg1', mockFlash.errorMessage
54
55        controller.assayService.collectAssayData = {a, b -> true}
56        controller.exportAssayAsExcel()
57
58        assertEquals 'Redirected action should match', [action: 'selectAssay'], redirectArgs
59        assertEquals 'Error message', 'msg2', mockFlash.errorMessage
60
61    }
62
63}
Note: See TracBrowser for help on using the browser.