Ignore:
Timestamp:
Apr 28, 2010, 11:14:56 PM (14 years ago)
Author:
gav
Message:

Refactor TaskSearchService.getTasks() to use HQL and avoid bug in ticket #64, also extend associated tests.

File:
1 edited

Legend:

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

    r511 r512  
    7070
    7171        // Tasks in the trash should not be returned.
    72         tasks[0].trash = true
    73         tasks[0].save(flush:true)
     72        taskA.trash = true
     73        taskA.save(flush:true)
    7474        assert taskSearchService.getTasks([:]).totalCount == taskCount - 1
    75         tasks[1].trash = true
    76         tasks[1].save(flush:true)
     75        taskB.trash = true
     76        taskB.save(flush:true)
    7777        assert taskSearchService.getTasks([:]).totalCount == taskCount - 2
    7878
    7979        // Restored tasks should be returned.
    80         tasks[0].trash = false
    81         tasks[0].save(flush:true)
     80        taskA.trash = false
     81        taskA.save(flush:true)
    8282        assert taskSearchService.getTasks([:]).totalCount == taskCount - 1
    83         tasks[1].trash = false
    84         tasks[1].save(flush:true)
     83        taskB.trash = false
     84        taskB.save(flush:true)
    8585        assert taskSearchService.getTasks([:]).totalCount == taskCount
    8686
    8787        // Tomorrows tasks should not be returned.
    88         tasks[0].targetStartDate = dateUtilService.tomorrow
    89         tasks[0].targetCompletionDate = dateUtilService.tomorrow
    90         tasks[0].save(flush:true)
     88        taskA.targetStartDate = dateUtilService.tomorrow
     89        taskA.targetCompletionDate = dateUtilService.tomorrow
     90        taskA.save(flush:true)
    9191        assert taskSearchService.getTasks([:]).totalCount == taskCount - 1
    9292
     93        // Tomorrows tasks should be returned, if we ask for them.
     94        assert taskSearchService.getTasks([:], dateUtilService.today, dateUtilService.tomorrow+1).totalCount == taskCount
     95
    9396        // Yesterdays tasks should not be returned.
    94         tasks[0].targetStartDate = dateUtilService.yesterday
    95         tasks[0].targetCompletionDate = dateUtilService.yesterday
    96         tasks[0].save(flush:true)
     97        taskA.targetStartDate = dateUtilService.yesterday
     98        taskA.targetCompletionDate = dateUtilService.yesterday
     99        taskA.save(flush:true)
    97100        assert taskSearchService.getTasks([:]).totalCount == taskCount - 1
    98101
     102        // Yesterdays tasks should be returned, if we ask for them.
     103        assert taskSearchService.getTasks([:], dateUtilService.yesterday, dateUtilService.tomorrow).totalCount == taskCount
     104
    99105        // Tasks that span today should be returned.
    100         tasks[0].targetStartDate = dateUtilService.yesterday
    101         tasks[0].targetCompletionDate = dateUtilService.tomorrow
    102         tasks[0].save(flush:true)
     106        taskA.targetStartDate = dateUtilService.yesterday
     107        taskA.targetCompletionDate = dateUtilService.tomorrow
     108        taskA.save(flush:true)
    103109        assert taskSearchService.getTasks([:]).totalCount == taskCount
    104110    } // testGetTasks()
Note: See TracChangeset for help on using the changeset viewer.