Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ hs_err_pid*

# explicit include
!gradle/wrapper/gradle-wrapper.jar

target

73 changes: 39 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def pomConfig = {
email "costea32@gmail.com"
}
}
scm{
scm {
connection "scm:git:git@github.com/TestMonkeys/Cucumber-JVM-Extensions---Formatter.git"
developerConnection "scm:git:git@github.com/TestMonkeys/Cucumber-JVM-Extensions---Formatter.git"
url "git@github.com/TestMonkeys/Cucumber-JVM-Extensions---Formatter.git"
Expand All @@ -94,8 +94,8 @@ publishing {
pom.withXml {
def root = asNode()
root.appendNode('description', 'Cucumber JVM extended formatters')
root.appendNode('name',libraryName)
root.appendNode('url',siteUrl)
root.appendNode('name', libraryName)
root.appendNode('url', siteUrl)
root.children().last() + pomConfig
}
}
Expand All @@ -104,45 +104,50 @@ publishing {
}

// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
publications =['MavenPub']
configurations = ['archives']
pkg {
repo = bintrayRepo
userOrg = 'testmonkeys'
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = false
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
//Optional. The passphrase for GPG signing'
}
}
}
}

//Properties properties = new Properties()
//properties.load(project.rootProject.file('local.properties').newDataInputStream())

//bintray {
// user = properties.getProperty("bintray.user")
// key = properties.getProperty("bintray.apikey")
// publications =['MavenPub']
// configurations = ['archives']
// pkg {
// repo = bintrayRepo
// userOrg = 'testmonkeys'
// name = bintrayName
// desc = libraryDescription
// websiteUrl = siteUrl
// vcsUrl = gitUrl
// licenses = allLicenses
// publish = false
// publicDownloadNumbers = true
// version {
// desc = libraryDescription
// gpg {
// sign = true //Determines whether to GPG sign the files. The default is false
// passphrase = properties.getProperty("bintray.gpg.password")
// //Optional. The passphrase for GPG signing'
// }
// }
// }
//}


repositories {
mavenCentral()
}

