From 5932d2e347156cf3780bfe609a8bcddc20712596 Mon Sep 17 00:00:00 2001 From: Kingsley Hendrickse Date: Fri, 25 May 2012 15:50:12 +0100 Subject: [PATCH] fixed issue #6 --- cucumber-reports.iml | 2 +- pom.xml | 7 ++- .../net/masterthought/jenkins/Runner.java | 38 +++++++------- .../masterthought/jenkins/json/Feature.java | 52 +++++++++++++------ velocity.log | 28 ++++++++++ 5 files changed, 89 insertions(+), 38 deletions(-) create mode 100644 velocity.log diff --git a/cucumber-reports.iml b/cucumber-reports.iml index 838d5af..0280fb4 100644 --- a/cucumber-reports.iml +++ b/cucumber-reports.iml @@ -40,6 +40,7 @@ + @@ -61,7 +62,6 @@ - diff --git a/pom.xml b/pom.xml index 5e296b4..37b46fd 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ net.masterthought.jenkins cucumber-reports - 0.0.9 + 0.0.10 hpi @@ -54,5 +54,10 @@ joda-time 2.1 + + com.google.guava + guava + r09 + diff --git a/src/main/java/net/masterthought/jenkins/Runner.java b/src/main/java/net/masterthought/jenkins/Runner.java index 14da779..41368a0 100644 --- a/src/main/java/net/masterthought/jenkins/Runner.java +++ b/src/main/java/net/masterthought/jenkins/Runner.java @@ -1,23 +1,23 @@ -//package net.masterthought.jenkins; -// -// -//import java.io.File; -//import java.util.ArrayList; -//import java.util.List; -// -//public class Runner { -// -// public static void main(String[] args) throws Exception { -// File rd = new File("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports"); -// List list = new ArrayList(); +package net.masterthought.jenkins; + + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class Runner { + + public static void main(String[] args) throws Exception { + File rd = new File("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports"); + List list = new ArrayList(); // list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/french.json"); // list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/co_cucumber.json"); // list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/ccp_cucumber.json"); // list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/ss_cucumber.json"); -// list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/local.json"); -// -// FeatureReportGenerator featureReportGenerator = new FeatureReportGenerator(list,rd,"","15","aaaaa"); -// featureReportGenerator.generateReports(); -// -// } -//} + list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/local.json"); + + FeatureReportGenerator featureReportGenerator = new FeatureReportGenerator(list,rd,"","15","aaaaa"); + featureReportGenerator.generateReports(); + + } +} diff --git a/src/main/java/net/masterthought/jenkins/json/Feature.java b/src/main/java/net/masterthought/jenkins/json/Feature.java index 7659144..954269c 100644 --- a/src/main/java/net/masterthought/jenkins/json/Feature.java +++ b/src/main/java/net/masterthought/jenkins/json/Feature.java @@ -1,6 +1,10 @@ package net.masterthought.jenkins.json; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; import org.apache.commons.lang.StringUtils; +import org.apache.tools.ant.util.regexp.Regexp; +import org.joda.time.DateTime; import java.util.ArrayList; import java.util.List; @@ -25,14 +29,14 @@ public class Feature { return elements; } - public boolean hasTags(){ + public boolean hasTags() { return Util.itemExists(tags); } - - public List getTagList(){ + + public List getTagList() { List tagList = new ArrayList(); - for(Tag tag : tags){ - tagList.add(tag.getName()); + for (Tag tag : tags) { + tagList.add(tag.getName()); } return tagList; } @@ -45,7 +49,7 @@ public class Feature { } return result; } - + public Util.Status getStatus() { Closure scenarioStatus = new Closure() { public Util.Status call(Element step) { @@ -58,9 +62,9 @@ public class Feature { private List lookUpSteps() { List stepStatuses = new ArrayList(); - for(Element element : elements){ - for(Step step : element.getSteps()){ - stepStatuses.add(step.getStatus()); + for (Element element : elements) { + for (Step step : element.getSteps()) { + stepStatuses.add(step.getStatus()); } } return stepStatuses; @@ -86,9 +90,18 @@ public class Feature { return result; } - public String getFileName() { - return uri.replaceAll("/", "-").replaceAll("\\\\", "-") + ".html"; - } + public String getFileName() { + List matches = new ArrayList(); + for (String line : Splitter.onPattern("/|\\\\").split(uri)) { + String modified = line.replaceAll("\\)|\\(",""); + modified = StringUtils.deleteWhitespace(modified).trim(); + matches.add(modified); + } + + matches = matches.subList(1,matches.size()); + String fileName = Joiner.on("-").join(matches) + ".html"; + return fileName; + } public int getNumberOfScenarios() { return elements.length; @@ -113,17 +126,22 @@ public class Feature { public String getRawStatus() { return getStatus().toString().toLowerCase(); } - - public String getDurationOfSteps(){ + + public String getDurationOfSteps() { Long totalDuration = 0L; - for(Element element : elements){ - for(Step step : element.getSteps()){ - totalDuration = totalDuration + step.getDuration(); + for (Element element : elements) { + for (Step step : element.getSteps()) { + totalDuration = totalDuration + step.getDuration(); } } return Util.formatDuration(totalDuration); } + private String getTimestamp() { + DateTime dateTime = new DateTime(); + return dateTime.getYear() + "" + dateTime.getMonthOfYear() + "" + dateTime.getDayOfMonth() + "" + dateTime.getHourOfDay() + "" + dateTime.getMinuteOfHour() + "" + dateTime.getSecondOfMinute() + "" + dateTime.getMillis(); + } + } diff --git a/velocity.log b/velocity.log new file mode 100644 index 0000000..fc41171 --- /dev/null +++ b/velocity.log @@ -0,0 +1,28 @@ +Fri May 25 15:35:24 BST 2012 [debug] AvalonLogChute initialized using file 'velocity.log' +Fri May 25 15:35:24 BST 2012 [trace] ******************************************************************* +Fri May 25 15:35:24 BST 2012 [debug] Starting Jakarta Velocity v1.5-SNAPSHOT (compiled: 2006-07-21 06:25:35) +Fri May 25 15:35:24 BST 2012 [trace] RuntimeInstance initializing. +Fri May 25 15:35:24 BST 2012 [debug] Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties +Fri May 25 15:35:24 BST 2012 [debug] Trying to use logger class org.apache.velocity.runtime.log.AvalonLogChute +Fri May 25 15:35:24 BST 2012 [debug] Using logger class org.apache.velocity.runtime.log.AvalonLogChute +Fri May 25 15:35:24 BST 2012 [debug] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl) +Fri May 25 15:35:24 BST 2012 [debug] ResourceLoader instantiated: org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader +Fri May 25 15:35:24 BST 2012 [trace] ClasspathResourceLoader : initialization complete. +Fri May 25 15:35:24 BST 2012 [debug] ResourceCache: initialized (class org.apache.velocity.runtime.resource.ResourceCacheImpl) +Fri May 25 15:35:24 BST 2012 [trace] Default ResourceManager initialization complete. +Fri May 25 15:35:24 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Literal +Fri May 25 15:35:24 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Macro +Fri May 25 15:35:24 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Parse +Fri May 25 15:35:24 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Include +Fri May 25 15:35:24 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach +Fri May 25 15:35:24 BST 2012 [debug] Created '20' parsers. +Fri May 25 15:35:24 BST 2012 [trace] Velocimacro : initialization starting. +Fri May 25 15:35:24 BST 2012 [debug] Velocimacro : "velocimacro.library" is not set. Trying default library: VM_global_library.vm +Fri May 25 15:35:24 BST 2012 [debug] Velocimacro : Default library not found. +Fri May 25 15:35:24 BST 2012 [debug] Velocimacro : allowInline = true : VMs can be defined inline in templates +Fri May 25 15:35:24 BST 2012 [debug] Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions +Fri May 25 15:35:24 BST 2012 [debug] Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed. +Fri May 25 15:35:24 BST 2012 [debug] Velocimacro : autoload off : VM system will not automatically reload global library macros +Fri May 25 15:35:24 BST 2012 [trace] Velocimacro : initialization complete. +Fri May 25 15:35:24 BST 2012 [trace] RuntimeInstance successfully initialized. +Fri May 25 15:35:24 BST 2012 [debug] ResourceManager : found templates/tagOverview.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader