notFailingStatuses) {
* @param jsonFileName JSON file name - without the extension
* @param qualifier Qualifier to use
*/
- public void setQualifier(@NonNull String jsonFileName, @NonNull String qualifier) {
+ public void setQualifier(String jsonFileName, String qualifier) {
qualifiers.put(jsonFileName, qualifier);
}
@@ -341,7 +340,7 @@ public void setQualifier(@NonNull String jsonFileName, @NonNull String qualifier
* @param jsonFileName JSON file name - without the extension
* @return Qualifier specified for this file or null
if none specified
*/
- public String getQualifier(@NonNull String jsonFileName) {
+ public String getQualifier(String jsonFileName) {
return qualifiers.get(jsonFileName);
}
@@ -351,7 +350,7 @@ public String getQualifier(@NonNull String jsonFileName) {
* @param jsonFileName JSON file name - without the extension
* @return true
if the qualifier was specified, false
otherwise
*/
- public boolean containsQualifier(@NonNull String jsonFileName) {
+ public boolean containsQualifier(String jsonFileName) {
return qualifiers.containsKey(jsonFileName);
}
@@ -360,7 +359,7 @@ public boolean containsQualifier(@NonNull String jsonFileName) {
*
* @param jsonFileName JSON file name - without the extension
*/
- public void removeQualifier(@NonNull String jsonFileName) {
+ public void removeQualifier(String jsonFileName) {
qualifiers.remove(jsonFileName);
}
diff --git a/src/main/java/net/masterthought/cucumber/reducers/ReportFeatureWithRetestMerger.java b/src/main/java/net/masterthought/cucumber/reducers/ReportFeatureWithRetestMerger.java
index 5a90ba1e9..fe07d86b2 100644
--- a/src/main/java/net/masterthought/cucumber/reducers/ReportFeatureWithRetestMerger.java
+++ b/src/main/java/net/masterthought/cucumber/reducers/ReportFeatureWithRetestMerger.java
@@ -1,25 +1,24 @@
package net.masterthought.cucumber.reducers;
-import net.masterthought.cucumber.json.Element;
-import net.masterthought.cucumber.json.Feature;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import static com.google.common.base.Preconditions.checkArgument;
+import net.masterthought.cucumber.json.Element;
+import net.masterthought.cucumber.json.Feature;
/**
* Merge list of given features. If there are couple of scenarios with the same Id then
* only the latest will be stored into the report.
- *
+ *
* Uses when need to generate a report with rerun results of failed tests.
*/
final class ReportFeatureWithRetestMerger implements ReportFeatureMerger {
private static final String ERROR = "You are not able to use this type of results merge. The start_timestamp field" +
" should be part of element object. Please, update the cucumber-jvm version.";
+
private static final ElementComparator ELEMENT_COMPARATOR = new ElementComparator();
@Override
@@ -29,8 +28,7 @@ public List merge(List features) {
Feature mergedFeature = mergedFeatures.get(candidate.getId());
if (mergedFeature == null) {
mergedFeatures.put(candidate.getId(), candidate);
- }
- else {
+ } else {
updateElements(mergedFeatures.get(candidate.getId()), candidate.getElements());
}
}
@@ -44,24 +42,25 @@ public List merge(List features) {
*
* @param feature - target object of Feature class.
* @param elements - list of elements which need to be inserted to the @feature with replacing
- * or adding to the end.
+ * or adding to the end.
*/
void updateElements(Feature feature, Element[] elements) {
for (int i = 0; i < elements.length; i++) {
Element current = elements[i];
if (current.isScenario()) {
- checkArgument(current.getStartTime() != null, ERROR);
+ if (current.getStartTime() == null) {
+ throw new IllegalArgumentException(ERROR);
+ }
int indexOfPreviousResult = find(feature.getElements(), current);
boolean hasBackground = isBackground(i - 1, elements);
if (indexOfPreviousResult < 0) {
feature.addElements(
hasBackground ?
- new Element[] {elements[i - 1], current} :
- new Element[] {current}
- );
- }
- else {
+ new Element[]{elements[i - 1], current} :
+ new Element[]{current}
+ );
+ } else {
if (replaceIfExists(feature.getElements()[indexOfPreviousResult], current)) {
feature.getElements()[indexOfPreviousResult] = current;
if (hasBackground && isBackground(indexOfPreviousResult - 1, feature.getElements())) {
diff --git a/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java b/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java
index 5f20d160d..1fff9618b 100644
--- a/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java
+++ b/src/test/java/net/masterthought/cucumber/ReportBuilderTest.java
@@ -18,7 +18,6 @@
import net.masterthought.cucumber.json.Feature;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.WildcardFileFilter;
-import org.apache.commons.io.filefilter.WildcardFileFilter.Builder;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.powermock.reflect.Whitebox;
@@ -222,8 +221,8 @@ void copyCustomResources_OnDirAsFile_ThrowsIOException() throws Exception {
File dir = new File("src/test/resources/js");
// when & then
- assertThatThrownBy(() -> Whitebox.invokeMethod(builder, "copyCustomResources", "js", dir))
- .isInstanceOf(ValidationException.class);
+ assertThatThrownBy(() -> Whitebox.invokeMethod(builder, "copyCustomResources", "js", dir))
+ .isInstanceOf(ValidationException.class);
}
@Test
diff --git a/src/test/java/net/masterthought/cucumber/generators/EscapeHtmlReferenceTest.java b/src/test/java/net/masterthought/cucumber/generators/EscapeHtmlReferenceTest.java
index 915741209..3586afe5f 100644
--- a/src/test/java/net/masterthought/cucumber/generators/EscapeHtmlReferenceTest.java
+++ b/src/test/java/net/masterthought/cucumber/generators/EscapeHtmlReferenceTest.java
@@ -1,11 +1,11 @@
package net.masterthought.cucumber.generators;
-import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
-import org.junit.jupiter.api.Test;
-
import static org.apache.commons.text.StringEscapeUtils.escapeHtml4;
import static org.assertj.core.api.Assertions.assertThat;
+import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
+import org.junit.jupiter.api.Test;
+
/**
* @author M.P. Korstanje (mpkorstanje@github)
*/
@@ -15,7 +15,7 @@ class EscapeHtmlReferenceTest {
private final ReferenceInsertionEventHandler insertionEventHandler = new EscapeHtmlReference();
@Test
- void referenceInsert_returnNormalText(){
+ void referenceInsert_returnNormalText() {
// given
String normalText = "a plain statement";
@@ -27,7 +27,7 @@ void referenceInsert_returnNormalText(){
}
@Test
- void referenceInsert_shouldEscapeHtmlForAnyLabel(){
+ void referenceInsert_shouldEscapeHtmlForAnyLabel() {
// given
String html = "a bold statement";
@@ -39,7 +39,7 @@ void referenceInsert_shouldEscapeHtmlForAnyLabel(){
}
@Test
- void referenceInsert_shouldNotEscapeWithSpecialTag(){
+ void referenceInsert_shouldNotEscapeWithSpecialTag() {
// given
String html = "a bold statement";
@@ -51,7 +51,7 @@ void referenceInsert_shouldNotEscapeWithSpecialTag(){
}
@Test
- void referenceInsert_shouldReturnNullForNull(){
+ void referenceInsert_shouldReturnNullForNull() {
// given
String html = null;
@@ -61,16 +61,4 @@ void referenceInsert_shouldReturnNullForNull(){
// then
assertThat(result).isNull();
}
-
- @Test
- void referenceInsert_shouldSanitize(){
- // given
- String html = "a hyper web reference";
-
- // when
- Object result = insertionEventHandler.referenceInsert(null, "$_sanitize_" + SOME_REFERENCE, html);
-
- // result
- assertThat(result).isEqualTo(html);
- }
}
diff --git a/src/test/java/net/masterthought/cucumber/generators/integrations/FeaturesOverviewPageIntegrationTest.java b/src/test/java/net/masterthought/cucumber/generators/integrations/FeaturesOverviewPageIntegrationTest.java
index 39f639d4c..db5fdae4d 100644
--- a/src/test/java/net/masterthought/cucumber/generators/integrations/FeaturesOverviewPageIntegrationTest.java
+++ b/src/test/java/net/masterthought/cucumber/generators/integrations/FeaturesOverviewPageIntegrationTest.java
@@ -59,8 +59,9 @@ void generatePage_generatesLead() {
void generatePage_generatesClassifications() {
// given
- final String[] names = {"Platform", "Browser", "Branch", "Repository"};
- final String[] values = {"Win", "Opera", "master", "Example Repository"};
+ // do not validate url as this is sanitized differently between JDKs 11, 17, 21
+ final String[] names = {"Platform", "Browser", "Branch"};
+ final String[] values = {"Win", "Opera", "master"};
setUpWithJson(SAMPLE_JSON);
for (int i = 0; i < names.length; i++) {
configuration.addClassifications(names[i], values[i]);