porscheinformatik / cucumber-report-db

Stores results of BDD tests with Cucumber-JVM in a database and provides reporting capabilities
18 stars 21 forks source link

Error getting ranking and charts if collection has empty items #27

Closed maxtar closed 9 years ago

maxtar commented 9 years ago

I've found following exception in this case:

10:40:49.211 [http-nio-8080-exec-1] WARN  o.s.data.mongodb.core.MongoTemplate - Command execution of { "mapreduce" : "Product_Version" , "map" : "function() {this.features.forEach(function(feature) { \n\tfeature.scenario
s.forEach(function(scenario) {\n\t\tscenario.steps.forEach(function(step) {\n\t\t\tif (step.result.status===\"failed\" || step.result.status===\"passed\" ){\n\t\t\t\temit(step.name, step.result.duration);\n\t\t\t}\n\t\t})\n\t})\n})}" , "
reduce" : "function(key, values) { return Math.max.apply(Math, values); }\n" , "verbose" : true , "out" : { "inline" : 1}} failed: exception: TypeError: Cannot call method 'forEach' of undefined
    at _funcs1:2:20
    at Array.forEach (native)
    at _funcs1 (_funcs1:1:37) near 'scenarios.forEach(function(scenario) '  (line 2)
10:40:49.218 [http-nio-8080-exec-1] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework
.dao.InvalidDataAccessApiUsageException: Command execution failed:  Error [exception: TypeError: Cannot call method 'forEach' of undefined
    at _funcs1:2:20
    at Array.forEach (native)
    at _funcs1 (_funcs1:1:37) near 'scenarios.forEach(function(scenario) '  (line 2)], Command = { "mapreduce" : "Product_Version" , "map" : "function() {this.features.forEach(function(feature) { \n\tfeature.scenarios.fo
rEach(function(scenario) {\n\t\tscenario.steps.forEach(function(step) {\n\t\t\tif (step.result.status===\"failed\" || step.result.status===\"passed\" ){\n\t\t\t\temit(step.name, step.result.duration);\n\t\t\t}\n\t\t})\n\t})\n})}" , "redu
ce" : "function(key, values) { return Math.max.apply(Math, values); }\n" , "verbose" : true , "out" : { "inline" : 1}}; nested exception is com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "errmsg" : "exception:
TypeError: Cannot call method 'forEach' of undefined\n    at _funcs1:2:20\n    at Array.forEach (native)\n    at _funcs1 (_funcs1:1:37) near 'scenarios.forEach(function(scenario) '  (line 2)" , "code" : 16722 , "ok" : 0.0}] with root cau
se
com.mongodb.CommandFailureException: { "serverUsed" : "localhost:27017" , "errmsg" : "exception: TypeError: Cannot call method 'forEach' of undefined\n    at _funcs1:2:20\n    at Array.forEach (native)\n    at _funcs1 (_funcs1:1:37) near
 'scenarios.forEach(function(scenario) '  (line 2)" , "code" : 16722 , "ok" : 0.0}
        at com.mongodb.CommandResult.getException(CommandResult.java:76) ~[mongo-java-driver-2.12.2.jar!/:na]
        at com.mongodb.CommandResult.throwOnError(CommandResult.java:131) ~[mongo-java-driver-2.12.2.jar!/:na]
        at org.springframework.data.mongodb.core.MongoTemplate.handleCommandError(MongoTemplate.java:1932) ~[spring-data-mongodb-1.5.1.RELEASE.jar!/:na]
        at org.springframework.data.mongodb.core.MongoTemplate.mapReduce(MongoTemplate.java:1250) ~[spring-data-mongodb-1.5.1.RELEASE.jar!/:na]
        at org.springframework.data.mongodb.core.MongoTemplate.mapReduce(MongoTemplate.java:1217) ~[spring-data-mongodb-1.5.1.RELEASE.jar!/:na]
        at at.porscheinformatik.cucumber.mongodb.rest.controller.StatisticsController.mapReduce(StatisticsController.java:78) ~[cucumber-mongodb-rest-1.1.0.RC16-SNAPSHOT.jar!/:na]
        at at.porscheinformatik.cucumber.mongodb.rest.controller.StatisticsController.findHighestSingleStepDuration(StatisticsController.java:53) ~[cucumber-mongodb-rest-1.1.0.RC16-SNAPSHOT.jar!/:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_45]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_45]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_45]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_45]
        at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215) ~[spring-web-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132) ~[spring-web-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:668) ~[javax.servlet-api-3.0.1.jar!/:3.0.1]
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837) ~[spring-webmvc-4.0.6.RELEASE.jar!/:4.0.6.RELEASE]
klausbayrhammer commented 9 years ago

I've deployed the fix to heroku and added a test-run with a feature-file without scenarios

maxtar commented 9 years ago

Thanx, work!