Skip to content

Commit

Permalink
Merge pull request #163 from trivago/remove-cloner-dependency
Browse files Browse the repository at this point in the history
Remove cloner dependency
  • Loading branch information
Benjamin Bischoff authored May 21, 2019
2 parents 7a04db7 + e13a89a commit 38a3cd1
Show file tree
Hide file tree
Showing 21 changed files with 118 additions and 105 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

Back to [Readme](README.md).

## [1.11.0] - 2019-05-21

### Fixed

* Much higher report generation speed
* Warnings in Java > 8
* Various small code style issues

### Changed

* Updated all dependencies

### Removed

* Cloner dependency
* JSoup dependency

## [1.10.2] - 2019-04-29

### Changed
Expand Down Expand Up @@ -441,6 +458,7 @@ steps with status `pending` or `undefined` (default value is `false`) (#74)

Initial project version on GitHub and Maven Central.

[1.11.0]: https://github.com/trivago/cluecumber-report-plugin/tree/1.11.0
[1.10.2]: https://github.com/trivago/cluecumber-report-plugin/tree/1.10.2
[1.10.1]: https://github.com/trivago/cluecumber-report-plugin/tree/1.10.1
[1.10.0]: https://github.com/trivago/cluecumber-report-plugin/tree/1.10.0
Expand Down
2 changes: 1 addition & 1 deletion example-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>de.benjamin-bischoff</groupId>
<artifactId>cluecumber-test-project</artifactId>
<version>1.10.2</version>
<version>1.11.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
20 changes: 3 additions & 17 deletions plugin-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.trivago.rta</groupId>
<artifactId>cluecumber-report-plugin</artifactId>
<version>1.10.2</version>
<version>1.11.0</version>
<url>https://github.com/trivago/cluecumber-report-plugin</url>

<name>Cluecumber Maven Plugin for Cucumber Reports</name>
Expand Down Expand Up @@ -65,7 +65,7 @@
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<maven.compile.encoding>UTF-8</maven.compile.encoding>

<maven.version>3.6.0</maven.version>
<maven.version>3.6.1</maven.version>
<maven.gpg.plugin.version>1.6</maven.gpg.plugin.version>
<nexus.staging.maven.plugin.version>1.6.8</nexus.staging.maven.plugin.version>
<maven.plugin.plugin.version>3.4</maven.plugin.plugin.version>
Expand All @@ -81,15 +81,13 @@
<maven.source.plugin.version>2.4</maven.source.plugin.version>
<plexus.utilities.version>3.2.0</plexus.utilities.version>

<mockito.version>2.25.1</mockito.version>
<mockito.version>2.27.0</mockito.version>
<junit5.vintage.version>5.5.0-M1</junit5.vintage.version>
<openpojo.version>0.8.12</openpojo.version>

<gson.version>2.8.5</gson.version>
<gsonfire.version>1.9.0-alpha1</gsonfire.version>
<freemarker.version>2.3.28</freemarker.version>
<jsoup.version>1.11.3</jsoup.version>
<cloning.version>1.9.12</cloning.version>
</properties>

<profiles>
Expand Down Expand Up @@ -242,18 +240,6 @@
<version>${plexus.utilities.version}</version>
</dependency>

<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>${jsoup.version}</version>
</dependency>

<dependency>
<groupId>uk.com.robust-it</groupId>
<artifactId>cloning</artifactId>
<version>${cloning.version}</version>
</dependency>

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class PluginSettings {
public final static String STEP_SUMMARY_TEMPLATE = "step-summary";
public final static String STEP_SUMMARY_PAGE_PATH = "step-summary";
public static final String STEP_SCENARIO_PAGE_PATH = "step-scenarios";
public static final String STEP_SCENARIO_PAGE_FRAGMENT = "/" + STEP_SCENARIO_PAGE_PATH + "/step_";;
public static final String STEP_SCENARIO_PAGE_FRAGMENT = "/" + STEP_SCENARIO_PAGE_PATH + "/step_";

public final static String FEATURE_SUMMARY_PAGE_NAME = "Feature Summary";
public final static String FEATURE_SUMMARY_TEMPLATE = "feature-summary";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,7 @@ public String returnTotalDurationString() {
}

public boolean hasHooks() {
if (getBefore().size() > 0 || getAfter().size() > 0) {
return true;
}
return false;
return getBefore().size() > 0 || getAfter().size() > 0;
}

public boolean hasDocStrings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.ArrayList;
import java.util.List;

public class Report {
public class Report implements Cloneable {
private int line;
private List<Element> elements = new ArrayList<>();
private String name = "";
Expand Down Expand Up @@ -110,4 +110,9 @@ public long getTotalDuration() {
}
return totalDurationNanoseconds;
}

@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.trivago.cluecumber.rendering;

import org.jsoup.Jsoup;

import java.time.Duration;
import java.time.ZoneId;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -53,16 +51,6 @@ public static long convertNanosecondsToMilliseconds(final long nanoseconds) {
return nanoseconds / MICROSECOND_FACTOR;
}

/**
* Returns prettified HTML
*
* @param html The source html.
* @return The prettified HTML.
*/
static String prettifyHtml(String html) {
return Jsoup.parse(html).toString().trim();
}

/**
* Return the current Cluecumber version.
*
Expand Down Expand Up @@ -128,7 +116,6 @@ public static ZonedDateTime convertTimestampToZonedDateTime(final String timesta
}
}


public static String convertZonedDateTimeToDateString(final ZonedDateTime startDateTime) {
try {
return startDateTime.withZoneSameInstant(ZoneId.systemDefault()).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import javax.inject.Singleton;

@Singleton
public class TemplateEngine {
class TemplateEngine {
private final TemplateConfiguration templateConfiguration;
private final AllFeaturesPageRenderer allFeaturesPageRenderer;
private final AllTagsPageRenderer allTagsPageRenderer;
Expand All @@ -45,7 +45,7 @@ public class TemplateEngine {
private final AllScenariosPageRenderer allScenariosPageRenderer;

@Inject
public TemplateEngine(
TemplateEngine(
final TemplateConfiguration templateConfiguration,
final AllFeaturesPageRenderer allFeaturesPageRenderer,
final AllTagsPageRenderer allTagsPageRenderer,
Expand All @@ -64,77 +64,77 @@ public TemplateEngine(
}

String getRenderedScenarioSummaryPageContent(final AllScenariosPageCollection allScenariosPageCollection) throws CluecumberPluginException {
return RenderingUtils.prettifyHtml(allScenariosPageRenderer.getRenderedContent(
return allScenariosPageRenderer.getRenderedContent(
allScenariosPageCollection,
templateConfiguration.getTemplate(PluginSettings.SCENARIO_SUMMARY_TEMPLATE)
));
);
}

String getRenderedScenarioSequencePageContent(final AllScenariosPageCollection allScenariosPageCollection) throws CluecumberPluginException {
return RenderingUtils.prettifyHtml(allScenariosPageRenderer.getRenderedContent(
return allScenariosPageRenderer.getRenderedContent(
allScenariosPageCollection,
templateConfiguration.getTemplate(PluginSettings.SCENARIO_SEQUENCE_TEMPLATE)
));
);
}

String getRenderedScenarioSummaryPageContentByTagFilter(
final AllScenariosPageCollection allScenariosPageCollection,
final Tag tag) throws CluecumberPluginException {

return RenderingUtils.prettifyHtml(allScenariosPageRenderer.getRenderedContentByTagFilter(
return allScenariosPageRenderer.getRenderedContentByTagFilter(
allScenariosPageCollection,
templateConfiguration.getTemplate(PluginSettings.SCENARIO_SUMMARY_TEMPLATE),
tag
));
);
}

String getRenderedScenarioSummaryPageContentByStepFilter(
final AllScenariosPageCollection allScenariosPageCollection,
final Step step) throws CluecumberPluginException {

return RenderingUtils.prettifyHtml(allScenariosPageRenderer.getRenderedContentByStepFilter(
return allScenariosPageRenderer.getRenderedContentByStepFilter(
allScenariosPageCollection,
templateConfiguration.getTemplate(PluginSettings.SCENARIO_SUMMARY_TEMPLATE),
step
));
);
}

String getRenderedScenarioSummaryPageContentByFeatureFilter(
final AllScenariosPageCollection allScenariosPageCollection,
final Feature feature) throws CluecumberPluginException {

return RenderingUtils.prettifyHtml(allScenariosPageRenderer.getRenderedContentByFeatureFilter(
return allScenariosPageRenderer.getRenderedContentByFeatureFilter(
allScenariosPageCollection,
templateConfiguration.getTemplate(PluginSettings.SCENARIO_SUMMARY_TEMPLATE),
feature
));
);
}

String getRenderedScenarioDetailPageContent(final ScenarioDetailsPageCollection scenarioDetailsPageCollection) throws CluecumberPluginException {
return RenderingUtils.prettifyHtml(scenarioDetailsPageRenderer.getRenderedContent(
return scenarioDetailsPageRenderer.getRenderedContent(
scenarioDetailsPageCollection,
templateConfiguration.getTemplate(PluginSettings.SCENARIO_DETAIL_TEMPLATE)
));
);
}

String getRenderedTagSummaryPageContent(final AllTagsPageCollection allTagsPageCollection) throws CluecumberPluginException {
return RenderingUtils.prettifyHtml(allTagsPageRenderer.getRenderedContent(
return allTagsPageRenderer.getRenderedContent(
allTagsPageCollection,
templateConfiguration.getTemplate(PluginSettings.TAG_SUMMARY_TEMPLATE)
));
);
}

String getRenderedStepSummaryPageContent(final AllStepsPageCollection allStepsPageCollection) throws CluecumberPluginException {
return RenderingUtils.prettifyHtml(allStepsPageRenderer.getRenderedContent(
return allStepsPageRenderer.getRenderedContent(
allStepsPageCollection,
templateConfiguration.getTemplate(PluginSettings.STEP_SUMMARY_TEMPLATE)
));
);
}

String getRenderedFeatureSummaryPageContent(final AllFeaturesPageCollection allFeaturesPageCollection) throws CluecumberPluginException {
return RenderingUtils.prettifyHtml(allFeaturesPageRenderer.getRenderedContent(
return allFeaturesPageRenderer.getRenderedContent(
allFeaturesPageCollection,
templateConfiguration.getTemplate(PluginSettings.FEATURE_SUMMARY_TEMPLATE)
));
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Arrays;
import java.util.List;

public class AllScenariosPageCollection extends PageCollection {
public class AllScenariosPageCollection extends PageCollection implements Cloneable {
private List<Report> reports = new ArrayList<>();
private List<CustomParameter> customParameters;
private Tag tagFilter;
Expand All @@ -55,7 +55,11 @@ public void addReports(final Report[] reportList) {
if (reportList == null) {
return;
}
this.reports.addAll(Arrays.asList(reportList));
addReports(Arrays.asList(reportList));
}

public void addReports(final List<Report> reportList) {
this.reports.addAll(reportList);
}

public int getTotalNumberOfScenarios() {
Expand Down Expand Up @@ -198,4 +202,19 @@ public Step getStepFilter() {
public void setStepFilter(final Step stepFilter) {
this.stepFilter = stepFilter;
}

@Override
public Object clone() throws CloneNotSupportedException {
final AllScenariosPageCollection clone = (AllScenariosPageCollection) super.clone();
clone.setFeatureFilter(null);
clone.setStepFilter(null);
clone.setTagFilter(null);
clone.clearReports();
List<Report> clonedReports = new ArrayList<>();
for (Report r : getReports()) {
clonedReports.add((Report) r.clone());
}
clone.addReports(clonedReports);
return clone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,4 @@ public boolean isExpandDocStrings() {
public void setExpandDocStrings(final boolean expandDocStrings) {
this.expandDocStrings = expandDocStrings;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ private void addChartJsonToReportDetails(final AllFeaturesPageCollection allFeat
data.setLabels(keys);

Options options = new Options();

Scales scales = new Scales();
List<Axis> xAxes = new ArrayList<>();
Axis xAxis = new Axis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.trivago.cluecumber.rendering.pages.renderers;

import com.rits.cloning.Cloner;
import com.trivago.cluecumber.constants.ChartColor;
import com.trivago.cluecumber.constants.ChartType;
import com.trivago.cluecumber.constants.Status;
Expand Down Expand Up @@ -45,22 +44,21 @@
public class AllScenariosPageRenderer extends PageRenderer {

private final PropertyManager propertyManager;
private final Cloner cloner;

@Inject
public AllScenariosPageRenderer(final ChartJsonConverter chartJsonConverter, PropertyManager propertyManager) {
AllScenariosPageRenderer(final ChartJsonConverter chartJsonConverter, PropertyManager propertyManager) {
super(chartJsonConverter);
this.propertyManager = propertyManager;
cloner = new Cloner();
}

public String getRenderedContent(
final AllScenariosPageCollection allScenariosPageCollection, final Template template)
throws CluecumberPluginException {

addChartJsonToReportDetails(allScenariosPageCollection);
addCustomParametersToReportDetails(allScenariosPageCollection);
return processedContent(template, allScenariosPageCollection);
AllScenariosPageCollection allScenariosPageCollectionClone = getAllScenariosPageCollectionClone(allScenariosPageCollection);
addChartJsonToReportDetails(allScenariosPageCollectionClone);
addCustomParametersToReportDetails(allScenariosPageCollectionClone);
return processedContent(template, allScenariosPageCollectionClone);
}

public String getRenderedContentByTagFilter(
Expand Down Expand Up @@ -124,7 +122,6 @@ public String getRenderedContentByFeatureFilter(
}

private void addChartJsonToReportDetails(final AllScenariosPageCollection allScenariosPageCollection) {

Chart chart = new Chart();
Data data = new Data();

Expand Down Expand Up @@ -177,7 +174,14 @@ private void addCustomParametersToReportDetails(final AllScenariosPageCollection
allScenariosPageCollection.setCustomParameters(customParameters);
}

private AllScenariosPageCollection getAllScenariosPageCollectionClone(final AllScenariosPageCollection allScenariosPageCollection) {
return cloner.deepClone(allScenariosPageCollection);
private AllScenariosPageCollection getAllScenariosPageCollectionClone(
final AllScenariosPageCollection allScenariosPageCollection) throws CluecumberPluginException {
AllScenariosPageCollection clone;
try {
clone = (AllScenariosPageCollection) allScenariosPageCollection.clone();
} catch (CloneNotSupportedException e) {
throw new CluecumberPluginException("Clone of AllScenariosPageCollection not supported: " + e.getMessage());
}
return clone;
}
}
Loading

0 comments on commit 38a3cd1

Please sign in to comment.