dependencies {
compile 'info.cukes:gherkin:2.12.2','info.cukes:gherkin-jvm-deps:1.0.3'
compile 'info.cukes:gherkin:2.12.2',
'info.cukes:gherkin-jvm-deps:1.0.3',
'io.cucumber:cucumber-core:3.0.2'


testCompile 'junit:junit:4.11',
'info.cukes:cucumber-java:1.2.4',
'info.cukes:cucumber-junit:1.2.4'
'info.cukes:cucumber-junit:1.2.4',
'io.cucumber:cucumber-junit:3.0.2',
'io.cucumber:cucumber-java:3.0.2'
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,26 @@
import gherkin.deps.com.google.gson.Gson;
import gherkin.deps.com.google.gson.GsonBuilder;
import gherkin.deps.net.iharder.Base64;
import gherkin.formatter.model.Background;
import gherkin.formatter.model.Examples;
import gherkin.formatter.model.Feature;
import gherkin.formatter.model.Match;
import gherkin.formatter.model.Result;
import gherkin.formatter.model.Scenario;
import gherkin.formatter.model.ScenarioOutline;
import gherkin.formatter.model.Step;
import gherkin.formatter.Formatter;
import gherkin.formatter.Reporter;
import gherkin.formatter.NiceAppendable;
import gherkin.formatter.model.*;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JsonFormatter implements Reporter, Formatter {
private final List<Map<String, Object>> featureMaps = new ArrayList<Map<String, Object>>();
private final List<Map<String, Object>> featureMaps = new ArrayList<>();
private final File outFolder;
private File outPutFile;
private int scenarioCount;

private Map<String, Object> featureMap;
private String uri;
private List<Map> beforeHooks = new ArrayList<Map>();
private List<Map> beforeHooks = new ArrayList<>();

private enum Phase {step, match, embedding, output, result}

Expand Down Expand Up @@ -116,7 +105,7 @@ public void scenario(Scenario scenario) {
getFeatureElements().add(scenario.toMap());
if (beforeHooks.size() > 0) {
getFeatureElement().put("before", beforeHooks);
beforeHooks = new ArrayList<Map>();
beforeHooks = new ArrayList<>();
}
}

Expand All @@ -142,7 +131,7 @@ public void match(Match match) {

@Override
public void embedding(String mimeType, byte[] data) {
final Map<String, String> embedding = new HashMap<String, String>();
final Map<String, String> embedding = new HashMap<>();
embedding.put("mime_type", mimeType);
embedding.put("data", Base64.encodeBytes(data));
getEmbeddings().add(embedding);
Expand All @@ -167,7 +156,7 @@ public void before(Match match, Result result) {
public void after(Match match, Result result) {
List<Map> hooks = getFeatureElement().get("after");
if (hooks == null) {
hooks = new ArrayList<Map>();
hooks = new ArrayList<>();
getFeatureElement().put("after", hooks);
}
hooks.add(buildHookMap(match,result));
Expand Down Expand Up @@ -246,7 +235,7 @@ public void endOfScenarioLifeCycle(Scenario scenario) {
private List<Map<String, Object>> getFeatureElements() {
List<Map<String, Object>> featureElements = (List) featureMap.get("elements");
if (featureElements == null) {
featureElements = new ArrayList<Map<String, Object>>();
featureElements = new ArrayList<>();
featureMap.put("elements", featureElements);
}
return featureElements;
Expand All @@ -263,7 +252,7 @@ private Map<Object, List<Map>> getFeatureElement() {
private List<Map> getAllExamples() {
List<Map> allExamples = getFeatureElement().get("examples");
if (allExamples == null) {
allExamples = new ArrayList<Map>();
allExamples = new ArrayList<>();
getFeatureElement().put("examples", allExamples);
}
return allExamples;
Expand All @@ -272,7 +261,7 @@ private List<Map> getAllExamples() {
private List<Map> getSteps() {
List<Map> steps = getFeatureElement().get("steps");
if (steps == null) {
steps = new ArrayList<Map>();
steps = new ArrayList<>();
getFeatureElement().put("steps", steps);
}
return steps;
Expand All @@ -281,7 +270,7 @@ private List<Map> getSteps() {
private List<Map<String, String>> getEmbeddings() {
List<Map<String, String>> embeddings = (List<Map<String, String>>) getCurrentStep(Phase.embedding).get("embeddings");
if (embeddings == null) {
embeddings = new ArrayList<Map<String, String>>();
embeddings = new ArrayList<>();
getCurrentStep(Phase.embedding).put("embeddings", embeddings);
}
return embeddings;
Expand All @@ -290,7 +279,7 @@ private List<Map<String, String>> getEmbeddings() {
private List<String> getOutput() {
List<String> output = (List<String>) getCurrentStep(Phase.output).get("output");
if (output == null) {
output = new ArrayList<String>();
output = new ArrayList<>();
getCurrentStep(Phase.output).put("output", output);
}
return output;
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/org/testmonkeys/cucumber2/ext/formatters/Nodes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package org.testmonkeys.cucumber2.ext.formatters;

public enum Nodes {

ELEMENTS("elements"),
STEPS("steps"),
MATCH("match"),
RESULT("result"),
URI("uri"),
KEYWORD("keyword"),
NAME("name"),
DESCRIPTION("description"),
LINE("line"),
ID("id"),
TAGS("tags"),
TYPE("type"),
BACKGROUND("background"),
SCENARIO("SCENARIO"),
DOC_STRING("doc_string"),
ROWS("rows"),
VAL("val"),
OFFSET("offset"),
ARGUMENTS("arguments"),
LOCATION("location"),
VALUE("value"),
CONTENT_TYPE("content_type"),
STATUS("status"),
ERROR_MESSAGE("error_message"),
DURATION("duration"),
AFTER("after"),
BEFORE("before"),
CELLS("cells"),
MIME_TYPE("mime_type"),
DATA("data"),
EMBEDDINGS("embeddings"),
OUTPUT("output");

public String value;

Nodes(String value){
this.value = value;
}

@Override
public String toString() {
return this.value;
}
}
Loading