I have a service with a method called getEmployeeSalary that i want to unit test but i can not mock and query the employee collections
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
}
Aucun commentaire:
Enregistrer un commentaire