我有一个名为getEmployeeSalary的方法的服务,我想进行单元测试,但我无法模拟和查询员工集合
private List getEmployeeSalary(String department, Date from){
def db = grailsApplication.mainContext.mongo.getDB(grailsApplication.config.grails.mongo.databaseName)
List employeeSalaryByDepartment = db.employee.aggregate([
[ '$match' : [ department: department,
dateCreated: ['$gte': from] ] ],
[
$group' : [
'_id': "\$department",
'sum': [ '$sum': "\$salary" ]
]
]
]).results()*.values()
return employeeSalaryByDepartment
}