source: branches/features/purchaseOrders/test/integration/CreateDataServiceTests.groovy @ 923

Last change on this file since 923 was 509, checked in by gav, 15 years ago

Some comments to CreateDataServiceTests.

File size: 2.9 KB
Line 
1import grails.test.*
2
3/**
4* Integration tests for CreateDataService.
5*/
6class CreateDataServiceTests extends GroovyTestCase {
7
8    // By default Grails will rollback the transaction after each test.
9    // Other tests may set this to false so be sure to assert-call-assert.
10    boolean transactional = true
11
12    def appConfigService
13    def createDataService
14
15    // Setup is called before each test.
16    protected void setUp() {
17        super.setUp()
18    }
19
20    // Tear down is called after each test.
21    protected void tearDown() {
22        super.tearDown()
23    }
24
25    void testBaseDataCreated() {
26
27        // Base data should have been created during bootstrap.
28        assertTrue appConfigService.exists("baseDataCreated")
29
30        // Some base data has indeed been created.
31        assert PersonGroupType.count() > 0
32
33    } // testBaseDataCreated()
34
35    void testCreateBaseData() {
36
37        // Base data has already been created in bootstrap,
38        // therefore simply running this will create a host of unique constraint errors
39        // if the method does not exit at the correct point and return false.
40        assertFalse createDataService.createBaseData()
41
42    } // testCreateBaseData()
43
44    void testCreateDemoData() {
45
46        def taskCount
47
48        // No demo tasks yet.
49        taskCount = Task.count()
50        assert taskCount == 0
51
52        // Base data has already been created in bootstrap so
53        // demo data creation should go forward.
54        assertTrue createDataService.createDemoData()
55
56        // Should now have some demo tasks.
57        taskCount = Task.count()
58        assert taskCount > 0
59
60        // Returns false since demo data has already been created.
61        assertFalse createDataService.createDemoData()
62
63        // Task count should not have changed.
64        assert Task.count() == taskCount
65
66    } // testCreateDemoData()
67
68    void testDemoDataCreationDisabled() {
69
70        def taskCount
71
72        // No demo tasks yet.
73        taskCount = Task.count()
74        assert taskCount == 0
75
76        appConfigService.set("demoDataCreationDisabled")
77
78        // False since demo data creation has disabled.
79        assertFalse createDataService.createDemoData()
80
81        // Still no demo tasks.
82        taskCount = Task.count()
83        assert taskCount == 0
84
85    } // testDemoDataCreationDisabled()
86
87    void testCreateDemoDataWithNoBaseData() {
88
89        def taskCount
90
91        // No demo tasks yet.
92        taskCount = Task.count()
93        assert taskCount == 0
94
95        // Base data has already been created in bootstrap so
96        // simulate base data not created.
97        assertTrue appConfigService.delete("baseDataCreated")
98
99        // Returns false since demo data creation has not been recorded.
100        assertFalse createDataService.createDemoData()
101
102        // Still no demo tasks.
103        taskCount = Task.count()
104        assert taskCount == 0
105
106    } // testCreateDemoDataWithNoBaseData()
107
108} // end class
Note: See TracBrowser for help on using the repository browser.