-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add changes from cucumber/common#1879
Fixes #67
- Loading branch information
1 parent
3ff9860
commit 203e83a
Showing
10 changed files
with
152 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 0 additions & 60 deletions
60
java/src/test/java/io/cucumber/htmlformatter/HtmlFormatterAcceptanceTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.cucumber.htmlformatter; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator.Mode; | ||
import com.fasterxml.jackson.annotation.JsonInclude.Include; | ||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.SerializationFeature; | ||
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.module.paramnames.ParameterNamesModule; | ||
|
||
final class Jackson { | ||
public static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder() | ||
.addModule(new Jdk8Module()) | ||
.addModule(new ParameterNamesModule(Mode.PROPERTIES)) | ||
.serializationInclusion(Include.NON_ABSENT) | ||
.constructorDetector(ConstructorDetector.USE_PROPERTIES_BASED) | ||
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) | ||
.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) | ||
.enable(DeserializationFeature.USE_LONG_FOR_INTS) | ||
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | ||
.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET) | ||
.build(); | ||
|
||
private Jackson() { | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.cucumber.htmlformatter; | ||
|
||
import io.cucumber.htmlformatter.MessagesToHtmlWriter.Serializer; | ||
import io.cucumber.messages.NdjsonToMessageIterable; | ||
import io.cucumber.messages.NdjsonToMessageIterable.Deserializer; | ||
import io.cucumber.messages.types.Envelope; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import static io.cucumber.htmlformatter.Jackson.OBJECT_MAPPER; | ||
|
||
public final class Main { | ||
private static final Deserializer deserializer = (json) -> OBJECT_MAPPER.readValue(json, Envelope.class); | ||
private static final Serializer serializer = OBJECT_MAPPER::writeValue; | ||
|
||
public static void main(String[] args) throws IOException { | ||
InputStream in = System.in; | ||
if (args.length == 1) { | ||
in = new FileInputStream(args[0]); | ||
} | ||
try (NdjsonToMessageIterable envelopes = new NdjsonToMessageIterable(in, deserializer)) { | ||
try (MessagesToHtmlWriter htmlWriter = new MessagesToHtmlWriter(System.out, serializer)) { | ||
for (Envelope envelope : envelopes) { | ||
htmlWriter.write(envelope); | ||
} | ||
} | ||
} catch (Throwable e) { | ||
// Workaround for https://github.com/mojohaus/exec-maven-plugin/issues/141 | ||
e.printStackTrace(); | ||
System.exit(1); | ||
} | ||
} | ||
} |
Oops, something went wrong.