Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>query</artifactId>
<version>[14.0.1,15.0.0)</version>
<version>[14.7.1-SNAPSHOT,15.0.0)</version>
</dependency>

<dependency>
Expand Down
31 changes: 4 additions & 27 deletions java/src/main/java/io/cucumber/jsonformatter/JsonReportWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
import io.cucumber.messages.types.PickleTable;
import io.cucumber.messages.types.PickleTableCell;
import io.cucumber.messages.types.PickleTag;
import io.cucumber.messages.types.Rule;
import io.cucumber.messages.types.RuleChild;
import io.cucumber.messages.types.Scenario;
import io.cucumber.messages.types.SourceReference;
import io.cucumber.messages.types.Step;
Expand Down Expand Up @@ -71,7 +69,6 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collector;
import java.util.stream.Stream;

import static io.cucumber.jsonformatter.IdNamingVisitor.formatId;
import static java.nio.charset.StandardCharsets.UTF_8;
Expand Down Expand Up @@ -247,17 +244,17 @@ private List<JvmElement> createJvmElement(JvmElementData data) {
// Ensure scenarios without steps are also included
.orElseGet(Collections::emptyList);
JvmElement testCase = createTestCase(data, scenarioTestStepsFinished);

List<JvmElement> elements = new ArrayList<>(2);
background.ifPresent(elements::add);
elements.add(testCase);
return elements;
}

private Map<Optional<Background>, List<TestStepFinished>> findStepsByBackGround(JvmElementData data) {
List<Background> backgrounds = data.lineage.feature()
.map(this::findBackgroundsBy)
.orElseGet(Collections::emptyList);
List<Background> backgrounds = new ArrayList<>(2);
data.lineage.background().ifPresent(backgrounds::add);
data.lineage.ruleBackground().ifPresent(backgrounds::add);

Map<Optional<Background>, List<TestStepFinished>> stepsByBackground = query
.findTestStepFinishedAndTestStepBy(data.testCaseStarted)
Expand Down Expand Up @@ -524,26 +521,6 @@ private String createLocation(TestStep step) {
return groupingBy(grouping, LinkedHashMap::new, collectingAndThen(toList(), extractKey));
}

private List<Background> findBackgroundsBy(Feature feature) {
return feature.getChildren()
.stream()
.map(featureChild -> {
List<Background> backgrounds = new ArrayList<>();
featureChild.getBackground().ifPresent(backgrounds::add);
featureChild.getRule()
.map(Rule::getChildren)
.map(Collection::stream)
.orElseGet(Stream::empty)
.map(RuleChild::getBackground)
.filter(Optional::isPresent)
.map(Optional::get)
.forEach(backgrounds::add);
return backgrounds;
})
.flatMap(Collection::stream)
.collect(toList());
}

private Optional<Background> findBackgroundBy(List<Background> backgrounds, PickleStep pickleStep) {
return backgrounds.stream()
.filter(background -> background.getSteps().stream()
Expand Down
Loading