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 cucumber-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<junit-xml-formatter.version>0.9.0</junit-xml-formatter.version>
<messages.version>29.0.1</messages.version>
<pretty-formatter.version>2.3.0</pretty-formatter.version>
<query.version>14.4.0</query.version>
<query.version>14.4.1-SNAPSHOT</query.version>
<tag-expressions.version>6.1.2</tag-expressions.version>
<teamcity-formatter.version>0.1.1</teamcity-formatter.version>
<testng-xml-formatter.version>0.6.0</testng-xml-formatter.version>
Expand Down
13 changes: 13 additions & 0 deletions cucumber-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>

<dependency>
<groupId>org.xmlunit</groupId>
Expand Down Expand Up @@ -260,6 +264,7 @@
<include>com.fasterxml.jackson.core:jackson-core</include>
<include>com.fasterxml.jackson.core:jackson-annotations</include>
<include>com.fasterxml.jackson.datatype:jackson-datatype-jdk8</include>
<include>com.fasterxml.jackson.datatype:jackson-datatype-jsr310</include>
</includes>
</artifactSet>
<relocations>
Expand Down Expand Up @@ -303,6 +308,14 @@
<exclude>META-INF/services/**</exclude>
</excludes>
</filter>
<filter>
<artifact>com.fasterxml.jackson.datatype:jackson-datatype-jsr310</artifact>
<excludes>
<exclude>**/module-info.class</exclude>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/services/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import com.fasterxml.jackson.databind.cfg.ConstructorDetector;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import static com.fasterxml.jackson.annotation.JsonInclude.Value.construct;

final class Jackson {
public static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder()
.addModule(new Jdk8Module())
.addModule(new JavaTimeModule())
.defaultPropertyInclusion(construct(
Include.NON_ABSENT,
Include.NON_ABSENT))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.cucumber.core.plugin;

import io.cucumber.messages.types.Location;
import io.cucumber.messages.types.SourceReference;

import java.util.Optional;
import java.util.function.Function;

final class SourceReferenceFormatter {
private final Function<String, String> uriFormatter;

SourceReferenceFormatter(Function<String, String> uriFormatter) {
this.uriFormatter = uriFormatter;
}

Optional<String> format(SourceReference sourceReference) {
if (sourceReference.getJavaMethod().isPresent()) {
return sourceReference.getJavaMethod()
.map(javaMethod -> String.format(
"%s.%s(%s)",
javaMethod.getClassName(),
javaMethod.getMethodName(),
String.join(",", javaMethod.getMethodParameterTypes())));
}
if (sourceReference.getJavaStackTraceElement().isPresent()) {
return sourceReference.getJavaStackTraceElement()
.map(javaStackTraceElement -> String.format(
"%s.%s(%s%s)",
javaStackTraceElement.getClassName(),
javaStackTraceElement.getMethodName(),
javaStackTraceElement.getFileName(),
sourceReference.getLocation().map(Location::getLine).map(line -> ":" + line).orElse("")));
}
if (sourceReference.getUri().isPresent()) {
return sourceReference.getUri()
.map(uri -> uriFormatter.apply(uri) + sourceReference.getLocation()
.map(location -> ":" + location.getLine())
.orElse(""));
}
return Optional.empty();
}
}
Loading
Loading