Changeset 529 for trunk/test


Ignore:
Timestamp:
May 10, 2010, 8:30:25 AM (15 years ago)
Author:
gav
Message:

Tweak CreateDataService to prevent issues during testing.
Repair getBudgetTasks() search.
Complete testGetBudgetTasks() test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/integration/TaskSearchServiceTests.groovy

    r514 r529  
    121121    void testGetPersonsTasks() {
    122122
    123         def result
    124123        def p = [:]
     124        def params = [:]
    125125
    126126        // Todays tasks should be returned, since Person #1 is lead and created the tasks.
    127         def tasks = taskSearchService.getPersonsTasks([:])
     127        def tasks = taskSearchService.getPersonsTasks(params)
    128128        assert tasks.totalCount == taskCount
    129129
     
    131131        taskA.trash = true
    132132        taskA.save(flush:true)
    133         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
     133        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
    134134        taskB.trash = true
    135135        taskB.save(flush:true)
    136         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 2
     136        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 2
    137137
    138138        // Restored tasks should be returned.
    139139        taskA.trash = false
    140140        taskA.save(flush:true)
    141         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
     141        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
    142142        taskB.trash = false
    143143        taskB.save(flush:true)
    144         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount
     144        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount
    145145
    146146        // Tomorrows tasks should not be returned.
     
    148148        taskA.targetCompletionDate = dateUtilService.tomorrow
    149149        taskA.save(flush:true)
    150         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
     150        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
    151151
    152152        // Tomorrows tasks should be returned, if we ask for them.
    153         assert taskSearchService.getPersonsTasks([:], null, dateUtilService.today, dateUtilService.tomorrow+1).totalCount == taskCount
     153        assert taskSearchService.getPersonsTasks(params, null, dateUtilService.today, dateUtilService.tomorrow+1).totalCount == taskCount
    154154
    155155        // Yesterdays tasks should not be returned.
     
    157157        taskA.targetCompletionDate = dateUtilService.yesterday
    158158        taskA.save(flush:true)
    159         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
     159        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
    160160
    161161        // Yesterdays tasks should be returned, if we ask for them.
    162         assert taskSearchService.getPersonsTasks([:], null, dateUtilService.yesterday, dateUtilService.tomorrow).totalCount == taskCount
     162        assert taskSearchService.getPersonsTasks(params, null, dateUtilService.yesterday, dateUtilService.tomorrow).totalCount == taskCount
    163163
    164164        // Tasks that span today should be returned.
     
    166166        taskA.targetCompletionDate = dateUtilService.tomorrow
    167167        taskA.save(flush:true)
    168         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount
     168        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount
    169169
    170170        // Tasks for a different person should not be returned.
    171171        taskA.leadPerson = Person.get(2)
    172172        taskA.save(flush:true)
    173         assert taskSearchService.getPersonsTasks([:]).totalCount == taskCount - 1
     173        assert taskSearchService.getPersonsTasks(params).totalCount == taskCount - 1
    174174
    175175        // Tasks for a specified leadPerson should be returned.
     
    177177        taskA.leadPerson = Person.get(2)
    178178        taskA.save(flush:true)
    179         assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 0
     179        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0
    180180        taskA.approved = true
    181181        taskA.save(flush:true)
    182         assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 1
     182        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1
    183183        // Moving the task to the trash, stops it being returned.
    184184        taskA.trash = true
    185185        taskA.save(flush:true)
    186         assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 0
     186        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0
    187187
    188188        // Tasks assigned to a person should be returned.
     
    193193                estimatedMinute: 20]
    194194        assert assignedPersonService.save(p).error == null
    195         assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 0
     195        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 0
    196196        taskB.approved = true
    197197        taskB.save(flush:true)
    198         assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 1
     198        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1
    199199
    200200        // Tasks assigned to a person via a group should be returned.
     
    209209                estimatedMinute: 30]
    210210        assert assignedGroupService.save(p).error == null
    211         assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 1 // Only taskB from above.
     211        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 1 // Only taskB from above.
    212212        taskA.approved = true
    213213        taskA.save(flush:true)
    214         assert taskSearchService.getPersonsTasks([:], Person.get(2)).totalCount == 2 // taskA and taskB.
     214        assert taskSearchService.getPersonsTasks(params, Person.get(2)).totalCount == 2 // taskA and taskB.
    215215
    216216    } // testGetTasks()
    217217
     218    void testGetBudgetTasks() {
     219
     220        def tasks
     221        def params = [:]
     222        def today = dateUtilService.today
     223        def yesterday = dateUtilService.yesterday
     224        def tomorrow = dateUtilService.tomorrow
     225        def unplanned = TaskBudgetStatus.read(1)
     226        def planned = TaskBudgetStatus.read(2)
     227
     228        assert planned != null
     229        assert unplanned != null
     230
     231        // Default is to return planned.
     232        // TaskA and taskB should be unplanned and therefore not returned.
     233        tasks = taskSearchService.getBudgetTasks(params)
     234        assert tasks.totalCount == 0
     235        tasks = taskSearchService.getBudgetTasks(params, planned)
     236        assert tasks.totalCount == 0
     237
     238        tasks = taskSearchService.getBudgetTasks(params, unplanned)
     239        assert tasks.totalCount == taskCount
     240        assert tasks.contains(taskA)
     241        assert tasks.contains(taskB)
     242
     243        // Planned tasks are returned.
     244        taskA.taskBudgetStatus = planned
     245        taskA.save(flush:true)
     246        tasks = taskSearchService.getBudgetTasks(params, planned)
     247        assert tasks.totalCount == 1
     248        assert tasks.contains(taskA)
     249
     250        // Tasks are returned when dates and budget status are specified.
     251        tasks = taskSearchService.getBudgetTasks(params, planned, today, tomorrow)
     252        assert tasks.totalCount == 1
     253        assert tasks.contains(taskA)
     254        tasks = taskSearchService.getBudgetTasks(params, unplanned, today, tomorrow)
     255        assert tasks.totalCount == 1
     256        assert tasks.contains(taskB)
     257
     258        // No tasks for yesterday
     259        tasks = taskSearchService.getBudgetTasks(params, null, yesterday, today)
     260        assert tasks.totalCount == 0
     261
     262        // Tasks that span today are returned.
     263        taskA.targetStartDate = yesterday
     264        taskA.targetCompletionDate = tomorrow+2
     265        taskA.save(flush:true)
     266        tasks = taskSearchService.getBudgetTasks(params, planned, today, tomorrow)
     267        assert tasks.totalCount == 1
     268        assert tasks.contains(taskA)
     269
     270    } // testGetBudgetTasks()
     271
    218272} // end class
Note: See TracChangeset for help on using the changeset viewer.