From d388ff0786d6c2a5d2809192f0bd6927c5516103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 10:50:51 +0000 Subject: [PATCH 01/63] Implement custom code generator for Java --- messages/java/Makefile | 9 +- .../java/io/cucumber/messages/Messages.java | 3128 +++++++++++++++++ messages/javascript/Makefile | 2 +- messages/jsonschema/scripts/codegen.rb | 19 + .../scripts/templates/java.enum.ts.erb | 36 + .../jsonschema/scripts/templates/java.ts.erb | 69 + .../scripts/templates/typescript.ts.erb | 2 +- 7 files changed, 3262 insertions(+), 3 deletions(-) create mode 100644 messages/java/src/main/java/io/cucumber/messages/Messages.java create mode 100644 messages/jsonschema/scripts/templates/java.enum.ts.erb create mode 100644 messages/jsonschema/scripts/templates/java.ts.erb diff --git a/messages/java/Makefile b/messages/java/Makefile index 716ba463bd..21bcdacb02 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -1,5 +1,12 @@ include default.mk JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") +TEMPLATES = $(shell find ../jsonschema/scripts/templates -name "*.erb") -.built: $(JSONSCHEMAS) +.codegen: src/main/java/io/cucumber/messages/Messages.java + +src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) $(TEMPLATES) ../jsonschema/scripts/codegen.rb + ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema > $@ + +clean: + rm -f src/main/java/io/messages/cucumber/Messages.java diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java new file mode 100644 index 0000000000..06980e8a79 --- /dev/null +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -0,0 +1,3128 @@ +package io.cucumber.messages; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Objects.requireNonNull; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; + +public class Messages { + + public static class Attachment { + private final String body; + public String getBody() { + return body; + } + + private final AttachmentContentEncoding contentEncoding; + public AttachmentContentEncoding getContentEncoding() { + return contentEncoding; + } + + private final String fileName; + public Optional getFileName() { + return ofNullable(fileName); + } + + private final String mediaType; + public String getMediaType() { + return mediaType; + } + + private final Source source; + public Optional getSource() { + return ofNullable(source); + } + + private final String testCaseStartedId; + public Optional getTestCaseStartedId() { + return ofNullable(testCaseStartedId); + } + + private final String testStepId; + public Optional getTestStepId() { + return ofNullable(testStepId); + } + + private final String url; + public Optional getUrl() { + return ofNullable(url); + } + + + public Attachment( + String body, + AttachmentContentEncoding contentEncoding, + String fileName, + String mediaType, + Source source, + String testCaseStartedId, + String testStepId, + String url + ) { + this.body = requireNonNull(body); + this.contentEncoding = requireNonNull(contentEncoding); + this.fileName = fileName; + this.mediaType = requireNonNull(mediaType); + this.source = source; + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.url = url; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Attachment that = (Attachment) o; + return + body.equals(that.body) && + contentEncoding.equals(that.contentEncoding) && + Objects.equals(fileName, that.fileName) && + mediaType.equals(that.mediaType) && + Objects.equals(source, that.source) && + Objects.equals(testCaseStartedId, that.testCaseStartedId) && + Objects.equals(testStepId, that.testStepId) && + Objects.equals(url, that.url); + } + + @Override + public int hashCode() { + return Objects.hash( + body, + contentEncoding, + fileName, + mediaType, + source, + testCaseStartedId, + testStepId, + url + ); + } + } + + + public static class Duration { + private final Integer seconds; + public Integer getSeconds() { + return seconds; + } + + private final Integer nanos; + public Integer getNanos() { + return nanos; + } + + + public Duration( + Integer seconds, + Integer nanos + ) { + this.seconds = requireNonNull(seconds); + this.nanos = requireNonNull(nanos); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Duration that = (Duration) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return Objects.hash( + seconds, + nanos + ); + } + } + + + public static class Envelope { + private final Attachment attachment; + public Optional getAttachment() { + return ofNullable(attachment); + } + + private final GherkinDocument gherkinDocument; + public Optional getGherkinDocument() { + return ofNullable(gherkinDocument); + } + + private final Hook hook; + public Optional getHook() { + return ofNullable(hook); + } + + private final Meta meta; + public Optional getMeta() { + return ofNullable(meta); + } + + private final ParameterType parameterType; + public Optional getParameterType() { + return ofNullable(parameterType); + } + + private final ParseError parseError; + public Optional getParseError() { + return ofNullable(parseError); + } + + private final Pickle pickle; + public Optional getPickle() { + return ofNullable(pickle); + } + + private final Source source; + public Optional getSource() { + return ofNullable(source); + } + + private final StepDefinition stepDefinition; + public Optional getStepDefinition() { + return ofNullable(stepDefinition); + } + + private final TestCase testCase; + public Optional getTestCase() { + return ofNullable(testCase); + } + + private final TestCaseFinished testCaseFinished; + public Optional getTestCaseFinished() { + return ofNullable(testCaseFinished); + } + + private final TestCaseStarted testCaseStarted; + public Optional getTestCaseStarted() { + return ofNullable(testCaseStarted); + } + + private final TestRunFinished testRunFinished; + public Optional getTestRunFinished() { + return ofNullable(testRunFinished); + } + + private final TestRunStarted testRunStarted; + public Optional getTestRunStarted() { + return ofNullable(testRunStarted); + } + + private final TestStepFinished testStepFinished; + public Optional getTestStepFinished() { + return ofNullable(testStepFinished); + } + + private final TestStepStarted testStepStarted; + public Optional getTestStepStarted() { + return ofNullable(testStepStarted); + } + + private final UndefinedParameterType undefinedParameterType; + public Optional getUndefinedParameterType() { + return ofNullable(undefinedParameterType); + } + + + public Envelope( + Attachment attachment, + GherkinDocument gherkinDocument, + Hook hook, + Meta meta, + ParameterType parameterType, + ParseError parseError, + Pickle pickle, + Source source, + StepDefinition stepDefinition, + TestCase testCase, + TestCaseFinished testCaseFinished, + TestCaseStarted testCaseStarted, + TestRunFinished testRunFinished, + TestRunStarted testRunStarted, + TestStepFinished testStepFinished, + TestStepStarted testStepStarted, + UndefinedParameterType undefinedParameterType + ) { + this.attachment = attachment; + this.gherkinDocument = gherkinDocument; + this.hook = hook; + this.meta = meta; + this.parameterType = parameterType; + this.parseError = parseError; + this.pickle = pickle; + this.source = source; + this.stepDefinition = stepDefinition; + this.testCase = testCase; + this.testCaseFinished = testCaseFinished; + this.testCaseStarted = testCaseStarted; + this.testRunFinished = testRunFinished; + this.testRunStarted = testRunStarted; + this.testStepFinished = testStepFinished; + this.testStepStarted = testStepStarted; + this.undefinedParameterType = undefinedParameterType; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Envelope that = (Envelope) o; + return + Objects.equals(attachment, that.attachment) && + Objects.equals(gherkinDocument, that.gherkinDocument) && + Objects.equals(hook, that.hook) && + Objects.equals(meta, that.meta) && + Objects.equals(parameterType, that.parameterType) && + Objects.equals(parseError, that.parseError) && + Objects.equals(pickle, that.pickle) && + Objects.equals(source, that.source) && + Objects.equals(stepDefinition, that.stepDefinition) && + Objects.equals(testCase, that.testCase) && + Objects.equals(testCaseFinished, that.testCaseFinished) && + Objects.equals(testCaseStarted, that.testCaseStarted) && + Objects.equals(testRunFinished, that.testRunFinished) && + Objects.equals(testRunStarted, that.testRunStarted) && + Objects.equals(testStepFinished, that.testStepFinished) && + Objects.equals(testStepStarted, that.testStepStarted) && + Objects.equals(undefinedParameterType, that.undefinedParameterType); + } + + @Override + public int hashCode() { + return Objects.hash( + attachment, + gherkinDocument, + hook, + meta, + parameterType, + parseError, + pickle, + source, + stepDefinition, + testCase, + testCaseFinished, + testCaseStarted, + testRunFinished, + testRunStarted, + testStepFinished, + testStepStarted, + undefinedParameterType + ); + } + } + + + public static class GherkinDocument { + private final String uri; + public Optional getUri() { + return ofNullable(uri); + } + + private final Feature feature; + public Optional getFeature() { + return ofNullable(feature); + } + + private final List comments; + public List getComments() { + return comments; + } + + + public GherkinDocument( + String uri, + Feature feature, + List comments + ) { + this.uri = uri; + this.feature = feature; + this.comments = requireNonNull(comments); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GherkinDocument that = (GherkinDocument) o; + return + Objects.equals(uri, that.uri) && + Objects.equals(feature, that.feature) && + comments.equals(that.comments); + } + + @Override + public int hashCode() { + return Objects.hash( + uri, + feature, + comments + ); + } + } + + + public static class Background { + private final Location location; + public Location getLocation() { + return location; + } + + private final String keyword; + public String getKeyword() { + return keyword; + } + + private final String name; + public String getName() { + return name; + } + + private final String description; + public String getDescription() { + return description; + } + + private final List steps; + public List getSteps() { + return steps; + } + + private final String id; + public String getId() { + return id; + } + + + public Background( + Location location, + String keyword, + String name, + String description, + List steps, + String id + ) { + this.location = requireNonNull(location); + this.keyword = requireNonNull(keyword); + this.name = requireNonNull(name); + this.description = requireNonNull(description); + this.steps = requireNonNull(steps); + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Background that = (Background) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + keyword, + name, + description, + steps, + id + ); + } + } + + + public static class Comment { + private final Location location; + public Location getLocation() { + return location; + } + + private final String text; + public String getText() { + return text; + } + + + public Comment( + Location location, + String text + ) { + this.location = requireNonNull(location); + this.text = requireNonNull(text); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Comment that = (Comment) o; + return + location.equals(that.location) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + text + ); + } + } + + + public static class DataTable { + private final Location location; + public Location getLocation() { + return location; + } + + private final List rows; + public List getRows() { + return rows; + } + + + public DataTable( + Location location, + List rows + ) { + this.location = requireNonNull(location); + this.rows = requireNonNull(rows); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DataTable that = (DataTable) o; + return + location.equals(that.location) && + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + rows + ); + } + } + + + public static class DocString { + private final Location location; + public Location getLocation() { + return location; + } + + private final String mediaType; + public Optional getMediaType() { + return ofNullable(mediaType); + } + + private final String content; + public String getContent() { + return content; + } + + private final String delimiter; + public String getDelimiter() { + return delimiter; + } + + + public DocString( + Location location, + String mediaType, + String content, + String delimiter + ) { + this.location = requireNonNull(location); + this.mediaType = mediaType; + this.content = requireNonNull(content); + this.delimiter = requireNonNull(delimiter); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DocString that = (DocString) o; + return + location.equals(that.location) && + Objects.equals(mediaType, that.mediaType) && + content.equals(that.content) && + delimiter.equals(that.delimiter); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + mediaType, + content, + delimiter + ); + } + } + + + public static class Examples { + private final Location location; + public Location getLocation() { + return location; + } + + private final List tags; + public List getTags() { + return tags; + } + + private final String keyword; + public String getKeyword() { + return keyword; + } + + private final String name; + public String getName() { + return name; + } + + private final String description; + public String getDescription() { + return description; + } + + private final TableRow tableHeader; + public Optional getTableHeader() { + return ofNullable(tableHeader); + } + + private final List tableBody; + public List getTableBody() { + return tableBody; + } + + private final String id; + public String getId() { + return id; + } + + + public Examples( + Location location, + List tags, + String keyword, + String name, + String description, + TableRow tableHeader, + List tableBody, + String id + ) { + this.location = requireNonNull(location); + this.tags = requireNonNull(tags); + this.keyword = requireNonNull(keyword); + this.name = requireNonNull(name); + this.description = requireNonNull(description); + this.tableHeader = tableHeader; + this.tableBody = requireNonNull(tableBody); + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Examples that = (Examples) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + Objects.equals(tableHeader, that.tableHeader) && + tableBody.equals(that.tableBody) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + keyword, + name, + description, + tableHeader, + tableBody, + id + ); + } + } + + + public static class Feature { + private final Location location; + public Location getLocation() { + return location; + } + + private final List tags; + public List getTags() { + return tags; + } + + private final String language; + public String getLanguage() { + return language; + } + + private final String keyword; + public String getKeyword() { + return keyword; + } + + private final String name; + public String getName() { + return name; + } + + private final String description; + public String getDescription() { + return description; + } + + private final List children; + public List getChildren() { + return children; + } + + + public Feature( + Location location, + List tags, + String language, + String keyword, + String name, + String description, + List children + ) { + this.location = requireNonNull(location); + this.tags = requireNonNull(tags); + this.language = requireNonNull(language); + this.keyword = requireNonNull(keyword); + this.name = requireNonNull(name); + this.description = requireNonNull(description); + this.children = requireNonNull(children); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Feature that = (Feature) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + language.equals(that.language) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + language, + keyword, + name, + description, + children + ); + } + } + + + public static class FeatureChild { + private final Rule rule; + public Optional getRule() { + return ofNullable(rule); + } + + private final Background background; + public Optional getBackground() { + return ofNullable(background); + } + + private final Scenario scenario; + public Optional getScenario() { + return ofNullable(scenario); + } + + + public FeatureChild( + Rule rule, + Background background, + Scenario scenario + ) { + this.rule = rule; + this.background = background; + this.scenario = scenario; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + FeatureChild that = (FeatureChild) o; + return + Objects.equals(rule, that.rule) && + Objects.equals(background, that.background) && + Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return Objects.hash( + rule, + background, + scenario + ); + } + } + + + public static class Rule { + private final Location location; + public Location getLocation() { + return location; + } + + private final List tags; + public List getTags() { + return tags; + } + + private final String keyword; + public String getKeyword() { + return keyword; + } + + private final String name; + public String getName() { + return name; + } + + private final String description; + public String getDescription() { + return description; + } + + private final List children; + public List getChildren() { + return children; + } + + private final String id; + public String getId() { + return id; + } + + + public Rule( + Location location, + List tags, + String keyword, + String name, + String description, + List children, + String id + ) { + this.location = requireNonNull(location); + this.tags = requireNonNull(tags); + this.keyword = requireNonNull(keyword); + this.name = requireNonNull(name); + this.description = requireNonNull(description); + this.children = requireNonNull(children); + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Rule that = (Rule) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + keyword, + name, + description, + children, + id + ); + } + } + + + public static class RuleChild { + private final Background background; + public Optional getBackground() { + return ofNullable(background); + } + + private final Scenario scenario; + public Optional getScenario() { + return ofNullable(scenario); + } + + + public RuleChild( + Background background, + Scenario scenario + ) { + this.background = background; + this.scenario = scenario; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RuleChild that = (RuleChild) o; + return + Objects.equals(background, that.background) && + Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return Objects.hash( + background, + scenario + ); + } + } + + + public static class Scenario { + private final Location location; + public Location getLocation() { + return location; + } + + private final List tags; + public List getTags() { + return tags; + } + + private final String keyword; + public String getKeyword() { + return keyword; + } + + private final String name; + public String getName() { + return name; + } + + private final String description; + public String getDescription() { + return description; + } + + private final List steps; + public List getSteps() { + return steps; + } + + private final List examples; + public List getExamples() { + return examples; + } + + private final String id; + public String getId() { + return id; + } + + + public Scenario( + Location location, + List tags, + String keyword, + String name, + String description, + List steps, + List examples, + String id + ) { + this.location = requireNonNull(location); + this.tags = requireNonNull(tags); + this.keyword = requireNonNull(keyword); + this.name = requireNonNull(name); + this.description = requireNonNull(description); + this.steps = requireNonNull(steps); + this.examples = requireNonNull(examples); + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Scenario that = (Scenario) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + examples.equals(that.examples) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + keyword, + name, + description, + steps, + examples, + id + ); + } + } + + + public static class Step { + private final Location location; + public Location getLocation() { + return location; + } + + private final String keyword; + public String getKeyword() { + return keyword; + } + + private final String text; + public String getText() { + return text; + } + + private final DocString docString; + public Optional getDocString() { + return ofNullable(docString); + } + + private final DataTable dataTable; + public Optional getDataTable() { + return ofNullable(dataTable); + } + + private final String id; + public String getId() { + return id; + } + + + public Step( + Location location, + String keyword, + String text, + DocString docString, + DataTable dataTable, + String id + ) { + this.location = requireNonNull(location); + this.keyword = requireNonNull(keyword); + this.text = requireNonNull(text); + this.docString = docString; + this.dataTable = dataTable; + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Step that = (Step) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + text.equals(that.text) && + Objects.equals(docString, that.docString) && + Objects.equals(dataTable, that.dataTable) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + keyword, + text, + docString, + dataTable, + id + ); + } + } + + + public static class TableCell { + private final Location location; + public Location getLocation() { + return location; + } + + private final String value; + public String getValue() { + return value; + } + + + public TableCell( + Location location, + String value + ) { + this.location = requireNonNull(location); + this.value = requireNonNull(value); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableCell that = (TableCell) o; + return + location.equals(that.location) && + value.equals(that.value); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + value + ); + } + } + + + public static class TableRow { + private final Location location; + public Location getLocation() { + return location; + } + + private final List cells; + public List getCells() { + return cells; + } + + private final String id; + public String getId() { + return id; + } + + + public TableRow( + Location location, + List cells, + String id + ) { + this.location = requireNonNull(location); + this.cells = requireNonNull(cells); + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableRow that = (TableRow) o; + return + location.equals(that.location) && + cells.equals(that.cells) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + cells, + id + ); + } + } + + + public static class Tag { + private final Location location; + public Location getLocation() { + return location; + } + + private final String name; + public String getName() { + return name; + } + + private final String id; + public String getId() { + return id; + } + + + public Tag( + Location location, + String name, + String id + ) { + this.location = requireNonNull(location); + this.name = requireNonNull(name); + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Tag that = (Tag) o; + return + location.equals(that.location) && + name.equals(that.name) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + name, + id + ); + } + } + + + public static class Hook { + private final String id; + public String getId() { + return id; + } + + private final SourceReference sourceReference; + public SourceReference getSourceReference() { + return sourceReference; + } + + private final String tagExpression; + public Optional getTagExpression() { + return ofNullable(tagExpression); + } + + + public Hook( + String id, + SourceReference sourceReference, + String tagExpression + ) { + this.id = requireNonNull(id); + this.sourceReference = requireNonNull(sourceReference); + this.tagExpression = tagExpression; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Hook that = (Hook) o; + return + id.equals(that.id) && + sourceReference.equals(that.sourceReference) && + Objects.equals(tagExpression, that.tagExpression); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + sourceReference, + tagExpression + ); + } + } + + + public static class Location { + private final Integer line; + public Integer getLine() { + return line; + } + + private final Integer column; + public Optional getColumn() { + return ofNullable(column); + } + + + public Location( + Integer line, + Integer column + ) { + this.line = requireNonNull(line); + this.column = column; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Location that = (Location) o; + return + line.equals(that.line) && + Objects.equals(column, that.column); + } + + @Override + public int hashCode() { + return Objects.hash( + line, + column + ); + } + } + + + public static class Meta { + private final String protocolVersion; + public String getProtocolVersion() { + return protocolVersion; + } + + private final Product implementation; + public Product getImplementation() { + return implementation; + } + + private final Product runtime; + public Product getRuntime() { + return runtime; + } + + private final Product os; + public Product getOs() { + return os; + } + + private final Product cpu; + public Product getCpu() { + return cpu; + } + + private final Ci ci; + public Optional getCi() { + return ofNullable(ci); + } + + + public Meta( + String protocolVersion, + Product implementation, + Product runtime, + Product os, + Product cpu, + Ci ci + ) { + this.protocolVersion = requireNonNull(protocolVersion); + this.implementation = requireNonNull(implementation); + this.runtime = requireNonNull(runtime); + this.os = requireNonNull(os); + this.cpu = requireNonNull(cpu); + this.ci = ci; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Meta that = (Meta) o; + return + protocolVersion.equals(that.protocolVersion) && + implementation.equals(that.implementation) && + runtime.equals(that.runtime) && + os.equals(that.os) && + cpu.equals(that.cpu) && + Objects.equals(ci, that.ci); + } + + @Override + public int hashCode() { + return Objects.hash( + protocolVersion, + implementation, + runtime, + os, + cpu, + ci + ); + } + } + + + public static class Ci { + private final String name; + public String getName() { + return name; + } + + private final String url; + public Optional getUrl() { + return ofNullable(url); + } + + private final String buildNumber; + public Optional getBuildNumber() { + return ofNullable(buildNumber); + } + + private final Git git; + public Optional getGit() { + return ofNullable(git); + } + + + public Ci( + String name, + String url, + String buildNumber, + Git git + ) { + this.name = requireNonNull(name); + this.url = url; + this.buildNumber = buildNumber; + this.git = git; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Ci that = (Ci) o; + return + name.equals(that.name) && + Objects.equals(url, that.url) && + Objects.equals(buildNumber, that.buildNumber) && + Objects.equals(git, that.git); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + url, + buildNumber, + git + ); + } + } + + + public static class Git { + private final String remote; + public String getRemote() { + return remote; + } + + private final String revision; + public String getRevision() { + return revision; + } + + private final String branch; + public Optional getBranch() { + return ofNullable(branch); + } + + private final String tag; + public Optional getTag() { + return ofNullable(tag); + } + + + public Git( + String remote, + String revision, + String branch, + String tag + ) { + this.remote = requireNonNull(remote); + this.revision = requireNonNull(revision); + this.branch = branch; + this.tag = tag; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Git that = (Git) o; + return + remote.equals(that.remote) && + revision.equals(that.revision) && + Objects.equals(branch, that.branch) && + Objects.equals(tag, that.tag); + } + + @Override + public int hashCode() { + return Objects.hash( + remote, + revision, + branch, + tag + ); + } + } + + + public static class Product { + private final String name; + public String getName() { + return name; + } + + private final String version; + public Optional getVersion() { + return ofNullable(version); + } + + + public Product( + String name, + String version + ) { + this.name = requireNonNull(name); + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Product that = (Product) o; + return + name.equals(that.name) && + Objects.equals(version, that.version); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + version + ); + } + } + + + public static class ParameterType { + private final String name; + public String getName() { + return name; + } + + private final List regularExpressions; + public List getRegularExpressions() { + return regularExpressions; + } + + private final Boolean preferForRegularExpressionMatch; + public Boolean getPreferForRegularExpressionMatch() { + return preferForRegularExpressionMatch; + } + + private final Boolean useForSnippets; + public Boolean getUseForSnippets() { + return useForSnippets; + } + + private final String id; + public String getId() { + return id; + } + + + public ParameterType( + String name, + List regularExpressions, + Boolean preferForRegularExpressionMatch, + Boolean useForSnippets, + String id + ) { + this.name = requireNonNull(name); + this.regularExpressions = requireNonNull(regularExpressions); + this.preferForRegularExpressionMatch = requireNonNull(preferForRegularExpressionMatch); + this.useForSnippets = requireNonNull(useForSnippets); + this.id = requireNonNull(id); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParameterType that = (ParameterType) o; + return + name.equals(that.name) && + regularExpressions.equals(that.regularExpressions) && + preferForRegularExpressionMatch.equals(that.preferForRegularExpressionMatch) && + useForSnippets.equals(that.useForSnippets) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + regularExpressions, + preferForRegularExpressionMatch, + useForSnippets, + id + ); + } + } + + + public static class ParseError { + private final SourceReference source; + public SourceReference getSource() { + return source; + } + + private final String message; + public String getMessage() { + return message; + } + + + public ParseError( + SourceReference source, + String message + ) { + this.source = requireNonNull(source); + this.message = requireNonNull(message); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParseError that = (ParseError) o; + return + source.equals(that.source) && + message.equals(that.message); + } + + @Override + public int hashCode() { + return Objects.hash( + source, + message + ); + } + } + + + public static class Pickle { + private final String id; + public String getId() { + return id; + } + + private final String uri; + public String getUri() { + return uri; + } + + private final String name; + public String getName() { + return name; + } + + private final String language; + public String getLanguage() { + return language; + } + + private final List steps; + public List getSteps() { + return steps; + } + + private final List tags; + public List getTags() { + return tags; + } + + private final List astNodeIds; + public List getAstNodeIds() { + return astNodeIds; + } + + + public Pickle( + String id, + String uri, + String name, + String language, + List steps, + List tags, + List astNodeIds + ) { + this.id = requireNonNull(id); + this.uri = requireNonNull(uri); + this.name = requireNonNull(name); + this.language = requireNonNull(language); + this.steps = requireNonNull(steps); + this.tags = requireNonNull(tags); + this.astNodeIds = requireNonNull(astNodeIds); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pickle that = (Pickle) o; + return + id.equals(that.id) && + uri.equals(that.uri) && + name.equals(that.name) && + language.equals(that.language) && + steps.equals(that.steps) && + tags.equals(that.tags) && + astNodeIds.equals(that.astNodeIds); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + uri, + name, + language, + steps, + tags, + astNodeIds + ); + } + } + + + public static class PickleDocString { + private final String mediaType; + public Optional getMediaType() { + return ofNullable(mediaType); + } + + private final String content; + public String getContent() { + return content; + } + + + public PickleDocString( + String mediaType, + String content + ) { + this.mediaType = mediaType; + this.content = requireNonNull(content); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleDocString that = (PickleDocString) o; + return + Objects.equals(mediaType, that.mediaType) && + content.equals(that.content); + } + + @Override + public int hashCode() { + return Objects.hash( + mediaType, + content + ); + } + } + + + public static class PickleStep { + private final PickleStepArgument argument; + public Optional getArgument() { + return ofNullable(argument); + } + + private final List astNodeIds; + public List getAstNodeIds() { + return astNodeIds; + } + + private final String id; + public String getId() { + return id; + } + + private final String text; + public String getText() { + return text; + } + + + public PickleStep( + PickleStepArgument argument, + List astNodeIds, + String id, + String text + ) { + this.argument = argument; + this.astNodeIds = requireNonNull(astNodeIds); + this.id = requireNonNull(id); + this.text = requireNonNull(text); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStep that = (PickleStep) o; + return + Objects.equals(argument, that.argument) && + astNodeIds.equals(that.astNodeIds) && + id.equals(that.id) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return Objects.hash( + argument, + astNodeIds, + id, + text + ); + } + } + + + public static class PickleStepArgument { + private final PickleDocString docString; + public Optional getDocString() { + return ofNullable(docString); + } + + private final PickleTable dataTable; + public Optional getDataTable() { + return ofNullable(dataTable); + } + + + public PickleStepArgument( + PickleDocString docString, + PickleTable dataTable + ) { + this.docString = docString; + this.dataTable = dataTable; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStepArgument that = (PickleStepArgument) o; + return + Objects.equals(docString, that.docString) && + Objects.equals(dataTable, that.dataTable); + } + + @Override + public int hashCode() { + return Objects.hash( + docString, + dataTable + ); + } + } + + + public static class PickleTable { + private final List rows; + public List getRows() { + return rows; + } + + + public PickleTable( + List rows + ) { + this.rows = requireNonNull(rows); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTable that = (PickleTable) o; + return + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return Objects.hash( + rows + ); + } + } + + + public static class PickleTableCell { + private final String value; + public String getValue() { + return value; + } + + + public PickleTableCell( + String value + ) { + this.value = requireNonNull(value); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableCell that = (PickleTableCell) o; + return + value.equals(that.value); + } + + @Override + public int hashCode() { + return Objects.hash( + value + ); + } + } + + + public static class PickleTableRow { + private final List cells; + public List getCells() { + return cells; + } + + + public PickleTableRow( + List cells + ) { + this.cells = requireNonNull(cells); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableRow that = (PickleTableRow) o; + return + cells.equals(that.cells); + } + + @Override + public int hashCode() { + return Objects.hash( + cells + ); + } + } + + + public static class PickleTag { + private final String name; + public String getName() { + return name; + } + + private final String astNodeId; + public String getAstNodeId() { + return astNodeId; + } + + + public PickleTag( + String name, + String astNodeId + ) { + this.name = requireNonNull(name); + this.astNodeId = requireNonNull(astNodeId); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTag that = (PickleTag) o; + return + name.equals(that.name) && + astNodeId.equals(that.astNodeId); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + astNodeId + ); + } + } + + + public static class Source { + private final String uri; + public String getUri() { + return uri; + } + + private final String data; + public String getData() { + return data; + } + + private final SourceMediaType mediaType; + public SourceMediaType getMediaType() { + return mediaType; + } + + + public Source( + String uri, + String data, + SourceMediaType mediaType + ) { + this.uri = requireNonNull(uri); + this.data = requireNonNull(data); + this.mediaType = requireNonNull(mediaType); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Source that = (Source) o; + return + uri.equals(that.uri) && + data.equals(that.data) && + mediaType.equals(that.mediaType); + } + + @Override + public int hashCode() { + return Objects.hash( + uri, + data, + mediaType + ); + } + } + + + public static class SourceReference { + private final String uri; + public Optional getUri() { + return ofNullable(uri); + } + + private final JavaMethod javaMethod; + public Optional getJavaMethod() { + return ofNullable(javaMethod); + } + + private final JavaStackTraceElement javaStackTraceElement; + public Optional getJavaStackTraceElement() { + return ofNullable(javaStackTraceElement); + } + + private final Location location; + public Optional getLocation() { + return ofNullable(location); + } + + + public SourceReference( + String uri, + JavaMethod javaMethod, + JavaStackTraceElement javaStackTraceElement, + Location location + ) { + this.uri = uri; + this.javaMethod = javaMethod; + this.javaStackTraceElement = javaStackTraceElement; + this.location = location; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SourceReference that = (SourceReference) o; + return + Objects.equals(uri, that.uri) && + Objects.equals(javaMethod, that.javaMethod) && + Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && + Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + return Objects.hash( + uri, + javaMethod, + javaStackTraceElement, + location + ); + } + } + + + public static class JavaMethod { + private final String className; + public String getClassName() { + return className; + } + + private final String methodName; + public String getMethodName() { + return methodName; + } + + private final List methodParameterTypes; + public List getMethodParameterTypes() { + return methodParameterTypes; + } + + + public JavaMethod( + String className, + String methodName, + List methodParameterTypes + ) { + this.className = requireNonNull(className); + this.methodName = requireNonNull(methodName); + this.methodParameterTypes = requireNonNull(methodParameterTypes); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaMethod that = (JavaMethod) o; + return + className.equals(that.className) && + methodName.equals(that.methodName) && + methodParameterTypes.equals(that.methodParameterTypes); + } + + @Override + public int hashCode() { + return Objects.hash( + className, + methodName, + methodParameterTypes + ); + } + } + + + public static class JavaStackTraceElement { + private final String className; + public String getClassName() { + return className; + } + + private final String fileName; + public String getFileName() { + return fileName; + } + + private final String methodName; + public String getMethodName() { + return methodName; + } + + + public JavaStackTraceElement( + String className, + String fileName, + String methodName + ) { + this.className = requireNonNull(className); + this.fileName = requireNonNull(fileName); + this.methodName = requireNonNull(methodName); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaStackTraceElement that = (JavaStackTraceElement) o; + return + className.equals(that.className) && + fileName.equals(that.fileName) && + methodName.equals(that.methodName); + } + + @Override + public int hashCode() { + return Objects.hash( + className, + fileName, + methodName + ); + } + } + + + public static class StepDefinition { + private final String id; + public String getId() { + return id; + } + + private final StepDefinitionPattern pattern; + public StepDefinitionPattern getPattern() { + return pattern; + } + + private final SourceReference sourceReference; + public SourceReference getSourceReference() { + return sourceReference; + } + + + public StepDefinition( + String id, + StepDefinitionPattern pattern, + SourceReference sourceReference + ) { + this.id = requireNonNull(id); + this.pattern = requireNonNull(pattern); + this.sourceReference = requireNonNull(sourceReference); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinition that = (StepDefinition) o; + return + id.equals(that.id) && + pattern.equals(that.pattern) && + sourceReference.equals(that.sourceReference); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + pattern, + sourceReference + ); + } + } + + + public static class StepDefinitionPattern { + private final String source; + public String getSource() { + return source; + } + + private final StepDefinitionPatternType type; + public StepDefinitionPatternType getType() { + return type; + } + + + public StepDefinitionPattern( + String source, + StepDefinitionPatternType type + ) { + this.source = requireNonNull(source); + this.type = requireNonNull(type); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinitionPattern that = (StepDefinitionPattern) o; + return + source.equals(that.source) && + type.equals(that.type); + } + + @Override + public int hashCode() { + return Objects.hash( + source, + type + ); + } + } + + + public static class TestCase { + private final String id; + public String getId() { + return id; + } + + private final String pickleId; + public String getPickleId() { + return pickleId; + } + + private final List testSteps; + public List getTestSteps() { + return testSteps; + } + + + public TestCase( + String id, + String pickleId, + List testSteps + ) { + this.id = requireNonNull(id); + this.pickleId = requireNonNull(pickleId); + this.testSteps = requireNonNull(testSteps); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCase that = (TestCase) o; + return + id.equals(that.id) && + pickleId.equals(that.pickleId) && + testSteps.equals(that.testSteps); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + pickleId, + testSteps + ); + } + } + + + public static class Group { + private final List children; + public List getChildren() { + return children; + } + + private final Integer start; + public Optional getStart() { + return ofNullable(start); + } + + private final String value; + public Optional getValue() { + return ofNullable(value); + } + + + public Group( + List children, + Integer start, + String value + ) { + this.children = requireNonNull(children); + this.start = start; + this.value = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Group that = (Group) o; + return + children.equals(that.children) && + Objects.equals(start, that.start) && + Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return Objects.hash( + children, + start, + value + ); + } + } + + + public static class StepMatchArgument { + private final Group group; + public Group getGroup() { + return group; + } + + private final String parameterTypeName; + public Optional getParameterTypeName() { + return ofNullable(parameterTypeName); + } + + + public StepMatchArgument( + Group group, + String parameterTypeName + ) { + this.group = requireNonNull(group); + this.parameterTypeName = parameterTypeName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgument that = (StepMatchArgument) o; + return + group.equals(that.group) && + Objects.equals(parameterTypeName, that.parameterTypeName); + } + + @Override + public int hashCode() { + return Objects.hash( + group, + parameterTypeName + ); + } + } + + + public static class StepMatchArgumentsList { + private final List stepMatchArguments; + public List getStepMatchArguments() { + return stepMatchArguments; + } + + + public StepMatchArgumentsList( + List stepMatchArguments + ) { + this.stepMatchArguments = requireNonNull(stepMatchArguments); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgumentsList that = (StepMatchArgumentsList) o; + return + stepMatchArguments.equals(that.stepMatchArguments); + } + + @Override + public int hashCode() { + return Objects.hash( + stepMatchArguments + ); + } + } + + + public static class TestStep { + private final String hookId; + public Optional getHookId() { + return ofNullable(hookId); + } + + private final String id; + public String getId() { + return id; + } + + private final String pickleStepId; + public Optional getPickleStepId() { + return ofNullable(pickleStepId); + } + + private final List stepDefinitionIds; + public Optional> getStepDefinitionIds() { + return ofNullable(stepDefinitionIds); + } + + private final List stepMatchArgumentsLists; + public Optional> getStepMatchArgumentsLists() { + return ofNullable(stepMatchArgumentsLists); + } + + + public TestStep( + String hookId, + String id, + String pickleStepId, + List stepDefinitionIds, + List stepMatchArgumentsLists + ) { + this.hookId = hookId; + this.id = requireNonNull(id); + this.pickleStepId = pickleStepId; + this.stepDefinitionIds = stepDefinitionIds; + this.stepMatchArgumentsLists = stepMatchArgumentsLists; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStep that = (TestStep) o; + return + Objects.equals(hookId, that.hookId) && + id.equals(that.id) && + Objects.equals(pickleStepId, that.pickleStepId) && + Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && + Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); + } + + @Override + public int hashCode() { + return Objects.hash( + hookId, + id, + pickleStepId, + stepDefinitionIds, + stepMatchArgumentsLists + ); + } + } + + + public static class TestCaseFinished { + private final String testCaseStartedId; + public String getTestCaseStartedId() { + return testCaseStartedId; + } + + private final Timestamp timestamp; + public Timestamp getTimestamp() { + return timestamp; + } + + private final Boolean willBeRetried; + public Boolean getWillBeRetried() { + return willBeRetried; + } + + + public TestCaseFinished( + String testCaseStartedId, + Timestamp timestamp, + Boolean willBeRetried + ) { + this.testCaseStartedId = requireNonNull(testCaseStartedId); + this.timestamp = requireNonNull(timestamp); + this.willBeRetried = requireNonNull(willBeRetried); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseFinished that = (TestCaseFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + timestamp.equals(that.timestamp) && + willBeRetried.equals(that.willBeRetried); + } + + @Override + public int hashCode() { + return Objects.hash( + testCaseStartedId, + timestamp, + willBeRetried + ); + } + } + + + public static class TestCaseStarted { + private final Integer attempt; + public Integer getAttempt() { + return attempt; + } + + private final String id; + public String getId() { + return id; + } + + private final String testCaseId; + public String getTestCaseId() { + return testCaseId; + } + + private final Timestamp timestamp; + public Timestamp getTimestamp() { + return timestamp; + } + + + public TestCaseStarted( + Integer attempt, + String id, + String testCaseId, + Timestamp timestamp + ) { + this.attempt = requireNonNull(attempt); + this.id = requireNonNull(id); + this.testCaseId = requireNonNull(testCaseId); + this.timestamp = requireNonNull(timestamp); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseStarted that = (TestCaseStarted) o; + return + attempt.equals(that.attempt) && + id.equals(that.id) && + testCaseId.equals(that.testCaseId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + attempt, + id, + testCaseId, + timestamp + ); + } + } + + + public static class TestRunFinished { + private final String message; + public Optional getMessage() { + return ofNullable(message); + } + + private final Boolean success; + public Boolean getSuccess() { + return success; + } + + private final Timestamp timestamp; + public Timestamp getTimestamp() { + return timestamp; + } + + + public TestRunFinished( + String message, + Boolean success, + Timestamp timestamp + ) { + this.message = message; + this.success = requireNonNull(success); + this.timestamp = requireNonNull(timestamp); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunFinished that = (TestRunFinished) o; + return + Objects.equals(message, that.message) && + success.equals(that.success) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + message, + success, + timestamp + ); + } + } + + + public static class TestRunStarted { + private final Timestamp timestamp; + public Timestamp getTimestamp() { + return timestamp; + } + + + public TestRunStarted( + Timestamp timestamp + ) { + this.timestamp = requireNonNull(timestamp); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunStarted that = (TestRunStarted) o; + return + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + timestamp + ); + } + } + + + public static class TestStepFinished { + private final String testCaseStartedId; + public String getTestCaseStartedId() { + return testCaseStartedId; + } + + private final String testStepId; + public String getTestStepId() { + return testStepId; + } + + private final TestStepResult testStepResult; + public TestStepResult getTestStepResult() { + return testStepResult; + } + + private final Timestamp timestamp; + public Timestamp getTimestamp() { + return timestamp; + } + + + public TestStepFinished( + String testCaseStartedId, + String testStepId, + TestStepResult testStepResult, + Timestamp timestamp + ) { + this.testCaseStartedId = requireNonNull(testCaseStartedId); + this.testStepId = requireNonNull(testStepId); + this.testStepResult = requireNonNull(testStepResult); + this.timestamp = requireNonNull(timestamp); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepFinished that = (TestStepFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + testStepResult.equals(that.testStepResult) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + testCaseStartedId, + testStepId, + testStepResult, + timestamp + ); + } + } + + + public static class TestStepResult { + private final Duration duration; + public Duration getDuration() { + return duration; + } + + private final String message; + public Optional getMessage() { + return ofNullable(message); + } + + private final TestStepResultStatus status; + public TestStepResultStatus getStatus() { + return status; + } + + + public TestStepResult( + Duration duration, + String message, + TestStepResultStatus status + ) { + this.duration = requireNonNull(duration); + this.message = message; + this.status = requireNonNull(status); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepResult that = (TestStepResult) o; + return + duration.equals(that.duration) && + Objects.equals(message, that.message) && + status.equals(that.status); + } + + @Override + public int hashCode() { + return Objects.hash( + duration, + message, + status + ); + } + } + + + public static class TestStepStarted { + private final String testCaseStartedId; + public String getTestCaseStartedId() { + return testCaseStartedId; + } + + private final String testStepId; + public String getTestStepId() { + return testStepId; + } + + private final Timestamp timestamp; + public Timestamp getTimestamp() { + return timestamp; + } + + + public TestStepStarted( + String testCaseStartedId, + String testStepId, + Timestamp timestamp + ) { + this.testCaseStartedId = requireNonNull(testCaseStartedId); + this.testStepId = requireNonNull(testStepId); + this.timestamp = requireNonNull(timestamp); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepStarted that = (TestStepStarted) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + testCaseStartedId, + testStepId, + timestamp + ); + } + } + + + public static class Timestamp { + private final Integer seconds; + public Integer getSeconds() { + return seconds; + } + + private final Integer nanos; + public Integer getNanos() { + return nanos; + } + + + public Timestamp( + Integer seconds, + Integer nanos + ) { + this.seconds = requireNonNull(seconds); + this.nanos = requireNonNull(nanos); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Timestamp that = (Timestamp) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return Objects.hash( + seconds, + nanos + ); + } + } + + + public static class UndefinedParameterType { + private final String expression; + public String getExpression() { + return expression; + } + + private final String name; + public String getName() { + return name; + } + + + public UndefinedParameterType( + String expression, + String name + ) { + this.expression = requireNonNull(expression); + this.name = requireNonNull(name); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UndefinedParameterType that = (UndefinedParameterType) o; + return + expression.equals(that.expression) && + name.equals(that.name); + } + + @Override + public int hashCode() { + return Objects.hash( + expression, + name + ); + } + } + + } +public enum AttachmentContentEncoding { + IDENTITY("IDENTITY"), + BASE64("BASE64"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap(); + + static { + for (AttachmentContentEncoding c: values()) { + CONSTANTS.put(c.value, c); + } + } + + AttachmentContentEncoding(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static AttachmentContentEncoding fromValue(String value) { + AttachmentContentEncoding constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } +} +public enum SourceMediaType { + TEXT_X_CUCUMBER_GHERKIN_PLAIN("text/x.cucumber.gherkin+plain"), + TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap(); + + static { + for (SourceMediaType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + SourceMediaType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static SourceMediaType fromValue(String value) { + SourceMediaType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } +} +public enum StepDefinitionPatternType { + CUCUMBER_EXPRESSION("CUCUMBER_EXPRESSION"), + REGULAR_EXPRESSION("REGULAR_EXPRESSION"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap(); + + static { + for (StepDefinitionPatternType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + StepDefinitionPatternType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static StepDefinitionPatternType fromValue(String value) { + StepDefinitionPatternType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } +} +public enum TestStepResultStatus { + UNKNOWN("UNKNOWN"), + PASSED("PASSED"), + SKIPPED("SKIPPED"), + PENDING("PENDING"), + UNDEFINED("UNDEFINED"), + AMBIGUOUS("AMBIGUOUS"), + FAILED("FAILED"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap(); + + static { + for (TestStepResultStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + TestStepResultStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static TestStepResultStatus fromValue(String value) { + TestStepResultStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } +} diff --git a/messages/javascript/Makefile b/messages/javascript/Makefile index 9daa7f7e99..122124f117 100644 --- a/messages/javascript/Makefile +++ b/messages/javascript/Makefile @@ -11,4 +11,4 @@ src/version.ts: package.json npm version --json | jq $$'"// This file is generated using `make src/version.ts` or `make .codegen`\nexport const version = \'" + (."@cucumber/messages") + "\'"' --raw-output > $@ clean: - rm -rf src/types/*.ts + rm -f src/messages.ts src/version.ts diff --git a/messages/jsonschema/scripts/codegen.rb b/messages/jsonschema/scripts/codegen.rb index fbe548cb14..40ce0949b5 100644 --- a/messages/jsonschema/scripts/codegen.rb +++ b/messages/jsonschema/scripts/codegen.rb @@ -144,6 +144,25 @@ def array_type_for(type_name) end end +class Java < Codegen + def initialize(paths) + template = File.read("#{TEMPLATES_DIRECTORY}/java.ts.erb") + enum_template = File.read("#{TEMPLATES_DIRECTORY}/java.enum.ts.erb") + + language_type_by_schema_type = { + 'integer' => 'Integer', + 'string' => 'String', + 'boolean' => 'Boolean', + } + + super(paths, template, enum_template, language_type_by_schema_type) + end + + def array_type_for(type_name) + "List<#{type_name}>" + end +end + class Perl < Codegen def initialize(paths, template_file_name: 'perl.pm.erb') template = File.read("#{TEMPLATES_DIRECTORY}/#{template_file_name}") diff --git a/messages/jsonschema/scripts/templates/java.enum.ts.erb b/messages/jsonschema/scripts/templates/java.enum.ts.erb new file mode 100644 index 0000000000..2478b75bda --- /dev/null +++ b/messages/jsonschema/scripts/templates/java.enum.ts.erb @@ -0,0 +1,36 @@ +public enum <%= enum[:name] %> { +<% enum[:values].each_with_index do |value, index| -%> + <%= enum_constant(value) %>("<%= value %>")<%= index < enum[:values].length-1 ? ',' : ';' %> +<% end -%> + + private final String value; + private final static java.util.Map> CONSTANTS = new java.util.HashMap>(); + + static { + for (<%= enum[:name] %> c: values()) { + CONSTANTS.put(c.value, c); + } + } + + <%= enum[:name] %>(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static <%= enum[:name] %> fromValue(String value) { + <%= enum[:name] %> constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } +} diff --git a/messages/jsonschema/scripts/templates/java.ts.erb b/messages/jsonschema/scripts/templates/java.ts.erb new file mode 100644 index 0000000000..e8db9affa5 --- /dev/null +++ b/messages/jsonschema/scripts/templates/java.ts.erb @@ -0,0 +1,69 @@ +package io.cucumber.messages; + +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Objects.requireNonNull; +import static java.util.Optional.empty; +import static java.util.Optional.of; +import static java.util.Optional.ofNullable; + +public class Messages { + <% @schemas.sort.each do |key, schema| %> + public static class <%= class_name(key) %> { + <%- schema['properties'].each do |property_name, property| -%> + private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; + <%- if (schema['required'] || []).index(property_name) -%> + public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { + return <%= property_name %>; + } + <%- else -%> + public Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { + return ofNullable(<%= property_name %>); + } + <%- end -%> + + <%- end -%> + + public <%= class_name(key) %>( + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> + <%- end -%> + ) { + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%- if (schema['required'] || []).index(property_name) -%> + this.<%= property_name %> = requireNonNull(<%= property_name %>); + <%- else -%> + this.<%= property_name %> = <%= property_name %>; + <%- end -%> + <%- end -%> + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + <%= class_name(key) %> that = (<%= class_name(key) %>) o; + return <%- schema['properties'].each_with_index do |(property_name, property), index| %> + <%- if (schema['required'] || []).index(property_name) -%> + <%= property_name -%>.equals(that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> + <%- else -%> + Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> + <%- end -%> + <% end -%> + + } + + @Override + public int hashCode() { + return Objects.hash( + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> + <%- end -%> + ); + } + } + + <% end -%> +} diff --git a/messages/jsonschema/scripts/templates/typescript.ts.erb b/messages/jsonschema/scripts/templates/typescript.ts.erb index 99c8a89991..e594ddc92c 100644 --- a/messages/jsonschema/scripts/templates/typescript.ts.erb +++ b/messages/jsonschema/scripts/templates/typescript.ts.erb @@ -18,4 +18,4 @@ export class <%= class_name(key) -%> { <%- end -%> } -<% end -%> \ No newline at end of file +<% end -%> From 0f51cba5bd4f10d7432df453bb376d34ff93f3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 12:21:03 +0000 Subject: [PATCH 02/63] Pass template as cli arg --- messages/go/Makefile | 5 +- messages/java/Makefile | 2 +- .../java/io/cucumber/messages/Messages.java | 3128 ----------------- messages/javascript/Makefile | 5 +- messages/jsonschema/Makefile | 5 +- messages/jsonschema/scripts/codegen.rb | 70 +- .../scripts/templates/go.enum.go.erb | 3 + .../scripts/templates/markdown.enum.md.erb | 3 + .../scripts/templates/perl.enum.pm.erb | 0 .../scripts/templates/ruby.enum.rb.erb | 3 + .../scripts/templates/typescript.enum.ts.erb | 4 +- messages/messages.md | 4 + messages/perl/Makefile | 4 +- messages/ruby/Makefile | 5 +- messages/ruby/lib/cucumber/messages.dtos.rb | 1 + 15 files changed, 59 insertions(+), 3183 deletions(-) delete mode 100644 messages/java/src/main/java/io/cucumber/messages/Messages.java delete mode 100644 messages/jsonschema/scripts/templates/perl.enum.pm.erb diff --git a/messages/go/Makefile b/messages/go/Makefile index acc9fe85f0..62171a8dce 100644 --- a/messages/go/Makefile +++ b/messages/go/Makefile @@ -4,5 +4,6 @@ JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") .deps: messages.go -messages.go: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb - ruby ../jsonschema/scripts/codegen.rb Go ../jsonschema > $@ +messages.go: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/go.go.erb ../jsonschema/scripts/templates/go.enum.go.erb + ruby ../jsonschema/scripts/codegen.rb Go ../jsonschema go.go.erb > $@ + ruby ../jsonschema/scripts/codegen.rb Go ../jsonschema go.enum.go.erb >> $@ diff --git a/messages/java/Makefile b/messages/java/Makefile index 21bcdacb02..dd76059913 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -3,7 +3,7 @@ include default.mk JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") TEMPLATES = $(shell find ../jsonschema/scripts/templates -name "*.erb") -.codegen: src/main/java/io/cucumber/messages/Messages.java +# .codegen: src/main/java/io/cucumber/messages/Messages.java src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) $(TEMPLATES) ../jsonschema/scripts/codegen.rb ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema > $@ diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java deleted file mode 100644 index 06980e8a79..0000000000 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ /dev/null @@ -1,3128 +0,0 @@ -package io.cucumber.messages; - -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import static java.util.Objects.requireNonNull; -import static java.util.Optional.empty; -import static java.util.Optional.of; -import static java.util.Optional.ofNullable; - -public class Messages { - - public static class Attachment { - private final String body; - public String getBody() { - return body; - } - - private final AttachmentContentEncoding contentEncoding; - public AttachmentContentEncoding getContentEncoding() { - return contentEncoding; - } - - private final String fileName; - public Optional getFileName() { - return ofNullable(fileName); - } - - private final String mediaType; - public String getMediaType() { - return mediaType; - } - - private final Source source; - public Optional getSource() { - return ofNullable(source); - } - - private final String testCaseStartedId; - public Optional getTestCaseStartedId() { - return ofNullable(testCaseStartedId); - } - - private final String testStepId; - public Optional getTestStepId() { - return ofNullable(testStepId); - } - - private final String url; - public Optional getUrl() { - return ofNullable(url); - } - - - public Attachment( - String body, - AttachmentContentEncoding contentEncoding, - String fileName, - String mediaType, - Source source, - String testCaseStartedId, - String testStepId, - String url - ) { - this.body = requireNonNull(body); - this.contentEncoding = requireNonNull(contentEncoding); - this.fileName = fileName; - this.mediaType = requireNonNull(mediaType); - this.source = source; - this.testCaseStartedId = testCaseStartedId; - this.testStepId = testStepId; - this.url = url; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Attachment that = (Attachment) o; - return - body.equals(that.body) && - contentEncoding.equals(that.contentEncoding) && - Objects.equals(fileName, that.fileName) && - mediaType.equals(that.mediaType) && - Objects.equals(source, that.source) && - Objects.equals(testCaseStartedId, that.testCaseStartedId) && - Objects.equals(testStepId, that.testStepId) && - Objects.equals(url, that.url); - } - - @Override - public int hashCode() { - return Objects.hash( - body, - contentEncoding, - fileName, - mediaType, - source, - testCaseStartedId, - testStepId, - url - ); - } - } - - - public static class Duration { - private final Integer seconds; - public Integer getSeconds() { - return seconds; - } - - private final Integer nanos; - public Integer getNanos() { - return nanos; - } - - - public Duration( - Integer seconds, - Integer nanos - ) { - this.seconds = requireNonNull(seconds); - this.nanos = requireNonNull(nanos); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Duration that = (Duration) o; - return - seconds.equals(that.seconds) && - nanos.equals(that.nanos); - } - - @Override - public int hashCode() { - return Objects.hash( - seconds, - nanos - ); - } - } - - - public static class Envelope { - private final Attachment attachment; - public Optional getAttachment() { - return ofNullable(attachment); - } - - private final GherkinDocument gherkinDocument; - public Optional getGherkinDocument() { - return ofNullable(gherkinDocument); - } - - private final Hook hook; - public Optional getHook() { - return ofNullable(hook); - } - - private final Meta meta; - public Optional getMeta() { - return ofNullable(meta); - } - - private final ParameterType parameterType; - public Optional getParameterType() { - return ofNullable(parameterType); - } - - private final ParseError parseError; - public Optional getParseError() { - return ofNullable(parseError); - } - - private final Pickle pickle; - public Optional getPickle() { - return ofNullable(pickle); - } - - private final Source source; - public Optional getSource() { - return ofNullable(source); - } - - private final StepDefinition stepDefinition; - public Optional getStepDefinition() { - return ofNullable(stepDefinition); - } - - private final TestCase testCase; - public Optional getTestCase() { - return ofNullable(testCase); - } - - private final TestCaseFinished testCaseFinished; - public Optional getTestCaseFinished() { - return ofNullable(testCaseFinished); - } - - private final TestCaseStarted testCaseStarted; - public Optional getTestCaseStarted() { - return ofNullable(testCaseStarted); - } - - private final TestRunFinished testRunFinished; - public Optional getTestRunFinished() { - return ofNullable(testRunFinished); - } - - private final TestRunStarted testRunStarted; - public Optional getTestRunStarted() { - return ofNullable(testRunStarted); - } - - private final TestStepFinished testStepFinished; - public Optional getTestStepFinished() { - return ofNullable(testStepFinished); - } - - private final TestStepStarted testStepStarted; - public Optional getTestStepStarted() { - return ofNullable(testStepStarted); - } - - private final UndefinedParameterType undefinedParameterType; - public Optional getUndefinedParameterType() { - return ofNullable(undefinedParameterType); - } - - - public Envelope( - Attachment attachment, - GherkinDocument gherkinDocument, - Hook hook, - Meta meta, - ParameterType parameterType, - ParseError parseError, - Pickle pickle, - Source source, - StepDefinition stepDefinition, - TestCase testCase, - TestCaseFinished testCaseFinished, - TestCaseStarted testCaseStarted, - TestRunFinished testRunFinished, - TestRunStarted testRunStarted, - TestStepFinished testStepFinished, - TestStepStarted testStepStarted, - UndefinedParameterType undefinedParameterType - ) { - this.attachment = attachment; - this.gherkinDocument = gherkinDocument; - this.hook = hook; - this.meta = meta; - this.parameterType = parameterType; - this.parseError = parseError; - this.pickle = pickle; - this.source = source; - this.stepDefinition = stepDefinition; - this.testCase = testCase; - this.testCaseFinished = testCaseFinished; - this.testCaseStarted = testCaseStarted; - this.testRunFinished = testRunFinished; - this.testRunStarted = testRunStarted; - this.testStepFinished = testStepFinished; - this.testStepStarted = testStepStarted; - this.undefinedParameterType = undefinedParameterType; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Envelope that = (Envelope) o; - return - Objects.equals(attachment, that.attachment) && - Objects.equals(gherkinDocument, that.gherkinDocument) && - Objects.equals(hook, that.hook) && - Objects.equals(meta, that.meta) && - Objects.equals(parameterType, that.parameterType) && - Objects.equals(parseError, that.parseError) && - Objects.equals(pickle, that.pickle) && - Objects.equals(source, that.source) && - Objects.equals(stepDefinition, that.stepDefinition) && - Objects.equals(testCase, that.testCase) && - Objects.equals(testCaseFinished, that.testCaseFinished) && - Objects.equals(testCaseStarted, that.testCaseStarted) && - Objects.equals(testRunFinished, that.testRunFinished) && - Objects.equals(testRunStarted, that.testRunStarted) && - Objects.equals(testStepFinished, that.testStepFinished) && - Objects.equals(testStepStarted, that.testStepStarted) && - Objects.equals(undefinedParameterType, that.undefinedParameterType); - } - - @Override - public int hashCode() { - return Objects.hash( - attachment, - gherkinDocument, - hook, - meta, - parameterType, - parseError, - pickle, - source, - stepDefinition, - testCase, - testCaseFinished, - testCaseStarted, - testRunFinished, - testRunStarted, - testStepFinished, - testStepStarted, - undefinedParameterType - ); - } - } - - - public static class GherkinDocument { - private final String uri; - public Optional getUri() { - return ofNullable(uri); - } - - private final Feature feature; - public Optional getFeature() { - return ofNullable(feature); - } - - private final List comments; - public List getComments() { - return comments; - } - - - public GherkinDocument( - String uri, - Feature feature, - List comments - ) { - this.uri = uri; - this.feature = feature; - this.comments = requireNonNull(comments); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - GherkinDocument that = (GherkinDocument) o; - return - Objects.equals(uri, that.uri) && - Objects.equals(feature, that.feature) && - comments.equals(that.comments); - } - - @Override - public int hashCode() { - return Objects.hash( - uri, - feature, - comments - ); - } - } - - - public static class Background { - private final Location location; - public Location getLocation() { - return location; - } - - private final String keyword; - public String getKeyword() { - return keyword; - } - - private final String name; - public String getName() { - return name; - } - - private final String description; - public String getDescription() { - return description; - } - - private final List steps; - public List getSteps() { - return steps; - } - - private final String id; - public String getId() { - return id; - } - - - public Background( - Location location, - String keyword, - String name, - String description, - List steps, - String id - ) { - this.location = requireNonNull(location); - this.keyword = requireNonNull(keyword); - this.name = requireNonNull(name); - this.description = requireNonNull(description); - this.steps = requireNonNull(steps); - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Background that = (Background) o; - return - location.equals(that.location) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - steps.equals(that.steps) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - keyword, - name, - description, - steps, - id - ); - } - } - - - public static class Comment { - private final Location location; - public Location getLocation() { - return location; - } - - private final String text; - public String getText() { - return text; - } - - - public Comment( - Location location, - String text - ) { - this.location = requireNonNull(location); - this.text = requireNonNull(text); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Comment that = (Comment) o; - return - location.equals(that.location) && - text.equals(that.text); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - text - ); - } - } - - - public static class DataTable { - private final Location location; - public Location getLocation() { - return location; - } - - private final List rows; - public List getRows() { - return rows; - } - - - public DataTable( - Location location, - List rows - ) { - this.location = requireNonNull(location); - this.rows = requireNonNull(rows); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DataTable that = (DataTable) o; - return - location.equals(that.location) && - rows.equals(that.rows); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - rows - ); - } - } - - - public static class DocString { - private final Location location; - public Location getLocation() { - return location; - } - - private final String mediaType; - public Optional getMediaType() { - return ofNullable(mediaType); - } - - private final String content; - public String getContent() { - return content; - } - - private final String delimiter; - public String getDelimiter() { - return delimiter; - } - - - public DocString( - Location location, - String mediaType, - String content, - String delimiter - ) { - this.location = requireNonNull(location); - this.mediaType = mediaType; - this.content = requireNonNull(content); - this.delimiter = requireNonNull(delimiter); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DocString that = (DocString) o; - return - location.equals(that.location) && - Objects.equals(mediaType, that.mediaType) && - content.equals(that.content) && - delimiter.equals(that.delimiter); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - mediaType, - content, - delimiter - ); - } - } - - - public static class Examples { - private final Location location; - public Location getLocation() { - return location; - } - - private final List tags; - public List getTags() { - return tags; - } - - private final String keyword; - public String getKeyword() { - return keyword; - } - - private final String name; - public String getName() { - return name; - } - - private final String description; - public String getDescription() { - return description; - } - - private final TableRow tableHeader; - public Optional getTableHeader() { - return ofNullable(tableHeader); - } - - private final List tableBody; - public List getTableBody() { - return tableBody; - } - - private final String id; - public String getId() { - return id; - } - - - public Examples( - Location location, - List tags, - String keyword, - String name, - String description, - TableRow tableHeader, - List tableBody, - String id - ) { - this.location = requireNonNull(location); - this.tags = requireNonNull(tags); - this.keyword = requireNonNull(keyword); - this.name = requireNonNull(name); - this.description = requireNonNull(description); - this.tableHeader = tableHeader; - this.tableBody = requireNonNull(tableBody); - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Examples that = (Examples) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - Objects.equals(tableHeader, that.tableHeader) && - tableBody.equals(that.tableBody) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - keyword, - name, - description, - tableHeader, - tableBody, - id - ); - } - } - - - public static class Feature { - private final Location location; - public Location getLocation() { - return location; - } - - private final List tags; - public List getTags() { - return tags; - } - - private final String language; - public String getLanguage() { - return language; - } - - private final String keyword; - public String getKeyword() { - return keyword; - } - - private final String name; - public String getName() { - return name; - } - - private final String description; - public String getDescription() { - return description; - } - - private final List children; - public List getChildren() { - return children; - } - - - public Feature( - Location location, - List tags, - String language, - String keyword, - String name, - String description, - List children - ) { - this.location = requireNonNull(location); - this.tags = requireNonNull(tags); - this.language = requireNonNull(language); - this.keyword = requireNonNull(keyword); - this.name = requireNonNull(name); - this.description = requireNonNull(description); - this.children = requireNonNull(children); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Feature that = (Feature) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - language.equals(that.language) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - children.equals(that.children); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - language, - keyword, - name, - description, - children - ); - } - } - - - public static class FeatureChild { - private final Rule rule; - public Optional getRule() { - return ofNullable(rule); - } - - private final Background background; - public Optional getBackground() { - return ofNullable(background); - } - - private final Scenario scenario; - public Optional getScenario() { - return ofNullable(scenario); - } - - - public FeatureChild( - Rule rule, - Background background, - Scenario scenario - ) { - this.rule = rule; - this.background = background; - this.scenario = scenario; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - FeatureChild that = (FeatureChild) o; - return - Objects.equals(rule, that.rule) && - Objects.equals(background, that.background) && - Objects.equals(scenario, that.scenario); - } - - @Override - public int hashCode() { - return Objects.hash( - rule, - background, - scenario - ); - } - } - - - public static class Rule { - private final Location location; - public Location getLocation() { - return location; - } - - private final List tags; - public List getTags() { - return tags; - } - - private final String keyword; - public String getKeyword() { - return keyword; - } - - private final String name; - public String getName() { - return name; - } - - private final String description; - public String getDescription() { - return description; - } - - private final List children; - public List getChildren() { - return children; - } - - private final String id; - public String getId() { - return id; - } - - - public Rule( - Location location, - List tags, - String keyword, - String name, - String description, - List children, - String id - ) { - this.location = requireNonNull(location); - this.tags = requireNonNull(tags); - this.keyword = requireNonNull(keyword); - this.name = requireNonNull(name); - this.description = requireNonNull(description); - this.children = requireNonNull(children); - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Rule that = (Rule) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - children.equals(that.children) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - keyword, - name, - description, - children, - id - ); - } - } - - - public static class RuleChild { - private final Background background; - public Optional getBackground() { - return ofNullable(background); - } - - private final Scenario scenario; - public Optional getScenario() { - return ofNullable(scenario); - } - - - public RuleChild( - Background background, - Scenario scenario - ) { - this.background = background; - this.scenario = scenario; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RuleChild that = (RuleChild) o; - return - Objects.equals(background, that.background) && - Objects.equals(scenario, that.scenario); - } - - @Override - public int hashCode() { - return Objects.hash( - background, - scenario - ); - } - } - - - public static class Scenario { - private final Location location; - public Location getLocation() { - return location; - } - - private final List tags; - public List getTags() { - return tags; - } - - private final String keyword; - public String getKeyword() { - return keyword; - } - - private final String name; - public String getName() { - return name; - } - - private final String description; - public String getDescription() { - return description; - } - - private final List steps; - public List getSteps() { - return steps; - } - - private final List examples; - public List getExamples() { - return examples; - } - - private final String id; - public String getId() { - return id; - } - - - public Scenario( - Location location, - List tags, - String keyword, - String name, - String description, - List steps, - List examples, - String id - ) { - this.location = requireNonNull(location); - this.tags = requireNonNull(tags); - this.keyword = requireNonNull(keyword); - this.name = requireNonNull(name); - this.description = requireNonNull(description); - this.steps = requireNonNull(steps); - this.examples = requireNonNull(examples); - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Scenario that = (Scenario) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - steps.equals(that.steps) && - examples.equals(that.examples) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - keyword, - name, - description, - steps, - examples, - id - ); - } - } - - - public static class Step { - private final Location location; - public Location getLocation() { - return location; - } - - private final String keyword; - public String getKeyword() { - return keyword; - } - - private final String text; - public String getText() { - return text; - } - - private final DocString docString; - public Optional getDocString() { - return ofNullable(docString); - } - - private final DataTable dataTable; - public Optional getDataTable() { - return ofNullable(dataTable); - } - - private final String id; - public String getId() { - return id; - } - - - public Step( - Location location, - String keyword, - String text, - DocString docString, - DataTable dataTable, - String id - ) { - this.location = requireNonNull(location); - this.keyword = requireNonNull(keyword); - this.text = requireNonNull(text); - this.docString = docString; - this.dataTable = dataTable; - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Step that = (Step) o; - return - location.equals(that.location) && - keyword.equals(that.keyword) && - text.equals(that.text) && - Objects.equals(docString, that.docString) && - Objects.equals(dataTable, that.dataTable) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - keyword, - text, - docString, - dataTable, - id - ); - } - } - - - public static class TableCell { - private final Location location; - public Location getLocation() { - return location; - } - - private final String value; - public String getValue() { - return value; - } - - - public TableCell( - Location location, - String value - ) { - this.location = requireNonNull(location); - this.value = requireNonNull(value); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TableCell that = (TableCell) o; - return - location.equals(that.location) && - value.equals(that.value); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - value - ); - } - } - - - public static class TableRow { - private final Location location; - public Location getLocation() { - return location; - } - - private final List cells; - public List getCells() { - return cells; - } - - private final String id; - public String getId() { - return id; - } - - - public TableRow( - Location location, - List cells, - String id - ) { - this.location = requireNonNull(location); - this.cells = requireNonNull(cells); - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TableRow that = (TableRow) o; - return - location.equals(that.location) && - cells.equals(that.cells) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - cells, - id - ); - } - } - - - public static class Tag { - private final Location location; - public Location getLocation() { - return location; - } - - private final String name; - public String getName() { - return name; - } - - private final String id; - public String getId() { - return id; - } - - - public Tag( - Location location, - String name, - String id - ) { - this.location = requireNonNull(location); - this.name = requireNonNull(name); - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Tag that = (Tag) o; - return - location.equals(that.location) && - name.equals(that.name) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - name, - id - ); - } - } - - - public static class Hook { - private final String id; - public String getId() { - return id; - } - - private final SourceReference sourceReference; - public SourceReference getSourceReference() { - return sourceReference; - } - - private final String tagExpression; - public Optional getTagExpression() { - return ofNullable(tagExpression); - } - - - public Hook( - String id, - SourceReference sourceReference, - String tagExpression - ) { - this.id = requireNonNull(id); - this.sourceReference = requireNonNull(sourceReference); - this.tagExpression = tagExpression; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Hook that = (Hook) o; - return - id.equals(that.id) && - sourceReference.equals(that.sourceReference) && - Objects.equals(tagExpression, that.tagExpression); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - sourceReference, - tagExpression - ); - } - } - - - public static class Location { - private final Integer line; - public Integer getLine() { - return line; - } - - private final Integer column; - public Optional getColumn() { - return ofNullable(column); - } - - - public Location( - Integer line, - Integer column - ) { - this.line = requireNonNull(line); - this.column = column; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Location that = (Location) o; - return - line.equals(that.line) && - Objects.equals(column, that.column); - } - - @Override - public int hashCode() { - return Objects.hash( - line, - column - ); - } - } - - - public static class Meta { - private final String protocolVersion; - public String getProtocolVersion() { - return protocolVersion; - } - - private final Product implementation; - public Product getImplementation() { - return implementation; - } - - private final Product runtime; - public Product getRuntime() { - return runtime; - } - - private final Product os; - public Product getOs() { - return os; - } - - private final Product cpu; - public Product getCpu() { - return cpu; - } - - private final Ci ci; - public Optional getCi() { - return ofNullable(ci); - } - - - public Meta( - String protocolVersion, - Product implementation, - Product runtime, - Product os, - Product cpu, - Ci ci - ) { - this.protocolVersion = requireNonNull(protocolVersion); - this.implementation = requireNonNull(implementation); - this.runtime = requireNonNull(runtime); - this.os = requireNonNull(os); - this.cpu = requireNonNull(cpu); - this.ci = ci; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Meta that = (Meta) o; - return - protocolVersion.equals(that.protocolVersion) && - implementation.equals(that.implementation) && - runtime.equals(that.runtime) && - os.equals(that.os) && - cpu.equals(that.cpu) && - Objects.equals(ci, that.ci); - } - - @Override - public int hashCode() { - return Objects.hash( - protocolVersion, - implementation, - runtime, - os, - cpu, - ci - ); - } - } - - - public static class Ci { - private final String name; - public String getName() { - return name; - } - - private final String url; - public Optional getUrl() { - return ofNullable(url); - } - - private final String buildNumber; - public Optional getBuildNumber() { - return ofNullable(buildNumber); - } - - private final Git git; - public Optional getGit() { - return ofNullable(git); - } - - - public Ci( - String name, - String url, - String buildNumber, - Git git - ) { - this.name = requireNonNull(name); - this.url = url; - this.buildNumber = buildNumber; - this.git = git; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Ci that = (Ci) o; - return - name.equals(that.name) && - Objects.equals(url, that.url) && - Objects.equals(buildNumber, that.buildNumber) && - Objects.equals(git, that.git); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - url, - buildNumber, - git - ); - } - } - - - public static class Git { - private final String remote; - public String getRemote() { - return remote; - } - - private final String revision; - public String getRevision() { - return revision; - } - - private final String branch; - public Optional getBranch() { - return ofNullable(branch); - } - - private final String tag; - public Optional getTag() { - return ofNullable(tag); - } - - - public Git( - String remote, - String revision, - String branch, - String tag - ) { - this.remote = requireNonNull(remote); - this.revision = requireNonNull(revision); - this.branch = branch; - this.tag = tag; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Git that = (Git) o; - return - remote.equals(that.remote) && - revision.equals(that.revision) && - Objects.equals(branch, that.branch) && - Objects.equals(tag, that.tag); - } - - @Override - public int hashCode() { - return Objects.hash( - remote, - revision, - branch, - tag - ); - } - } - - - public static class Product { - private final String name; - public String getName() { - return name; - } - - private final String version; - public Optional getVersion() { - return ofNullable(version); - } - - - public Product( - String name, - String version - ) { - this.name = requireNonNull(name); - this.version = version; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Product that = (Product) o; - return - name.equals(that.name) && - Objects.equals(version, that.version); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - version - ); - } - } - - - public static class ParameterType { - private final String name; - public String getName() { - return name; - } - - private final List regularExpressions; - public List getRegularExpressions() { - return regularExpressions; - } - - private final Boolean preferForRegularExpressionMatch; - public Boolean getPreferForRegularExpressionMatch() { - return preferForRegularExpressionMatch; - } - - private final Boolean useForSnippets; - public Boolean getUseForSnippets() { - return useForSnippets; - } - - private final String id; - public String getId() { - return id; - } - - - public ParameterType( - String name, - List regularExpressions, - Boolean preferForRegularExpressionMatch, - Boolean useForSnippets, - String id - ) { - this.name = requireNonNull(name); - this.regularExpressions = requireNonNull(regularExpressions); - this.preferForRegularExpressionMatch = requireNonNull(preferForRegularExpressionMatch); - this.useForSnippets = requireNonNull(useForSnippets); - this.id = requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ParameterType that = (ParameterType) o; - return - name.equals(that.name) && - regularExpressions.equals(that.regularExpressions) && - preferForRegularExpressionMatch.equals(that.preferForRegularExpressionMatch) && - useForSnippets.equals(that.useForSnippets) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - regularExpressions, - preferForRegularExpressionMatch, - useForSnippets, - id - ); - } - } - - - public static class ParseError { - private final SourceReference source; - public SourceReference getSource() { - return source; - } - - private final String message; - public String getMessage() { - return message; - } - - - public ParseError( - SourceReference source, - String message - ) { - this.source = requireNonNull(source); - this.message = requireNonNull(message); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ParseError that = (ParseError) o; - return - source.equals(that.source) && - message.equals(that.message); - } - - @Override - public int hashCode() { - return Objects.hash( - source, - message - ); - } - } - - - public static class Pickle { - private final String id; - public String getId() { - return id; - } - - private final String uri; - public String getUri() { - return uri; - } - - private final String name; - public String getName() { - return name; - } - - private final String language; - public String getLanguage() { - return language; - } - - private final List steps; - public List getSteps() { - return steps; - } - - private final List tags; - public List getTags() { - return tags; - } - - private final List astNodeIds; - public List getAstNodeIds() { - return astNodeIds; - } - - - public Pickle( - String id, - String uri, - String name, - String language, - List steps, - List tags, - List astNodeIds - ) { - this.id = requireNonNull(id); - this.uri = requireNonNull(uri); - this.name = requireNonNull(name); - this.language = requireNonNull(language); - this.steps = requireNonNull(steps); - this.tags = requireNonNull(tags); - this.astNodeIds = requireNonNull(astNodeIds); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Pickle that = (Pickle) o; - return - id.equals(that.id) && - uri.equals(that.uri) && - name.equals(that.name) && - language.equals(that.language) && - steps.equals(that.steps) && - tags.equals(that.tags) && - astNodeIds.equals(that.astNodeIds); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - uri, - name, - language, - steps, - tags, - astNodeIds - ); - } - } - - - public static class PickleDocString { - private final String mediaType; - public Optional getMediaType() { - return ofNullable(mediaType); - } - - private final String content; - public String getContent() { - return content; - } - - - public PickleDocString( - String mediaType, - String content - ) { - this.mediaType = mediaType; - this.content = requireNonNull(content); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleDocString that = (PickleDocString) o; - return - Objects.equals(mediaType, that.mediaType) && - content.equals(that.content); - } - - @Override - public int hashCode() { - return Objects.hash( - mediaType, - content - ); - } - } - - - public static class PickleStep { - private final PickleStepArgument argument; - public Optional getArgument() { - return ofNullable(argument); - } - - private final List astNodeIds; - public List getAstNodeIds() { - return astNodeIds; - } - - private final String id; - public String getId() { - return id; - } - - private final String text; - public String getText() { - return text; - } - - - public PickleStep( - PickleStepArgument argument, - List astNodeIds, - String id, - String text - ) { - this.argument = argument; - this.astNodeIds = requireNonNull(astNodeIds); - this.id = requireNonNull(id); - this.text = requireNonNull(text); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleStep that = (PickleStep) o; - return - Objects.equals(argument, that.argument) && - astNodeIds.equals(that.astNodeIds) && - id.equals(that.id) && - text.equals(that.text); - } - - @Override - public int hashCode() { - return Objects.hash( - argument, - astNodeIds, - id, - text - ); - } - } - - - public static class PickleStepArgument { - private final PickleDocString docString; - public Optional getDocString() { - return ofNullable(docString); - } - - private final PickleTable dataTable; - public Optional getDataTable() { - return ofNullable(dataTable); - } - - - public PickleStepArgument( - PickleDocString docString, - PickleTable dataTable - ) { - this.docString = docString; - this.dataTable = dataTable; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleStepArgument that = (PickleStepArgument) o; - return - Objects.equals(docString, that.docString) && - Objects.equals(dataTable, that.dataTable); - } - - @Override - public int hashCode() { - return Objects.hash( - docString, - dataTable - ); - } - } - - - public static class PickleTable { - private final List rows; - public List getRows() { - return rows; - } - - - public PickleTable( - List rows - ) { - this.rows = requireNonNull(rows); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTable that = (PickleTable) o; - return - rows.equals(that.rows); - } - - @Override - public int hashCode() { - return Objects.hash( - rows - ); - } - } - - - public static class PickleTableCell { - private final String value; - public String getValue() { - return value; - } - - - public PickleTableCell( - String value - ) { - this.value = requireNonNull(value); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTableCell that = (PickleTableCell) o; - return - value.equals(that.value); - } - - @Override - public int hashCode() { - return Objects.hash( - value - ); - } - } - - - public static class PickleTableRow { - private final List cells; - public List getCells() { - return cells; - } - - - public PickleTableRow( - List cells - ) { - this.cells = requireNonNull(cells); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTableRow that = (PickleTableRow) o; - return - cells.equals(that.cells); - } - - @Override - public int hashCode() { - return Objects.hash( - cells - ); - } - } - - - public static class PickleTag { - private final String name; - public String getName() { - return name; - } - - private final String astNodeId; - public String getAstNodeId() { - return astNodeId; - } - - - public PickleTag( - String name, - String astNodeId - ) { - this.name = requireNonNull(name); - this.astNodeId = requireNonNull(astNodeId); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTag that = (PickleTag) o; - return - name.equals(that.name) && - astNodeId.equals(that.astNodeId); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - astNodeId - ); - } - } - - - public static class Source { - private final String uri; - public String getUri() { - return uri; - } - - private final String data; - public String getData() { - return data; - } - - private final SourceMediaType mediaType; - public SourceMediaType getMediaType() { - return mediaType; - } - - - public Source( - String uri, - String data, - SourceMediaType mediaType - ) { - this.uri = requireNonNull(uri); - this.data = requireNonNull(data); - this.mediaType = requireNonNull(mediaType); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Source that = (Source) o; - return - uri.equals(that.uri) && - data.equals(that.data) && - mediaType.equals(that.mediaType); - } - - @Override - public int hashCode() { - return Objects.hash( - uri, - data, - mediaType - ); - } - } - - - public static class SourceReference { - private final String uri; - public Optional getUri() { - return ofNullable(uri); - } - - private final JavaMethod javaMethod; - public Optional getJavaMethod() { - return ofNullable(javaMethod); - } - - private final JavaStackTraceElement javaStackTraceElement; - public Optional getJavaStackTraceElement() { - return ofNullable(javaStackTraceElement); - } - - private final Location location; - public Optional getLocation() { - return ofNullable(location); - } - - - public SourceReference( - String uri, - JavaMethod javaMethod, - JavaStackTraceElement javaStackTraceElement, - Location location - ) { - this.uri = uri; - this.javaMethod = javaMethod; - this.javaStackTraceElement = javaStackTraceElement; - this.location = location; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SourceReference that = (SourceReference) o; - return - Objects.equals(uri, that.uri) && - Objects.equals(javaMethod, that.javaMethod) && - Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && - Objects.equals(location, that.location); - } - - @Override - public int hashCode() { - return Objects.hash( - uri, - javaMethod, - javaStackTraceElement, - location - ); - } - } - - - public static class JavaMethod { - private final String className; - public String getClassName() { - return className; - } - - private final String methodName; - public String getMethodName() { - return methodName; - } - - private final List methodParameterTypes; - public List getMethodParameterTypes() { - return methodParameterTypes; - } - - - public JavaMethod( - String className, - String methodName, - List methodParameterTypes - ) { - this.className = requireNonNull(className); - this.methodName = requireNonNull(methodName); - this.methodParameterTypes = requireNonNull(methodParameterTypes); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - JavaMethod that = (JavaMethod) o; - return - className.equals(that.className) && - methodName.equals(that.methodName) && - methodParameterTypes.equals(that.methodParameterTypes); - } - - @Override - public int hashCode() { - return Objects.hash( - className, - methodName, - methodParameterTypes - ); - } - } - - - public static class JavaStackTraceElement { - private final String className; - public String getClassName() { - return className; - } - - private final String fileName; - public String getFileName() { - return fileName; - } - - private final String methodName; - public String getMethodName() { - return methodName; - } - - - public JavaStackTraceElement( - String className, - String fileName, - String methodName - ) { - this.className = requireNonNull(className); - this.fileName = requireNonNull(fileName); - this.methodName = requireNonNull(methodName); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - JavaStackTraceElement that = (JavaStackTraceElement) o; - return - className.equals(that.className) && - fileName.equals(that.fileName) && - methodName.equals(that.methodName); - } - - @Override - public int hashCode() { - return Objects.hash( - className, - fileName, - methodName - ); - } - } - - - public static class StepDefinition { - private final String id; - public String getId() { - return id; - } - - private final StepDefinitionPattern pattern; - public StepDefinitionPattern getPattern() { - return pattern; - } - - private final SourceReference sourceReference; - public SourceReference getSourceReference() { - return sourceReference; - } - - - public StepDefinition( - String id, - StepDefinitionPattern pattern, - SourceReference sourceReference - ) { - this.id = requireNonNull(id); - this.pattern = requireNonNull(pattern); - this.sourceReference = requireNonNull(sourceReference); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepDefinition that = (StepDefinition) o; - return - id.equals(that.id) && - pattern.equals(that.pattern) && - sourceReference.equals(that.sourceReference); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - pattern, - sourceReference - ); - } - } - - - public static class StepDefinitionPattern { - private final String source; - public String getSource() { - return source; - } - - private final StepDefinitionPatternType type; - public StepDefinitionPatternType getType() { - return type; - } - - - public StepDefinitionPattern( - String source, - StepDefinitionPatternType type - ) { - this.source = requireNonNull(source); - this.type = requireNonNull(type); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepDefinitionPattern that = (StepDefinitionPattern) o; - return - source.equals(that.source) && - type.equals(that.type); - } - - @Override - public int hashCode() { - return Objects.hash( - source, - type - ); - } - } - - - public static class TestCase { - private final String id; - public String getId() { - return id; - } - - private final String pickleId; - public String getPickleId() { - return pickleId; - } - - private final List testSteps; - public List getTestSteps() { - return testSteps; - } - - - public TestCase( - String id, - String pickleId, - List testSteps - ) { - this.id = requireNonNull(id); - this.pickleId = requireNonNull(pickleId); - this.testSteps = requireNonNull(testSteps); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCase that = (TestCase) o; - return - id.equals(that.id) && - pickleId.equals(that.pickleId) && - testSteps.equals(that.testSteps); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - pickleId, - testSteps - ); - } - } - - - public static class Group { - private final List children; - public List getChildren() { - return children; - } - - private final Integer start; - public Optional getStart() { - return ofNullable(start); - } - - private final String value; - public Optional getValue() { - return ofNullable(value); - } - - - public Group( - List children, - Integer start, - String value - ) { - this.children = requireNonNull(children); - this.start = start; - this.value = value; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Group that = (Group) o; - return - children.equals(that.children) && - Objects.equals(start, that.start) && - Objects.equals(value, that.value); - } - - @Override - public int hashCode() { - return Objects.hash( - children, - start, - value - ); - } - } - - - public static class StepMatchArgument { - private final Group group; - public Group getGroup() { - return group; - } - - private final String parameterTypeName; - public Optional getParameterTypeName() { - return ofNullable(parameterTypeName); - } - - - public StepMatchArgument( - Group group, - String parameterTypeName - ) { - this.group = requireNonNull(group); - this.parameterTypeName = parameterTypeName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepMatchArgument that = (StepMatchArgument) o; - return - group.equals(that.group) && - Objects.equals(parameterTypeName, that.parameterTypeName); - } - - @Override - public int hashCode() { - return Objects.hash( - group, - parameterTypeName - ); - } - } - - - public static class StepMatchArgumentsList { - private final List stepMatchArguments; - public List getStepMatchArguments() { - return stepMatchArguments; - } - - - public StepMatchArgumentsList( - List stepMatchArguments - ) { - this.stepMatchArguments = requireNonNull(stepMatchArguments); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepMatchArgumentsList that = (StepMatchArgumentsList) o; - return - stepMatchArguments.equals(that.stepMatchArguments); - } - - @Override - public int hashCode() { - return Objects.hash( - stepMatchArguments - ); - } - } - - - public static class TestStep { - private final String hookId; - public Optional getHookId() { - return ofNullable(hookId); - } - - private final String id; - public String getId() { - return id; - } - - private final String pickleStepId; - public Optional getPickleStepId() { - return ofNullable(pickleStepId); - } - - private final List stepDefinitionIds; - public Optional> getStepDefinitionIds() { - return ofNullable(stepDefinitionIds); - } - - private final List stepMatchArgumentsLists; - public Optional> getStepMatchArgumentsLists() { - return ofNullable(stepMatchArgumentsLists); - } - - - public TestStep( - String hookId, - String id, - String pickleStepId, - List stepDefinitionIds, - List stepMatchArgumentsLists - ) { - this.hookId = hookId; - this.id = requireNonNull(id); - this.pickleStepId = pickleStepId; - this.stepDefinitionIds = stepDefinitionIds; - this.stepMatchArgumentsLists = stepMatchArgumentsLists; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStep that = (TestStep) o; - return - Objects.equals(hookId, that.hookId) && - id.equals(that.id) && - Objects.equals(pickleStepId, that.pickleStepId) && - Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && - Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); - } - - @Override - public int hashCode() { - return Objects.hash( - hookId, - id, - pickleStepId, - stepDefinitionIds, - stepMatchArgumentsLists - ); - } - } - - - public static class TestCaseFinished { - private final String testCaseStartedId; - public String getTestCaseStartedId() { - return testCaseStartedId; - } - - private final Timestamp timestamp; - public Timestamp getTimestamp() { - return timestamp; - } - - private final Boolean willBeRetried; - public Boolean getWillBeRetried() { - return willBeRetried; - } - - - public TestCaseFinished( - String testCaseStartedId, - Timestamp timestamp, - Boolean willBeRetried - ) { - this.testCaseStartedId = requireNonNull(testCaseStartedId); - this.timestamp = requireNonNull(timestamp); - this.willBeRetried = requireNonNull(willBeRetried); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCaseFinished that = (TestCaseFinished) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - timestamp.equals(that.timestamp) && - willBeRetried.equals(that.willBeRetried); - } - - @Override - public int hashCode() { - return Objects.hash( - testCaseStartedId, - timestamp, - willBeRetried - ); - } - } - - - public static class TestCaseStarted { - private final Integer attempt; - public Integer getAttempt() { - return attempt; - } - - private final String id; - public String getId() { - return id; - } - - private final String testCaseId; - public String getTestCaseId() { - return testCaseId; - } - - private final Timestamp timestamp; - public Timestamp getTimestamp() { - return timestamp; - } - - - public TestCaseStarted( - Integer attempt, - String id, - String testCaseId, - Timestamp timestamp - ) { - this.attempt = requireNonNull(attempt); - this.id = requireNonNull(id); - this.testCaseId = requireNonNull(testCaseId); - this.timestamp = requireNonNull(timestamp); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCaseStarted that = (TestCaseStarted) o; - return - attempt.equals(that.attempt) && - id.equals(that.id) && - testCaseId.equals(that.testCaseId) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - attempt, - id, - testCaseId, - timestamp - ); - } - } - - - public static class TestRunFinished { - private final String message; - public Optional getMessage() { - return ofNullable(message); - } - - private final Boolean success; - public Boolean getSuccess() { - return success; - } - - private final Timestamp timestamp; - public Timestamp getTimestamp() { - return timestamp; - } - - - public TestRunFinished( - String message, - Boolean success, - Timestamp timestamp - ) { - this.message = message; - this.success = requireNonNull(success); - this.timestamp = requireNonNull(timestamp); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestRunFinished that = (TestRunFinished) o; - return - Objects.equals(message, that.message) && - success.equals(that.success) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - message, - success, - timestamp - ); - } - } - - - public static class TestRunStarted { - private final Timestamp timestamp; - public Timestamp getTimestamp() { - return timestamp; - } - - - public TestRunStarted( - Timestamp timestamp - ) { - this.timestamp = requireNonNull(timestamp); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestRunStarted that = (TestRunStarted) o; - return - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - timestamp - ); - } - } - - - public static class TestStepFinished { - private final String testCaseStartedId; - public String getTestCaseStartedId() { - return testCaseStartedId; - } - - private final String testStepId; - public String getTestStepId() { - return testStepId; - } - - private final TestStepResult testStepResult; - public TestStepResult getTestStepResult() { - return testStepResult; - } - - private final Timestamp timestamp; - public Timestamp getTimestamp() { - return timestamp; - } - - - public TestStepFinished( - String testCaseStartedId, - String testStepId, - TestStepResult testStepResult, - Timestamp timestamp - ) { - this.testCaseStartedId = requireNonNull(testCaseStartedId); - this.testStepId = requireNonNull(testStepId); - this.testStepResult = requireNonNull(testStepResult); - this.timestamp = requireNonNull(timestamp); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepFinished that = (TestStepFinished) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - testStepId.equals(that.testStepId) && - testStepResult.equals(that.testStepResult) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - testCaseStartedId, - testStepId, - testStepResult, - timestamp - ); - } - } - - - public static class TestStepResult { - private final Duration duration; - public Duration getDuration() { - return duration; - } - - private final String message; - public Optional getMessage() { - return ofNullable(message); - } - - private final TestStepResultStatus status; - public TestStepResultStatus getStatus() { - return status; - } - - - public TestStepResult( - Duration duration, - String message, - TestStepResultStatus status - ) { - this.duration = requireNonNull(duration); - this.message = message; - this.status = requireNonNull(status); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepResult that = (TestStepResult) o; - return - duration.equals(that.duration) && - Objects.equals(message, that.message) && - status.equals(that.status); - } - - @Override - public int hashCode() { - return Objects.hash( - duration, - message, - status - ); - } - } - - - public static class TestStepStarted { - private final String testCaseStartedId; - public String getTestCaseStartedId() { - return testCaseStartedId; - } - - private final String testStepId; - public String getTestStepId() { - return testStepId; - } - - private final Timestamp timestamp; - public Timestamp getTimestamp() { - return timestamp; - } - - - public TestStepStarted( - String testCaseStartedId, - String testStepId, - Timestamp timestamp - ) { - this.testCaseStartedId = requireNonNull(testCaseStartedId); - this.testStepId = requireNonNull(testStepId); - this.timestamp = requireNonNull(timestamp); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepStarted that = (TestStepStarted) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - testStepId.equals(that.testStepId) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - testCaseStartedId, - testStepId, - timestamp - ); - } - } - - - public static class Timestamp { - private final Integer seconds; - public Integer getSeconds() { - return seconds; - } - - private final Integer nanos; - public Integer getNanos() { - return nanos; - } - - - public Timestamp( - Integer seconds, - Integer nanos - ) { - this.seconds = requireNonNull(seconds); - this.nanos = requireNonNull(nanos); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Timestamp that = (Timestamp) o; - return - seconds.equals(that.seconds) && - nanos.equals(that.nanos); - } - - @Override - public int hashCode() { - return Objects.hash( - seconds, - nanos - ); - } - } - - - public static class UndefinedParameterType { - private final String expression; - public String getExpression() { - return expression; - } - - private final String name; - public String getName() { - return name; - } - - - public UndefinedParameterType( - String expression, - String name - ) { - this.expression = requireNonNull(expression); - this.name = requireNonNull(name); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - UndefinedParameterType that = (UndefinedParameterType) o; - return - expression.equals(that.expression) && - name.equals(that.name); - } - - @Override - public int hashCode() { - return Objects.hash( - expression, - name - ); - } - } - - } -public enum AttachmentContentEncoding { - IDENTITY("IDENTITY"), - BASE64("BASE64"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap(); - - static { - for (AttachmentContentEncoding c: values()) { - CONSTANTS.put(c.value, c); - } - } - - AttachmentContentEncoding(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static AttachmentContentEncoding fromValue(String value) { - AttachmentContentEncoding constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } -} -public enum SourceMediaType { - TEXT_X_CUCUMBER_GHERKIN_PLAIN("text/x.cucumber.gherkin+plain"), - TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap(); - - static { - for (SourceMediaType c: values()) { - CONSTANTS.put(c.value, c); - } - } - - SourceMediaType(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static SourceMediaType fromValue(String value) { - SourceMediaType constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } -} -public enum StepDefinitionPatternType { - CUCUMBER_EXPRESSION("CUCUMBER_EXPRESSION"), - REGULAR_EXPRESSION("REGULAR_EXPRESSION"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap(); - - static { - for (StepDefinitionPatternType c: values()) { - CONSTANTS.put(c.value, c); - } - } - - StepDefinitionPatternType(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static StepDefinitionPatternType fromValue(String value) { - StepDefinitionPatternType constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } -} -public enum TestStepResultStatus { - UNKNOWN("UNKNOWN"), - PASSED("PASSED"), - SKIPPED("SKIPPED"), - PENDING("PENDING"), - UNDEFINED("UNDEFINED"), - AMBIGUOUS("AMBIGUOUS"), - FAILED("FAILED"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap(); - - static { - for (TestStepResultStatus c: values()) { - CONSTANTS.put(c.value, c); - } - } - - TestStepResultStatus(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static TestStepResultStatus fromValue(String value) { - TestStepResultStatus constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } -} diff --git a/messages/javascript/Makefile b/messages/javascript/Makefile index 122124f117..bbb56538ef 100644 --- a/messages/javascript/Makefile +++ b/messages/javascript/Makefile @@ -4,8 +4,9 @@ JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") .codegen: src/messages.ts src/version.ts -src/messages.ts: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb - ruby ../jsonschema/scripts/codegen.rb TypeScript ../jsonschema > $@ +src/messages.ts: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/typescript.ts.erb ../jsonschema/scripts/templates/typescript.enum.ts.erb + ruby ../jsonschema/scripts/codegen.rb TypeScript ../jsonschema typescript.ts.erb > $@ + ruby ../jsonschema/scripts/codegen.rb TypeScript ../jsonschema typescript.enum.ts.erb >> $@ src/version.ts: package.json npm version --json | jq $$'"// This file is generated using `make src/version.ts` or `make .codegen`\nexport const version = \'" + (."@cucumber/messages") + "\'"' --raw-output > $@ diff --git a/messages/jsonschema/Makefile b/messages/jsonschema/Makefile index c91ff21512..3bafdc7e4d 100644 --- a/messages/jsonschema/Makefile +++ b/messages/jsonschema/Makefile @@ -12,8 +12,9 @@ default: .validated ../messages.md ../../node_modules ../../package-lock.json: cd ../.. && npm install -../messages.md: $(SCHEMA_FILES) ./scripts/codegen.rb - ruby ./scripts/codegen.rb Markdown . > $@ +../messages.md: $(SCHEMA_FILES) ./scripts/codegen.rb ./scripts/templates/typescript.ts.erb ./scripts/templates/typescript.enum.ts.erb + ruby ./scripts/codegen.rb Markdown . markdown.md.erb > $@ + ruby ./scripts/codegen.rb Markdown . markdown.enum.md.erb >> $@ ## General targets called by parent makefiles diff --git a/messages/jsonschema/scripts/codegen.rb b/messages/jsonschema/scripts/codegen.rb index 40ce0949b5..f1c5f21943 100644 --- a/messages/jsonschema/scripts/codegen.rb +++ b/messages/jsonschema/scripts/codegen.rb @@ -5,14 +5,12 @@ class Codegen TEMPLATES_DIRECTORY = "#{File.dirname(__FILE__)}/templates/" - def initialize(paths, template, enum_template, language_type_by_schema_type) + def initialize(paths, language_type_by_schema_type) @paths = paths - @template = ERB.new(template, nil, '-') - @enum_template = ERB.new(enum_template, nil, '-') @language_type_by_schema_type = language_type_by_schema_type @schemas = {} - @enums = Set.new + @enum_set = Set.new @paths.each do |path| expanded_path = File.expand_path(path) @@ -24,13 +22,14 @@ def initialize(paths, template, enum_template, language_type_by_schema_type) raise e end end + + @enums = @enum_set.to_a.sort{|a,b| a[:name] <=> b[:name]} end - def generate - STDOUT.write @template.result(binding) - @enums.to_a.sort{|a,b| a[:name] <=> b[:name]}.each do |enum| - STDOUT.write @enum_template.result(binding) - end + def generate(template_name) + template_source = File.read("#{TEMPLATES_DIRECTORY}/#{template_name}") + template = ERB.new(template_source, nil, '-') + STDOUT.write template.result(binding) end def add_schema(key, schema) @@ -39,6 +38,15 @@ def add_schema(key, schema) subkey = "#{key}/#{name}" add_schema(subkey, subschema) end + + schema['properties'].each do |property_name, property| + enum = property['enum'] + if enum + parent_type_name = class_name(key) + enum_type_name = "#{parent_type_name}#{capitalize(property_name)}" + @enum_set.add({ name: enum_type_name, values: enum }) + end + end end def native_type?(type_name) @@ -85,7 +93,6 @@ def type_for(parent_type_name, property_name, property) raise "No type mapping for JSONSchema type #{type}. Schema:\n#{JSON.pretty_generate(property)}" unless @language_type_by_schema_type[type] if enum enum_type_name = "#{parent_type_name}#{capitalize(property_name)}" - @enums.add({ name: enum_type_name, values: enum }) property_type_from_enum(enum_type_name) else @language_type_by_schema_type[type] @@ -127,16 +134,13 @@ def underscore(camel_cased_word) class TypeScript < Codegen def initialize(paths) - template = File.read("#{TEMPLATES_DIRECTORY}/typescript.ts.erb") - enum_template = File.read("#{TEMPLATES_DIRECTORY}/typescript.enum.ts.erb") - language_type_by_schema_type = { 'integer' => 'number', 'string' => 'string', 'boolean' => 'boolean', } - super(paths, template, enum_template, language_type_by_schema_type) + super(paths, language_type_by_schema_type) end def array_type_for(type_name) @@ -146,16 +150,13 @@ def array_type_for(type_name) class Java < Codegen def initialize(paths) - template = File.read("#{TEMPLATES_DIRECTORY}/java.ts.erb") - enum_template = File.read("#{TEMPLATES_DIRECTORY}/java.enum.ts.erb") - language_type_by_schema_type = { 'integer' => 'Integer', 'string' => 'String', 'boolean' => 'Boolean', } - super(paths, template, enum_template, language_type_by_schema_type) + super(paths, language_type_by_schema_type) end def array_type_for(type_name) @@ -164,17 +165,14 @@ def array_type_for(type_name) end class Perl < Codegen - def initialize(paths, template_file_name: 'perl.pm.erb') - template = File.read("#{TEMPLATES_DIRECTORY}/#{template_file_name}") - enum_template = File.read("#{TEMPLATES_DIRECTORY}/perl.enum.pm.erb") - + def initialize(paths) language_type_by_schema_type = { 'integer' => 'number', 'string' => 'string', 'boolean' => 'boolean', } - super(paths, template, enum_template, language_type_by_schema_type) + super(paths, language_type_by_schema_type) end def array_type_for(type_name) @@ -217,17 +215,14 @@ def format_description(raw_description) end class Ruby < Codegen - def initialize(paths, template_file_name: 'ruby.rb.erb') - template = File.read("#{TEMPLATES_DIRECTORY}/#{template_file_name}") - enum_template = File.read("#{TEMPLATES_DIRECTORY}/ruby.enum.rb.erb") - + def initialize(paths) language_type_by_schema_type = { 'integer' => 'number', 'string' => 'string', 'boolean' => 'boolean', } - super(paths, template, enum_template, language_type_by_schema_type) + super(paths, language_type_by_schema_type) end def array_type_for(type_name) @@ -260,23 +255,14 @@ def format_description(raw_description, indent_string: " ") end end -class RubyDeserializers < Ruby - def initialize(paths) - super(paths, template_file_name: 'ruby_deserializers.rb.erb') - end -end - class Go < Codegen def initialize(paths) - template = File.read("#{TEMPLATES_DIRECTORY}/go.go.erb") - enum_template = File.read("#{TEMPLATES_DIRECTORY}/go.enum.go.erb") - language_type_by_schema_type = { 'integer' => 'int64', 'string' => 'string', 'boolean' => 'bool', } - super(paths, template, enum_template, language_type_by_schema_type) + super(paths, language_type_by_schema_type) end def property_type_from_ref(ref) @@ -290,15 +276,12 @@ def array_type_for(type_name) class Markdown < Codegen def initialize(paths) - template = File.read("#{TEMPLATES_DIRECTORY}/markdown.md.erb") - enum_template = File.read("#{TEMPLATES_DIRECTORY}/markdown.enum.md.erb") - language_type_by_schema_type = { 'integer' => 'integer', 'string' => 'string', 'boolean' => 'boolean', } - super(paths, template, enum_template, language_type_by_schema_type) + super(paths, language_type_by_schema_type) end def property_type_from_ref(ref) @@ -318,4 +301,5 @@ def array_type_for(type_name) path = ARGV[1] paths = File.file?(path) ? [path] : Dir["#{path}/*.json"] codegen = clazz.new(paths) -codegen.generate +template_name = ARGV[2] +codegen.generate(template_name) diff --git a/messages/jsonschema/scripts/templates/go.enum.go.erb b/messages/jsonschema/scripts/templates/go.enum.go.erb index b4bacdf951..64ad6e8ab9 100644 --- a/messages/jsonschema/scripts/templates/go.enum.go.erb +++ b/messages/jsonschema/scripts/templates/go.enum.go.erb @@ -1,3 +1,4 @@ +<% @enums.each do |enum| -%> type <%= enum[:name] %> string const( @@ -16,3 +17,5 @@ func (e <%= enum[:name] %>) String() string { panic("Bad enum value for <%= enum[:name] %>") } } + +<% end -%> diff --git a/messages/jsonschema/scripts/templates/markdown.enum.md.erb b/messages/jsonschema/scripts/templates/markdown.enum.md.erb index e72f44bd61..17e813aa45 100644 --- a/messages/jsonschema/scripts/templates/markdown.enum.md.erb +++ b/messages/jsonschema/scripts/templates/markdown.enum.md.erb @@ -1,3 +1,4 @@ +<% @enums.each do |enum| -%> ## <%= enum[:name] %> One of the following: @@ -5,3 +6,5 @@ One of the following: <% enum[:values].each do |value| -%> * `"<%= value %>"` <% end %> + +<% end -%> diff --git a/messages/jsonschema/scripts/templates/perl.enum.pm.erb b/messages/jsonschema/scripts/templates/perl.enum.pm.erb deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/messages/jsonschema/scripts/templates/ruby.enum.rb.erb b/messages/jsonschema/scripts/templates/ruby.enum.rb.erb index bf36b4456c..7c55382e1e 100644 --- a/messages/jsonschema/scripts/templates/ruby.enum.rb.erb +++ b/messages/jsonschema/scripts/templates/ruby.enum.rb.erb @@ -1,6 +1,9 @@ +<% @enums.each do |enum| -%> class Cucumber::Messages::<%= enum[:name] %> <%- enum[:values].each_with_index do |value, index| -%> <%= enum_constant(value) %> = '<%= value %>' <%- end -%> end + +<%- end -%> diff --git a/messages/jsonschema/scripts/templates/typescript.enum.ts.erb b/messages/jsonschema/scripts/templates/typescript.enum.ts.erb index 92ee3e5ecc..1946ce2328 100644 --- a/messages/jsonschema/scripts/templates/typescript.enum.ts.erb +++ b/messages/jsonschema/scripts/templates/typescript.enum.ts.erb @@ -1,6 +1,8 @@ +<% @enums.each do |enum| -%> export enum <%= enum[:name] %> { <% enum[:values].each do |value| -%> <%= enum_constant(value) %> = '<%= value %>', <% end -%> } -<% %> + +<% end -%> diff --git a/messages/messages.md b/messages/messages.md index 2c528425c9..10209365d6 100644 --- a/messages/messages.md +++ b/messages/messages.md @@ -478,6 +478,7 @@ One of the following: * `"IDENTITY"` * `"BASE64"` + ## SourceMediaType One of the following: @@ -485,6 +486,7 @@ One of the following: * `"text/x.cucumber.gherkin+plain"` * `"text/x.cucumber.gherkin+markdown"` + ## StepDefinitionPatternType One of the following: @@ -492,6 +494,7 @@ One of the following: * `"CUCUMBER_EXPRESSION"` * `"REGULAR_EXPRESSION"` + ## TestStepResultStatus One of the following: @@ -504,3 +507,4 @@ One of the following: * `"AMBIGUOUS"` * `"FAILED"` + diff --git a/messages/perl/Makefile b/messages/perl/Makefile index 50d8df2127..29fa3c0848 100644 --- a/messages/perl/Makefile +++ b/messages/perl/Makefile @@ -11,8 +11,8 @@ test: lib/Cucumber/Messages.pm .cpanfile_dependencies PERL5LIB=${PERL5LIB} AUTHOR_TESTS=1 prove -l .PHONY: test clean clobber -lib/Cucumber/Messages.pm: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/perl.pm.erb ../jsonschema/scripts/templates/perl.enum.pm.erb - ruby ../jsonschema/scripts/codegen.rb Perl ../jsonschema > $@ +lib/Cucumber/Messages.pm: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/perl.pm.erb + ruby ../jsonschema/scripts/codegen.rb Perl ../jsonschema perl.pm.erb > $@ clean: rm -rf Cucumber-* .cpanfile_dependencies .built CHANGELOG.md diff --git a/messages/ruby/Makefile b/messages/ruby/Makefile index 17a84e34ec..261969e328 100644 --- a/messages/ruby/Makefile +++ b/messages/ruby/Makefile @@ -5,10 +5,11 @@ JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") .deps: lib/cucumber/messages.dtos.rb lib/cucumber/messages.deserializers.rb lib/cucumber/messages.dtos.rb: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/ruby.rb.erb ../jsonschema/scripts/templates/ruby.enum.rb.erb - ruby ../jsonschema/scripts/codegen.rb Ruby ../jsonschema > $@ + ruby ../jsonschema/scripts/codegen.rb Ruby ../jsonschema ruby.rb.erb > $@ + ruby ../jsonschema/scripts/codegen.rb Ruby ../jsonschema ruby.enum.rb.erb >> $@ lib/cucumber/messages.deserializers.rb: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/ruby_deserializers.rb.erb - ruby ../jsonschema/scripts/codegen.rb RubyDeserializers ../jsonschema > $@ + ruby ../jsonschema/scripts/codegen.rb Ruby ../jsonschema ruby_deserializers.rb.erb > $@ clean: rm -f lib/cucumber/messages.dtos.rb diff --git a/messages/ruby/lib/cucumber/messages.dtos.rb b/messages/ruby/lib/cucumber/messages.dtos.rb index dbcdf3240f..b3dd2eb96a 100644 --- a/messages/ruby/lib/cucumber/messages.dtos.rb +++ b/messages/ruby/lib/cucumber/messages.dtos.rb @@ -1909,3 +1909,4 @@ class Cucumber::Messages::TestStepResultStatus AMBIGUOUS = 'AMBIGUOUS' FAILED = 'FAILED' end + From c880f433d54b84a293f207ef6fbe6e7bc4fc9833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 13:42:11 +0000 Subject: [PATCH 03/63] Update tests to use new code --- messages/java/Makefile | 12 +- messages/java/pom.xml | 27 +- .../main/java/io/cucumber/messages/JSON.java | 2 + .../java/io/cucumber/messages/Messages.java | 4599 +++++++++++++++++ .../messages/NdjsonToMessageIterable.java | 3 +- .../io/cucumber/messages/TimeConversion.java | 3 +- .../MessageSerializationContract.java | 18 +- .../messages/NdjsonSerializationTest.java | 10 +- .../cucumber/messages/TimeConversionTest.java | 3 +- messages/jsonschema/scripts/codegen.rb | 5 +- .../jsonschema/scripts/templates/go.go.erb | 2 +- .../scripts/templates/java.enum.java.erb | 39 + .../scripts/templates/java.enum.ts.erb | 36 - .../templates/{java.ts.erb => java.java.erb} | 69 +- .../scripts/templates/markdown.md.erb | 2 +- .../jsonschema/scripts/templates/perl.pm.erb | 2 +- .../jsonschema/scripts/templates/ruby.rb.erb | 2 +- .../templates/ruby_deserializers.rb.erb | 2 +- .../scripts/templates/typescript.ts.erb | 2 +- 19 files changed, 4718 insertions(+), 120 deletions(-) create mode 100644 messages/java/src/main/java/io/cucumber/messages/Messages.java create mode 100644 messages/jsonschema/scripts/templates/java.enum.java.erb delete mode 100644 messages/jsonschema/scripts/templates/java.enum.ts.erb rename messages/jsonschema/scripts/templates/{java.ts.erb => java.java.erb} (51%) diff --git a/messages/java/Makefile b/messages/java/Makefile index dd76059913..b3558e914b 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -1,12 +1,16 @@ include default.mk JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") -TEMPLATES = $(shell find ../jsonschema/scripts/templates -name "*.erb") -# .codegen: src/main/java/io/cucumber/messages/Messages.java +.codegen: src/main/java/io/cucumber/messages/Messages.java -src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) $(TEMPLATES) ../jsonschema/scripts/codegen.rb - ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema > $@ +src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/java.java.erb ../jsonschema/scripts/templates/java.enum.java.erb + echo "package io.cucumber.messages;" > $@ + echo >> $@ + echo "public class Messages {" >> $@ + ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.java.erb >> $@ + ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> $@ + echo "}" >> $@ clean: rm -f src/main/java/io/messages/cucumber/Messages.java diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 09aa67ca9f..0ccde4c1f8 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -49,6 +49,11 @@ jackson-databind + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + + org.junit.jupiter junit-jupiter @@ -72,27 +77,6 @@ - - org.jsonschema2pojo - jsonschema2pojo-maven-plugin - 1.1.1 - - ${basedir}/../jsonschema - *.json - none - true - true - false - io.cucumber.messages.types - - - - - generate - - - - org.apache.maven.plugins maven-shade-plugin @@ -108,6 +92,7 @@ com.fasterxml.jackson.core:jackson-databind com.fasterxml.jackson.core:jackson-core com.fasterxml.jackson.core:jackson-annotations + com.fasterxml.jackson.core:jackson-datatype-jdk8 diff --git a/messages/java/src/main/java/io/cucumber/messages/JSON.java b/messages/java/src/main/java/io/cucumber/messages/JSON.java index 474e74b662..0ecba30263 100644 --- a/messages/java/src/main/java/io/cucumber/messages/JSON.java +++ b/messages/java/src/main/java/io/cucumber/messages/JSON.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import java.io.IOException; import java.io.OutputStream; @@ -12,6 +13,7 @@ public final class JSON { private static final ObjectMapper mapper = new ObjectMapper() + .registerModule(new Jdk8Module()) .setSerializationInclusion(JsonInclude.Include.NON_NULL) .enable(WRITE_ENUMS_USING_TO_STRING) .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java new file mode 100644 index 0000000000..cfee0fc379 --- /dev/null +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -0,0 +1,4599 @@ +package io.cucumber.messages; + +public class Messages { + + public static class Attachment { + private String body; + private AttachmentContentEncoding contentEncoding; + private String fileName; + private String mediaType; + private Source source; + private String testCaseStartedId; + private String testStepId; + private String url; + + public Attachment() {} + + public Attachment( + String body, + AttachmentContentEncoding contentEncoding, + String fileName, + String mediaType, + Source source, + String testCaseStartedId, + String testStepId, + String url + ) { + this.body = java.util.Objects.requireNonNull(body); + this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); + this.fileName = fileName; + this.mediaType = java.util.Objects.requireNonNull(mediaType); + this.source = source; + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.url = url; + } + + public String getBody() { + return java.util.Objects.requireNonNull(body); + } + + public void setBody(String body) { + this.body = java.util.Objects.requireNonNull(body); + } + + public AttachmentContentEncoding getContentEncoding() { + return java.util.Objects.requireNonNull(contentEncoding); + } + + public void setContentEncoding(AttachmentContentEncoding contentEncoding) { + this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); + } + + public java.util.Optional getFileName() { + return java.util.Optional.ofNullable(fileName); + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getMediaType() { + return java.util.Objects.requireNonNull(mediaType); + } + + public void setMediaType(String mediaType) { + this.mediaType = java.util.Objects.requireNonNull(mediaType); + } + + public java.util.Optional getSource() { + return java.util.Optional.ofNullable(source); + } + + public void setSource(Source source) { + this.source = source; + } + + public java.util.Optional getTestCaseStartedId() { + return java.util.Optional.ofNullable(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = testCaseStartedId; + } + + public java.util.Optional getTestStepId() { + return java.util.Optional.ofNullable(testStepId); + } + + public void setTestStepId(String testStepId) { + this.testStepId = testStepId; + } + + public java.util.Optional getUrl() { + return java.util.Optional.ofNullable(url); + } + + public void setUrl(String url) { + this.url = url; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Attachment that = (Attachment) o; + return + body.equals(that.body) && + contentEncoding.equals(that.contentEncoding) && + java.util.Objects.equals(fileName, that.fileName) && + mediaType.equals(that.mediaType) && + java.util.Objects.equals(source, that.source) && + java.util.Objects.equals(testCaseStartedId, that.testCaseStartedId) && + java.util.Objects.equals(testStepId, that.testStepId) && + java.util.Objects.equals(url, that.url); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + body, + contentEncoding, + fileName, + mediaType, + source, + testCaseStartedId, + testStepId, + url + ); + } + + @Override + public String toString() { + return "Attachment{" + + "body=" + body + + ", contentEncoding=" + contentEncoding + + ", fileName=" + fileName + + ", mediaType=" + mediaType + + ", source=" + source + + ", testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", url=" + url + + '}'; + } + } + + + public static class Duration { + private Long seconds; + private Long nanos; + + public Duration() {} + + public Duration( + Long seconds, + Long nanos + ) { + this.seconds = java.util.Objects.requireNonNull(seconds); + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + public Long getSeconds() { + return java.util.Objects.requireNonNull(seconds); + } + + public void setSeconds(Long seconds) { + this.seconds = java.util.Objects.requireNonNull(seconds); + } + + public Long getNanos() { + return java.util.Objects.requireNonNull(nanos); + } + + public void setNanos(Long nanos) { + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Duration that = (Duration) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + seconds, + nanos + ); + } + + @Override + public String toString() { + return "Duration{" + + "seconds=" + seconds + + ", nanos=" + nanos + + '}'; + } + } + + + public static class Envelope { + private Attachment attachment; + private GherkinDocument gherkinDocument; + private Hook hook; + private Meta meta; + private ParameterType parameterType; + private ParseError parseError; + private Pickle pickle; + private Source source; + private StepDefinition stepDefinition; + private TestCase testCase; + private TestCaseFinished testCaseFinished; + private TestCaseStarted testCaseStarted; + private TestRunFinished testRunFinished; + private TestRunStarted testRunStarted; + private TestStepFinished testStepFinished; + private TestStepStarted testStepStarted; + private UndefinedParameterType undefinedParameterType; + + public Envelope() {} + + public Envelope( + Attachment attachment, + GherkinDocument gherkinDocument, + Hook hook, + Meta meta, + ParameterType parameterType, + ParseError parseError, + Pickle pickle, + Source source, + StepDefinition stepDefinition, + TestCase testCase, + TestCaseFinished testCaseFinished, + TestCaseStarted testCaseStarted, + TestRunFinished testRunFinished, + TestRunStarted testRunStarted, + TestStepFinished testStepFinished, + TestStepStarted testStepStarted, + UndefinedParameterType undefinedParameterType + ) { + this.attachment = attachment; + this.gherkinDocument = gherkinDocument; + this.hook = hook; + this.meta = meta; + this.parameterType = parameterType; + this.parseError = parseError; + this.pickle = pickle; + this.source = source; + this.stepDefinition = stepDefinition; + this.testCase = testCase; + this.testCaseFinished = testCaseFinished; + this.testCaseStarted = testCaseStarted; + this.testRunFinished = testRunFinished; + this.testRunStarted = testRunStarted; + this.testStepFinished = testStepFinished; + this.testStepStarted = testStepStarted; + this.undefinedParameterType = undefinedParameterType; + } + + public java.util.Optional getAttachment() { + return java.util.Optional.ofNullable(attachment); + } + + public void setAttachment(Attachment attachment) { + this.attachment = attachment; + } + + public java.util.Optional getGherkinDocument() { + return java.util.Optional.ofNullable(gherkinDocument); + } + + public void setGherkinDocument(GherkinDocument gherkinDocument) { + this.gherkinDocument = gherkinDocument; + } + + public java.util.Optional getHook() { + return java.util.Optional.ofNullable(hook); + } + + public void setHook(Hook hook) { + this.hook = hook; + } + + public java.util.Optional getMeta() { + return java.util.Optional.ofNullable(meta); + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public java.util.Optional getParameterType() { + return java.util.Optional.ofNullable(parameterType); + } + + public void setParameterType(ParameterType parameterType) { + this.parameterType = parameterType; + } + + public java.util.Optional getParseError() { + return java.util.Optional.ofNullable(parseError); + } + + public void setParseError(ParseError parseError) { + this.parseError = parseError; + } + + public java.util.Optional getPickle() { + return java.util.Optional.ofNullable(pickle); + } + + public void setPickle(Pickle pickle) { + this.pickle = pickle; + } + + public java.util.Optional getSource() { + return java.util.Optional.ofNullable(source); + } + + public void setSource(Source source) { + this.source = source; + } + + public java.util.Optional getStepDefinition() { + return java.util.Optional.ofNullable(stepDefinition); + } + + public void setStepDefinition(StepDefinition stepDefinition) { + this.stepDefinition = stepDefinition; + } + + public java.util.Optional getTestCase() { + return java.util.Optional.ofNullable(testCase); + } + + public void setTestCase(TestCase testCase) { + this.testCase = testCase; + } + + public java.util.Optional getTestCaseFinished() { + return java.util.Optional.ofNullable(testCaseFinished); + } + + public void setTestCaseFinished(TestCaseFinished testCaseFinished) { + this.testCaseFinished = testCaseFinished; + } + + public java.util.Optional getTestCaseStarted() { + return java.util.Optional.ofNullable(testCaseStarted); + } + + public void setTestCaseStarted(TestCaseStarted testCaseStarted) { + this.testCaseStarted = testCaseStarted; + } + + public java.util.Optional getTestRunFinished() { + return java.util.Optional.ofNullable(testRunFinished); + } + + public void setTestRunFinished(TestRunFinished testRunFinished) { + this.testRunFinished = testRunFinished; + } + + public java.util.Optional getTestRunStarted() { + return java.util.Optional.ofNullable(testRunStarted); + } + + public void setTestRunStarted(TestRunStarted testRunStarted) { + this.testRunStarted = testRunStarted; + } + + public java.util.Optional getTestStepFinished() { + return java.util.Optional.ofNullable(testStepFinished); + } + + public void setTestStepFinished(TestStepFinished testStepFinished) { + this.testStepFinished = testStepFinished; + } + + public java.util.Optional getTestStepStarted() { + return java.util.Optional.ofNullable(testStepStarted); + } + + public void setTestStepStarted(TestStepStarted testStepStarted) { + this.testStepStarted = testStepStarted; + } + + public java.util.Optional getUndefinedParameterType() { + return java.util.Optional.ofNullable(undefinedParameterType); + } + + public void setUndefinedParameterType(UndefinedParameterType undefinedParameterType) { + this.undefinedParameterType = undefinedParameterType; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Envelope that = (Envelope) o; + return + java.util.Objects.equals(attachment, that.attachment) && + java.util.Objects.equals(gherkinDocument, that.gherkinDocument) && + java.util.Objects.equals(hook, that.hook) && + java.util.Objects.equals(meta, that.meta) && + java.util.Objects.equals(parameterType, that.parameterType) && + java.util.Objects.equals(parseError, that.parseError) && + java.util.Objects.equals(pickle, that.pickle) && + java.util.Objects.equals(source, that.source) && + java.util.Objects.equals(stepDefinition, that.stepDefinition) && + java.util.Objects.equals(testCase, that.testCase) && + java.util.Objects.equals(testCaseFinished, that.testCaseFinished) && + java.util.Objects.equals(testCaseStarted, that.testCaseStarted) && + java.util.Objects.equals(testRunFinished, that.testRunFinished) && + java.util.Objects.equals(testRunStarted, that.testRunStarted) && + java.util.Objects.equals(testStepFinished, that.testStepFinished) && + java.util.Objects.equals(testStepStarted, that.testStepStarted) && + java.util.Objects.equals(undefinedParameterType, that.undefinedParameterType); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + attachment, + gherkinDocument, + hook, + meta, + parameterType, + parseError, + pickle, + source, + stepDefinition, + testCase, + testCaseFinished, + testCaseStarted, + testRunFinished, + testRunStarted, + testStepFinished, + testStepStarted, + undefinedParameterType + ); + } + + @Override + public String toString() { + return "Envelope{" + + "attachment=" + attachment + + ", gherkinDocument=" + gherkinDocument + + ", hook=" + hook + + ", meta=" + meta + + ", parameterType=" + parameterType + + ", parseError=" + parseError + + ", pickle=" + pickle + + ", source=" + source + + ", stepDefinition=" + stepDefinition + + ", testCase=" + testCase + + ", testCaseFinished=" + testCaseFinished + + ", testCaseStarted=" + testCaseStarted + + ", testRunFinished=" + testRunFinished + + ", testRunStarted=" + testRunStarted + + ", testStepFinished=" + testStepFinished + + ", testStepStarted=" + testStepStarted + + ", undefinedParameterType=" + undefinedParameterType + + '}'; + } + } + + + public static class GherkinDocument { + private String uri; + private Feature feature; + private java.util.List comments; + + public GherkinDocument() {} + + public GherkinDocument( + String uri, + Feature feature, + java.util.List comments + ) { + this.uri = uri; + this.feature = feature; + this.comments = java.util.Objects.requireNonNull(comments); + } + + public java.util.Optional getUri() { + return java.util.Optional.ofNullable(uri); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public java.util.Optional getFeature() { + return java.util.Optional.ofNullable(feature); + } + + public void setFeature(Feature feature) { + this.feature = feature; + } + + public java.util.List getComments() { + return java.util.Objects.requireNonNull(comments); + } + + public void setComments(java.util.List comments) { + this.comments = java.util.Objects.requireNonNull(comments); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GherkinDocument that = (GherkinDocument) o; + return + java.util.Objects.equals(uri, that.uri) && + java.util.Objects.equals(feature, that.feature) && + comments.equals(that.comments); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + uri, + feature, + comments + ); + } + + @Override + public String toString() { + return "GherkinDocument{" + + "uri=" + uri + + ", feature=" + feature + + ", comments=" + comments + + '}'; + } + } + + + public static class Background { + private Location location; + private String keyword; + private String name; + private String description; + private java.util.List steps; + private String id; + + public Background() {} + + public Background( + Location location, + String keyword, + String name, + String description, + java.util.List steps, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.steps = java.util.Objects.requireNonNull(steps); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getSteps() { + return java.util.Objects.requireNonNull(steps); + } + + public void setSteps(java.util.List steps) { + this.steps = java.util.Objects.requireNonNull(steps); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Background that = (Background) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + keyword, + name, + description, + steps, + id + ); + } + + @Override + public String toString() { + return "Background{" + + "location=" + location + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", steps=" + steps + + ", id=" + id + + '}'; + } + } + + + public static class Comment { + private Location location; + private String text; + + public Comment() {} + + public Comment( + Location location, + String text + ) { + this.location = java.util.Objects.requireNonNull(location); + this.text = java.util.Objects.requireNonNull(text); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getText() { + return java.util.Objects.requireNonNull(text); + } + + public void setText(String text) { + this.text = java.util.Objects.requireNonNull(text); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Comment that = (Comment) o; + return + location.equals(that.location) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + text + ); + } + + @Override + public String toString() { + return "Comment{" + + "location=" + location + + ", text=" + text + + '}'; + } + } + + + public static class DataTable { + private Location location; + private java.util.List rows; + + public DataTable() {} + + public DataTable( + Location location, + java.util.List rows + ) { + this.location = java.util.Objects.requireNonNull(location); + this.rows = java.util.Objects.requireNonNull(rows); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getRows() { + return java.util.Objects.requireNonNull(rows); + } + + public void setRows(java.util.List rows) { + this.rows = java.util.Objects.requireNonNull(rows); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DataTable that = (DataTable) o; + return + location.equals(that.location) && + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + rows + ); + } + + @Override + public String toString() { + return "DataTable{" + + "location=" + location + + ", rows=" + rows + + '}'; + } + } + + + public static class DocString { + private Location location; + private String mediaType; + private String content; + private String delimiter; + + public DocString() {} + + public DocString( + Location location, + String mediaType, + String content, + String delimiter + ) { + this.location = java.util.Objects.requireNonNull(location); + this.mediaType = mediaType; + this.content = java.util.Objects.requireNonNull(content); + this.delimiter = java.util.Objects.requireNonNull(delimiter); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.Optional getMediaType() { + return java.util.Optional.ofNullable(mediaType); + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getContent() { + return java.util.Objects.requireNonNull(content); + } + + public void setContent(String content) { + this.content = java.util.Objects.requireNonNull(content); + } + + public String getDelimiter() { + return java.util.Objects.requireNonNull(delimiter); + } + + public void setDelimiter(String delimiter) { + this.delimiter = java.util.Objects.requireNonNull(delimiter); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DocString that = (DocString) o; + return + location.equals(that.location) && + java.util.Objects.equals(mediaType, that.mediaType) && + content.equals(that.content) && + delimiter.equals(that.delimiter); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + mediaType, + content, + delimiter + ); + } + + @Override + public String toString() { + return "DocString{" + + "location=" + location + + ", mediaType=" + mediaType + + ", content=" + content + + ", delimiter=" + delimiter + + '}'; + } + } + + + public static class Examples { + private Location location; + private java.util.List tags; + private String keyword; + private String name; + private String description; + private TableRow tableHeader; + private java.util.List tableBody; + private String id; + + public Examples() {} + + public Examples( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + TableRow tableHeader, + java.util.List tableBody, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.tableHeader = tableHeader; + this.tableBody = java.util.Objects.requireNonNull(tableBody); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.Optional getTableHeader() { + return java.util.Optional.ofNullable(tableHeader); + } + + public void setTableHeader(TableRow tableHeader) { + this.tableHeader = tableHeader; + } + + public java.util.List getTableBody() { + return java.util.Objects.requireNonNull(tableBody); + } + + public void setTableBody(java.util.List tableBody) { + this.tableBody = java.util.Objects.requireNonNull(tableBody); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Examples that = (Examples) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + java.util.Objects.equals(tableHeader, that.tableHeader) && + tableBody.equals(that.tableBody) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + keyword, + name, + description, + tableHeader, + tableBody, + id + ); + } + + @Override + public String toString() { + return "Examples{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", tableHeader=" + tableHeader + + ", tableBody=" + tableBody + + ", id=" + id + + '}'; + } + } + + + public static class Feature { + private Location location; + private java.util.List tags; + private String language; + private String keyword; + private String name; + private String description; + private java.util.List children; + + public Feature() {} + + public Feature( + Location location, + java.util.List tags, + String language, + String keyword, + String name, + String description, + java.util.List children + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.language = java.util.Objects.requireNonNull(language); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.children = java.util.Objects.requireNonNull(children); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getLanguage() { + return java.util.Objects.requireNonNull(language); + } + + public void setLanguage(String language) { + this.language = java.util.Objects.requireNonNull(language); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getChildren() { + return java.util.Objects.requireNonNull(children); + } + + public void setChildren(java.util.List children) { + this.children = java.util.Objects.requireNonNull(children); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Feature that = (Feature) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + language.equals(that.language) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + language, + keyword, + name, + description, + children + ); + } + + @Override + public String toString() { + return "Feature{" + + "location=" + location + + ", tags=" + tags + + ", language=" + language + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", children=" + children + + '}'; + } + } + + + public static class FeatureChild { + private Rule rule; + private Background background; + private Scenario scenario; + + public FeatureChild() {} + + public FeatureChild( + Rule rule, + Background background, + Scenario scenario + ) { + this.rule = rule; + this.background = background; + this.scenario = scenario; + } + + public java.util.Optional getRule() { + return java.util.Optional.ofNullable(rule); + } + + public void setRule(Rule rule) { + this.rule = rule; + } + + public java.util.Optional getBackground() { + return java.util.Optional.ofNullable(background); + } + + public void setBackground(Background background) { + this.background = background; + } + + public java.util.Optional getScenario() { + return java.util.Optional.ofNullable(scenario); + } + + public void setScenario(Scenario scenario) { + this.scenario = scenario; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + FeatureChild that = (FeatureChild) o; + return + java.util.Objects.equals(rule, that.rule) && + java.util.Objects.equals(background, that.background) && + java.util.Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + rule, + background, + scenario + ); + } + + @Override + public String toString() { + return "FeatureChild{" + + "rule=" + rule + + ", background=" + background + + ", scenario=" + scenario + + '}'; + } + } + + + public static class Rule { + private Location location; + private java.util.List tags; + private String keyword; + private String name; + private String description; + private java.util.List children; + private String id; + + public Rule() {} + + public Rule( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + java.util.List children, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.children = java.util.Objects.requireNonNull(children); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getChildren() { + return java.util.Objects.requireNonNull(children); + } + + public void setChildren(java.util.List children) { + this.children = java.util.Objects.requireNonNull(children); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Rule that = (Rule) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + keyword, + name, + description, + children, + id + ); + } + + @Override + public String toString() { + return "Rule{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", children=" + children + + ", id=" + id + + '}'; + } + } + + + public static class RuleChild { + private Background background; + private Scenario scenario; + + public RuleChild() {} + + public RuleChild( + Background background, + Scenario scenario + ) { + this.background = background; + this.scenario = scenario; + } + + public java.util.Optional getBackground() { + return java.util.Optional.ofNullable(background); + } + + public void setBackground(Background background) { + this.background = background; + } + + public java.util.Optional getScenario() { + return java.util.Optional.ofNullable(scenario); + } + + public void setScenario(Scenario scenario) { + this.scenario = scenario; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RuleChild that = (RuleChild) o; + return + java.util.Objects.equals(background, that.background) && + java.util.Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + background, + scenario + ); + } + + @Override + public String toString() { + return "RuleChild{" + + "background=" + background + + ", scenario=" + scenario + + '}'; + } + } + + + public static class Scenario { + private Location location; + private java.util.List tags; + private String keyword; + private String name; + private String description; + private java.util.List steps; + private java.util.List examples; + private String id; + + public Scenario() {} + + public Scenario( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + java.util.List steps, + java.util.List examples, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.steps = java.util.Objects.requireNonNull(steps); + this.examples = java.util.Objects.requireNonNull(examples); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getSteps() { + return java.util.Objects.requireNonNull(steps); + } + + public void setSteps(java.util.List steps) { + this.steps = java.util.Objects.requireNonNull(steps); + } + + public java.util.List getExamples() { + return java.util.Objects.requireNonNull(examples); + } + + public void setExamples(java.util.List examples) { + this.examples = java.util.Objects.requireNonNull(examples); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Scenario that = (Scenario) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + examples.equals(that.examples) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + keyword, + name, + description, + steps, + examples, + id + ); + } + + @Override + public String toString() { + return "Scenario{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", steps=" + steps + + ", examples=" + examples + + ", id=" + id + + '}'; + } + } + + + public static class Step { + private Location location; + private String keyword; + private String text; + private DocString docString; + private DataTable dataTable; + private String id; + + public Step() {} + + public Step( + Location location, + String keyword, + String text, + DocString docString, + DataTable dataTable, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.text = java.util.Objects.requireNonNull(text); + this.docString = docString; + this.dataTable = dataTable; + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getText() { + return java.util.Objects.requireNonNull(text); + } + + public void setText(String text) { + this.text = java.util.Objects.requireNonNull(text); + } + + public java.util.Optional getDocString() { + return java.util.Optional.ofNullable(docString); + } + + public void setDocString(DocString docString) { + this.docString = docString; + } + + public java.util.Optional getDataTable() { + return java.util.Optional.ofNullable(dataTable); + } + + public void setDataTable(DataTable dataTable) { + this.dataTable = dataTable; + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Step that = (Step) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + text.equals(that.text) && + java.util.Objects.equals(docString, that.docString) && + java.util.Objects.equals(dataTable, that.dataTable) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + keyword, + text, + docString, + dataTable, + id + ); + } + + @Override + public String toString() { + return "Step{" + + "location=" + location + + ", keyword=" + keyword + + ", text=" + text + + ", docString=" + docString + + ", dataTable=" + dataTable + + ", id=" + id + + '}'; + } + } + + + public static class TableCell { + private Location location; + private String value; + + public TableCell() {} + + public TableCell( + Location location, + String value + ) { + this.location = java.util.Objects.requireNonNull(location); + this.value = java.util.Objects.requireNonNull(value); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getValue() { + return java.util.Objects.requireNonNull(value); + } + + public void setValue(String value) { + this.value = java.util.Objects.requireNonNull(value); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableCell that = (TableCell) o; + return + location.equals(that.location) && + value.equals(that.value); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + value + ); + } + + @Override + public String toString() { + return "TableCell{" + + "location=" + location + + ", value=" + value + + '}'; + } + } + + + public static class TableRow { + private Location location; + private java.util.List cells; + private String id; + + public TableRow() {} + + public TableRow( + Location location, + java.util.List cells, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.cells = java.util.Objects.requireNonNull(cells); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getCells() { + return java.util.Objects.requireNonNull(cells); + } + + public void setCells(java.util.List cells) { + this.cells = java.util.Objects.requireNonNull(cells); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableRow that = (TableRow) o; + return + location.equals(that.location) && + cells.equals(that.cells) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + cells, + id + ); + } + + @Override + public String toString() { + return "TableRow{" + + "location=" + location + + ", cells=" + cells + + ", id=" + id + + '}'; + } + } + + + public static class Tag { + private Location location; + private String name; + private String id; + + public Tag() {} + + public Tag( + Location location, + String name, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.name = java.util.Objects.requireNonNull(name); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Tag that = (Tag) o; + return + location.equals(that.location) && + name.equals(that.name) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + name, + id + ); + } + + @Override + public String toString() { + return "Tag{" + + "location=" + location + + ", name=" + name + + ", id=" + id + + '}'; + } + } + + + public static class Hook { + private String id; + private SourceReference sourceReference; + private String tagExpression; + + public Hook() {} + + public Hook( + String id, + SourceReference sourceReference, + String tagExpression + ) { + this.id = java.util.Objects.requireNonNull(id); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + this.tagExpression = tagExpression; + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public SourceReference getSourceReference() { + return java.util.Objects.requireNonNull(sourceReference); + } + + public void setSourceReference(SourceReference sourceReference) { + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + } + + public java.util.Optional getTagExpression() { + return java.util.Optional.ofNullable(tagExpression); + } + + public void setTagExpression(String tagExpression) { + this.tagExpression = tagExpression; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Hook that = (Hook) o; + return + id.equals(that.id) && + sourceReference.equals(that.sourceReference) && + java.util.Objects.equals(tagExpression, that.tagExpression); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + sourceReference, + tagExpression + ); + } + + @Override + public String toString() { + return "Hook{" + + "id=" + id + + ", sourceReference=" + sourceReference + + ", tagExpression=" + tagExpression + + '}'; + } + } + + + public static class Location { + private Long line; + private Long column; + + public Location() {} + + public Location( + Long line, + Long column + ) { + this.line = java.util.Objects.requireNonNull(line); + this.column = column; + } + + public Long getLine() { + return java.util.Objects.requireNonNull(line); + } + + public void setLine(Long line) { + this.line = java.util.Objects.requireNonNull(line); + } + + public java.util.Optional getColumn() { + return java.util.Optional.ofNullable(column); + } + + public void setColumn(Long column) { + this.column = column; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Location that = (Location) o; + return + line.equals(that.line) && + java.util.Objects.equals(column, that.column); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + line, + column + ); + } + + @Override + public String toString() { + return "Location{" + + "line=" + line + + ", column=" + column + + '}'; + } + } + + + public static class Meta { + private String protocolVersion; + private Product implementation; + private Product runtime; + private Product os; + private Product cpu; + private Ci ci; + + public Meta() {} + + public Meta( + String protocolVersion, + Product implementation, + Product runtime, + Product os, + Product cpu, + Ci ci + ) { + this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); + this.implementation = java.util.Objects.requireNonNull(implementation); + this.runtime = java.util.Objects.requireNonNull(runtime); + this.os = java.util.Objects.requireNonNull(os); + this.cpu = java.util.Objects.requireNonNull(cpu); + this.ci = ci; + } + + public String getProtocolVersion() { + return java.util.Objects.requireNonNull(protocolVersion); + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); + } + + public Product getImplementation() { + return java.util.Objects.requireNonNull(implementation); + } + + public void setImplementation(Product implementation) { + this.implementation = java.util.Objects.requireNonNull(implementation); + } + + public Product getRuntime() { + return java.util.Objects.requireNonNull(runtime); + } + + public void setRuntime(Product runtime) { + this.runtime = java.util.Objects.requireNonNull(runtime); + } + + public Product getOs() { + return java.util.Objects.requireNonNull(os); + } + + public void setOs(Product os) { + this.os = java.util.Objects.requireNonNull(os); + } + + public Product getCpu() { + return java.util.Objects.requireNonNull(cpu); + } + + public void setCpu(Product cpu) { + this.cpu = java.util.Objects.requireNonNull(cpu); + } + + public java.util.Optional getCi() { + return java.util.Optional.ofNullable(ci); + } + + public void setCi(Ci ci) { + this.ci = ci; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Meta that = (Meta) o; + return + protocolVersion.equals(that.protocolVersion) && + implementation.equals(that.implementation) && + runtime.equals(that.runtime) && + os.equals(that.os) && + cpu.equals(that.cpu) && + java.util.Objects.equals(ci, that.ci); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + protocolVersion, + implementation, + runtime, + os, + cpu, + ci + ); + } + + @Override + public String toString() { + return "Meta{" + + "protocolVersion=" + protocolVersion + + ", implementation=" + implementation + + ", runtime=" + runtime + + ", os=" + os + + ", cpu=" + cpu + + ", ci=" + ci + + '}'; + } + } + + + public static class Ci { + private String name; + private String url; + private String buildNumber; + private Git git; + + public Ci() {} + + public Ci( + String name, + String url, + String buildNumber, + Git git + ) { + this.name = java.util.Objects.requireNonNull(name); + this.url = url; + this.buildNumber = buildNumber; + this.git = git; + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public java.util.Optional getUrl() { + return java.util.Optional.ofNullable(url); + } + + public void setUrl(String url) { + this.url = url; + } + + public java.util.Optional getBuildNumber() { + return java.util.Optional.ofNullable(buildNumber); + } + + public void setBuildNumber(String buildNumber) { + this.buildNumber = buildNumber; + } + + public java.util.Optional getGit() { + return java.util.Optional.ofNullable(git); + } + + public void setGit(Git git) { + this.git = git; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Ci that = (Ci) o; + return + name.equals(that.name) && + java.util.Objects.equals(url, that.url) && + java.util.Objects.equals(buildNumber, that.buildNumber) && + java.util.Objects.equals(git, that.git); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + url, + buildNumber, + git + ); + } + + @Override + public String toString() { + return "Ci{" + + "name=" + name + + ", url=" + url + + ", buildNumber=" + buildNumber + + ", git=" + git + + '}'; + } + } + + + public static class Git { + private String remote; + private String revision; + private String branch; + private String tag; + + public Git() {} + + public Git( + String remote, + String revision, + String branch, + String tag + ) { + this.remote = java.util.Objects.requireNonNull(remote); + this.revision = java.util.Objects.requireNonNull(revision); + this.branch = branch; + this.tag = tag; + } + + public String getRemote() { + return java.util.Objects.requireNonNull(remote); + } + + public void setRemote(String remote) { + this.remote = java.util.Objects.requireNonNull(remote); + } + + public String getRevision() { + return java.util.Objects.requireNonNull(revision); + } + + public void setRevision(String revision) { + this.revision = java.util.Objects.requireNonNull(revision); + } + + public java.util.Optional getBranch() { + return java.util.Optional.ofNullable(branch); + } + + public void setBranch(String branch) { + this.branch = branch; + } + + public java.util.Optional getTag() { + return java.util.Optional.ofNullable(tag); + } + + public void setTag(String tag) { + this.tag = tag; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Git that = (Git) o; + return + remote.equals(that.remote) && + revision.equals(that.revision) && + java.util.Objects.equals(branch, that.branch) && + java.util.Objects.equals(tag, that.tag); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + remote, + revision, + branch, + tag + ); + } + + @Override + public String toString() { + return "Git{" + + "remote=" + remote + + ", revision=" + revision + + ", branch=" + branch + + ", tag=" + tag + + '}'; + } + } + + + public static class Product { + private String name; + private String version; + + public Product() {} + + public Product( + String name, + String version + ) { + this.name = java.util.Objects.requireNonNull(name); + this.version = version; + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public java.util.Optional getVersion() { + return java.util.Optional.ofNullable(version); + } + + public void setVersion(String version) { + this.version = version; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Product that = (Product) o; + return + name.equals(that.name) && + java.util.Objects.equals(version, that.version); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + version + ); + } + + @Override + public String toString() { + return "Product{" + + "name=" + name + + ", version=" + version + + '}'; + } + } + + + public static class ParameterType { + private String name; + private java.util.List regularExpressions; + private Boolean preferForRegularExpressionMatch; + private Boolean useForSnippets; + private String id; + + public ParameterType() {} + + public ParameterType( + String name, + java.util.List regularExpressions, + Boolean preferForRegularExpressionMatch, + Boolean useForSnippets, + String id + ) { + this.name = java.util.Objects.requireNonNull(name); + this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); + this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); + this.id = java.util.Objects.requireNonNull(id); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public java.util.List getRegularExpressions() { + return java.util.Objects.requireNonNull(regularExpressions); + } + + public void setRegularExpressions(java.util.List regularExpressions) { + this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); + } + + public Boolean getPreferForRegularExpressionMatch() { + return java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + } + + public void setPreferForRegularExpressionMatch(Boolean preferForRegularExpressionMatch) { + this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + } + + public Boolean getUseForSnippets() { + return java.util.Objects.requireNonNull(useForSnippets); + } + + public void setUseForSnippets(Boolean useForSnippets) { + this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParameterType that = (ParameterType) o; + return + name.equals(that.name) && + regularExpressions.equals(that.regularExpressions) && + preferForRegularExpressionMatch.equals(that.preferForRegularExpressionMatch) && + useForSnippets.equals(that.useForSnippets) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + regularExpressions, + preferForRegularExpressionMatch, + useForSnippets, + id + ); + } + + @Override + public String toString() { + return "ParameterType{" + + "name=" + name + + ", regularExpressions=" + regularExpressions + + ", preferForRegularExpressionMatch=" + preferForRegularExpressionMatch + + ", useForSnippets=" + useForSnippets + + ", id=" + id + + '}'; + } + } + + + public static class ParseError { + private SourceReference source; + private String message; + + public ParseError() {} + + public ParseError( + SourceReference source, + String message + ) { + this.source = java.util.Objects.requireNonNull(source); + this.message = java.util.Objects.requireNonNull(message); + } + + public SourceReference getSource() { + return java.util.Objects.requireNonNull(source); + } + + public void setSource(SourceReference source) { + this.source = java.util.Objects.requireNonNull(source); + } + + public String getMessage() { + return java.util.Objects.requireNonNull(message); + } + + public void setMessage(String message) { + this.message = java.util.Objects.requireNonNull(message); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParseError that = (ParseError) o; + return + source.equals(that.source) && + message.equals(that.message); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + source, + message + ); + } + + @Override + public String toString() { + return "ParseError{" + + "source=" + source + + ", message=" + message + + '}'; + } + } + + + public static class Pickle { + private String id; + private String uri; + private String name; + private String language; + private java.util.List steps; + private java.util.List tags; + private java.util.List astNodeIds; + + public Pickle() {} + + public Pickle( + String id, + String uri, + String name, + String language, + java.util.List steps, + java.util.List tags, + java.util.List astNodeIds + ) { + this.id = java.util.Objects.requireNonNull(id); + this.uri = java.util.Objects.requireNonNull(uri); + this.name = java.util.Objects.requireNonNull(name); + this.language = java.util.Objects.requireNonNull(language); + this.steps = java.util.Objects.requireNonNull(steps); + this.tags = java.util.Objects.requireNonNull(tags); + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getUri() { + return java.util.Objects.requireNonNull(uri); + } + + public void setUri(String uri) { + this.uri = java.util.Objects.requireNonNull(uri); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getLanguage() { + return java.util.Objects.requireNonNull(language); + } + + public void setLanguage(String language) { + this.language = java.util.Objects.requireNonNull(language); + } + + public java.util.List getSteps() { + return java.util.Objects.requireNonNull(steps); + } + + public void setSteps(java.util.List steps) { + this.steps = java.util.Objects.requireNonNull(steps); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public java.util.List getAstNodeIds() { + return java.util.Objects.requireNonNull(astNodeIds); + } + + public void setAstNodeIds(java.util.List astNodeIds) { + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pickle that = (Pickle) o; + return + id.equals(that.id) && + uri.equals(that.uri) && + name.equals(that.name) && + language.equals(that.language) && + steps.equals(that.steps) && + tags.equals(that.tags) && + astNodeIds.equals(that.astNodeIds); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + uri, + name, + language, + steps, + tags, + astNodeIds + ); + } + + @Override + public String toString() { + return "Pickle{" + + "id=" + id + + ", uri=" + uri + + ", name=" + name + + ", language=" + language + + ", steps=" + steps + + ", tags=" + tags + + ", astNodeIds=" + astNodeIds + + '}'; + } + } + + + public static class PickleDocString { + private String mediaType; + private String content; + + public PickleDocString() {} + + public PickleDocString( + String mediaType, + String content + ) { + this.mediaType = mediaType; + this.content = java.util.Objects.requireNonNull(content); + } + + public java.util.Optional getMediaType() { + return java.util.Optional.ofNullable(mediaType); + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getContent() { + return java.util.Objects.requireNonNull(content); + } + + public void setContent(String content) { + this.content = java.util.Objects.requireNonNull(content); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleDocString that = (PickleDocString) o; + return + java.util.Objects.equals(mediaType, that.mediaType) && + content.equals(that.content); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + mediaType, + content + ); + } + + @Override + public String toString() { + return "PickleDocString{" + + "mediaType=" + mediaType + + ", content=" + content + + '}'; + } + } + + + public static class PickleStep { + private PickleStepArgument argument; + private java.util.List astNodeIds; + private String id; + private String text; + + public PickleStep() {} + + public PickleStep( + PickleStepArgument argument, + java.util.List astNodeIds, + String id, + String text + ) { + this.argument = argument; + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + this.id = java.util.Objects.requireNonNull(id); + this.text = java.util.Objects.requireNonNull(text); + } + + public java.util.Optional getArgument() { + return java.util.Optional.ofNullable(argument); + } + + public void setArgument(PickleStepArgument argument) { + this.argument = argument; + } + + public java.util.List getAstNodeIds() { + return java.util.Objects.requireNonNull(astNodeIds); + } + + public void setAstNodeIds(java.util.List astNodeIds) { + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getText() { + return java.util.Objects.requireNonNull(text); + } + + public void setText(String text) { + this.text = java.util.Objects.requireNonNull(text); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStep that = (PickleStep) o; + return + java.util.Objects.equals(argument, that.argument) && + astNodeIds.equals(that.astNodeIds) && + id.equals(that.id) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + argument, + astNodeIds, + id, + text + ); + } + + @Override + public String toString() { + return "PickleStep{" + + "argument=" + argument + + ", astNodeIds=" + astNodeIds + + ", id=" + id + + ", text=" + text + + '}'; + } + } + + + public static class PickleStepArgument { + private PickleDocString docString; + private PickleTable dataTable; + + public PickleStepArgument() {} + + public PickleStepArgument( + PickleDocString docString, + PickleTable dataTable + ) { + this.docString = docString; + this.dataTable = dataTable; + } + + public java.util.Optional getDocString() { + return java.util.Optional.ofNullable(docString); + } + + public void setDocString(PickleDocString docString) { + this.docString = docString; + } + + public java.util.Optional getDataTable() { + return java.util.Optional.ofNullable(dataTable); + } + + public void setDataTable(PickleTable dataTable) { + this.dataTable = dataTable; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStepArgument that = (PickleStepArgument) o; + return + java.util.Objects.equals(docString, that.docString) && + java.util.Objects.equals(dataTable, that.dataTable); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + docString, + dataTable + ); + } + + @Override + public String toString() { + return "PickleStepArgument{" + + "docString=" + docString + + ", dataTable=" + dataTable + + '}'; + } + } + + + public static class PickleTable { + private java.util.List rows; + + public PickleTable() {} + + public PickleTable( + java.util.List rows + ) { + this.rows = java.util.Objects.requireNonNull(rows); + } + + public java.util.List getRows() { + return java.util.Objects.requireNonNull(rows); + } + + public void setRows(java.util.List rows) { + this.rows = java.util.Objects.requireNonNull(rows); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTable that = (PickleTable) o; + return + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + rows + ); + } + + @Override + public String toString() { + return "PickleTable{" + + "rows=" + rows + + '}'; + } + } + + + public static class PickleTableCell { + private String value; + + public PickleTableCell() {} + + public PickleTableCell( + String value + ) { + this.value = java.util.Objects.requireNonNull(value); + } + + public String getValue() { + return java.util.Objects.requireNonNull(value); + } + + public void setValue(String value) { + this.value = java.util.Objects.requireNonNull(value); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableCell that = (PickleTableCell) o; + return + value.equals(that.value); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + value + ); + } + + @Override + public String toString() { + return "PickleTableCell{" + + "value=" + value + + '}'; + } + } + + + public static class PickleTableRow { + private java.util.List cells; + + public PickleTableRow() {} + + public PickleTableRow( + java.util.List cells + ) { + this.cells = java.util.Objects.requireNonNull(cells); + } + + public java.util.List getCells() { + return java.util.Objects.requireNonNull(cells); + } + + public void setCells(java.util.List cells) { + this.cells = java.util.Objects.requireNonNull(cells); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableRow that = (PickleTableRow) o; + return + cells.equals(that.cells); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + cells + ); + } + + @Override + public String toString() { + return "PickleTableRow{" + + "cells=" + cells + + '}'; + } + } + + + public static class PickleTag { + private String name; + private String astNodeId; + + public PickleTag() {} + + public PickleTag( + String name, + String astNodeId + ) { + this.name = java.util.Objects.requireNonNull(name); + this.astNodeId = java.util.Objects.requireNonNull(astNodeId); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getAstNodeId() { + return java.util.Objects.requireNonNull(astNodeId); + } + + public void setAstNodeId(String astNodeId) { + this.astNodeId = java.util.Objects.requireNonNull(astNodeId); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTag that = (PickleTag) o; + return + name.equals(that.name) && + astNodeId.equals(that.astNodeId); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + astNodeId + ); + } + + @Override + public String toString() { + return "PickleTag{" + + "name=" + name + + ", astNodeId=" + astNodeId + + '}'; + } + } + + + public static class Source { + private String uri; + private String data; + private SourceMediaType mediaType; + + public Source() {} + + public Source( + String uri, + String data, + SourceMediaType mediaType + ) { + this.uri = java.util.Objects.requireNonNull(uri); + this.data = java.util.Objects.requireNonNull(data); + this.mediaType = java.util.Objects.requireNonNull(mediaType); + } + + public String getUri() { + return java.util.Objects.requireNonNull(uri); + } + + public void setUri(String uri) { + this.uri = java.util.Objects.requireNonNull(uri); + } + + public String getData() { + return java.util.Objects.requireNonNull(data); + } + + public void setData(String data) { + this.data = java.util.Objects.requireNonNull(data); + } + + public SourceMediaType getMediaType() { + return java.util.Objects.requireNonNull(mediaType); + } + + public void setMediaType(SourceMediaType mediaType) { + this.mediaType = java.util.Objects.requireNonNull(mediaType); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Source that = (Source) o; + return + uri.equals(that.uri) && + data.equals(that.data) && + mediaType.equals(that.mediaType); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + uri, + data, + mediaType + ); + } + + @Override + public String toString() { + return "Source{" + + "uri=" + uri + + ", data=" + data + + ", mediaType=" + mediaType + + '}'; + } + } + + + public static class SourceReference { + private String uri; + private JavaMethod javaMethod; + private JavaStackTraceElement javaStackTraceElement; + private Location location; + + public SourceReference() {} + + public SourceReference( + String uri, + JavaMethod javaMethod, + JavaStackTraceElement javaStackTraceElement, + Location location + ) { + this.uri = uri; + this.javaMethod = javaMethod; + this.javaStackTraceElement = javaStackTraceElement; + this.location = location; + } + + public java.util.Optional getUri() { + return java.util.Optional.ofNullable(uri); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public java.util.Optional getJavaMethod() { + return java.util.Optional.ofNullable(javaMethod); + } + + public void setJavaMethod(JavaMethod javaMethod) { + this.javaMethod = javaMethod; + } + + public java.util.Optional getJavaStackTraceElement() { + return java.util.Optional.ofNullable(javaStackTraceElement); + } + + public void setJavaStackTraceElement(JavaStackTraceElement javaStackTraceElement) { + this.javaStackTraceElement = javaStackTraceElement; + } + + public java.util.Optional getLocation() { + return java.util.Optional.ofNullable(location); + } + + public void setLocation(Location location) { + this.location = location; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SourceReference that = (SourceReference) o; + return + java.util.Objects.equals(uri, that.uri) && + java.util.Objects.equals(javaMethod, that.javaMethod) && + java.util.Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && + java.util.Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + uri, + javaMethod, + javaStackTraceElement, + location + ); + } + + @Override + public String toString() { + return "SourceReference{" + + "uri=" + uri + + ", javaMethod=" + javaMethod + + ", javaStackTraceElement=" + javaStackTraceElement + + ", location=" + location + + '}'; + } + } + + + public static class JavaMethod { + private String className; + private String methodName; + private java.util.List methodParameterTypes; + + public JavaMethod() {} + + public JavaMethod( + String className, + String methodName, + java.util.List methodParameterTypes + ) { + this.className = java.util.Objects.requireNonNull(className); + this.methodName = java.util.Objects.requireNonNull(methodName); + this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); + } + + public String getClassName() { + return java.util.Objects.requireNonNull(className); + } + + public void setClassName(String className) { + this.className = java.util.Objects.requireNonNull(className); + } + + public String getMethodName() { + return java.util.Objects.requireNonNull(methodName); + } + + public void setMethodName(String methodName) { + this.methodName = java.util.Objects.requireNonNull(methodName); + } + + public java.util.List getMethodParameterTypes() { + return java.util.Objects.requireNonNull(methodParameterTypes); + } + + public void setMethodParameterTypes(java.util.List methodParameterTypes) { + this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaMethod that = (JavaMethod) o; + return + className.equals(that.className) && + methodName.equals(that.methodName) && + methodParameterTypes.equals(that.methodParameterTypes); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + className, + methodName, + methodParameterTypes + ); + } + + @Override + public String toString() { + return "JavaMethod{" + + "className=" + className + + ", methodName=" + methodName + + ", methodParameterTypes=" + methodParameterTypes + + '}'; + } + } + + + public static class JavaStackTraceElement { + private String className; + private String fileName; + private String methodName; + + public JavaStackTraceElement() {} + + public JavaStackTraceElement( + String className, + String fileName, + String methodName + ) { + this.className = java.util.Objects.requireNonNull(className); + this.fileName = java.util.Objects.requireNonNull(fileName); + this.methodName = java.util.Objects.requireNonNull(methodName); + } + + public String getClassName() { + return java.util.Objects.requireNonNull(className); + } + + public void setClassName(String className) { + this.className = java.util.Objects.requireNonNull(className); + } + + public String getFileName() { + return java.util.Objects.requireNonNull(fileName); + } + + public void setFileName(String fileName) { + this.fileName = java.util.Objects.requireNonNull(fileName); + } + + public String getMethodName() { + return java.util.Objects.requireNonNull(methodName); + } + + public void setMethodName(String methodName) { + this.methodName = java.util.Objects.requireNonNull(methodName); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaStackTraceElement that = (JavaStackTraceElement) o; + return + className.equals(that.className) && + fileName.equals(that.fileName) && + methodName.equals(that.methodName); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + className, + fileName, + methodName + ); + } + + @Override + public String toString() { + return "JavaStackTraceElement{" + + "className=" + className + + ", fileName=" + fileName + + ", methodName=" + methodName + + '}'; + } + } + + + public static class StepDefinition { + private String id; + private StepDefinitionPattern pattern; + private SourceReference sourceReference; + + public StepDefinition() {} + + public StepDefinition( + String id, + StepDefinitionPattern pattern, + SourceReference sourceReference + ) { + this.id = java.util.Objects.requireNonNull(id); + this.pattern = java.util.Objects.requireNonNull(pattern); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public StepDefinitionPattern getPattern() { + return java.util.Objects.requireNonNull(pattern); + } + + public void setPattern(StepDefinitionPattern pattern) { + this.pattern = java.util.Objects.requireNonNull(pattern); + } + + public SourceReference getSourceReference() { + return java.util.Objects.requireNonNull(sourceReference); + } + + public void setSourceReference(SourceReference sourceReference) { + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinition that = (StepDefinition) o; + return + id.equals(that.id) && + pattern.equals(that.pattern) && + sourceReference.equals(that.sourceReference); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + pattern, + sourceReference + ); + } + + @Override + public String toString() { + return "StepDefinition{" + + "id=" + id + + ", pattern=" + pattern + + ", sourceReference=" + sourceReference + + '}'; + } + } + + + public static class StepDefinitionPattern { + private String source; + private StepDefinitionPatternType type; + + public StepDefinitionPattern() {} + + public StepDefinitionPattern( + String source, + StepDefinitionPatternType type + ) { + this.source = java.util.Objects.requireNonNull(source); + this.type = java.util.Objects.requireNonNull(type); + } + + public String getSource() { + return java.util.Objects.requireNonNull(source); + } + + public void setSource(String source) { + this.source = java.util.Objects.requireNonNull(source); + } + + public StepDefinitionPatternType getType() { + return java.util.Objects.requireNonNull(type); + } + + public void setType(StepDefinitionPatternType type) { + this.type = java.util.Objects.requireNonNull(type); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinitionPattern that = (StepDefinitionPattern) o; + return + source.equals(that.source) && + type.equals(that.type); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + source, + type + ); + } + + @Override + public String toString() { + return "StepDefinitionPattern{" + + "source=" + source + + ", type=" + type + + '}'; + } + } + + + public static class TestCase { + private String id; + private String pickleId; + private java.util.List testSteps; + + public TestCase() {} + + public TestCase( + String id, + String pickleId, + java.util.List testSteps + ) { + this.id = java.util.Objects.requireNonNull(id); + this.pickleId = java.util.Objects.requireNonNull(pickleId); + this.testSteps = java.util.Objects.requireNonNull(testSteps); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getPickleId() { + return java.util.Objects.requireNonNull(pickleId); + } + + public void setPickleId(String pickleId) { + this.pickleId = java.util.Objects.requireNonNull(pickleId); + } + + public java.util.List getTestSteps() { + return java.util.Objects.requireNonNull(testSteps); + } + + public void setTestSteps(java.util.List testSteps) { + this.testSteps = java.util.Objects.requireNonNull(testSteps); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCase that = (TestCase) o; + return + id.equals(that.id) && + pickleId.equals(that.pickleId) && + testSteps.equals(that.testSteps); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + pickleId, + testSteps + ); + } + + @Override + public String toString() { + return "TestCase{" + + "id=" + id + + ", pickleId=" + pickleId + + ", testSteps=" + testSteps + + '}'; + } + } + + + public static class Group { + private java.util.List children; + private Long start; + private String value; + + public Group() {} + + public Group( + java.util.List children, + Long start, + String value + ) { + this.children = java.util.Objects.requireNonNull(children); + this.start = start; + this.value = value; + } + + public java.util.List getChildren() { + return java.util.Objects.requireNonNull(children); + } + + public void setChildren(java.util.List children) { + this.children = java.util.Objects.requireNonNull(children); + } + + public java.util.Optional getStart() { + return java.util.Optional.ofNullable(start); + } + + public void setStart(Long start) { + this.start = start; + } + + public java.util.Optional getValue() { + return java.util.Optional.ofNullable(value); + } + + public void setValue(String value) { + this.value = value; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Group that = (Group) o; + return + children.equals(that.children) && + java.util.Objects.equals(start, that.start) && + java.util.Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + children, + start, + value + ); + } + + @Override + public String toString() { + return "Group{" + + "children=" + children + + ", start=" + start + + ", value=" + value + + '}'; + } + } + + + public static class StepMatchArgument { + private Group group; + private String parameterTypeName; + + public StepMatchArgument() {} + + public StepMatchArgument( + Group group, + String parameterTypeName + ) { + this.group = java.util.Objects.requireNonNull(group); + this.parameterTypeName = parameterTypeName; + } + + public Group getGroup() { + return java.util.Objects.requireNonNull(group); + } + + public void setGroup(Group group) { + this.group = java.util.Objects.requireNonNull(group); + } + + public java.util.Optional getParameterTypeName() { + return java.util.Optional.ofNullable(parameterTypeName); + } + + public void setParameterTypeName(String parameterTypeName) { + this.parameterTypeName = parameterTypeName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgument that = (StepMatchArgument) o; + return + group.equals(that.group) && + java.util.Objects.equals(parameterTypeName, that.parameterTypeName); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + group, + parameterTypeName + ); + } + + @Override + public String toString() { + return "StepMatchArgument{" + + "group=" + group + + ", parameterTypeName=" + parameterTypeName + + '}'; + } + } + + + public static class StepMatchArgumentsList { + private java.util.List stepMatchArguments; + + public StepMatchArgumentsList() {} + + public StepMatchArgumentsList( + java.util.List stepMatchArguments + ) { + this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); + } + + public java.util.List getStepMatchArguments() { + return java.util.Objects.requireNonNull(stepMatchArguments); + } + + public void setStepMatchArguments(java.util.List stepMatchArguments) { + this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgumentsList that = (StepMatchArgumentsList) o; + return + stepMatchArguments.equals(that.stepMatchArguments); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + stepMatchArguments + ); + } + + @Override + public String toString() { + return "StepMatchArgumentsList{" + + "stepMatchArguments=" + stepMatchArguments + + '}'; + } + } + + + public static class TestStep { + private String hookId; + private String id; + private String pickleStepId; + private java.util.List stepDefinitionIds; + private java.util.List stepMatchArgumentsLists; + + public TestStep() {} + + public TestStep( + String hookId, + String id, + String pickleStepId, + java.util.List stepDefinitionIds, + java.util.List stepMatchArgumentsLists + ) { + this.hookId = hookId; + this.id = java.util.Objects.requireNonNull(id); + this.pickleStepId = pickleStepId; + this.stepDefinitionIds = stepDefinitionIds; + this.stepMatchArgumentsLists = stepMatchArgumentsLists; + } + + public java.util.Optional getHookId() { + return java.util.Optional.ofNullable(hookId); + } + + public void setHookId(String hookId) { + this.hookId = hookId; + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public java.util.Optional getPickleStepId() { + return java.util.Optional.ofNullable(pickleStepId); + } + + public void setPickleStepId(String pickleStepId) { + this.pickleStepId = pickleStepId; + } + + public java.util.Optional> getStepDefinitionIds() { + return java.util.Optional.ofNullable(stepDefinitionIds); + } + + public void setStepDefinitionIds(java.util.List stepDefinitionIds) { + this.stepDefinitionIds = stepDefinitionIds; + } + + public java.util.Optional> getStepMatchArgumentsLists() { + return java.util.Optional.ofNullable(stepMatchArgumentsLists); + } + + public void setStepMatchArgumentsLists(java.util.List stepMatchArgumentsLists) { + this.stepMatchArgumentsLists = stepMatchArgumentsLists; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStep that = (TestStep) o; + return + java.util.Objects.equals(hookId, that.hookId) && + id.equals(that.id) && + java.util.Objects.equals(pickleStepId, that.pickleStepId) && + java.util.Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && + java.util.Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + hookId, + id, + pickleStepId, + stepDefinitionIds, + stepMatchArgumentsLists + ); + } + + @Override + public String toString() { + return "TestStep{" + + "hookId=" + hookId + + ", id=" + id + + ", pickleStepId=" + pickleStepId + + ", stepDefinitionIds=" + stepDefinitionIds + + ", stepMatchArgumentsLists=" + stepMatchArgumentsLists + + '}'; + } + } + + + public static class TestCaseFinished { + private String testCaseStartedId; + private Timestamp timestamp; + private Boolean willBeRetried; + + public TestCaseFinished() {} + + public TestCaseFinished( + String testCaseStartedId, + Timestamp timestamp, + Boolean willBeRetried + ) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); + } + + public String getTestCaseStartedId() { + return java.util.Objects.requireNonNull(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public Boolean getWillBeRetried() { + return java.util.Objects.requireNonNull(willBeRetried); + } + + public void setWillBeRetried(Boolean willBeRetried) { + this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseFinished that = (TestCaseFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + timestamp.equals(that.timestamp) && + willBeRetried.equals(that.willBeRetried); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + testCaseStartedId, + timestamp, + willBeRetried + ); + } + + @Override + public String toString() { + return "TestCaseFinished{" + + "testCaseStartedId=" + testCaseStartedId + + ", timestamp=" + timestamp + + ", willBeRetried=" + willBeRetried + + '}'; + } + } + + + public static class TestCaseStarted { + private Long attempt; + private String id; + private String testCaseId; + private Timestamp timestamp; + + public TestCaseStarted() {} + + public TestCaseStarted( + Long attempt, + String id, + String testCaseId, + Timestamp timestamp + ) { + this.attempt = java.util.Objects.requireNonNull(attempt); + this.id = java.util.Objects.requireNonNull(id); + this.testCaseId = java.util.Objects.requireNonNull(testCaseId); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public Long getAttempt() { + return java.util.Objects.requireNonNull(attempt); + } + + public void setAttempt(Long attempt) { + this.attempt = java.util.Objects.requireNonNull(attempt); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getTestCaseId() { + return java.util.Objects.requireNonNull(testCaseId); + } + + public void setTestCaseId(String testCaseId) { + this.testCaseId = java.util.Objects.requireNonNull(testCaseId); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseStarted that = (TestCaseStarted) o; + return + attempt.equals(that.attempt) && + id.equals(that.id) && + testCaseId.equals(that.testCaseId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + attempt, + id, + testCaseId, + timestamp + ); + } + + @Override + public String toString() { + return "TestCaseStarted{" + + "attempt=" + attempt + + ", id=" + id + + ", testCaseId=" + testCaseId + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class TestRunFinished { + private String message; + private Boolean success; + private Timestamp timestamp; + + public TestRunFinished() {} + + public TestRunFinished( + String message, + Boolean success, + Timestamp timestamp + ) { + this.message = message; + this.success = java.util.Objects.requireNonNull(success); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public java.util.Optional getMessage() { + return java.util.Optional.ofNullable(message); + } + + public void setMessage(String message) { + this.message = message; + } + + public Boolean getSuccess() { + return java.util.Objects.requireNonNull(success); + } + + public void setSuccess(Boolean success) { + this.success = java.util.Objects.requireNonNull(success); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunFinished that = (TestRunFinished) o; + return + java.util.Objects.equals(message, that.message) && + success.equals(that.success) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + message, + success, + timestamp + ); + } + + @Override + public String toString() { + return "TestRunFinished{" + + "message=" + message + + ", success=" + success + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class TestRunStarted { + private Timestamp timestamp; + + public TestRunStarted() {} + + public TestRunStarted( + Timestamp timestamp + ) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunStarted that = (TestRunStarted) o; + return + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + timestamp + ); + } + + @Override + public String toString() { + return "TestRunStarted{" + + "timestamp=" + timestamp + + '}'; + } + } + + + public static class TestStepFinished { + private String testCaseStartedId; + private String testStepId; + private TestStepResult testStepResult; + private Timestamp timestamp; + + public TestStepFinished() {} + + public TestStepFinished( + String testCaseStartedId, + String testStepId, + TestStepResult testStepResult, + Timestamp timestamp + ) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.testStepId = java.util.Objects.requireNonNull(testStepId); + this.testStepResult = java.util.Objects.requireNonNull(testStepResult); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public String getTestCaseStartedId() { + return java.util.Objects.requireNonNull(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + } + + public String getTestStepId() { + return java.util.Objects.requireNonNull(testStepId); + } + + public void setTestStepId(String testStepId) { + this.testStepId = java.util.Objects.requireNonNull(testStepId); + } + + public TestStepResult getTestStepResult() { + return java.util.Objects.requireNonNull(testStepResult); + } + + public void setTestStepResult(TestStepResult testStepResult) { + this.testStepResult = java.util.Objects.requireNonNull(testStepResult); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepFinished that = (TestStepFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + testStepResult.equals(that.testStepResult) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + testCaseStartedId, + testStepId, + testStepResult, + timestamp + ); + } + + @Override + public String toString() { + return "TestStepFinished{" + + "testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", testStepResult=" + testStepResult + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class TestStepResult { + private Duration duration; + private String message; + private TestStepResultStatus status; + + public TestStepResult() {} + + public TestStepResult( + Duration duration, + String message, + TestStepResultStatus status + ) { + this.duration = java.util.Objects.requireNonNull(duration); + this.message = message; + this.status = java.util.Objects.requireNonNull(status); + } + + public Duration getDuration() { + return java.util.Objects.requireNonNull(duration); + } + + public void setDuration(Duration duration) { + this.duration = java.util.Objects.requireNonNull(duration); + } + + public java.util.Optional getMessage() { + return java.util.Optional.ofNullable(message); + } + + public void setMessage(String message) { + this.message = message; + } + + public TestStepResultStatus getStatus() { + return java.util.Objects.requireNonNull(status); + } + + public void setStatus(TestStepResultStatus status) { + this.status = java.util.Objects.requireNonNull(status); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepResult that = (TestStepResult) o; + return + duration.equals(that.duration) && + java.util.Objects.equals(message, that.message) && + status.equals(that.status); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + duration, + message, + status + ); + } + + @Override + public String toString() { + return "TestStepResult{" + + "duration=" + duration + + ", message=" + message + + ", status=" + status + + '}'; + } + } + + + public static class TestStepStarted { + private String testCaseStartedId; + private String testStepId; + private Timestamp timestamp; + + public TestStepStarted() {} + + public TestStepStarted( + String testCaseStartedId, + String testStepId, + Timestamp timestamp + ) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.testStepId = java.util.Objects.requireNonNull(testStepId); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public String getTestCaseStartedId() { + return java.util.Objects.requireNonNull(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + } + + public String getTestStepId() { + return java.util.Objects.requireNonNull(testStepId); + } + + public void setTestStepId(String testStepId) { + this.testStepId = java.util.Objects.requireNonNull(testStepId); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepStarted that = (TestStepStarted) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + testCaseStartedId, + testStepId, + timestamp + ); + } + + @Override + public String toString() { + return "TestStepStarted{" + + "testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class Timestamp { + private Long seconds; + private Long nanos; + + public Timestamp() {} + + public Timestamp( + Long seconds, + Long nanos + ) { + this.seconds = java.util.Objects.requireNonNull(seconds); + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + public Long getSeconds() { + return java.util.Objects.requireNonNull(seconds); + } + + public void setSeconds(Long seconds) { + this.seconds = java.util.Objects.requireNonNull(seconds); + } + + public Long getNanos() { + return java.util.Objects.requireNonNull(nanos); + } + + public void setNanos(Long nanos) { + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Timestamp that = (Timestamp) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + seconds, + nanos + ); + } + + @Override + public String toString() { + return "Timestamp{" + + "seconds=" + seconds + + ", nanos=" + nanos + + '}'; + } + } + + + public static class UndefinedParameterType { + private String expression; + private String name; + + public UndefinedParameterType() {} + + public UndefinedParameterType( + String expression, + String name + ) { + this.expression = java.util.Objects.requireNonNull(expression); + this.name = java.util.Objects.requireNonNull(name); + } + + public String getExpression() { + return java.util.Objects.requireNonNull(expression); + } + + public void setExpression(String expression) { + this.expression = java.util.Objects.requireNonNull(expression); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UndefinedParameterType that = (UndefinedParameterType) o; + return + expression.equals(that.expression) && + name.equals(that.name); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + expression, + name + ); + } + + @Override + public String toString() { + return "UndefinedParameterType{" + + "expression=" + expression + + ", name=" + name + + '}'; + } + } + + public enum AttachmentContentEncoding { + IDENTITY("IDENTITY"), + BASE64("BASE64"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (AttachmentContentEncoding c: values()) { + CONSTANTS.put(c.value, c); + } + } + + AttachmentContentEncoding(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static AttachmentContentEncoding fromValue(String value) { + AttachmentContentEncoding constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + + public enum SourceMediaType { + TEXT_X_CUCUMBER_GHERKIN_PLAIN("text/x.cucumber.gherkin+plain"), + TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (SourceMediaType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + SourceMediaType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static SourceMediaType fromValue(String value) { + SourceMediaType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + + public enum StepDefinitionPatternType { + CUCUMBER_EXPRESSION("CUCUMBER_EXPRESSION"), + REGULAR_EXPRESSION("REGULAR_EXPRESSION"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (StepDefinitionPatternType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + StepDefinitionPatternType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static StepDefinitionPatternType fromValue(String value) { + StepDefinitionPatternType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + + public enum TestStepResultStatus { + UNKNOWN("UNKNOWN"), + PASSED("PASSED"), + SKIPPED("SKIPPED"), + PENDING("PENDING"), + UNDEFINED("UNDEFINED"), + AMBIGUOUS("AMBIGUOUS"), + FAILED("FAILED"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (TestStepResultStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + TestStepResultStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static TestStepResultStatus fromValue(String value) { + TestStepResultStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + +} diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 85cfaaefbb..1a1175f315 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -2,7 +2,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; -import io.cucumber.messages.types.Envelope; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.BufferedReader; @@ -12,6 +11,8 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; +import static io.cucumber.messages.Messages.*; + /** * Iterates over messages read from a stream. Client code should not depend on this class * directly, but rather on a {@code Iterable} object. diff --git a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java index 89a522f25e..a394a8ff15 100644 --- a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java +++ b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java @@ -1,7 +1,6 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Duration; -import io.cucumber.messages.types.Timestamp; +import static io.cucumber.messages.Messages.*; public final class TimeConversion { diff --git a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java index 347f0ce8cb..334641ae2b 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java @@ -1,11 +1,5 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Attachment; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Location; -import io.cucumber.messages.types.Source; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -13,9 +7,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import static io.cucumber.messages.Messages.*; import static java.util.Collections.emptyList; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -26,13 +22,15 @@ void can_serialise_messages_over_a_stream() throws IOException { List outgoingMessages = new ArrayList<>(); { Envelope envelope = new Envelope(); - envelope.setSource(new Source(null, "Feature: Hello", null)); + envelope.setSource(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); outgoingMessages.add(envelope); } { Envelope envelope = new Envelope(); Attachment attachment = new Attachment(); attachment.setBody("the body"); + attachment.setContentEncoding(AttachmentContentEncoding.IDENTITY); + attachment.setMediaType("text/plain"); envelope.setAttachment(attachment); outgoingMessages.add(envelope); } @@ -49,11 +47,11 @@ void writes_empty_arrays_and_empty_strings() throws IOException { new GherkinDocument( "hello.feature", new Feature( - new Location(), + new Location(1L, 1L), emptyList(), "en", - null, - null, + "Given ", + "Hello", "", emptyList() ), diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index caa246bd9c..6c607fc6d9 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -1,8 +1,5 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Attachment; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.Source; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -13,6 +10,7 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; +import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -26,7 +24,7 @@ protected MessageWriter makeMessageWriter(OutputStream output) { } @Override - protected Iterable makeMessageIterable(InputStream input) { + protected Iterable makeMessageIterable(InputStream input) { return new NdjsonToMessageIterable(input); } @@ -34,7 +32,7 @@ protected Iterable makeMessageIterable(InputStream input) { void writes_source_envelope() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); MessageWriter writer = makeMessageWriter(output); - writer.write(new Source("uri", "data", Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + writer.write(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); String json = new String(output.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}\n", json); } @@ -70,7 +68,7 @@ void handles_enums() { Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); - assertEquals(Attachment.ContentEncoding.BASE_64, envelope.getAttachment().getContentEncoding()); + assertEquals(AttachmentContentEncoding.BASE64, envelope.getAttachment().get().getContentEncoding()); assertFalse(iterator.hasNext()); } diff --git a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java index 23e4a850d9..b62c38af95 100644 --- a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java @@ -1,9 +1,8 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Duration; -import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; +import static io.cucumber.messages.Messages.*; import static io.cucumber.messages.TimeConversion.durationToJavaDuration; import static io.cucumber.messages.TimeConversion.javaDurationToDuration; import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp; diff --git a/messages/jsonschema/scripts/codegen.rb b/messages/jsonschema/scripts/codegen.rb index f1c5f21943..f1f903afe7 100644 --- a/messages/jsonschema/scripts/codegen.rb +++ b/messages/jsonschema/scripts/codegen.rb @@ -23,6 +23,7 @@ def initialize(paths, language_type_by_schema_type) end end + @schemas = @schemas.sort @enums = @enum_set.to_a.sort{|a,b| a[:name] <=> b[:name]} end @@ -151,7 +152,7 @@ def array_type_for(type_name) class Java < Codegen def initialize(paths) language_type_by_schema_type = { - 'integer' => 'Integer', + 'integer' => 'Long', 'string' => 'String', 'boolean' => 'Boolean', } @@ -160,7 +161,7 @@ def initialize(paths) end def array_type_for(type_name) - "List<#{type_name}>" + "java.util.List<#{type_name}>" end end diff --git a/messages/jsonschema/scripts/templates/go.go.erb b/messages/jsonschema/scripts/templates/go.go.erb index 9b415c947c..a85a52a419 100644 --- a/messages/jsonschema/scripts/templates/go.go.erb +++ b/messages/jsonschema/scripts/templates/go.go.erb @@ -1,6 +1,6 @@ package messages -<% @schemas.sort.each do |key, schema| -%> +<% @schemas.each do |key, schema| -%> type <%= class_name(key) %> struct { <%- schema['properties'].each do |property_name, property| -%> <%- diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb new file mode 100644 index 0000000000..785fd6a492 --- /dev/null +++ b/messages/jsonschema/scripts/templates/java.enum.java.erb @@ -0,0 +1,39 @@ +<% @enums.each do |enum| -%> + public enum <%= enum[:name] %> { + <% enum[:values].each_with_index do |value, index| -%> + <%= enum_constant(value) %>("<%= value %>")<%= index < enum[:values].length-1 ? ',' : ';' %> + <% end -%> + + private final String value; + private final static java.util.Map> CONSTANTS = new java.util.HashMap<>(); + + static { + for (<%= enum[:name] %> c: values()) { + CONSTANTS.put(c.value, c); + } + } + + <%= enum[:name] %>(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static <%= enum[:name] %> fromValue(String value) { + <%= enum[:name] %> constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + +<% end -%> diff --git a/messages/jsonschema/scripts/templates/java.enum.ts.erb b/messages/jsonschema/scripts/templates/java.enum.ts.erb deleted file mode 100644 index 2478b75bda..0000000000 --- a/messages/jsonschema/scripts/templates/java.enum.ts.erb +++ /dev/null @@ -1,36 +0,0 @@ -public enum <%= enum[:name] %> { -<% enum[:values].each_with_index do |value, index| -%> - <%= enum_constant(value) %>("<%= value %>")<%= index < enum[:values].length-1 ? ',' : ';' %> -<% end -%> - - private final String value; - private final static java.util.Map> CONSTANTS = new java.util.HashMap>(); - - static { - for (<%= enum[:name] %> c: values()) { - CONSTANTS.put(c.value, c); - } - } - - <%= enum[:name] %>(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static <%= enum[:name] %> fromValue(String value) { - <%= enum[:name] %> constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } -} diff --git a/messages/jsonschema/scripts/templates/java.ts.erb b/messages/jsonschema/scripts/templates/java.java.erb similarity index 51% rename from messages/jsonschema/scripts/templates/java.ts.erb rename to messages/jsonschema/scripts/templates/java.java.erb index e8db9affa5..46f3ba4e1c 100644 --- a/messages/jsonschema/scripts/templates/java.ts.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,30 +1,10 @@ -package io.cucumber.messages; - -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -import static java.util.Objects.requireNonNull; -import static java.util.Optional.empty; -import static java.util.Optional.of; -import static java.util.Optional.ofNullable; - -public class Messages { - <% @schemas.sort.each do |key, schema| %> +<% @schemas.each do |key, schema| %> public static class <%= class_name(key) %> { - <%- schema['properties'].each do |property_name, property| -%> - private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; - <%- if (schema['required'] || []).index(property_name) -%> - public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { - return <%= property_name %>; - } - <%- else -%> - public Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { - return ofNullable(<%= property_name %>); - } - <%- end -%> + <%- schema['properties'].each do |property_name, property| -%> + private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; + <%- end -%> - <%- end -%> + public <%= class_name(key) %>() {} public <%= class_name(key) %>( <%- schema['properties'].each_with_index do |(property_name, property), index| -%> @@ -33,13 +13,34 @@ public class Messages { ) { <%- schema['properties'].each_with_index do |(property_name, property), index| -%> <%- if (schema['required'] || []).index(property_name) -%> - this.<%= property_name %> = requireNonNull(<%= property_name %>); + this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); <%- else -%> this.<%= property_name %> = <%= property_name %>; <%- end -%> <%- end -%> } + <%- schema['properties'].each do |property_name, property| -%> + <%- if (schema['required'] || []).index(property_name) -%> + public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { + return java.util.Objects.requireNonNull(<%= property_name %>); + } + + public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); + } + <%- else -%> + public java.util.Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { + return java.util.Optional.ofNullable(<%= property_name %>); + } + + public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + this.<%= property_name %> = <%= property_name %>; + } + <%- end -%> + + <%- end -%> + @Override public boolean equals(Object o) { if (this == o) return true; @@ -49,7 +50,7 @@ public class Messages { <%- if (schema['required'] || []).index(property_name) -%> <%= property_name -%>.equals(that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> <%- else -%> - Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> + java.util.Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> <%- end -%> <% end -%> @@ -57,13 +58,21 @@ public class Messages { @Override public int hashCode() { - return Objects.hash( + return java.util.Objects.hash( <%- schema['properties'].each_with_index do |(property_name, property), index| -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> <%- end -%> ); } + + @Override + public String toString() { + return "<%= class_name(key) %>{" + + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + "<%= index == 0 ? '' : ', '%><%= property_name %>=" + <%= property_name %> + + <%- end -%> + '}'; + } } - <% end -%> -} +<% end -%> diff --git a/messages/jsonschema/scripts/templates/markdown.md.erb b/messages/jsonschema/scripts/templates/markdown.md.erb index 6337feaa66..ec4ef7c002 100644 --- a/messages/jsonschema/scripts/templates/markdown.md.erb +++ b/messages/jsonschema/scripts/templates/markdown.md.erb @@ -3,7 +3,7 @@ Each message is an instance of [Envelope](#envelope). The `Envelope` message will only have one of its fields set, which indicates the payload of the message. -<% @schemas.sort.each do |key, schema| -%> +<% @schemas.each do |key, schema| -%> ## <%= class_name(key) %> | Field | Type | Required | Description | diff --git a/messages/jsonschema/scripts/templates/perl.pm.erb b/messages/jsonschema/scripts/templates/perl.pm.erb index dfab124c9d..b5fa275832 100644 --- a/messages/jsonschema/scripts/templates/perl.pm.erb +++ b/messages/jsonschema/scripts/templates/perl.pm.erb @@ -44,7 +44,7 @@ use Cucumber::Messages::Message; =cut -<%- @schemas.sort.each do |key, schema| %> +<%- @schemas.each do |key, schema| %> package Cucumber::Messages::<%= class_name(key) %> { diff --git a/messages/jsonschema/scripts/templates/ruby.rb.erb b/messages/jsonschema/scripts/templates/ruby.rb.erb index cb38beda77..505f1c4b43 100644 --- a/messages/jsonschema/scripts/templates/ruby.rb.erb +++ b/messages/jsonschema/scripts/templates/ruby.rb.erb @@ -5,7 +5,7 @@ require 'cucumber/messages/message' module Cucumber module Messages - <%- @schemas.sort.each do |key, schema| %> + <%- @schemas.each do |key, schema| %> ## # Represents the <%= class_name(key) %> message in Cucumber's {message protocol}[https://github.com/cucumber/common/tree/main/messages#readme]. diff --git a/messages/jsonschema/scripts/templates/ruby_deserializers.rb.erb b/messages/jsonschema/scripts/templates/ruby_deserializers.rb.erb index 6134e2de50..47c2875f5c 100644 --- a/messages/jsonschema/scripts/templates/ruby_deserializers.rb.erb +++ b/messages/jsonschema/scripts/templates/ruby_deserializers.rb.erb @@ -6,7 +6,7 @@ require 'json' module Cucumber module Messages - <%- @schemas.sort.each do |key, schema| -%> + <%- @schemas.each do |key, schema| -%> class <%= class_name(key) %> diff --git a/messages/jsonschema/scripts/templates/typescript.ts.erb b/messages/jsonschema/scripts/templates/typescript.ts.erb index e594ddc92c..83aea321d9 100644 --- a/messages/jsonschema/scripts/templates/typescript.ts.erb +++ b/messages/jsonschema/scripts/templates/typescript.ts.erb @@ -1,7 +1,7 @@ import { Type } from 'class-transformer' import 'reflect-metadata' -<% @schemas.sort.each do |key, schema| -%> +<% @schemas.each do |key, schema| -%> export class <%= class_name(key) -%> { <%- schema['properties'].each do |property_name, property| -%> From e852173e522258eb492a396a353b6b356953b658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 15:10:36 +0000 Subject: [PATCH 04/63] Update gherkin and html-formatter --- .templates/java/.gitignore | 1 + .templates/java/default.mk | 7 +- config/java/.gitignore | 1 + config/java/default.mk | 7 +- gherkin/java/.gitignore | 1 + gherkin/java/default.mk | 7 +- gherkin/java/pom.xml | 2 +- .../java/io/cucumber/gherkin/AstNode.java | 6 +- .../java/io/cucumber/gherkin/Gherkin.java | 19 ++--- .../gherkin/GherkinDocumentBuilder.java | 22 +---- .../main/java/io/cucumber/gherkin/Main.java | 2 +- .../gherkin/pickles/PickleCompiler.java | 80 +++++++++---------- .../gherkin/GherkinDocumentBuilderTest.java | 14 ++-- .../java/io/cucumber/gherkin/GherkinTest.java | 23 +++--- .../cucumber/gherkin/MessageVersionTest.java | 2 +- .../java/io/cucumber/gherkin/ParserTest.java | 4 +- html-formatter/java/.gitignore | 1 + html-formatter/java/default.mk | 7 +- html-formatter/java/pom.xml | 2 +- .../java/io/cucumber/htmlformatter/Main.java | 2 +- .../htmlformatter/MessagesToHtmlWriter.java | 2 +- .../MessagesToHtmlWriterTest.java | 4 +- json-to-messages/java-testdata/.gitignore | 1 + json-to-messages/java-testdata/default.mk | 7 +- messages/CHANGELOG.md | 4 + messages/java/.gitignore | 1 + messages/java/Makefile | 3 - messages/java/default.mk | 7 +- .../java/io/cucumber/messages/Messages.java | 52 ++++++------ .../scripts/templates/java.java.erb | 2 +- 30 files changed, 142 insertions(+), 151 deletions(-) diff --git a/.templates/java/.gitignore b/.templates/java/.gitignore index d21e336dd4..ff801497cf 100644 --- a/.templates/java/.gitignore +++ b/.templates/java/.gitignore @@ -12,5 +12,6 @@ dependency-reduced-pom.xml .tested* .compared .built +.codegen # Approval tests acceptance/ diff --git a/.templates/java/default.mk b/.templates/java/default.mk index b96c5444f2..ca398124a9 100644 --- a/.templates/java/default.mk +++ b/.templates/java/default.mk @@ -12,13 +12,16 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su default: .tested .PHONY: default +.codegen: + touch $@ + .tested: .tested-jar-check .tested-jar-check: .deps .built ./scripts/check-jar.sh $(JAR) touch $@ -.built: pom.xml $(JAVA_SOURCE_FILES) +.built: pom.xml $(JAVA_SOURCE_FILES) .codegen mvn install touch $@ @@ -59,7 +62,7 @@ clean: clean-java .PHONY: clean clean-java: - rm -rf target .deps .tested* .built acceptance + rm -rf target .deps .tested* .built acceptance .codegen mvn clean .PHONY: clean-java diff --git a/config/java/.gitignore b/config/java/.gitignore index d21e336dd4..ff801497cf 100644 --- a/config/java/.gitignore +++ b/config/java/.gitignore @@ -12,5 +12,6 @@ dependency-reduced-pom.xml .tested* .compared .built +.codegen # Approval tests acceptance/ diff --git a/config/java/default.mk b/config/java/default.mk index b96c5444f2..ca398124a9 100644 --- a/config/java/default.mk +++ b/config/java/default.mk @@ -12,13 +12,16 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su default: .tested .PHONY: default +.codegen: + touch $@ + .tested: .tested-jar-check .tested-jar-check: .deps .built ./scripts/check-jar.sh $(JAR) touch $@ -.built: pom.xml $(JAVA_SOURCE_FILES) +.built: pom.xml $(JAVA_SOURCE_FILES) .codegen mvn install touch $@ @@ -59,7 +62,7 @@ clean: clean-java .PHONY: clean clean-java: - rm -rf target .deps .tested* .built acceptance + rm -rf target .deps .tested* .built acceptance .codegen mvn clean .PHONY: clean-java diff --git a/gherkin/java/.gitignore b/gherkin/java/.gitignore index d21e336dd4..ff801497cf 100644 --- a/gherkin/java/.gitignore +++ b/gherkin/java/.gitignore @@ -12,5 +12,6 @@ dependency-reduced-pom.xml .tested* .compared .built +.codegen # Approval tests acceptance/ diff --git a/gherkin/java/default.mk b/gherkin/java/default.mk index b96c5444f2..ca398124a9 100644 --- a/gherkin/java/default.mk +++ b/gherkin/java/default.mk @@ -12,13 +12,16 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su default: .tested .PHONY: default +.codegen: + touch $@ + .tested: .tested-jar-check .tested-jar-check: .deps .built ./scripts/check-jar.sh $(JAR) touch $@ -.built: pom.xml $(JAVA_SOURCE_FILES) +.built: pom.xml $(JAVA_SOURCE_FILES) .codegen mvn install touch $@ @@ -59,7 +62,7 @@ clean: clean-java .PHONY: clean clean-java: - rm -rf target .deps .tested* .built acceptance + rm -rf target .deps .tested* .built acceptance .codegen mvn clean .PHONY: clean-java diff --git a/gherkin/java/pom.xml b/gherkin/java/pom.xml index 3091876d46..f848c21907 100644 --- a/gherkin/java/pom.xml +++ b/gherkin/java/pom.xml @@ -29,7 +29,7 @@ io.cucumber messages - [17.1.1,18.0.0) + [17.1.2-SNAPSHOT,18.0.0) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java b/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java index 824557e17f..76cc337665 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java @@ -18,11 +18,7 @@ public AstNode(RuleType ruleType) { } public void add(RuleType ruleType, Object obj) { - List items = subItems.get(ruleType); - if (items == null) { - items = new ArrayList(); - subItems.put(ruleType, items); - } + List items = subItems.computeIfAbsent(ruleType, k -> new ArrayList<>()); items.add(obj); } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index b5a095c0e7..8ce65b5b4e 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -2,13 +2,6 @@ import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Location; -import io.cucumber.messages.types.ParseError; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.Source; -import io.cucumber.messages.types.SourceReference; import java.io.FileInputStream; import java.io.IOException; @@ -21,6 +14,8 @@ import java.util.function.Function; import java.util.stream.Stream; +import static io.cucumber.messages.Messages.*; + /** * Main entry point for the Gherkin library */ @@ -51,7 +46,7 @@ public static Stream fromSources(List envelopes, boolean inc public static Envelope makeSourceEnvelope(String data, String uri) { Envelope envelope = new Envelope(); - envelope.setSource(new Source(uri, data, Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + envelope.setSource(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); return envelope; } @@ -93,10 +88,10 @@ private Stream parserMessageStream(Envelope envelope, boolean includeS if (includeSource) { messages.add(envelope); } - if (envelope.getSource() != null) { + if (envelope.getSource().isPresent()) { Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); - Source source = envelope.getSource(); + Source source = envelope.getSource().get(); String uri = source.getUri(); String data = source.getData(); @@ -143,8 +138,8 @@ private void addParseError(List messages, ParserException e, String ur null, null, // We want 0 values not to be serialised, which is why we set them to null // This is a legacy requirement brought over from old protobuf behaviour - new Location( - line == 0 ? null : line, + new io.cucumber.messages.Messages.Location( + line, column == 0 ? null : column ) ), diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index 934035b516..4ea2aee790 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -1,21 +1,6 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Background; -import io.cucumber.messages.types.Comment; -import io.cucumber.messages.types.DataTable; -import io.cucumber.messages.types.DocString; -import io.cucumber.messages.types.Examples; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.FeatureChild; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Rule; -import io.cucumber.messages.types.RuleChild; -import io.cucumber.messages.types.Scenario; -import io.cucumber.messages.types.Step; -import io.cucumber.messages.types.TableCell; -import io.cucumber.messages.types.TableRow; -import io.cucumber.messages.types.Tag; import java.util.ArrayDeque; import java.util.ArrayList; @@ -24,6 +9,7 @@ import java.util.List; import java.util.stream.Collectors; +import static io.cucumber.messages.Messages.*; import static io.cucumber.gherkin.Parser.Builder; import static io.cucumber.gherkin.Parser.RuleType; import static io.cucumber.gherkin.Parser.TokenType; @@ -264,7 +250,7 @@ private void ensureCellCount(List rows) { if (row.getCells().size() != cellCount) { io.cucumber.gherkin.Location location = new io.cucumber.gherkin.Location( row.getLocation().getLine().intValue(), - row.getLocation().getColumn().intValue() + row.getLocation().getColumn().orElse(0L).intValue() ); throw new ParserException.AstBuilderException("inconsistent cell count within the table", location); } @@ -287,9 +273,9 @@ private List getSteps(AstNode node) { return node.getItems(RuleType.Step); } - private io.cucumber.messages.types.Location getLocation(Token token, int column) { + private io.cucumber.messages.Messages.Location getLocation(Token token, int column) { column = column == 0 ? token.location.getColumn() : column; - return new io.cucumber.messages.types.Location((long) token.location.getLine(), (long) column); + return new io.cucumber.messages.Messages.Location((long) token.location.getLine(), (long) column); } private String getDescription(AstNode node) { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java index 5a61b26b61..e60e41a3fe 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java @@ -3,13 +3,13 @@ import io.cucumber.messages.IdGenerator; import io.cucumber.messages.MessageToNdjsonWriter; import io.cucumber.messages.MessageWriter; -import io.cucumber.messages.types.Envelope; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; +import static io.cucumber.messages.Messages.*; import static java.util.Arrays.asList; public class Main { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java index c0c87453d0..02eaca1455 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java @@ -1,27 +1,6 @@ package io.cucumber.gherkin.pickles; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.DataTable; -import io.cucumber.messages.types.DocString; -import io.cucumber.messages.types.Examples; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.FeatureChild; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.PickleDocString; -import io.cucumber.messages.types.PickleStep; -import io.cucumber.messages.types.PickleStepArgument; -import io.cucumber.messages.types.PickleTable; -import io.cucumber.messages.types.PickleTableCell; -import io.cucumber.messages.types.PickleTableRow; -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.Step; -import io.cucumber.messages.types.TableCell; -import io.cucumber.messages.types.TableRow; -import io.cucumber.messages.types.Tag; import java.util.ArrayList; import java.util.Collection; @@ -30,6 +9,27 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static io.cucumber.messages.Messages.DataTable; +import static io.cucumber.messages.Messages.DocString; +import static io.cucumber.messages.Messages.Examples; +import static io.cucumber.messages.Messages.Feature; +import static io.cucumber.messages.Messages.FeatureChild; +import static io.cucumber.messages.Messages.GherkinDocument; +import static io.cucumber.messages.Messages.Pickle; +import static io.cucumber.messages.Messages.PickleDocString; +import static io.cucumber.messages.Messages.PickleStep; +import static io.cucumber.messages.Messages.PickleStepArgument; +import static io.cucumber.messages.Messages.PickleTable; +import static io.cucumber.messages.Messages.PickleTableCell; +import static io.cucumber.messages.Messages.PickleTableRow; +import static io.cucumber.messages.Messages.PickleTag; +import static io.cucumber.messages.Messages.Rule; +import static io.cucumber.messages.Messages.RuleChild; +import static io.cucumber.messages.Messages.Scenario; +import static io.cucumber.messages.Messages.Step; +import static io.cucumber.messages.Messages.TableCell; +import static io.cucumber.messages.Messages.TableRow; +import static io.cucumber.messages.Messages.Tag; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static java.util.Collections.unmodifiableList; @@ -44,10 +44,10 @@ public PickleCompiler(IdGenerator idGenerator) { public List compile(GherkinDocument gherkinDocument, String uri) { List pickles = new ArrayList<>(); - Feature feature = gherkinDocument.getFeature(); - if (feature == null) { + if (!gherkinDocument.getFeature().isPresent()) { return pickles; } + Feature feature = gherkinDocument.getFeature().get(); String language = feature.getLanguage(); @@ -59,12 +59,12 @@ private void compileFeature(List pickles, Feature feature, String langua List tags = feature.getTags(); List featureBackgroundSteps = new ArrayList<>(); for (FeatureChild featureChild : feature.getChildren()) { - if (featureChild.getBackground() != null) { - featureBackgroundSteps.addAll(featureChild.getBackground().getSteps()); - } else if (featureChild.getRule() != null) { - compileRule(pickles, featureChild.getRule(), tags, featureBackgroundSteps, language, uri); - } else { - Scenario scenario = featureChild.getScenario(); + if (featureChild.getBackground().isPresent()) { + featureBackgroundSteps.addAll(featureChild.getBackground().get().getSteps()); + } else if (featureChild.getRule().isPresent()) { + compileRule(pickles, featureChild.getRule().get(), tags, featureBackgroundSteps, language, uri); + } else if (featureChild.getScenario().isPresent()) { + Scenario scenario = featureChild.getScenario().get(); if (scenario.getExamples().isEmpty()) { compileScenario(pickles, scenario, tags, featureBackgroundSteps, language, uri); } else { @@ -82,10 +82,10 @@ private void compileRule(List pickles, Rule rule, List parentTags, ruleTags.addAll(rule.getTags()); for (RuleChild ruleChild : rule.getChildren()) { - if (ruleChild.getBackground() != null) { - ruleBackgroundSteps.addAll(ruleChild.getBackground().getSteps()); - } else { - Scenario scenario = ruleChild.getScenario(); + if (ruleChild.getBackground().isPresent()) { + ruleBackgroundSteps.addAll(ruleChild.getBackground().get().getSteps()); + } else if (ruleChild.getScenario().isPresent()) { + Scenario scenario = ruleChild.getScenario().get(); if (scenario.getExamples().isEmpty()) { compileScenario(pickles, scenario, ruleTags, ruleBackgroundSteps, language, uri); } else { @@ -122,8 +122,8 @@ private void compileScenario(List pickles, Scenario scenario, List private void compileScenarioOutline(List pickles, Scenario scenario, List featureTags, List backgroundSteps, String language, String uri) { for (final Examples examples : scenario.getExamples()) { - if (examples.getTableHeader() == null) continue; - List variableCells = examples.getTableHeader().getCells(); + if (!examples.getTableHeader().isPresent()) continue; + List variableCells = examples.getTableHeader().get().getCells(); for (final TableRow valuesRow : examples.getTableBody()) { List valueCells = valuesRow.getCells(); @@ -176,7 +176,7 @@ private PickleTable pickleDataTable(DataTable dataTable, List variabl private PickleDocString pickleDocString(DocString docString, List variableCells, List valueCells) { return new PickleDocString( - docString.getMediaType() == null ? null : interpolate(docString.getMediaType(), variableCells, valueCells), + docString.getMediaType().isPresent() ? interpolate(docString.getMediaType().get(), variableCells, valueCells) : null, interpolate(docString.getContent(), variableCells, valueCells) ); } @@ -196,12 +196,12 @@ private PickleStep pickleStep(Step step, List variableCells, TableRow pickleStep.setAstNodeIds(astNodeIds); } - if (step.getDataTable() != null) { - pickleStep.setArgument(new PickleStepArgument(null, pickleDataTable(step.getDataTable(), variableCells, valueCells))); + if (step.getDataTable().isPresent()) { + pickleStep.setArgument(new PickleStepArgument(null, pickleDataTable(step.getDataTable().get(), variableCells, valueCells))); } - if (step.getDocString() != null) { - pickleStep.setArgument(new PickleStepArgument(pickleDocString(step.getDocString(), variableCells, valueCells), null)); + if (step.getDocString().isPresent()) { + pickleStep.setArgument(new PickleStepArgument(pickleDocString(step.getDocString().get(), variableCells, valueCells), null)); } return pickleStep; } diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index 6e7cb8bc24..8751f14df6 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -2,15 +2,11 @@ import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Comment; -import io.cucumber.messages.types.FeatureChild; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.TableRow; import org.junit.Test; import java.util.List; +import static io.cucumber.messages.Messages.*; import static org.junit.Assert.assertEquals; public class GherkinDocumentBuilderTest { @@ -24,8 +20,8 @@ public void is_reusable() { GherkinDocument d1 = parser.parse("Feature: 1", matcher); GherkinDocument d2 = parser.parse("Feature: 2", matcher); - assertEquals("1", d1.getFeature().getName()); - assertEquals("2", d2.getFeature().getName()); + assertEquals("1", d1.getFeature().get().getName()); + assertEquals("2", d2.getFeature().get().getName()); } @Test @@ -53,7 +49,7 @@ public void parses_rules() { " Given b"; GherkinDocument doc = parser.parse(data); - List children = doc.getFeature().getChildren(); + List children = doc.getFeature().get().getChildren(); assertEquals(3, children.size()); IdGenerator idGenerator = new IdGenerator.Incrementing(); @@ -84,7 +80,7 @@ public void sets_empty_table_cells() { " Given a table\n" + " |a||b|" ); - TableRow row = doc.getFeature().getChildren().get(0).getScenario().getSteps().get(0).getDataTable().getRows().get(0); + TableRow row = doc.getFeature().get().getChildren().get(0).getScenario().get().getSteps().get(0).getDataTable().get().getRows().get(0); assertEquals("a", row.getCells().get(0).getValue()); assertEquals("", row.getCells().get(1).getValue()); assertEquals("b", row.getCells().get(2).getValue()); diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java index 2c6af09f7c..07528a3cf1 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java @@ -1,12 +1,6 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.PickleStep; -import io.cucumber.messages.types.Scenario; import org.junit.Test; import java.io.File; @@ -18,6 +12,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static io.cucumber.messages.Messages.*; import static io.cucumber.gherkin.Gherkin.makeSourceEnvelope; import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; @@ -32,9 +27,9 @@ public void use_this_in_readme() { boolean includeAst = true; boolean includePickles = true; Stream envelopeStream = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator); - Stream pickleStream = envelopeStream.filter(envelope -> envelope.getPickle() != null); + Stream pickleStream = envelopeStream.filter(envelope -> envelope.getPickle().isPresent()); - assertEquals("minimalistic", pickleStream.collect(Collectors.toList()).get(0).getPickle().getName()); + assertEquals("minimalistic", pickleStream.collect(Collectors.toList()).get(0).getPickle().get().getName()); } @@ -47,14 +42,14 @@ public void provides_access_to_the_ast() { List envelopes = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator).collect(Collectors.toList()); // Get the AST - GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument(); + GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument().get(); // Get the Feature node of the AST - Feature feature = gherkinDocument.getFeature(); + Feature feature = gherkinDocument.getFeature().get(); assertEquals("Minimal", feature.getName()); // Get the first Scenario node of the Feature node - Scenario scenario = feature.getChildren().get(0).getScenario(); + Scenario scenario = feature.getChildren().get(0).getScenario().get(); assertEquals("minimalistic", scenario.getName()); } @@ -65,7 +60,7 @@ public void provides_access_to_pickles_which_are_compiled_from_the_ast() { .collect(Collectors.toList()); // Get the first pickle - Pickle pickle = envelopes.get(0).getPickle(); + Pickle pickle = envelopes.get(0).getPickle().get(); // Get the first step of the pickle PickleStep step = pickle.getSteps().get(0); @@ -80,8 +75,8 @@ public void parses_supplied_source() { " Given the minimalism\n", "test.feature"); List envelopes = Gherkin.fromSources(singletonList(envelope), false, true, false, idGenerator).collect(Collectors.toList()); - GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument(); - Feature feature = gherkinDocument.getFeature(); + GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument().get(); + Feature feature = gherkinDocument.getFeature().get(); assertEquals("Minimal", feature.getName()); } } diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java index 63eecf708e..b6eaf16e4b 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -import io.cucumber.messages.types.Envelope; +import static io.cucumber.messages.Messages.*; import org.junit.Test; import static org.junit.Assert.assertNotNull; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index 1d6ff6f2e6..b3d20996fa 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -1,7 +1,7 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.GherkinDocument; +import static io.cucumber.messages.Messages.*; import org.junit.Test; import static org.junit.Assert.assertEquals; @@ -15,6 +15,6 @@ public void change_default_language() { Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); GherkinDocument gherkinDocument = parser.parse("Egenskap: i18n support\n", matcher); - assertEquals("no", gherkinDocument.getFeature().getLanguage()); + assertEquals("no", gherkinDocument.getFeature().get().getLanguage()); } } diff --git a/html-formatter/java/.gitignore b/html-formatter/java/.gitignore index d21e336dd4..ff801497cf 100644 --- a/html-formatter/java/.gitignore +++ b/html-formatter/java/.gitignore @@ -12,5 +12,6 @@ dependency-reduced-pom.xml .tested* .compared .built +.codegen # Approval tests acceptance/ diff --git a/html-formatter/java/default.mk b/html-formatter/java/default.mk index b96c5444f2..ca398124a9 100644 --- a/html-formatter/java/default.mk +++ b/html-formatter/java/default.mk @@ -12,13 +12,16 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su default: .tested .PHONY: default +.codegen: + touch $@ + .tested: .tested-jar-check .tested-jar-check: .deps .built ./scripts/check-jar.sh $(JAR) touch $@ -.built: pom.xml $(JAVA_SOURCE_FILES) +.built: pom.xml $(JAVA_SOURCE_FILES) .codegen mvn install touch $@ @@ -59,7 +62,7 @@ clean: clean-java .PHONY: clean clean-java: - rm -rf target .deps .tested* .built acceptance + rm -rf target .deps .tested* .built acceptance .codegen mvn clean .PHONY: clean-java diff --git a/html-formatter/java/pom.xml b/html-formatter/java/pom.xml index dabae339b6..588abab204 100644 --- a/html-formatter/java/pom.xml +++ b/html-formatter/java/pom.xml @@ -41,7 +41,7 @@ io.cucumber messages - [17.1.0,18.0.0) + [17.1.2-SNAPSHOT,18.0.0) org.hamcrest diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java index f81339d283..167afbf18b 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java @@ -1,7 +1,7 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.NdjsonToMessageIterable; -import io.cucumber.messages.types.Envelope; +import static io.cucumber.messages.Messages.*; import java.io.OutputStreamWriter; diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index 85c90c5ebe..fca9b7278c 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -1,7 +1,6 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.JSON; -import io.cucumber.messages.types.Envelope; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -12,6 +11,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; +import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 6b3ed59da6..b4d6abcfe3 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -1,9 +1,6 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.TimeConversion; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.TestRunFinished; -import io.cucumber.messages.types.TestRunStarted; import org.junit.jupiter.api.Test; import java.io.BufferedWriter; @@ -12,6 +9,7 @@ import java.io.OutputStreamWriter; import java.time.Instant; +import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/json-to-messages/java-testdata/.gitignore b/json-to-messages/java-testdata/.gitignore index d21e336dd4..ff801497cf 100644 --- a/json-to-messages/java-testdata/.gitignore +++ b/json-to-messages/java-testdata/.gitignore @@ -12,5 +12,6 @@ dependency-reduced-pom.xml .tested* .compared .built +.codegen # Approval tests acceptance/ diff --git a/json-to-messages/java-testdata/default.mk b/json-to-messages/java-testdata/default.mk index b96c5444f2..ca398124a9 100644 --- a/json-to-messages/java-testdata/default.mk +++ b/json-to-messages/java-testdata/default.mk @@ -12,13 +12,16 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su default: .tested .PHONY: default +.codegen: + touch $@ + .tested: .tested-jar-check .tested-jar-check: .deps .built ./scripts/check-jar.sh $(JAR) touch $@ -.built: pom.xml $(JAVA_SOURCE_FILES) +.built: pom.xml $(JAVA_SOURCE_FILES) .codegen mvn install touch $@ @@ -59,7 +62,7 @@ clean: clean-java .PHONY: clean clean-java: - rm -rf target .deps .tested* .built acceptance + rm -rf target .deps .tested* .built acceptance .codegen mvn clean .PHONY: clean-java diff --git a/messages/CHANGELOG.md b/messages/CHANGELOG.md index b268e58acf..9844581c40 100644 --- a/messages/CHANGELOG.md +++ b/messages/CHANGELOG.md @@ -14,6 +14,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +* Java: Generate Java code that uses `Optional` in getters. This makes the library + more type safe (avoids illegal null values). To upgrade, replace `import io.cucumber.messages.types.*` with `import static io.cucumber.messages.Messages.*`. + ([#1858](https://github.com/cucumber/common/pull/1858) [aslakhellesoy]) + ### Deprecated ### Removed diff --git a/messages/java/.gitignore b/messages/java/.gitignore index d21e336dd4..ff801497cf 100644 --- a/messages/java/.gitignore +++ b/messages/java/.gitignore @@ -12,5 +12,6 @@ dependency-reduced-pom.xml .tested* .compared .built +.codegen # Approval tests acceptance/ diff --git a/messages/java/Makefile b/messages/java/Makefile index b3558e914b..23bb1961dd 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -11,6 +11,3 @@ src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/s ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.java.erb >> $@ ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> $@ echo "}" >> $@ - -clean: - rm -f src/main/java/io/messages/cucumber/Messages.java diff --git a/messages/java/default.mk b/messages/java/default.mk index b96c5444f2..ca398124a9 100644 --- a/messages/java/default.mk +++ b/messages/java/default.mk @@ -12,13 +12,16 @@ rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(su default: .tested .PHONY: default +.codegen: + touch $@ + .tested: .tested-jar-check .tested-jar-check: .deps .built ./scripts/check-jar.sh $(JAR) touch $@ -.built: pom.xml $(JAVA_SOURCE_FILES) +.built: pom.xml $(JAVA_SOURCE_FILES) .codegen mvn install touch $@ @@ -59,7 +62,7 @@ clean: clean-java .PHONY: clean clean-java: - rm -rf target .deps .tested* .built acceptance + rm -rf target .deps .tested* .built acceptance .codegen mvn clean .PHONY: clean-java diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index cfee0fc379..bb006a6ce9 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -476,7 +476,7 @@ public String toString() { public static class GherkinDocument { private String uri; private Feature feature; - private java.util.List comments; + private java.util.List comments = new java.util.ArrayList<>(); public GherkinDocument() {} @@ -551,7 +551,7 @@ public static class Background { private String keyword; private String name; private String description; - private java.util.List steps; + private java.util.List steps = new java.util.ArrayList<>(); private String id; public Background() {} @@ -722,7 +722,7 @@ public String toString() { public static class DataTable { private Location location; - private java.util.List rows; + private java.util.List rows = new java.util.ArrayList<>(); public DataTable() {} @@ -868,12 +868,12 @@ public String toString() { public static class Examples { private Location location; - private java.util.List tags; + private java.util.List tags = new java.util.ArrayList<>(); private String keyword; private String name; private String description; private TableRow tableHeader; - private java.util.List tableBody; + private java.util.List tableBody = new java.util.ArrayList<>(); private String id; public Examples() {} @@ -1011,12 +1011,12 @@ public String toString() { public static class Feature { private Location location; - private java.util.List tags; + private java.util.List tags = new java.util.ArrayList<>(); private String language; private String keyword; private String name; private String description; - private java.util.List children; + private java.util.List children = new java.util.ArrayList<>(); public Feature() {} @@ -1213,11 +1213,11 @@ public String toString() { public static class Rule { private Location location; - private java.util.List tags; + private java.util.List tags = new java.util.ArrayList<>(); private String keyword; private String name; private String description; - private java.util.List children; + private java.util.List children = new java.util.ArrayList<>(); private String id; public Rule() {} @@ -1401,12 +1401,12 @@ public String toString() { public static class Scenario { private Location location; - private java.util.List tags; + private java.util.List tags = new java.util.ArrayList<>(); private String keyword; private String name; private String description; - private java.util.List steps; - private java.util.List examples; + private java.util.List steps = new java.util.ArrayList<>(); + private java.util.List examples = new java.util.ArrayList<>(); private String id; public Scenario() {} @@ -1718,7 +1718,7 @@ public String toString() { public static class TableRow { private Location location; - private java.util.List cells; + private java.util.List cells = new java.util.ArrayList<>(); private String id; public TableRow() {} @@ -2344,7 +2344,7 @@ public String toString() { public static class ParameterType { private String name; - private java.util.List regularExpressions; + private java.util.List regularExpressions = new java.util.ArrayList<>(); private Boolean preferForRegularExpressionMatch; private Boolean useForSnippets; private String id; @@ -2507,9 +2507,9 @@ public static class Pickle { private String uri; private String name; private String language; - private java.util.List steps; - private java.util.List tags; - private java.util.List astNodeIds; + private java.util.List steps = new java.util.ArrayList<>(); + private java.util.List tags = new java.util.ArrayList<>(); + private java.util.List astNodeIds = new java.util.ArrayList<>(); public Pickle() {} @@ -2692,7 +2692,7 @@ public String toString() { public static class PickleStep { private PickleStepArgument argument; - private java.util.List astNodeIds; + private java.util.List astNodeIds = new java.util.ArrayList<>(); private String id; private String text; @@ -2837,7 +2837,7 @@ public String toString() { public static class PickleTable { - private java.util.List rows; + private java.util.List rows = new java.util.ArrayList<>(); public PickleTable() {} @@ -2927,7 +2927,7 @@ public String toString() { public static class PickleTableRow { - private java.util.List cells; + private java.util.List cells = new java.util.ArrayList<>(); public PickleTableRow() {} @@ -3193,7 +3193,7 @@ public String toString() { public static class JavaMethod { private String className; private String methodName; - private java.util.List methodParameterTypes; + private java.util.List methodParameterTypes = new java.util.ArrayList<>(); public JavaMethod() {} @@ -3471,7 +3471,7 @@ public String toString() { public static class TestCase { private String id; private String pickleId; - private java.util.List testSteps; + private java.util.List testSteps = new java.util.ArrayList<>(); public TestCase() {} @@ -3542,7 +3542,7 @@ public String toString() { public static class Group { - private java.util.List children; + private java.util.List children = new java.util.ArrayList<>(); private Long start; private String value; @@ -3674,7 +3674,7 @@ public String toString() { public static class StepMatchArgumentsList { - private java.util.List stepMatchArguments; + private java.util.List stepMatchArguments = new java.util.ArrayList<>(); public StepMatchArgumentsList() {} @@ -3722,8 +3722,8 @@ public static class TestStep { private String hookId; private String id; private String pickleStepId; - private java.util.List stepDefinitionIds; - private java.util.List stepMatchArgumentsLists; + private java.util.List stepDefinitionIds = new java.util.ArrayList<>(); + private java.util.List stepMatchArgumentsLists = new java.util.ArrayList<>(); public TestStep() {} diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 46f3ba4e1c..f2bc0f6b52 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,7 +1,7 @@ <% @schemas.each do |key, schema| %> public static class <%= class_name(key) %> { <%- schema['properties'].each do |property_name, property| -%> - private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; + private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= property['items'] ? ' = new java.util.ArrayList<>()' : '' %>; <%- end -%> public <%= class_name(key) %>() {} From 1db93febaeaa3d64b1b3c5f6e9c9bebd1d588773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 15:22:33 +0000 Subject: [PATCH 05/63] Fix shading --- messages/java/pom.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 0ccde4c1f8..0b4bdf2765 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -92,7 +92,7 @@ com.fasterxml.jackson.core:jackson-databind com.fasterxml.jackson.core:jackson-core com.fasterxml.jackson.core:jackson-annotations - com.fasterxml.jackson.core:jackson-datatype-jdk8 + com.fasterxml.jackson.datatype:jackson-datatype-jdk8 @@ -123,6 +123,13 @@ META-INF/MANIFEST.MF + + com.fasterxml.jackson.datatype:jackson-datatype-jdk8 + + **/module-info.class + META-INF/MANIFEST.MF + + From 5e4a35dd4bd4a7f451aa14f1f4de41e361325534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 15:39:14 +0000 Subject: [PATCH 06/63] Fix serialization --- .../java/src/main/java/io/cucumber/messages/JSON.java | 2 +- .../io/cucumber/messages/NdjsonSerializationTest.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/JSON.java b/messages/java/src/main/java/io/cucumber/messages/JSON.java index 0ecba30263..8d1122fce6 100644 --- a/messages/java/src/main/java/io/cucumber/messages/JSON.java +++ b/messages/java/src/main/java/io/cucumber/messages/JSON.java @@ -14,7 +14,7 @@ public final class JSON { private static final ObjectMapper mapper = new ObjectMapper() .registerModule(new Jdk8Module()) - .setSerializationInclusion(JsonInclude.Include.NON_NULL) + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) .enable(WRITE_ENUMS_USING_TO_STRING) .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index 6c607fc6d9..c982f5f4bd 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.Iterator; @@ -37,6 +38,15 @@ void writes_source_envelope() throws IOException { assertEquals("{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}\n", json); } + @Test + void does_not_serialize_null_fields() throws IOException { + ByteArrayOutputStream output = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(output); + JSON.writeValue(writer, new Envelope()); + writer.flush(); + assertEquals("{}", new String(output.toByteArray(), UTF_8)); + } + @Test void ignores_missing_fields() { InputStream input = new ByteArrayInputStream("{\"unused\": 99}\n".getBytes(UTF_8)); From 6b86b54556be0e32dd9a6808b9d22ede07b5c57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 18:40:39 +0000 Subject: [PATCH 07/63] Replace custom codegen with jsonschema2pojo-maven-plugin --- messages/java/Makefile | 12 - messages/java/pom.xml | 22 + .../java/io/cucumber/messages/Messages.java | 4599 ----------------- .../messages/NdjsonToMessageIterable.java | 3 +- .../io/cucumber/messages/TimeConversion.java | 3 +- .../MessageSerializationContract.java | 12 +- .../messages/NdjsonSerializationTest.java | 10 +- .../cucumber/messages/TimeConversionTest.java | 3 +- 8 files changed, 41 insertions(+), 4623 deletions(-) delete mode 100644 messages/java/src/main/java/io/cucumber/messages/Messages.java diff --git a/messages/java/Makefile b/messages/java/Makefile index 23bb1961dd..551e68e27a 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -1,13 +1 @@ include default.mk - -JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") - -.codegen: src/main/java/io/cucumber/messages/Messages.java - -src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/java.java.erb ../jsonschema/scripts/templates/java.enum.java.erb - echo "package io.cucumber.messages;" > $@ - echo >> $@ - echo "public class Messages {" >> $@ - ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.java.erb >> $@ - ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> $@ - echo "}" >> $@ diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 0b4bdf2765..2dc5e98792 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -77,6 +77,28 @@ + + org.jsonschema2pojo + jsonschema2pojo-maven-plugin + 1.1.1 + + ${basedir}/../jsonschema + *.json + none + true + true + false + true + io.cucumber.messages.types + + + + + generate + + + + org.apache.maven.plugins maven-shade-plugin diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java deleted file mode 100644 index bb006a6ce9..0000000000 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ /dev/null @@ -1,4599 +0,0 @@ -package io.cucumber.messages; - -public class Messages { - - public static class Attachment { - private String body; - private AttachmentContentEncoding contentEncoding; - private String fileName; - private String mediaType; - private Source source; - private String testCaseStartedId; - private String testStepId; - private String url; - - public Attachment() {} - - public Attachment( - String body, - AttachmentContentEncoding contentEncoding, - String fileName, - String mediaType, - Source source, - String testCaseStartedId, - String testStepId, - String url - ) { - this.body = java.util.Objects.requireNonNull(body); - this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); - this.fileName = fileName; - this.mediaType = java.util.Objects.requireNonNull(mediaType); - this.source = source; - this.testCaseStartedId = testCaseStartedId; - this.testStepId = testStepId; - this.url = url; - } - - public String getBody() { - return java.util.Objects.requireNonNull(body); - } - - public void setBody(String body) { - this.body = java.util.Objects.requireNonNull(body); - } - - public AttachmentContentEncoding getContentEncoding() { - return java.util.Objects.requireNonNull(contentEncoding); - } - - public void setContentEncoding(AttachmentContentEncoding contentEncoding) { - this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); - } - - public java.util.Optional getFileName() { - return java.util.Optional.ofNullable(fileName); - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getMediaType() { - return java.util.Objects.requireNonNull(mediaType); - } - - public void setMediaType(String mediaType) { - this.mediaType = java.util.Objects.requireNonNull(mediaType); - } - - public java.util.Optional getSource() { - return java.util.Optional.ofNullable(source); - } - - public void setSource(Source source) { - this.source = source; - } - - public java.util.Optional getTestCaseStartedId() { - return java.util.Optional.ofNullable(testCaseStartedId); - } - - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = testCaseStartedId; - } - - public java.util.Optional getTestStepId() { - return java.util.Optional.ofNullable(testStepId); - } - - public void setTestStepId(String testStepId) { - this.testStepId = testStepId; - } - - public java.util.Optional getUrl() { - return java.util.Optional.ofNullable(url); - } - - public void setUrl(String url) { - this.url = url; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Attachment that = (Attachment) o; - return - body.equals(that.body) && - contentEncoding.equals(that.contentEncoding) && - java.util.Objects.equals(fileName, that.fileName) && - mediaType.equals(that.mediaType) && - java.util.Objects.equals(source, that.source) && - java.util.Objects.equals(testCaseStartedId, that.testCaseStartedId) && - java.util.Objects.equals(testStepId, that.testStepId) && - java.util.Objects.equals(url, that.url); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - body, - contentEncoding, - fileName, - mediaType, - source, - testCaseStartedId, - testStepId, - url - ); - } - - @Override - public String toString() { - return "Attachment{" + - "body=" + body + - ", contentEncoding=" + contentEncoding + - ", fileName=" + fileName + - ", mediaType=" + mediaType + - ", source=" + source + - ", testCaseStartedId=" + testCaseStartedId + - ", testStepId=" + testStepId + - ", url=" + url + - '}'; - } - } - - - public static class Duration { - private Long seconds; - private Long nanos; - - public Duration() {} - - public Duration( - Long seconds, - Long nanos - ) { - this.seconds = java.util.Objects.requireNonNull(seconds); - this.nanos = java.util.Objects.requireNonNull(nanos); - } - - public Long getSeconds() { - return java.util.Objects.requireNonNull(seconds); - } - - public void setSeconds(Long seconds) { - this.seconds = java.util.Objects.requireNonNull(seconds); - } - - public Long getNanos() { - return java.util.Objects.requireNonNull(nanos); - } - - public void setNanos(Long nanos) { - this.nanos = java.util.Objects.requireNonNull(nanos); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Duration that = (Duration) o; - return - seconds.equals(that.seconds) && - nanos.equals(that.nanos); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - seconds, - nanos - ); - } - - @Override - public String toString() { - return "Duration{" + - "seconds=" + seconds + - ", nanos=" + nanos + - '}'; - } - } - - - public static class Envelope { - private Attachment attachment; - private GherkinDocument gherkinDocument; - private Hook hook; - private Meta meta; - private ParameterType parameterType; - private ParseError parseError; - private Pickle pickle; - private Source source; - private StepDefinition stepDefinition; - private TestCase testCase; - private TestCaseFinished testCaseFinished; - private TestCaseStarted testCaseStarted; - private TestRunFinished testRunFinished; - private TestRunStarted testRunStarted; - private TestStepFinished testStepFinished; - private TestStepStarted testStepStarted; - private UndefinedParameterType undefinedParameterType; - - public Envelope() {} - - public Envelope( - Attachment attachment, - GherkinDocument gherkinDocument, - Hook hook, - Meta meta, - ParameterType parameterType, - ParseError parseError, - Pickle pickle, - Source source, - StepDefinition stepDefinition, - TestCase testCase, - TestCaseFinished testCaseFinished, - TestCaseStarted testCaseStarted, - TestRunFinished testRunFinished, - TestRunStarted testRunStarted, - TestStepFinished testStepFinished, - TestStepStarted testStepStarted, - UndefinedParameterType undefinedParameterType - ) { - this.attachment = attachment; - this.gherkinDocument = gherkinDocument; - this.hook = hook; - this.meta = meta; - this.parameterType = parameterType; - this.parseError = parseError; - this.pickle = pickle; - this.source = source; - this.stepDefinition = stepDefinition; - this.testCase = testCase; - this.testCaseFinished = testCaseFinished; - this.testCaseStarted = testCaseStarted; - this.testRunFinished = testRunFinished; - this.testRunStarted = testRunStarted; - this.testStepFinished = testStepFinished; - this.testStepStarted = testStepStarted; - this.undefinedParameterType = undefinedParameterType; - } - - public java.util.Optional getAttachment() { - return java.util.Optional.ofNullable(attachment); - } - - public void setAttachment(Attachment attachment) { - this.attachment = attachment; - } - - public java.util.Optional getGherkinDocument() { - return java.util.Optional.ofNullable(gherkinDocument); - } - - public void setGherkinDocument(GherkinDocument gherkinDocument) { - this.gherkinDocument = gherkinDocument; - } - - public java.util.Optional getHook() { - return java.util.Optional.ofNullable(hook); - } - - public void setHook(Hook hook) { - this.hook = hook; - } - - public java.util.Optional getMeta() { - return java.util.Optional.ofNullable(meta); - } - - public void setMeta(Meta meta) { - this.meta = meta; - } - - public java.util.Optional getParameterType() { - return java.util.Optional.ofNullable(parameterType); - } - - public void setParameterType(ParameterType parameterType) { - this.parameterType = parameterType; - } - - public java.util.Optional getParseError() { - return java.util.Optional.ofNullable(parseError); - } - - public void setParseError(ParseError parseError) { - this.parseError = parseError; - } - - public java.util.Optional getPickle() { - return java.util.Optional.ofNullable(pickle); - } - - public void setPickle(Pickle pickle) { - this.pickle = pickle; - } - - public java.util.Optional getSource() { - return java.util.Optional.ofNullable(source); - } - - public void setSource(Source source) { - this.source = source; - } - - public java.util.Optional getStepDefinition() { - return java.util.Optional.ofNullable(stepDefinition); - } - - public void setStepDefinition(StepDefinition stepDefinition) { - this.stepDefinition = stepDefinition; - } - - public java.util.Optional getTestCase() { - return java.util.Optional.ofNullable(testCase); - } - - public void setTestCase(TestCase testCase) { - this.testCase = testCase; - } - - public java.util.Optional getTestCaseFinished() { - return java.util.Optional.ofNullable(testCaseFinished); - } - - public void setTestCaseFinished(TestCaseFinished testCaseFinished) { - this.testCaseFinished = testCaseFinished; - } - - public java.util.Optional getTestCaseStarted() { - return java.util.Optional.ofNullable(testCaseStarted); - } - - public void setTestCaseStarted(TestCaseStarted testCaseStarted) { - this.testCaseStarted = testCaseStarted; - } - - public java.util.Optional getTestRunFinished() { - return java.util.Optional.ofNullable(testRunFinished); - } - - public void setTestRunFinished(TestRunFinished testRunFinished) { - this.testRunFinished = testRunFinished; - } - - public java.util.Optional getTestRunStarted() { - return java.util.Optional.ofNullable(testRunStarted); - } - - public void setTestRunStarted(TestRunStarted testRunStarted) { - this.testRunStarted = testRunStarted; - } - - public java.util.Optional getTestStepFinished() { - return java.util.Optional.ofNullable(testStepFinished); - } - - public void setTestStepFinished(TestStepFinished testStepFinished) { - this.testStepFinished = testStepFinished; - } - - public java.util.Optional getTestStepStarted() { - return java.util.Optional.ofNullable(testStepStarted); - } - - public void setTestStepStarted(TestStepStarted testStepStarted) { - this.testStepStarted = testStepStarted; - } - - public java.util.Optional getUndefinedParameterType() { - return java.util.Optional.ofNullable(undefinedParameterType); - } - - public void setUndefinedParameterType(UndefinedParameterType undefinedParameterType) { - this.undefinedParameterType = undefinedParameterType; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Envelope that = (Envelope) o; - return - java.util.Objects.equals(attachment, that.attachment) && - java.util.Objects.equals(gherkinDocument, that.gherkinDocument) && - java.util.Objects.equals(hook, that.hook) && - java.util.Objects.equals(meta, that.meta) && - java.util.Objects.equals(parameterType, that.parameterType) && - java.util.Objects.equals(parseError, that.parseError) && - java.util.Objects.equals(pickle, that.pickle) && - java.util.Objects.equals(source, that.source) && - java.util.Objects.equals(stepDefinition, that.stepDefinition) && - java.util.Objects.equals(testCase, that.testCase) && - java.util.Objects.equals(testCaseFinished, that.testCaseFinished) && - java.util.Objects.equals(testCaseStarted, that.testCaseStarted) && - java.util.Objects.equals(testRunFinished, that.testRunFinished) && - java.util.Objects.equals(testRunStarted, that.testRunStarted) && - java.util.Objects.equals(testStepFinished, that.testStepFinished) && - java.util.Objects.equals(testStepStarted, that.testStepStarted) && - java.util.Objects.equals(undefinedParameterType, that.undefinedParameterType); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - attachment, - gherkinDocument, - hook, - meta, - parameterType, - parseError, - pickle, - source, - stepDefinition, - testCase, - testCaseFinished, - testCaseStarted, - testRunFinished, - testRunStarted, - testStepFinished, - testStepStarted, - undefinedParameterType - ); - } - - @Override - public String toString() { - return "Envelope{" + - "attachment=" + attachment + - ", gherkinDocument=" + gherkinDocument + - ", hook=" + hook + - ", meta=" + meta + - ", parameterType=" + parameterType + - ", parseError=" + parseError + - ", pickle=" + pickle + - ", source=" + source + - ", stepDefinition=" + stepDefinition + - ", testCase=" + testCase + - ", testCaseFinished=" + testCaseFinished + - ", testCaseStarted=" + testCaseStarted + - ", testRunFinished=" + testRunFinished + - ", testRunStarted=" + testRunStarted + - ", testStepFinished=" + testStepFinished + - ", testStepStarted=" + testStepStarted + - ", undefinedParameterType=" + undefinedParameterType + - '}'; - } - } - - - public static class GherkinDocument { - private String uri; - private Feature feature; - private java.util.List comments = new java.util.ArrayList<>(); - - public GherkinDocument() {} - - public GherkinDocument( - String uri, - Feature feature, - java.util.List comments - ) { - this.uri = uri; - this.feature = feature; - this.comments = java.util.Objects.requireNonNull(comments); - } - - public java.util.Optional getUri() { - return java.util.Optional.ofNullable(uri); - } - - public void setUri(String uri) { - this.uri = uri; - } - - public java.util.Optional getFeature() { - return java.util.Optional.ofNullable(feature); - } - - public void setFeature(Feature feature) { - this.feature = feature; - } - - public java.util.List getComments() { - return java.util.Objects.requireNonNull(comments); - } - - public void setComments(java.util.List comments) { - this.comments = java.util.Objects.requireNonNull(comments); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - GherkinDocument that = (GherkinDocument) o; - return - java.util.Objects.equals(uri, that.uri) && - java.util.Objects.equals(feature, that.feature) && - comments.equals(that.comments); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - uri, - feature, - comments - ); - } - - @Override - public String toString() { - return "GherkinDocument{" + - "uri=" + uri + - ", feature=" + feature + - ", comments=" + comments + - '}'; - } - } - - - public static class Background { - private Location location; - private String keyword; - private String name; - private String description; - private java.util.List steps = new java.util.ArrayList<>(); - private String id; - - public Background() {} - - public Background( - Location location, - String keyword, - String name, - String description, - java.util.List steps, - String id - ) { - this.location = java.util.Objects.requireNonNull(location); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.steps = java.util.Objects.requireNonNull(steps); - this.id = java.util.Objects.requireNonNull(id); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getDescription() { - return java.util.Objects.requireNonNull(description); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); - } - - public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps); - } - - public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Background that = (Background) o; - return - location.equals(that.location) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - steps.equals(that.steps) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - keyword, - name, - description, - steps, - id - ); - } - - @Override - public String toString() { - return "Background{" + - "location=" + location + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", steps=" + steps + - ", id=" + id + - '}'; - } - } - - - public static class Comment { - private Location location; - private String text; - - public Comment() {} - - public Comment( - Location location, - String text - ) { - this.location = java.util.Objects.requireNonNull(location); - this.text = java.util.Objects.requireNonNull(text); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public String getText() { - return java.util.Objects.requireNonNull(text); - } - - public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Comment that = (Comment) o; - return - location.equals(that.location) && - text.equals(that.text); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - text - ); - } - - @Override - public String toString() { - return "Comment{" + - "location=" + location + - ", text=" + text + - '}'; - } - } - - - public static class DataTable { - private Location location; - private java.util.List rows = new java.util.ArrayList<>(); - - public DataTable() {} - - public DataTable( - Location location, - java.util.List rows - ) { - this.location = java.util.Objects.requireNonNull(location); - this.rows = java.util.Objects.requireNonNull(rows); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public java.util.List getRows() { - return java.util.Objects.requireNonNull(rows); - } - - public void setRows(java.util.List rows) { - this.rows = java.util.Objects.requireNonNull(rows); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DataTable that = (DataTable) o; - return - location.equals(that.location) && - rows.equals(that.rows); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - rows - ); - } - - @Override - public String toString() { - return "DataTable{" + - "location=" + location + - ", rows=" + rows + - '}'; - } - } - - - public static class DocString { - private Location location; - private String mediaType; - private String content; - private String delimiter; - - public DocString() {} - - public DocString( - Location location, - String mediaType, - String content, - String delimiter - ) { - this.location = java.util.Objects.requireNonNull(location); - this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content); - this.delimiter = java.util.Objects.requireNonNull(delimiter); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public java.util.Optional getMediaType() { - return java.util.Optional.ofNullable(mediaType); - } - - public void setMediaType(String mediaType) { - this.mediaType = mediaType; - } - - public String getContent() { - return java.util.Objects.requireNonNull(content); - } - - public void setContent(String content) { - this.content = java.util.Objects.requireNonNull(content); - } - - public String getDelimiter() { - return java.util.Objects.requireNonNull(delimiter); - } - - public void setDelimiter(String delimiter) { - this.delimiter = java.util.Objects.requireNonNull(delimiter); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DocString that = (DocString) o; - return - location.equals(that.location) && - java.util.Objects.equals(mediaType, that.mediaType) && - content.equals(that.content) && - delimiter.equals(that.delimiter); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - mediaType, - content, - delimiter - ); - } - - @Override - public String toString() { - return "DocString{" + - "location=" + location + - ", mediaType=" + mediaType + - ", content=" + content + - ", delimiter=" + delimiter + - '}'; - } - } - - - public static class Examples { - private Location location; - private java.util.List tags = new java.util.ArrayList<>(); - private String keyword; - private String name; - private String description; - private TableRow tableHeader; - private java.util.List tableBody = new java.util.ArrayList<>(); - private String id; - - public Examples() {} - - public Examples( - Location location, - java.util.List tags, - String keyword, - String name, - String description, - TableRow tableHeader, - java.util.List tableBody, - String id - ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.tableHeader = tableHeader; - this.tableBody = java.util.Objects.requireNonNull(tableBody); - this.id = java.util.Objects.requireNonNull(id); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); - } - - public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getDescription() { - return java.util.Objects.requireNonNull(description); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); - } - - public java.util.Optional getTableHeader() { - return java.util.Optional.ofNullable(tableHeader); - } - - public void setTableHeader(TableRow tableHeader) { - this.tableHeader = tableHeader; - } - - public java.util.List getTableBody() { - return java.util.Objects.requireNonNull(tableBody); - } - - public void setTableBody(java.util.List tableBody) { - this.tableBody = java.util.Objects.requireNonNull(tableBody); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Examples that = (Examples) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - java.util.Objects.equals(tableHeader, that.tableHeader) && - tableBody.equals(that.tableBody) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - tags, - keyword, - name, - description, - tableHeader, - tableBody, - id - ); - } - - @Override - public String toString() { - return "Examples{" + - "location=" + location + - ", tags=" + tags + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", tableHeader=" + tableHeader + - ", tableBody=" + tableBody + - ", id=" + id + - '}'; - } - } - - - public static class Feature { - private Location location; - private java.util.List tags = new java.util.ArrayList<>(); - private String language; - private String keyword; - private String name; - private String description; - private java.util.List children = new java.util.ArrayList<>(); - - public Feature() {} - - public Feature( - Location location, - java.util.List tags, - String language, - String keyword, - String name, - String description, - java.util.List children - ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.language = java.util.Objects.requireNonNull(language); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.children = java.util.Objects.requireNonNull(children); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); - } - - public String getLanguage() { - return java.util.Objects.requireNonNull(language); - } - - public void setLanguage(String language) { - this.language = java.util.Objects.requireNonNull(language); - } - - public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getDescription() { - return java.util.Objects.requireNonNull(description); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); - } - - public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children); - } - - public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Feature that = (Feature) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - language.equals(that.language) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - children.equals(that.children); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - tags, - language, - keyword, - name, - description, - children - ); - } - - @Override - public String toString() { - return "Feature{" + - "location=" + location + - ", tags=" + tags + - ", language=" + language + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", children=" + children + - '}'; - } - } - - - public static class FeatureChild { - private Rule rule; - private Background background; - private Scenario scenario; - - public FeatureChild() {} - - public FeatureChild( - Rule rule, - Background background, - Scenario scenario - ) { - this.rule = rule; - this.background = background; - this.scenario = scenario; - } - - public java.util.Optional getRule() { - return java.util.Optional.ofNullable(rule); - } - - public void setRule(Rule rule) { - this.rule = rule; - } - - public java.util.Optional getBackground() { - return java.util.Optional.ofNullable(background); - } - - public void setBackground(Background background) { - this.background = background; - } - - public java.util.Optional getScenario() { - return java.util.Optional.ofNullable(scenario); - } - - public void setScenario(Scenario scenario) { - this.scenario = scenario; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - FeatureChild that = (FeatureChild) o; - return - java.util.Objects.equals(rule, that.rule) && - java.util.Objects.equals(background, that.background) && - java.util.Objects.equals(scenario, that.scenario); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - rule, - background, - scenario - ); - } - - @Override - public String toString() { - return "FeatureChild{" + - "rule=" + rule + - ", background=" + background + - ", scenario=" + scenario + - '}'; - } - } - - - public static class Rule { - private Location location; - private java.util.List tags = new java.util.ArrayList<>(); - private String keyword; - private String name; - private String description; - private java.util.List children = new java.util.ArrayList<>(); - private String id; - - public Rule() {} - - public Rule( - Location location, - java.util.List tags, - String keyword, - String name, - String description, - java.util.List children, - String id - ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.children = java.util.Objects.requireNonNull(children); - this.id = java.util.Objects.requireNonNull(id); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); - } - - public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getDescription() { - return java.util.Objects.requireNonNull(description); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); - } - - public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children); - } - - public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Rule that = (Rule) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - children.equals(that.children) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - tags, - keyword, - name, - description, - children, - id - ); - } - - @Override - public String toString() { - return "Rule{" + - "location=" + location + - ", tags=" + tags + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", children=" + children + - ", id=" + id + - '}'; - } - } - - - public static class RuleChild { - private Background background; - private Scenario scenario; - - public RuleChild() {} - - public RuleChild( - Background background, - Scenario scenario - ) { - this.background = background; - this.scenario = scenario; - } - - public java.util.Optional getBackground() { - return java.util.Optional.ofNullable(background); - } - - public void setBackground(Background background) { - this.background = background; - } - - public java.util.Optional getScenario() { - return java.util.Optional.ofNullable(scenario); - } - - public void setScenario(Scenario scenario) { - this.scenario = scenario; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RuleChild that = (RuleChild) o; - return - java.util.Objects.equals(background, that.background) && - java.util.Objects.equals(scenario, that.scenario); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - background, - scenario - ); - } - - @Override - public String toString() { - return "RuleChild{" + - "background=" + background + - ", scenario=" + scenario + - '}'; - } - } - - - public static class Scenario { - private Location location; - private java.util.List tags = new java.util.ArrayList<>(); - private String keyword; - private String name; - private String description; - private java.util.List steps = new java.util.ArrayList<>(); - private java.util.List examples = new java.util.ArrayList<>(); - private String id; - - public Scenario() {} - - public Scenario( - Location location, - java.util.List tags, - String keyword, - String name, - String description, - java.util.List steps, - java.util.List examples, - String id - ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.steps = java.util.Objects.requireNonNull(steps); - this.examples = java.util.Objects.requireNonNull(examples); - this.id = java.util.Objects.requireNonNull(id); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); - } - - public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getDescription() { - return java.util.Objects.requireNonNull(description); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); - } - - public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps); - } - - public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps); - } - - public java.util.List getExamples() { - return java.util.Objects.requireNonNull(examples); - } - - public void setExamples(java.util.List examples) { - this.examples = java.util.Objects.requireNonNull(examples); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Scenario that = (Scenario) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - steps.equals(that.steps) && - examples.equals(that.examples) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - tags, - keyword, - name, - description, - steps, - examples, - id - ); - } - - @Override - public String toString() { - return "Scenario{" + - "location=" + location + - ", tags=" + tags + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", steps=" + steps + - ", examples=" + examples + - ", id=" + id + - '}'; - } - } - - - public static class Step { - private Location location; - private String keyword; - private String text; - private DocString docString; - private DataTable dataTable; - private String id; - - public Step() {} - - public Step( - Location location, - String keyword, - String text, - DocString docString, - DataTable dataTable, - String id - ) { - this.location = java.util.Objects.requireNonNull(location); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.text = java.util.Objects.requireNonNull(text); - this.docString = docString; - this.dataTable = dataTable; - this.id = java.util.Objects.requireNonNull(id); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); - } - - public String getText() { - return java.util.Objects.requireNonNull(text); - } - - public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text); - } - - public java.util.Optional getDocString() { - return java.util.Optional.ofNullable(docString); - } - - public void setDocString(DocString docString) { - this.docString = docString; - } - - public java.util.Optional getDataTable() { - return java.util.Optional.ofNullable(dataTable); - } - - public void setDataTable(DataTable dataTable) { - this.dataTable = dataTable; - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Step that = (Step) o; - return - location.equals(that.location) && - keyword.equals(that.keyword) && - text.equals(that.text) && - java.util.Objects.equals(docString, that.docString) && - java.util.Objects.equals(dataTable, that.dataTable) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - keyword, - text, - docString, - dataTable, - id - ); - } - - @Override - public String toString() { - return "Step{" + - "location=" + location + - ", keyword=" + keyword + - ", text=" + text + - ", docString=" + docString + - ", dataTable=" + dataTable + - ", id=" + id + - '}'; - } - } - - - public static class TableCell { - private Location location; - private String value; - - public TableCell() {} - - public TableCell( - Location location, - String value - ) { - this.location = java.util.Objects.requireNonNull(location); - this.value = java.util.Objects.requireNonNull(value); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public String getValue() { - return java.util.Objects.requireNonNull(value); - } - - public void setValue(String value) { - this.value = java.util.Objects.requireNonNull(value); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TableCell that = (TableCell) o; - return - location.equals(that.location) && - value.equals(that.value); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - value - ); - } - - @Override - public String toString() { - return "TableCell{" + - "location=" + location + - ", value=" + value + - '}'; - } - } - - - public static class TableRow { - private Location location; - private java.util.List cells = new java.util.ArrayList<>(); - private String id; - - public TableRow() {} - - public TableRow( - Location location, - java.util.List cells, - String id - ) { - this.location = java.util.Objects.requireNonNull(location); - this.cells = java.util.Objects.requireNonNull(cells); - this.id = java.util.Objects.requireNonNull(id); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public java.util.List getCells() { - return java.util.Objects.requireNonNull(cells); - } - - public void setCells(java.util.List cells) { - this.cells = java.util.Objects.requireNonNull(cells); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TableRow that = (TableRow) o; - return - location.equals(that.location) && - cells.equals(that.cells) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - cells, - id - ); - } - - @Override - public String toString() { - return "TableRow{" + - "location=" + location + - ", cells=" + cells + - ", id=" + id + - '}'; - } - } - - - public static class Tag { - private Location location; - private String name; - private String id; - - public Tag() {} - - public Tag( - Location location, - String name, - String id - ) { - this.location = java.util.Objects.requireNonNull(location); - this.name = java.util.Objects.requireNonNull(name); - this.id = java.util.Objects.requireNonNull(id); - } - - public Location getLocation() { - return java.util.Objects.requireNonNull(location); - } - - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Tag that = (Tag) o; - return - location.equals(that.location) && - name.equals(that.name) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - location, - name, - id - ); - } - - @Override - public String toString() { - return "Tag{" + - "location=" + location + - ", name=" + name + - ", id=" + id + - '}'; - } - } - - - public static class Hook { - private String id; - private SourceReference sourceReference; - private String tagExpression; - - public Hook() {} - - public Hook( - String id, - SourceReference sourceReference, - String tagExpression - ) { - this.id = java.util.Objects.requireNonNull(id); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); - this.tagExpression = tagExpression; - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - public SourceReference getSourceReference() { - return java.util.Objects.requireNonNull(sourceReference); - } - - public void setSourceReference(SourceReference sourceReference) { - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); - } - - public java.util.Optional getTagExpression() { - return java.util.Optional.ofNullable(tagExpression); - } - - public void setTagExpression(String tagExpression) { - this.tagExpression = tagExpression; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Hook that = (Hook) o; - return - id.equals(that.id) && - sourceReference.equals(that.sourceReference) && - java.util.Objects.equals(tagExpression, that.tagExpression); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - id, - sourceReference, - tagExpression - ); - } - - @Override - public String toString() { - return "Hook{" + - "id=" + id + - ", sourceReference=" + sourceReference + - ", tagExpression=" + tagExpression + - '}'; - } - } - - - public static class Location { - private Long line; - private Long column; - - public Location() {} - - public Location( - Long line, - Long column - ) { - this.line = java.util.Objects.requireNonNull(line); - this.column = column; - } - - public Long getLine() { - return java.util.Objects.requireNonNull(line); - } - - public void setLine(Long line) { - this.line = java.util.Objects.requireNonNull(line); - } - - public java.util.Optional getColumn() { - return java.util.Optional.ofNullable(column); - } - - public void setColumn(Long column) { - this.column = column; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Location that = (Location) o; - return - line.equals(that.line) && - java.util.Objects.equals(column, that.column); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - line, - column - ); - } - - @Override - public String toString() { - return "Location{" + - "line=" + line + - ", column=" + column + - '}'; - } - } - - - public static class Meta { - private String protocolVersion; - private Product implementation; - private Product runtime; - private Product os; - private Product cpu; - private Ci ci; - - public Meta() {} - - public Meta( - String protocolVersion, - Product implementation, - Product runtime, - Product os, - Product cpu, - Ci ci - ) { - this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); - this.implementation = java.util.Objects.requireNonNull(implementation); - this.runtime = java.util.Objects.requireNonNull(runtime); - this.os = java.util.Objects.requireNonNull(os); - this.cpu = java.util.Objects.requireNonNull(cpu); - this.ci = ci; - } - - public String getProtocolVersion() { - return java.util.Objects.requireNonNull(protocolVersion); - } - - public void setProtocolVersion(String protocolVersion) { - this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); - } - - public Product getImplementation() { - return java.util.Objects.requireNonNull(implementation); - } - - public void setImplementation(Product implementation) { - this.implementation = java.util.Objects.requireNonNull(implementation); - } - - public Product getRuntime() { - return java.util.Objects.requireNonNull(runtime); - } - - public void setRuntime(Product runtime) { - this.runtime = java.util.Objects.requireNonNull(runtime); - } - - public Product getOs() { - return java.util.Objects.requireNonNull(os); - } - - public void setOs(Product os) { - this.os = java.util.Objects.requireNonNull(os); - } - - public Product getCpu() { - return java.util.Objects.requireNonNull(cpu); - } - - public void setCpu(Product cpu) { - this.cpu = java.util.Objects.requireNonNull(cpu); - } - - public java.util.Optional getCi() { - return java.util.Optional.ofNullable(ci); - } - - public void setCi(Ci ci) { - this.ci = ci; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Meta that = (Meta) o; - return - protocolVersion.equals(that.protocolVersion) && - implementation.equals(that.implementation) && - runtime.equals(that.runtime) && - os.equals(that.os) && - cpu.equals(that.cpu) && - java.util.Objects.equals(ci, that.ci); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - protocolVersion, - implementation, - runtime, - os, - cpu, - ci - ); - } - - @Override - public String toString() { - return "Meta{" + - "protocolVersion=" + protocolVersion + - ", implementation=" + implementation + - ", runtime=" + runtime + - ", os=" + os + - ", cpu=" + cpu + - ", ci=" + ci + - '}'; - } - } - - - public static class Ci { - private String name; - private String url; - private String buildNumber; - private Git git; - - public Ci() {} - - public Ci( - String name, - String url, - String buildNumber, - Git git - ) { - this.name = java.util.Objects.requireNonNull(name); - this.url = url; - this.buildNumber = buildNumber; - this.git = git; - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public java.util.Optional getUrl() { - return java.util.Optional.ofNullable(url); - } - - public void setUrl(String url) { - this.url = url; - } - - public java.util.Optional getBuildNumber() { - return java.util.Optional.ofNullable(buildNumber); - } - - public void setBuildNumber(String buildNumber) { - this.buildNumber = buildNumber; - } - - public java.util.Optional getGit() { - return java.util.Optional.ofNullable(git); - } - - public void setGit(Git git) { - this.git = git; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Ci that = (Ci) o; - return - name.equals(that.name) && - java.util.Objects.equals(url, that.url) && - java.util.Objects.equals(buildNumber, that.buildNumber) && - java.util.Objects.equals(git, that.git); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - name, - url, - buildNumber, - git - ); - } - - @Override - public String toString() { - return "Ci{" + - "name=" + name + - ", url=" + url + - ", buildNumber=" + buildNumber + - ", git=" + git + - '}'; - } - } - - - public static class Git { - private String remote; - private String revision; - private String branch; - private String tag; - - public Git() {} - - public Git( - String remote, - String revision, - String branch, - String tag - ) { - this.remote = java.util.Objects.requireNonNull(remote); - this.revision = java.util.Objects.requireNonNull(revision); - this.branch = branch; - this.tag = tag; - } - - public String getRemote() { - return java.util.Objects.requireNonNull(remote); - } - - public void setRemote(String remote) { - this.remote = java.util.Objects.requireNonNull(remote); - } - - public String getRevision() { - return java.util.Objects.requireNonNull(revision); - } - - public void setRevision(String revision) { - this.revision = java.util.Objects.requireNonNull(revision); - } - - public java.util.Optional getBranch() { - return java.util.Optional.ofNullable(branch); - } - - public void setBranch(String branch) { - this.branch = branch; - } - - public java.util.Optional getTag() { - return java.util.Optional.ofNullable(tag); - } - - public void setTag(String tag) { - this.tag = tag; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Git that = (Git) o; - return - remote.equals(that.remote) && - revision.equals(that.revision) && - java.util.Objects.equals(branch, that.branch) && - java.util.Objects.equals(tag, that.tag); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - remote, - revision, - branch, - tag - ); - } - - @Override - public String toString() { - return "Git{" + - "remote=" + remote + - ", revision=" + revision + - ", branch=" + branch + - ", tag=" + tag + - '}'; - } - } - - - public static class Product { - private String name; - private String version; - - public Product() {} - - public Product( - String name, - String version - ) { - this.name = java.util.Objects.requireNonNull(name); - this.version = version; - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public java.util.Optional getVersion() { - return java.util.Optional.ofNullable(version); - } - - public void setVersion(String version) { - this.version = version; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Product that = (Product) o; - return - name.equals(that.name) && - java.util.Objects.equals(version, that.version); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - name, - version - ); - } - - @Override - public String toString() { - return "Product{" + - "name=" + name + - ", version=" + version + - '}'; - } - } - - - public static class ParameterType { - private String name; - private java.util.List regularExpressions = new java.util.ArrayList<>(); - private Boolean preferForRegularExpressionMatch; - private Boolean useForSnippets; - private String id; - - public ParameterType() {} - - public ParameterType( - String name, - java.util.List regularExpressions, - Boolean preferForRegularExpressionMatch, - Boolean useForSnippets, - String id - ) { - this.name = java.util.Objects.requireNonNull(name); - this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); - this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); - this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); - this.id = java.util.Objects.requireNonNull(id); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public java.util.List getRegularExpressions() { - return java.util.Objects.requireNonNull(regularExpressions); - } - - public void setRegularExpressions(java.util.List regularExpressions) { - this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); - } - - public Boolean getPreferForRegularExpressionMatch() { - return java.util.Objects.requireNonNull(preferForRegularExpressionMatch); - } - - public void setPreferForRegularExpressionMatch(Boolean preferForRegularExpressionMatch) { - this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); - } - - public Boolean getUseForSnippets() { - return java.util.Objects.requireNonNull(useForSnippets); - } - - public void setUseForSnippets(Boolean useForSnippets) { - this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ParameterType that = (ParameterType) o; - return - name.equals(that.name) && - regularExpressions.equals(that.regularExpressions) && - preferForRegularExpressionMatch.equals(that.preferForRegularExpressionMatch) && - useForSnippets.equals(that.useForSnippets) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - name, - regularExpressions, - preferForRegularExpressionMatch, - useForSnippets, - id - ); - } - - @Override - public String toString() { - return "ParameterType{" + - "name=" + name + - ", regularExpressions=" + regularExpressions + - ", preferForRegularExpressionMatch=" + preferForRegularExpressionMatch + - ", useForSnippets=" + useForSnippets + - ", id=" + id + - '}'; - } - } - - - public static class ParseError { - private SourceReference source; - private String message; - - public ParseError() {} - - public ParseError( - SourceReference source, - String message - ) { - this.source = java.util.Objects.requireNonNull(source); - this.message = java.util.Objects.requireNonNull(message); - } - - public SourceReference getSource() { - return java.util.Objects.requireNonNull(source); - } - - public void setSource(SourceReference source) { - this.source = java.util.Objects.requireNonNull(source); - } - - public String getMessage() { - return java.util.Objects.requireNonNull(message); - } - - public void setMessage(String message) { - this.message = java.util.Objects.requireNonNull(message); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ParseError that = (ParseError) o; - return - source.equals(that.source) && - message.equals(that.message); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - source, - message - ); - } - - @Override - public String toString() { - return "ParseError{" + - "source=" + source + - ", message=" + message + - '}'; - } - } - - - public static class Pickle { - private String id; - private String uri; - private String name; - private String language; - private java.util.List steps = new java.util.ArrayList<>(); - private java.util.List tags = new java.util.ArrayList<>(); - private java.util.List astNodeIds = new java.util.ArrayList<>(); - - public Pickle() {} - - public Pickle( - String id, - String uri, - String name, - String language, - java.util.List steps, - java.util.List tags, - java.util.List astNodeIds - ) { - this.id = java.util.Objects.requireNonNull(id); - this.uri = java.util.Objects.requireNonNull(uri); - this.name = java.util.Objects.requireNonNull(name); - this.language = java.util.Objects.requireNonNull(language); - this.steps = java.util.Objects.requireNonNull(steps); - this.tags = java.util.Objects.requireNonNull(tags); - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - public String getUri() { - return java.util.Objects.requireNonNull(uri); - } - - public void setUri(String uri) { - this.uri = java.util.Objects.requireNonNull(uri); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getLanguage() { - return java.util.Objects.requireNonNull(language); - } - - public void setLanguage(String language) { - this.language = java.util.Objects.requireNonNull(language); - } - - public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps); - } - - public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps); - } - - public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); - } - - public java.util.List getAstNodeIds() { - return java.util.Objects.requireNonNull(astNodeIds); - } - - public void setAstNodeIds(java.util.List astNodeIds) { - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Pickle that = (Pickle) o; - return - id.equals(that.id) && - uri.equals(that.uri) && - name.equals(that.name) && - language.equals(that.language) && - steps.equals(that.steps) && - tags.equals(that.tags) && - astNodeIds.equals(that.astNodeIds); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - id, - uri, - name, - language, - steps, - tags, - astNodeIds - ); - } - - @Override - public String toString() { - return "Pickle{" + - "id=" + id + - ", uri=" + uri + - ", name=" + name + - ", language=" + language + - ", steps=" + steps + - ", tags=" + tags + - ", astNodeIds=" + astNodeIds + - '}'; - } - } - - - public static class PickleDocString { - private String mediaType; - private String content; - - public PickleDocString() {} - - public PickleDocString( - String mediaType, - String content - ) { - this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content); - } - - public java.util.Optional getMediaType() { - return java.util.Optional.ofNullable(mediaType); - } - - public void setMediaType(String mediaType) { - this.mediaType = mediaType; - } - - public String getContent() { - return java.util.Objects.requireNonNull(content); - } - - public void setContent(String content) { - this.content = java.util.Objects.requireNonNull(content); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleDocString that = (PickleDocString) o; - return - java.util.Objects.equals(mediaType, that.mediaType) && - content.equals(that.content); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - mediaType, - content - ); - } - - @Override - public String toString() { - return "PickleDocString{" + - "mediaType=" + mediaType + - ", content=" + content + - '}'; - } - } - - - public static class PickleStep { - private PickleStepArgument argument; - private java.util.List astNodeIds = new java.util.ArrayList<>(); - private String id; - private String text; - - public PickleStep() {} - - public PickleStep( - PickleStepArgument argument, - java.util.List astNodeIds, - String id, - String text - ) { - this.argument = argument; - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); - this.id = java.util.Objects.requireNonNull(id); - this.text = java.util.Objects.requireNonNull(text); - } - - public java.util.Optional getArgument() { - return java.util.Optional.ofNullable(argument); - } - - public void setArgument(PickleStepArgument argument) { - this.argument = argument; - } - - public java.util.List getAstNodeIds() { - return java.util.Objects.requireNonNull(astNodeIds); - } - - public void setAstNodeIds(java.util.List astNodeIds) { - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - public String getText() { - return java.util.Objects.requireNonNull(text); - } - - public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleStep that = (PickleStep) o; - return - java.util.Objects.equals(argument, that.argument) && - astNodeIds.equals(that.astNodeIds) && - id.equals(that.id) && - text.equals(that.text); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - argument, - astNodeIds, - id, - text - ); - } - - @Override - public String toString() { - return "PickleStep{" + - "argument=" + argument + - ", astNodeIds=" + astNodeIds + - ", id=" + id + - ", text=" + text + - '}'; - } - } - - - public static class PickleStepArgument { - private PickleDocString docString; - private PickleTable dataTable; - - public PickleStepArgument() {} - - public PickleStepArgument( - PickleDocString docString, - PickleTable dataTable - ) { - this.docString = docString; - this.dataTable = dataTable; - } - - public java.util.Optional getDocString() { - return java.util.Optional.ofNullable(docString); - } - - public void setDocString(PickleDocString docString) { - this.docString = docString; - } - - public java.util.Optional getDataTable() { - return java.util.Optional.ofNullable(dataTable); - } - - public void setDataTable(PickleTable dataTable) { - this.dataTable = dataTable; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleStepArgument that = (PickleStepArgument) o; - return - java.util.Objects.equals(docString, that.docString) && - java.util.Objects.equals(dataTable, that.dataTable); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - docString, - dataTable - ); - } - - @Override - public String toString() { - return "PickleStepArgument{" + - "docString=" + docString + - ", dataTable=" + dataTable + - '}'; - } - } - - - public static class PickleTable { - private java.util.List rows = new java.util.ArrayList<>(); - - public PickleTable() {} - - public PickleTable( - java.util.List rows - ) { - this.rows = java.util.Objects.requireNonNull(rows); - } - - public java.util.List getRows() { - return java.util.Objects.requireNonNull(rows); - } - - public void setRows(java.util.List rows) { - this.rows = java.util.Objects.requireNonNull(rows); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTable that = (PickleTable) o; - return - rows.equals(that.rows); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - rows - ); - } - - @Override - public String toString() { - return "PickleTable{" + - "rows=" + rows + - '}'; - } - } - - - public static class PickleTableCell { - private String value; - - public PickleTableCell() {} - - public PickleTableCell( - String value - ) { - this.value = java.util.Objects.requireNonNull(value); - } - - public String getValue() { - return java.util.Objects.requireNonNull(value); - } - - public void setValue(String value) { - this.value = java.util.Objects.requireNonNull(value); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTableCell that = (PickleTableCell) o; - return - value.equals(that.value); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - value - ); - } - - @Override - public String toString() { - return "PickleTableCell{" + - "value=" + value + - '}'; - } - } - - - public static class PickleTableRow { - private java.util.List cells = new java.util.ArrayList<>(); - - public PickleTableRow() {} - - public PickleTableRow( - java.util.List cells - ) { - this.cells = java.util.Objects.requireNonNull(cells); - } - - public java.util.List getCells() { - return java.util.Objects.requireNonNull(cells); - } - - public void setCells(java.util.List cells) { - this.cells = java.util.Objects.requireNonNull(cells); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTableRow that = (PickleTableRow) o; - return - cells.equals(that.cells); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - cells - ); - } - - @Override - public String toString() { - return "PickleTableRow{" + - "cells=" + cells + - '}'; - } - } - - - public static class PickleTag { - private String name; - private String astNodeId; - - public PickleTag() {} - - public PickleTag( - String name, - String astNodeId - ) { - this.name = java.util.Objects.requireNonNull(name); - this.astNodeId = java.util.Objects.requireNonNull(astNodeId); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - public String getAstNodeId() { - return java.util.Objects.requireNonNull(astNodeId); - } - - public void setAstNodeId(String astNodeId) { - this.astNodeId = java.util.Objects.requireNonNull(astNodeId); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTag that = (PickleTag) o; - return - name.equals(that.name) && - astNodeId.equals(that.astNodeId); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - name, - astNodeId - ); - } - - @Override - public String toString() { - return "PickleTag{" + - "name=" + name + - ", astNodeId=" + astNodeId + - '}'; - } - } - - - public static class Source { - private String uri; - private String data; - private SourceMediaType mediaType; - - public Source() {} - - public Source( - String uri, - String data, - SourceMediaType mediaType - ) { - this.uri = java.util.Objects.requireNonNull(uri); - this.data = java.util.Objects.requireNonNull(data); - this.mediaType = java.util.Objects.requireNonNull(mediaType); - } - - public String getUri() { - return java.util.Objects.requireNonNull(uri); - } - - public void setUri(String uri) { - this.uri = java.util.Objects.requireNonNull(uri); - } - - public String getData() { - return java.util.Objects.requireNonNull(data); - } - - public void setData(String data) { - this.data = java.util.Objects.requireNonNull(data); - } - - public SourceMediaType getMediaType() { - return java.util.Objects.requireNonNull(mediaType); - } - - public void setMediaType(SourceMediaType mediaType) { - this.mediaType = java.util.Objects.requireNonNull(mediaType); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Source that = (Source) o; - return - uri.equals(that.uri) && - data.equals(that.data) && - mediaType.equals(that.mediaType); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - uri, - data, - mediaType - ); - } - - @Override - public String toString() { - return "Source{" + - "uri=" + uri + - ", data=" + data + - ", mediaType=" + mediaType + - '}'; - } - } - - - public static class SourceReference { - private String uri; - private JavaMethod javaMethod; - private JavaStackTraceElement javaStackTraceElement; - private Location location; - - public SourceReference() {} - - public SourceReference( - String uri, - JavaMethod javaMethod, - JavaStackTraceElement javaStackTraceElement, - Location location - ) { - this.uri = uri; - this.javaMethod = javaMethod; - this.javaStackTraceElement = javaStackTraceElement; - this.location = location; - } - - public java.util.Optional getUri() { - return java.util.Optional.ofNullable(uri); - } - - public void setUri(String uri) { - this.uri = uri; - } - - public java.util.Optional getJavaMethod() { - return java.util.Optional.ofNullable(javaMethod); - } - - public void setJavaMethod(JavaMethod javaMethod) { - this.javaMethod = javaMethod; - } - - public java.util.Optional getJavaStackTraceElement() { - return java.util.Optional.ofNullable(javaStackTraceElement); - } - - public void setJavaStackTraceElement(JavaStackTraceElement javaStackTraceElement) { - this.javaStackTraceElement = javaStackTraceElement; - } - - public java.util.Optional getLocation() { - return java.util.Optional.ofNullable(location); - } - - public void setLocation(Location location) { - this.location = location; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SourceReference that = (SourceReference) o; - return - java.util.Objects.equals(uri, that.uri) && - java.util.Objects.equals(javaMethod, that.javaMethod) && - java.util.Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && - java.util.Objects.equals(location, that.location); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - uri, - javaMethod, - javaStackTraceElement, - location - ); - } - - @Override - public String toString() { - return "SourceReference{" + - "uri=" + uri + - ", javaMethod=" + javaMethod + - ", javaStackTraceElement=" + javaStackTraceElement + - ", location=" + location + - '}'; - } - } - - - public static class JavaMethod { - private String className; - private String methodName; - private java.util.List methodParameterTypes = new java.util.ArrayList<>(); - - public JavaMethod() {} - - public JavaMethod( - String className, - String methodName, - java.util.List methodParameterTypes - ) { - this.className = java.util.Objects.requireNonNull(className); - this.methodName = java.util.Objects.requireNonNull(methodName); - this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); - } - - public String getClassName() { - return java.util.Objects.requireNonNull(className); - } - - public void setClassName(String className) { - this.className = java.util.Objects.requireNonNull(className); - } - - public String getMethodName() { - return java.util.Objects.requireNonNull(methodName); - } - - public void setMethodName(String methodName) { - this.methodName = java.util.Objects.requireNonNull(methodName); - } - - public java.util.List getMethodParameterTypes() { - return java.util.Objects.requireNonNull(methodParameterTypes); - } - - public void setMethodParameterTypes(java.util.List methodParameterTypes) { - this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - JavaMethod that = (JavaMethod) o; - return - className.equals(that.className) && - methodName.equals(that.methodName) && - methodParameterTypes.equals(that.methodParameterTypes); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - className, - methodName, - methodParameterTypes - ); - } - - @Override - public String toString() { - return "JavaMethod{" + - "className=" + className + - ", methodName=" + methodName + - ", methodParameterTypes=" + methodParameterTypes + - '}'; - } - } - - - public static class JavaStackTraceElement { - private String className; - private String fileName; - private String methodName; - - public JavaStackTraceElement() {} - - public JavaStackTraceElement( - String className, - String fileName, - String methodName - ) { - this.className = java.util.Objects.requireNonNull(className); - this.fileName = java.util.Objects.requireNonNull(fileName); - this.methodName = java.util.Objects.requireNonNull(methodName); - } - - public String getClassName() { - return java.util.Objects.requireNonNull(className); - } - - public void setClassName(String className) { - this.className = java.util.Objects.requireNonNull(className); - } - - public String getFileName() { - return java.util.Objects.requireNonNull(fileName); - } - - public void setFileName(String fileName) { - this.fileName = java.util.Objects.requireNonNull(fileName); - } - - public String getMethodName() { - return java.util.Objects.requireNonNull(methodName); - } - - public void setMethodName(String methodName) { - this.methodName = java.util.Objects.requireNonNull(methodName); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - JavaStackTraceElement that = (JavaStackTraceElement) o; - return - className.equals(that.className) && - fileName.equals(that.fileName) && - methodName.equals(that.methodName); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - className, - fileName, - methodName - ); - } - - @Override - public String toString() { - return "JavaStackTraceElement{" + - "className=" + className + - ", fileName=" + fileName + - ", methodName=" + methodName + - '}'; - } - } - - - public static class StepDefinition { - private String id; - private StepDefinitionPattern pattern; - private SourceReference sourceReference; - - public StepDefinition() {} - - public StepDefinition( - String id, - StepDefinitionPattern pattern, - SourceReference sourceReference - ) { - this.id = java.util.Objects.requireNonNull(id); - this.pattern = java.util.Objects.requireNonNull(pattern); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - public StepDefinitionPattern getPattern() { - return java.util.Objects.requireNonNull(pattern); - } - - public void setPattern(StepDefinitionPattern pattern) { - this.pattern = java.util.Objects.requireNonNull(pattern); - } - - public SourceReference getSourceReference() { - return java.util.Objects.requireNonNull(sourceReference); - } - - public void setSourceReference(SourceReference sourceReference) { - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepDefinition that = (StepDefinition) o; - return - id.equals(that.id) && - pattern.equals(that.pattern) && - sourceReference.equals(that.sourceReference); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - id, - pattern, - sourceReference - ); - } - - @Override - public String toString() { - return "StepDefinition{" + - "id=" + id + - ", pattern=" + pattern + - ", sourceReference=" + sourceReference + - '}'; - } - } - - - public static class StepDefinitionPattern { - private String source; - private StepDefinitionPatternType type; - - public StepDefinitionPattern() {} - - public StepDefinitionPattern( - String source, - StepDefinitionPatternType type - ) { - this.source = java.util.Objects.requireNonNull(source); - this.type = java.util.Objects.requireNonNull(type); - } - - public String getSource() { - return java.util.Objects.requireNonNull(source); - } - - public void setSource(String source) { - this.source = java.util.Objects.requireNonNull(source); - } - - public StepDefinitionPatternType getType() { - return java.util.Objects.requireNonNull(type); - } - - public void setType(StepDefinitionPatternType type) { - this.type = java.util.Objects.requireNonNull(type); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepDefinitionPattern that = (StepDefinitionPattern) o; - return - source.equals(that.source) && - type.equals(that.type); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - source, - type - ); - } - - @Override - public String toString() { - return "StepDefinitionPattern{" + - "source=" + source + - ", type=" + type + - '}'; - } - } - - - public static class TestCase { - private String id; - private String pickleId; - private java.util.List testSteps = new java.util.ArrayList<>(); - - public TestCase() {} - - public TestCase( - String id, - String pickleId, - java.util.List testSteps - ) { - this.id = java.util.Objects.requireNonNull(id); - this.pickleId = java.util.Objects.requireNonNull(pickleId); - this.testSteps = java.util.Objects.requireNonNull(testSteps); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - public String getPickleId() { - return java.util.Objects.requireNonNull(pickleId); - } - - public void setPickleId(String pickleId) { - this.pickleId = java.util.Objects.requireNonNull(pickleId); - } - - public java.util.List getTestSteps() { - return java.util.Objects.requireNonNull(testSteps); - } - - public void setTestSteps(java.util.List testSteps) { - this.testSteps = java.util.Objects.requireNonNull(testSteps); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCase that = (TestCase) o; - return - id.equals(that.id) && - pickleId.equals(that.pickleId) && - testSteps.equals(that.testSteps); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - id, - pickleId, - testSteps - ); - } - - @Override - public String toString() { - return "TestCase{" + - "id=" + id + - ", pickleId=" + pickleId + - ", testSteps=" + testSteps + - '}'; - } - } - - - public static class Group { - private java.util.List children = new java.util.ArrayList<>(); - private Long start; - private String value; - - public Group() {} - - public Group( - java.util.List children, - Long start, - String value - ) { - this.children = java.util.Objects.requireNonNull(children); - this.start = start; - this.value = value; - } - - public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children); - } - - public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children); - } - - public java.util.Optional getStart() { - return java.util.Optional.ofNullable(start); - } - - public void setStart(Long start) { - this.start = start; - } - - public java.util.Optional getValue() { - return java.util.Optional.ofNullable(value); - } - - public void setValue(String value) { - this.value = value; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Group that = (Group) o; - return - children.equals(that.children) && - java.util.Objects.equals(start, that.start) && - java.util.Objects.equals(value, that.value); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - children, - start, - value - ); - } - - @Override - public String toString() { - return "Group{" + - "children=" + children + - ", start=" + start + - ", value=" + value + - '}'; - } - } - - - public static class StepMatchArgument { - private Group group; - private String parameterTypeName; - - public StepMatchArgument() {} - - public StepMatchArgument( - Group group, - String parameterTypeName - ) { - this.group = java.util.Objects.requireNonNull(group); - this.parameterTypeName = parameterTypeName; - } - - public Group getGroup() { - return java.util.Objects.requireNonNull(group); - } - - public void setGroup(Group group) { - this.group = java.util.Objects.requireNonNull(group); - } - - public java.util.Optional getParameterTypeName() { - return java.util.Optional.ofNullable(parameterTypeName); - } - - public void setParameterTypeName(String parameterTypeName) { - this.parameterTypeName = parameterTypeName; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepMatchArgument that = (StepMatchArgument) o; - return - group.equals(that.group) && - java.util.Objects.equals(parameterTypeName, that.parameterTypeName); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - group, - parameterTypeName - ); - } - - @Override - public String toString() { - return "StepMatchArgument{" + - "group=" + group + - ", parameterTypeName=" + parameterTypeName + - '}'; - } - } - - - public static class StepMatchArgumentsList { - private java.util.List stepMatchArguments = new java.util.ArrayList<>(); - - public StepMatchArgumentsList() {} - - public StepMatchArgumentsList( - java.util.List stepMatchArguments - ) { - this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); - } - - public java.util.List getStepMatchArguments() { - return java.util.Objects.requireNonNull(stepMatchArguments); - } - - public void setStepMatchArguments(java.util.List stepMatchArguments) { - this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepMatchArgumentsList that = (StepMatchArgumentsList) o; - return - stepMatchArguments.equals(that.stepMatchArguments); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - stepMatchArguments - ); - } - - @Override - public String toString() { - return "StepMatchArgumentsList{" + - "stepMatchArguments=" + stepMatchArguments + - '}'; - } - } - - - public static class TestStep { - private String hookId; - private String id; - private String pickleStepId; - private java.util.List stepDefinitionIds = new java.util.ArrayList<>(); - private java.util.List stepMatchArgumentsLists = new java.util.ArrayList<>(); - - public TestStep() {} - - public TestStep( - String hookId, - String id, - String pickleStepId, - java.util.List stepDefinitionIds, - java.util.List stepMatchArgumentsLists - ) { - this.hookId = hookId; - this.id = java.util.Objects.requireNonNull(id); - this.pickleStepId = pickleStepId; - this.stepDefinitionIds = stepDefinitionIds; - this.stepMatchArgumentsLists = stepMatchArgumentsLists; - } - - public java.util.Optional getHookId() { - return java.util.Optional.ofNullable(hookId); - } - - public void setHookId(String hookId) { - this.hookId = hookId; - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - public java.util.Optional getPickleStepId() { - return java.util.Optional.ofNullable(pickleStepId); - } - - public void setPickleStepId(String pickleStepId) { - this.pickleStepId = pickleStepId; - } - - public java.util.Optional> getStepDefinitionIds() { - return java.util.Optional.ofNullable(stepDefinitionIds); - } - - public void setStepDefinitionIds(java.util.List stepDefinitionIds) { - this.stepDefinitionIds = stepDefinitionIds; - } - - public java.util.Optional> getStepMatchArgumentsLists() { - return java.util.Optional.ofNullable(stepMatchArgumentsLists); - } - - public void setStepMatchArgumentsLists(java.util.List stepMatchArgumentsLists) { - this.stepMatchArgumentsLists = stepMatchArgumentsLists; - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStep that = (TestStep) o; - return - java.util.Objects.equals(hookId, that.hookId) && - id.equals(that.id) && - java.util.Objects.equals(pickleStepId, that.pickleStepId) && - java.util.Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && - java.util.Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - hookId, - id, - pickleStepId, - stepDefinitionIds, - stepMatchArgumentsLists - ); - } - - @Override - public String toString() { - return "TestStep{" + - "hookId=" + hookId + - ", id=" + id + - ", pickleStepId=" + pickleStepId + - ", stepDefinitionIds=" + stepDefinitionIds + - ", stepMatchArgumentsLists=" + stepMatchArgumentsLists + - '}'; - } - } - - - public static class TestCaseFinished { - private String testCaseStartedId; - private Timestamp timestamp; - private Boolean willBeRetried; - - public TestCaseFinished() {} - - public TestCaseFinished( - String testCaseStartedId, - Timestamp timestamp, - Boolean willBeRetried - ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - this.timestamp = java.util.Objects.requireNonNull(timestamp); - this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); - } - - public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId); - } - - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - } - - public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - public Boolean getWillBeRetried() { - return java.util.Objects.requireNonNull(willBeRetried); - } - - public void setWillBeRetried(Boolean willBeRetried) { - this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCaseFinished that = (TestCaseFinished) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - timestamp.equals(that.timestamp) && - willBeRetried.equals(that.willBeRetried); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - testCaseStartedId, - timestamp, - willBeRetried - ); - } - - @Override - public String toString() { - return "TestCaseFinished{" + - "testCaseStartedId=" + testCaseStartedId + - ", timestamp=" + timestamp + - ", willBeRetried=" + willBeRetried + - '}'; - } - } - - - public static class TestCaseStarted { - private Long attempt; - private String id; - private String testCaseId; - private Timestamp timestamp; - - public TestCaseStarted() {} - - public TestCaseStarted( - Long attempt, - String id, - String testCaseId, - Timestamp timestamp - ) { - this.attempt = java.util.Objects.requireNonNull(attempt); - this.id = java.util.Objects.requireNonNull(id); - this.testCaseId = java.util.Objects.requireNonNull(testCaseId); - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - public Long getAttempt() { - return java.util.Objects.requireNonNull(attempt); - } - - public void setAttempt(Long attempt) { - this.attempt = java.util.Objects.requireNonNull(attempt); - } - - public String getId() { - return java.util.Objects.requireNonNull(id); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); - } - - public String getTestCaseId() { - return java.util.Objects.requireNonNull(testCaseId); - } - - public void setTestCaseId(String testCaseId) { - this.testCaseId = java.util.Objects.requireNonNull(testCaseId); - } - - public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCaseStarted that = (TestCaseStarted) o; - return - attempt.equals(that.attempt) && - id.equals(that.id) && - testCaseId.equals(that.testCaseId) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - attempt, - id, - testCaseId, - timestamp - ); - } - - @Override - public String toString() { - return "TestCaseStarted{" + - "attempt=" + attempt + - ", id=" + id + - ", testCaseId=" + testCaseId + - ", timestamp=" + timestamp + - '}'; - } - } - - - public static class TestRunFinished { - private String message; - private Boolean success; - private Timestamp timestamp; - - public TestRunFinished() {} - - public TestRunFinished( - String message, - Boolean success, - Timestamp timestamp - ) { - this.message = message; - this.success = java.util.Objects.requireNonNull(success); - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - public java.util.Optional getMessage() { - return java.util.Optional.ofNullable(message); - } - - public void setMessage(String message) { - this.message = message; - } - - public Boolean getSuccess() { - return java.util.Objects.requireNonNull(success); - } - - public void setSuccess(Boolean success) { - this.success = java.util.Objects.requireNonNull(success); - } - - public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestRunFinished that = (TestRunFinished) o; - return - java.util.Objects.equals(message, that.message) && - success.equals(that.success) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - message, - success, - timestamp - ); - } - - @Override - public String toString() { - return "TestRunFinished{" + - "message=" + message + - ", success=" + success + - ", timestamp=" + timestamp + - '}'; - } - } - - - public static class TestRunStarted { - private Timestamp timestamp; - - public TestRunStarted() {} - - public TestRunStarted( - Timestamp timestamp - ) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestRunStarted that = (TestRunStarted) o; - return - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - timestamp - ); - } - - @Override - public String toString() { - return "TestRunStarted{" + - "timestamp=" + timestamp + - '}'; - } - } - - - public static class TestStepFinished { - private String testCaseStartedId; - private String testStepId; - private TestStepResult testStepResult; - private Timestamp timestamp; - - public TestStepFinished() {} - - public TestStepFinished( - String testCaseStartedId, - String testStepId, - TestStepResult testStepResult, - Timestamp timestamp - ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - this.testStepId = java.util.Objects.requireNonNull(testStepId); - this.testStepResult = java.util.Objects.requireNonNull(testStepResult); - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId); - } - - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - } - - public String getTestStepId() { - return java.util.Objects.requireNonNull(testStepId); - } - - public void setTestStepId(String testStepId) { - this.testStepId = java.util.Objects.requireNonNull(testStepId); - } - - public TestStepResult getTestStepResult() { - return java.util.Objects.requireNonNull(testStepResult); - } - - public void setTestStepResult(TestStepResult testStepResult) { - this.testStepResult = java.util.Objects.requireNonNull(testStepResult); - } - - public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepFinished that = (TestStepFinished) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - testStepId.equals(that.testStepId) && - testStepResult.equals(that.testStepResult) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - testCaseStartedId, - testStepId, - testStepResult, - timestamp - ); - } - - @Override - public String toString() { - return "TestStepFinished{" + - "testCaseStartedId=" + testCaseStartedId + - ", testStepId=" + testStepId + - ", testStepResult=" + testStepResult + - ", timestamp=" + timestamp + - '}'; - } - } - - - public static class TestStepResult { - private Duration duration; - private String message; - private TestStepResultStatus status; - - public TestStepResult() {} - - public TestStepResult( - Duration duration, - String message, - TestStepResultStatus status - ) { - this.duration = java.util.Objects.requireNonNull(duration); - this.message = message; - this.status = java.util.Objects.requireNonNull(status); - } - - public Duration getDuration() { - return java.util.Objects.requireNonNull(duration); - } - - public void setDuration(Duration duration) { - this.duration = java.util.Objects.requireNonNull(duration); - } - - public java.util.Optional getMessage() { - return java.util.Optional.ofNullable(message); - } - - public void setMessage(String message) { - this.message = message; - } - - public TestStepResultStatus getStatus() { - return java.util.Objects.requireNonNull(status); - } - - public void setStatus(TestStepResultStatus status) { - this.status = java.util.Objects.requireNonNull(status); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepResult that = (TestStepResult) o; - return - duration.equals(that.duration) && - java.util.Objects.equals(message, that.message) && - status.equals(that.status); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - duration, - message, - status - ); - } - - @Override - public String toString() { - return "TestStepResult{" + - "duration=" + duration + - ", message=" + message + - ", status=" + status + - '}'; - } - } - - - public static class TestStepStarted { - private String testCaseStartedId; - private String testStepId; - private Timestamp timestamp; - - public TestStepStarted() {} - - public TestStepStarted( - String testCaseStartedId, - String testStepId, - Timestamp timestamp - ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - this.testStepId = java.util.Objects.requireNonNull(testStepId); - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId); - } - - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - } - - public String getTestStepId() { - return java.util.Objects.requireNonNull(testStepId); - } - - public void setTestStepId(String testStepId) { - this.testStepId = java.util.Objects.requireNonNull(testStepId); - } - - public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepStarted that = (TestStepStarted) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - testStepId.equals(that.testStepId) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - testCaseStartedId, - testStepId, - timestamp - ); - } - - @Override - public String toString() { - return "TestStepStarted{" + - "testCaseStartedId=" + testCaseStartedId + - ", testStepId=" + testStepId + - ", timestamp=" + timestamp + - '}'; - } - } - - - public static class Timestamp { - private Long seconds; - private Long nanos; - - public Timestamp() {} - - public Timestamp( - Long seconds, - Long nanos - ) { - this.seconds = java.util.Objects.requireNonNull(seconds); - this.nanos = java.util.Objects.requireNonNull(nanos); - } - - public Long getSeconds() { - return java.util.Objects.requireNonNull(seconds); - } - - public void setSeconds(Long seconds) { - this.seconds = java.util.Objects.requireNonNull(seconds); - } - - public Long getNanos() { - return java.util.Objects.requireNonNull(nanos); - } - - public void setNanos(Long nanos) { - this.nanos = java.util.Objects.requireNonNull(nanos); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Timestamp that = (Timestamp) o; - return - seconds.equals(that.seconds) && - nanos.equals(that.nanos); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - seconds, - nanos - ); - } - - @Override - public String toString() { - return "Timestamp{" + - "seconds=" + seconds + - ", nanos=" + nanos + - '}'; - } - } - - - public static class UndefinedParameterType { - private String expression; - private String name; - - public UndefinedParameterType() {} - - public UndefinedParameterType( - String expression, - String name - ) { - this.expression = java.util.Objects.requireNonNull(expression); - this.name = java.util.Objects.requireNonNull(name); - } - - public String getExpression() { - return java.util.Objects.requireNonNull(expression); - } - - public void setExpression(String expression) { - this.expression = java.util.Objects.requireNonNull(expression); - } - - public String getName() { - return java.util.Objects.requireNonNull(name); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); - } - - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - UndefinedParameterType that = (UndefinedParameterType) o; - return - expression.equals(that.expression) && - name.equals(that.name); - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - expression, - name - ); - } - - @Override - public String toString() { - return "UndefinedParameterType{" + - "expression=" + expression + - ", name=" + name + - '}'; - } - } - - public enum AttachmentContentEncoding { - IDENTITY("IDENTITY"), - BASE64("BASE64"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (AttachmentContentEncoding c: values()) { - CONSTANTS.put(c.value, c); - } - } - - AttachmentContentEncoding(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static AttachmentContentEncoding fromValue(String value) { - AttachmentContentEncoding constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } - } - - public enum SourceMediaType { - TEXT_X_CUCUMBER_GHERKIN_PLAIN("text/x.cucumber.gherkin+plain"), - TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (SourceMediaType c: values()) { - CONSTANTS.put(c.value, c); - } - } - - SourceMediaType(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static SourceMediaType fromValue(String value) { - SourceMediaType constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } - } - - public enum StepDefinitionPatternType { - CUCUMBER_EXPRESSION("CUCUMBER_EXPRESSION"), - REGULAR_EXPRESSION("REGULAR_EXPRESSION"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (StepDefinitionPatternType c: values()) { - CONSTANTS.put(c.value, c); - } - } - - StepDefinitionPatternType(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static StepDefinitionPatternType fromValue(String value) { - StepDefinitionPatternType constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } - } - - public enum TestStepResultStatus { - UNKNOWN("UNKNOWN"), - PASSED("PASSED"), - SKIPPED("SKIPPED"), - PENDING("PENDING"), - UNDEFINED("UNDEFINED"), - AMBIGUOUS("AMBIGUOUS"), - FAILED("FAILED"); - - private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (TestStepResultStatus c: values()) { - CONSTANTS.put(c.value, c); - } - } - - TestStepResultStatus(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static TestStepResultStatus fromValue(String value) { - TestStepResultStatus constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } - } - -} diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 1a1175f315..ef3fb36b24 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import io.cucumber.messages.types.Envelope; import java.io.BufferedReader; import java.io.IOException; @@ -11,8 +12,6 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; -import static io.cucumber.messages.Messages.*; - /** * Iterates over messages read from a stream. Client code should not depend on this class * directly, but rather on a {@code Iterable} object. diff --git a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java index a394a8ff15..89a522f25e 100644 --- a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java +++ b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java @@ -1,6 +1,7 @@ package io.cucumber.messages; -import static io.cucumber.messages.Messages.*; +import io.cucumber.messages.types.Duration; +import io.cucumber.messages.types.Timestamp; public final class TimeConversion { diff --git a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java index 334641ae2b..e8d97f2735 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java @@ -1,5 +1,11 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Attachment; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Location; +import io.cucumber.messages.types.Source; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -7,11 +13,9 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import static io.cucumber.messages.Messages.*; import static java.util.Collections.emptyList; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -22,14 +26,14 @@ void can_serialise_messages_over_a_stream() throws IOException { List outgoingMessages = new ArrayList<>(); { Envelope envelope = new Envelope(); - envelope.setSource(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + envelope.setSource(new Source("hello.feature", "Feature: Hello", Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); outgoingMessages.add(envelope); } { Envelope envelope = new Envelope(); Attachment attachment = new Attachment(); attachment.setBody("the body"); - attachment.setContentEncoding(AttachmentContentEncoding.IDENTITY); + attachment.setContentEncoding(Attachment.ContentEncoding.IDENTITY); attachment.setMediaType("text/plain"); envelope.setAttachment(attachment); outgoingMessages.add(envelope); diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index c982f5f4bd..87cbca0242 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -1,5 +1,8 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Attachment; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Source; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -11,7 +14,6 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; -import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -25,7 +27,7 @@ protected MessageWriter makeMessageWriter(OutputStream output) { } @Override - protected Iterable makeMessageIterable(InputStream input) { + protected Iterable makeMessageIterable(InputStream input) { return new NdjsonToMessageIterable(input); } @@ -33,7 +35,7 @@ protected Iterable makeMessageIterable(InputStream input) { void writes_source_envelope() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); MessageWriter writer = makeMessageWriter(output); - writer.write(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + writer.write(new Source("uri", "data", Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); String json = new String(output.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}\n", json); } @@ -78,7 +80,7 @@ void handles_enums() { Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); - assertEquals(AttachmentContentEncoding.BASE64, envelope.getAttachment().get().getContentEncoding()); + assertEquals(Attachment.ContentEncoding.BASE_64, envelope.getAttachment().get().getContentEncoding()); assertFalse(iterator.hasNext()); } diff --git a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java index b62c38af95..23e4a850d9 100644 --- a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java @@ -1,8 +1,9 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Duration; +import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; -import static io.cucumber.messages.Messages.*; import static io.cucumber.messages.TimeConversion.durationToJavaDuration; import static io.cucumber.messages.TimeConversion.javaDurationToDuration; import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp; From efe26b46690840ec2bdfe9dbdfdeab5dd65a0f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 18:49:52 +0000 Subject: [PATCH 08/63] Remove Java code generator. Update imports. --- .../java/io/cucumber/gherkin/Gherkin.java | 12 ++- .../gherkin/GherkinDocumentBuilder.java | 23 ++++-- .../main/java/io/cucumber/gherkin/Main.java | 2 +- .../gherkin/pickles/PickleCompiler.java | 42 +++++----- .../gherkin/GherkinDocumentBuilderTest.java | 6 +- .../java/io/cucumber/gherkin/GherkinTest.java | 7 +- .../java/io/cucumber/gherkin/ParserTest.java | 2 +- .../java/io/cucumber/htmlformatter/Main.java | 2 +- .../htmlformatter/MessagesToHtmlWriter.java | 2 +- .../MessagesToHtmlWriterTest.java | 4 +- .../scripts/templates/java.enum.java.erb | 39 ---------- .../scripts/templates/java.java.erb | 78 ------------------- 12 files changed, 65 insertions(+), 154 deletions(-) delete mode 100644 messages/jsonschema/scripts/templates/java.enum.java.erb delete mode 100644 messages/jsonschema/scripts/templates/java.java.erb diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index 8ce65b5b4e..29d4b4b27b 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -2,6 +2,12 @@ import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.ParseError; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.SourceReference; import java.io.FileInputStream; import java.io.IOException; @@ -14,8 +20,6 @@ import java.util.function.Function; import java.util.stream.Stream; -import static io.cucumber.messages.Messages.*; - /** * Main entry point for the Gherkin library */ @@ -46,7 +50,7 @@ public static Stream fromSources(List envelopes, boolean inc public static Envelope makeSourceEnvelope(String data, String uri) { Envelope envelope = new Envelope(); - envelope.setSource(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + envelope.setSource(new Source(uri, data, Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); return envelope; } @@ -138,7 +142,7 @@ private void addParseError(List messages, ParserException e, String ur null, null, // We want 0 values not to be serialised, which is why we set them to null // This is a legacy requirement brought over from old protobuf behaviour - new io.cucumber.messages.Messages.Location( + new io.cucumber.messages.types.Location( line, column == 0 ? null : column ) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index 4ea2aee790..c92877681f 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -1,6 +1,21 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.types.Background; +import io.cucumber.messages.types.Comment; +import io.cucumber.messages.types.DataTable; +import io.cucumber.messages.types.DocString; +import io.cucumber.messages.types.Examples; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.FeatureChild; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Rule; +import io.cucumber.messages.types.RuleChild; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.Step; +import io.cucumber.messages.types.TableCell; +import io.cucumber.messages.types.TableRow; +import io.cucumber.messages.types.Tag; import java.util.ArrayDeque; import java.util.ArrayList; @@ -9,12 +24,10 @@ import java.util.List; import java.util.stream.Collectors; -import static io.cucumber.messages.Messages.*; -import static io.cucumber.gherkin.Parser.Builder; import static io.cucumber.gherkin.Parser.RuleType; import static io.cucumber.gherkin.Parser.TokenType; -public class GherkinDocumentBuilder implements Builder { +public class GherkinDocumentBuilder implements Parser.Builder { private final IdGenerator idGenerator; private Deque stack; @@ -273,9 +286,9 @@ private List getSteps(AstNode node) { return node.getItems(RuleType.Step); } - private io.cucumber.messages.Messages.Location getLocation(Token token, int column) { + private io.cucumber.messages.types.Location getLocation(Token token, int column) { column = column == 0 ? token.location.getColumn() : column; - return new io.cucumber.messages.Messages.Location((long) token.location.getLine(), (long) column); + return new io.cucumber.messages.types.Location((long) token.location.getLine(), (long) column); } private String getDescription(AstNode node) { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java index e60e41a3fe..5a61b26b61 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java @@ -3,13 +3,13 @@ import io.cucumber.messages.IdGenerator; import io.cucumber.messages.MessageToNdjsonWriter; import io.cucumber.messages.MessageWriter; +import io.cucumber.messages.types.Envelope; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; -import static io.cucumber.messages.Messages.*; import static java.util.Arrays.asList; public class Main { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java index 02eaca1455..dff914d9ce 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java @@ -1,6 +1,27 @@ package io.cucumber.gherkin.pickles; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.types.DataTable; +import io.cucumber.messages.types.DocString; +import io.cucumber.messages.types.Examples; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.FeatureChild; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.PickleDocString; +import io.cucumber.messages.types.PickleStep; +import io.cucumber.messages.types.PickleStepArgument; +import io.cucumber.messages.types.PickleTable; +import io.cucumber.messages.types.PickleTableCell; +import io.cucumber.messages.types.PickleTableRow; +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.Step; +import io.cucumber.messages.types.TableCell; +import io.cucumber.messages.types.TableRow; +import io.cucumber.messages.types.Tag; import java.util.ArrayList; import java.util.Collection; @@ -9,27 +30,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static io.cucumber.messages.Messages.DataTable; -import static io.cucumber.messages.Messages.DocString; -import static io.cucumber.messages.Messages.Examples; -import static io.cucumber.messages.Messages.Feature; -import static io.cucumber.messages.Messages.FeatureChild; -import static io.cucumber.messages.Messages.GherkinDocument; -import static io.cucumber.messages.Messages.Pickle; -import static io.cucumber.messages.Messages.PickleDocString; -import static io.cucumber.messages.Messages.PickleStep; -import static io.cucumber.messages.Messages.PickleStepArgument; -import static io.cucumber.messages.Messages.PickleTable; -import static io.cucumber.messages.Messages.PickleTableCell; -import static io.cucumber.messages.Messages.PickleTableRow; -import static io.cucumber.messages.Messages.PickleTag; -import static io.cucumber.messages.Messages.Rule; -import static io.cucumber.messages.Messages.RuleChild; -import static io.cucumber.messages.Messages.Scenario; -import static io.cucumber.messages.Messages.Step; -import static io.cucumber.messages.Messages.TableCell; -import static io.cucumber.messages.Messages.TableRow; -import static io.cucumber.messages.Messages.Tag; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static java.util.Collections.unmodifiableList; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index 8751f14df6..823a32fe22 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -2,11 +2,15 @@ import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.types.Comment; +import io.cucumber.messages.types.FeatureChild; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.TableRow; import org.junit.Test; import java.util.List; -import static io.cucumber.messages.Messages.*; import static org.junit.Assert.assertEquals; public class GherkinDocumentBuilderTest { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java index 07528a3cf1..7f05426685 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java @@ -1,6 +1,12 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.PickleStep; +import io.cucumber.messages.types.Scenario; import org.junit.Test; import java.io.File; @@ -12,7 +18,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static io.cucumber.messages.Messages.*; import static io.cucumber.gherkin.Gherkin.makeSourceEnvelope; import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index b3d20996fa..0d9e92ed2f 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -1,7 +1,7 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import static io.cucumber.messages.Messages.*; +import io.cucumber.messages.types.GherkinDocument; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java index 167afbf18b..f81339d283 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java @@ -1,7 +1,7 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.NdjsonToMessageIterable; -import static io.cucumber.messages.Messages.*; +import io.cucumber.messages.types.Envelope; import java.io.OutputStreamWriter; diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index fca9b7278c..85c90c5ebe 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -1,6 +1,7 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.JSON; +import io.cucumber.messages.types.Envelope; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -11,7 +12,6 @@ import java.io.OutputStreamWriter; import java.io.Writer; -import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index b4d6abcfe3..6b3ed59da6 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -1,6 +1,9 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.TimeConversion; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.TestRunFinished; +import io.cucumber.messages.types.TestRunStarted; import org.junit.jupiter.api.Test; import java.io.BufferedWriter; @@ -9,7 +12,6 @@ import java.io.OutputStreamWriter; import java.time.Instant; -import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb deleted file mode 100644 index 785fd6a492..0000000000 --- a/messages/jsonschema/scripts/templates/java.enum.java.erb +++ /dev/null @@ -1,39 +0,0 @@ -<% @enums.each do |enum| -%> - public enum <%= enum[:name] %> { - <% enum[:values].each_with_index do |value, index| -%> - <%= enum_constant(value) %>("<%= value %>")<%= index < enum[:values].length-1 ? ',' : ';' %> - <% end -%> - - private final String value; - private final static java.util.Map> CONSTANTS = new java.util.HashMap<>(); - - static { - for (<%= enum[:name] %> c: values()) { - CONSTANTS.put(c.value, c); - } - } - - <%= enum[:name] %>(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static <%= enum[:name] %> fromValue(String value) { - <%= enum[:name] %> constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } - } - } - -<% end -%> diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb deleted file mode 100644 index f2bc0f6b52..0000000000 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ /dev/null @@ -1,78 +0,0 @@ -<% @schemas.each do |key, schema| %> - public static class <%= class_name(key) %> { - <%- schema['properties'].each do |property_name, property| -%> - private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= property['items'] ? ' = new java.util.ArrayList<>()' : '' %>; - <%- end -%> - - public <%= class_name(key) %>() {} - - public <%= class_name(key) %>( - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> - <%- end -%> - ) { - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - <%- if (schema['required'] || []).index(property_name) -%> - this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); - <%- else -%> - this.<%= property_name %> = <%= property_name %>; - <%- end -%> - <%- end -%> - } - - <%- schema['properties'].each do |property_name, property| -%> - <%- if (schema['required'] || []).index(property_name) -%> - public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { - return java.util.Objects.requireNonNull(<%= property_name %>); - } - - public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); - } - <%- else -%> - public java.util.Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { - return java.util.Optional.ofNullable(<%= property_name %>); - } - - public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - this.<%= property_name %> = <%= property_name %>; - } - <%- end -%> - - <%- end -%> - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - <%= class_name(key) %> that = (<%= class_name(key) %>) o; - return <%- schema['properties'].each_with_index do |(property_name, property), index| %> - <%- if (schema['required'] || []).index(property_name) -%> - <%= property_name -%>.equals(that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> - <%- else -%> - java.util.Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> - <%- end -%> - <% end -%> - - } - - @Override - public int hashCode() { - return java.util.Objects.hash( - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> - <%- end -%> - ); - } - - @Override - public String toString() { - return "<%= class_name(key) %>{" + - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - "<%= index == 0 ? '' : ', '%><%= property_name %>=" + <%= property_name %> + - <%- end -%> - '}'; - } - } - -<% end -%> From ce700eb4b982543412b257ad1cfc1832b8c64c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 19:04:47 +0000 Subject: [PATCH 09/63] Fix serialization --- messages/java/src/main/java/io/cucumber/messages/JSON.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/JSON.java b/messages/java/src/main/java/io/cucumber/messages/JSON.java index 8d1122fce6..0ecba30263 100644 --- a/messages/java/src/main/java/io/cucumber/messages/JSON.java +++ b/messages/java/src/main/java/io/cucumber/messages/JSON.java @@ -14,7 +14,7 @@ public final class JSON { private static final ObjectMapper mapper = new ObjectMapper() .registerModule(new Jdk8Module()) - .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) + .setSerializationInclusion(JsonInclude.Include.NON_NULL) .enable(WRITE_ENUMS_USING_TO_STRING) .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); From a718f2ffc65afd2ddf1bff44737cfbd7de0a998d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 19:07:30 +0000 Subject: [PATCH 10/63] Fix compilation error --- .../src/test/java/io/cucumber/gherkin/MessageVersionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java index b6eaf16e4b..63eecf708e 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -import static io.cucumber.messages.Messages.*; +import io.cucumber.messages.types.Envelope; import org.junit.Test; import static org.junit.Assert.assertNotNull; From 4a4963e765703d236c3c9a939d25d1a4e936ac52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 5 Jan 2022 19:09:00 +0000 Subject: [PATCH 11/63] Remove Java code generator --- messages/jsonschema/scripts/codegen.rb | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/messages/jsonschema/scripts/codegen.rb b/messages/jsonschema/scripts/codegen.rb index f1f903afe7..9703440112 100644 --- a/messages/jsonschema/scripts/codegen.rb +++ b/messages/jsonschema/scripts/codegen.rb @@ -149,22 +149,6 @@ def array_type_for(type_name) end end -class Java < Codegen - def initialize(paths) - language_type_by_schema_type = { - 'integer' => 'Long', - 'string' => 'String', - 'boolean' => 'Boolean', - } - - super(paths, language_type_by_schema_type) - end - - def array_type_for(type_name) - "java.util.List<#{type_name}>" - end -end - class Perl < Codegen def initialize(paths) language_type_by_schema_type = { From 2109b57cb7f7e96b0069e7d8ab67464eeffab457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 09:34:14 +0000 Subject: [PATCH 12/63] Switch back to NON_ABSENT --- messages/java/src/main/java/io/cucumber/messages/JSON.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/JSON.java b/messages/java/src/main/java/io/cucumber/messages/JSON.java index 0ecba30263..8d1122fce6 100644 --- a/messages/java/src/main/java/io/cucumber/messages/JSON.java +++ b/messages/java/src/main/java/io/cucumber/messages/JSON.java @@ -14,7 +14,7 @@ public final class JSON { private static final ObjectMapper mapper = new ObjectMapper() .registerModule(new Jdk8Module()) - .setSerializationInclusion(JsonInclude.Include.NON_NULL) + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) .enable(WRITE_ENUMS_USING_TO_STRING) .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); From 7327402c8be8b1a7987f00d9470e2454fb14dd7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 16:12:35 +0000 Subject: [PATCH 13/63] Improve optional code --- .../java/io/cucumber/gherkin/Gherkin.java | 72 +++++++++++-------- .../java/io/cucumber/gherkin/GherkinTest.java | 20 +++--- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index 29d4b4b27b..b8c53e95a7 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -20,6 +20,8 @@ import java.util.function.Function; import java.util.stream.Stream; +import static java.util.Collections.emptyList; + /** * Main entry point for the Gherkin library */ @@ -92,45 +94,55 @@ private Stream parserMessageStream(Envelope envelope, boolean includeS if (includeSource) { messages.add(envelope); } - if (envelope.getSource().isPresent()) { + messages.addAll(parseSource(envelope, includeGherkinDocument, includePickles)); + return messages.stream(); + } - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); - Source source = envelope.getSource().get(); - String uri = source.getUri(); - String data = source.getData(); + private List parseSource(Envelope envelope, boolean includeGherkinDocument, boolean includePickles) { + return envelope.getSource() + .map(source -> parseSource(includeGherkinDocument, includePickles, source)) + .orElse(emptyList()); + } + + private List parseSource(boolean includeGherkinDocument, boolean includePickles, Source source) { + List messages = new ArrayList<>(); - try { - GherkinDocument gherkinDocument = null; + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); + String uri = source.getUri(); + String data = source.getData(); - if (includeGherkinDocument) { + try { + GherkinDocument gherkinDocument = null; + + if (includeGherkinDocument) { + gherkinDocument = parser.parse(data); + gherkinDocument.setUri(uri); + Envelope gherkinDocumentEnvelope = new Envelope(); + gherkinDocumentEnvelope.setGherkinDocument(gherkinDocument); + messages.add(gherkinDocumentEnvelope); + } + if (includePickles) { + if (gherkinDocument == null) { gherkinDocument = parser.parse(data); gherkinDocument.setUri(uri); - Envelope gherkinDocumentEnvelope = new Envelope(); - gherkinDocumentEnvelope.setGherkinDocument(gherkinDocument); - messages.add(gherkinDocumentEnvelope); - } - if (includePickles) { - if (gherkinDocument == null) { - gherkinDocument = parser.parse(data); - gherkinDocument.setUri(uri); - } - PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); - List pickles = pickleCompiler.compile(gherkinDocument, uri); - for (Pickle pickle : pickles) { - Envelope pickleEnvelope = new Envelope(); - pickleEnvelope.setPickle(pickle); - messages.add(pickleEnvelope); - } } - } catch (ParserException.CompositeParserException e) { - for (ParserException error : e.errors) { - addParseError(messages, error, uri); + PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); + List pickles = pickleCompiler.compile(gherkinDocument, uri); + for (Pickle pickle : pickles) { + Envelope pickleEnvelope = new Envelope(); + pickleEnvelope.setPickle(pickle); + messages.add(pickleEnvelope); } - } catch (ParserException e) { - addParseError(messages, e, uri); } + } catch (ParserException.CompositeParserException e) { + for (ParserException error : e.errors) { + addParseError(messages, error, uri); + } + } catch (ParserException e) { + addParseError(messages, e, uri); } - return messages.stream(); + + return messages; } private void addParseError(List messages, ParserException e, String uri) { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java index 7f05426685..302f97e624 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java @@ -9,14 +9,8 @@ import io.cucumber.messages.types.Scenario; import org.junit.Test; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; import java.util.stream.Collectors; -import java.util.stream.Stream; import static io.cucumber.gherkin.Gherkin.makeSourceEnvelope; import static java.util.Collections.singletonList; @@ -31,10 +25,12 @@ public void use_this_in_readme() { boolean includeSource = false; boolean includeAst = true; boolean includePickles = true; - Stream envelopeStream = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator); - Stream pickleStream = envelopeStream.filter(envelope -> envelope.getPickle().isPresent()); - - assertEquals("minimalistic", pickleStream.collect(Collectors.toList()).get(0).getPickle().get().getName()); + String name = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator) + .filter(envelope -> envelope.getPickle().isPresent()) + .findFirst().get() + .getPickle().get() + .getName(); + assertEquals("minimalistic", name); } @@ -61,8 +57,8 @@ public void provides_access_to_the_ast() { @Test public void provides_access_to_pickles_which_are_compiled_from_the_ast() { List envelopes = Gherkin.fromPaths(singletonList("testdata/good/scenario_outline.feature") - , false, false, true, idGenerator) - .collect(Collectors.toList()); + , false, false, true, idGenerator) + .collect(Collectors.toList()); // Get the first pickle Pickle pickle = envelopes.get(0).getPickle().get(); From e6ea1f899f53b08dbcb2eb138f02270ad24f233d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 16:13:20 +0000 Subject: [PATCH 14/63] Revert "Remove Java code generator" This reverts commit 4a4963e765703d236c3c9a939d25d1a4e936ac52. --- messages/jsonschema/scripts/codegen.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/messages/jsonschema/scripts/codegen.rb b/messages/jsonschema/scripts/codegen.rb index 9703440112..f1f903afe7 100644 --- a/messages/jsonschema/scripts/codegen.rb +++ b/messages/jsonschema/scripts/codegen.rb @@ -149,6 +149,22 @@ def array_type_for(type_name) end end +class Java < Codegen + def initialize(paths) + language_type_by_schema_type = { + 'integer' => 'Long', + 'string' => 'String', + 'boolean' => 'Boolean', + } + + super(paths, language_type_by_schema_type) + end + + def array_type_for(type_name) + "java.util.List<#{type_name}>" + end +end + class Perl < Codegen def initialize(paths) language_type_by_schema_type = { From 489da010c9bf1bb3f9e88334ed15b5317d3ca396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 16:19:30 +0000 Subject: [PATCH 15/63] Revert "Remove Java code generator. Update imports." This reverts commit efe26b46690840ec2bdfe9dbdfdeab5dd65a0f0f. --- .../java/io/cucumber/gherkin/Gherkin.java | 11 +-- .../gherkin/GherkinDocumentBuilder.java | 23 ++---- .../main/java/io/cucumber/gherkin/Main.java | 2 +- .../gherkin/pickles/PickleCompiler.java | 42 +++++----- .../gherkin/GherkinDocumentBuilderTest.java | 6 +- .../java/io/cucumber/gherkin/GherkinTest.java | 7 +- .../java/io/cucumber/gherkin/ParserTest.java | 2 +- .../java/io/cucumber/htmlformatter/Main.java | 2 +- .../htmlformatter/MessagesToHtmlWriter.java | 2 +- .../MessagesToHtmlWriterTest.java | 4 +- .../scripts/templates/java.enum.java.erb | 39 ++++++++++ .../scripts/templates/java.java.erb | 78 +++++++++++++++++++ 12 files changed, 153 insertions(+), 65 deletions(-) create mode 100644 messages/jsonschema/scripts/templates/java.enum.java.erb create mode 100644 messages/jsonschema/scripts/templates/java.java.erb diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index b8c53e95a7..fbd0f28722 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -2,12 +2,6 @@ import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.ParseError; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.Source; -import io.cucumber.messages.types.SourceReference; import java.io.FileInputStream; import java.io.IOException; @@ -21,6 +15,7 @@ import java.util.stream.Stream; import static java.util.Collections.emptyList; +import static io.cucumber.messages.Messages.*; /** * Main entry point for the Gherkin library @@ -52,7 +47,7 @@ public static Stream fromSources(List envelopes, boolean inc public static Envelope makeSourceEnvelope(String data, String uri) { Envelope envelope = new Envelope(); - envelope.setSource(new Source(uri, data, Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + envelope.setSource(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); return envelope; } @@ -154,7 +149,7 @@ private void addParseError(List messages, ParserException e, String ur null, null, // We want 0 values not to be serialised, which is why we set them to null // This is a legacy requirement brought over from old protobuf behaviour - new io.cucumber.messages.types.Location( + new io.cucumber.messages.Messages.Location( line, column == 0 ? null : column ) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index c92877681f..4ea2aee790 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -1,21 +1,6 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Background; -import io.cucumber.messages.types.Comment; -import io.cucumber.messages.types.DataTable; -import io.cucumber.messages.types.DocString; -import io.cucumber.messages.types.Examples; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.FeatureChild; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Rule; -import io.cucumber.messages.types.RuleChild; -import io.cucumber.messages.types.Scenario; -import io.cucumber.messages.types.Step; -import io.cucumber.messages.types.TableCell; -import io.cucumber.messages.types.TableRow; -import io.cucumber.messages.types.Tag; import java.util.ArrayDeque; import java.util.ArrayList; @@ -24,10 +9,12 @@ import java.util.List; import java.util.stream.Collectors; +import static io.cucumber.messages.Messages.*; +import static io.cucumber.gherkin.Parser.Builder; import static io.cucumber.gherkin.Parser.RuleType; import static io.cucumber.gherkin.Parser.TokenType; -public class GherkinDocumentBuilder implements Parser.Builder { +public class GherkinDocumentBuilder implements Builder { private final IdGenerator idGenerator; private Deque stack; @@ -286,9 +273,9 @@ private List getSteps(AstNode node) { return node.getItems(RuleType.Step); } - private io.cucumber.messages.types.Location getLocation(Token token, int column) { + private io.cucumber.messages.Messages.Location getLocation(Token token, int column) { column = column == 0 ? token.location.getColumn() : column; - return new io.cucumber.messages.types.Location((long) token.location.getLine(), (long) column); + return new io.cucumber.messages.Messages.Location((long) token.location.getLine(), (long) column); } private String getDescription(AstNode node) { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java index 5a61b26b61..e60e41a3fe 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java @@ -3,13 +3,13 @@ import io.cucumber.messages.IdGenerator; import io.cucumber.messages.MessageToNdjsonWriter; import io.cucumber.messages.MessageWriter; -import io.cucumber.messages.types.Envelope; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; +import static io.cucumber.messages.Messages.*; import static java.util.Arrays.asList; public class Main { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java index dff914d9ce..02eaca1455 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java @@ -1,27 +1,6 @@ package io.cucumber.gherkin.pickles; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.DataTable; -import io.cucumber.messages.types.DocString; -import io.cucumber.messages.types.Examples; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.FeatureChild; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.PickleDocString; -import io.cucumber.messages.types.PickleStep; -import io.cucumber.messages.types.PickleStepArgument; -import io.cucumber.messages.types.PickleTable; -import io.cucumber.messages.types.PickleTableCell; -import io.cucumber.messages.types.PickleTableRow; -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.Step; -import io.cucumber.messages.types.TableCell; -import io.cucumber.messages.types.TableRow; -import io.cucumber.messages.types.Tag; import java.util.ArrayList; import java.util.Collection; @@ -30,6 +9,27 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import static io.cucumber.messages.Messages.DataTable; +import static io.cucumber.messages.Messages.DocString; +import static io.cucumber.messages.Messages.Examples; +import static io.cucumber.messages.Messages.Feature; +import static io.cucumber.messages.Messages.FeatureChild; +import static io.cucumber.messages.Messages.GherkinDocument; +import static io.cucumber.messages.Messages.Pickle; +import static io.cucumber.messages.Messages.PickleDocString; +import static io.cucumber.messages.Messages.PickleStep; +import static io.cucumber.messages.Messages.PickleStepArgument; +import static io.cucumber.messages.Messages.PickleTable; +import static io.cucumber.messages.Messages.PickleTableCell; +import static io.cucumber.messages.Messages.PickleTableRow; +import static io.cucumber.messages.Messages.PickleTag; +import static io.cucumber.messages.Messages.Rule; +import static io.cucumber.messages.Messages.RuleChild; +import static io.cucumber.messages.Messages.Scenario; +import static io.cucumber.messages.Messages.Step; +import static io.cucumber.messages.Messages.TableCell; +import static io.cucumber.messages.Messages.TableRow; +import static io.cucumber.messages.Messages.Tag; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static java.util.Collections.unmodifiableList; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index 823a32fe22..8751f14df6 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -2,15 +2,11 @@ import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Comment; -import io.cucumber.messages.types.FeatureChild; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.TableRow; import org.junit.Test; import java.util.List; +import static io.cucumber.messages.Messages.*; import static org.junit.Assert.assertEquals; public class GherkinDocumentBuilderTest { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java index 302f97e624..fde2a60bb2 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java @@ -1,17 +1,12 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Pickle; -import io.cucumber.messages.types.PickleStep; -import io.cucumber.messages.types.Scenario; import org.junit.Test; import java.util.List; import java.util.stream.Collectors; +import static io.cucumber.messages.Messages.*; import static io.cucumber.gherkin.Gherkin.makeSourceEnvelope; import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index 0d9e92ed2f..b3d20996fa 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -1,7 +1,7 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.types.GherkinDocument; +import static io.cucumber.messages.Messages.*; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java index f81339d283..167afbf18b 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java @@ -1,7 +1,7 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.NdjsonToMessageIterable; -import io.cucumber.messages.types.Envelope; +import static io.cucumber.messages.Messages.*; import java.io.OutputStreamWriter; diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index 85c90c5ebe..fca9b7278c 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -1,7 +1,6 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.JSON; -import io.cucumber.messages.types.Envelope; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -12,6 +11,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; +import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 6b3ed59da6..b4d6abcfe3 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -1,9 +1,6 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.TimeConversion; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.TestRunFinished; -import io.cucumber.messages.types.TestRunStarted; import org.junit.jupiter.api.Test; import java.io.BufferedWriter; @@ -12,6 +9,7 @@ import java.io.OutputStreamWriter; import java.time.Instant; +import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb new file mode 100644 index 0000000000..785fd6a492 --- /dev/null +++ b/messages/jsonschema/scripts/templates/java.enum.java.erb @@ -0,0 +1,39 @@ +<% @enums.each do |enum| -%> + public enum <%= enum[:name] %> { + <% enum[:values].each_with_index do |value, index| -%> + <%= enum_constant(value) %>("<%= value %>")<%= index < enum[:values].length-1 ? ',' : ';' %> + <% end -%> + + private final String value; + private final static java.util.Map> CONSTANTS = new java.util.HashMap<>(); + + static { + for (<%= enum[:name] %> c: values()) { + CONSTANTS.put(c.value, c); + } + } + + <%= enum[:name] %>(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static <%= enum[:name] %> fromValue(String value) { + <%= enum[:name] %> constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + +<% end -%> diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb new file mode 100644 index 0000000000..f2bc0f6b52 --- /dev/null +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -0,0 +1,78 @@ +<% @schemas.each do |key, schema| %> + public static class <%= class_name(key) %> { + <%- schema['properties'].each do |property_name, property| -%> + private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= property['items'] ? ' = new java.util.ArrayList<>()' : '' %>; + <%- end -%> + + public <%= class_name(key) %>() {} + + public <%= class_name(key) %>( + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> + <%- end -%> + ) { + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%- if (schema['required'] || []).index(property_name) -%> + this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); + <%- else -%> + this.<%= property_name %> = <%= property_name %>; + <%- end -%> + <%- end -%> + } + + <%- schema['properties'].each do |property_name, property| -%> + <%- if (schema['required'] || []).index(property_name) -%> + public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { + return java.util.Objects.requireNonNull(<%= property_name %>); + } + + public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); + } + <%- else -%> + public java.util.Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { + return java.util.Optional.ofNullable(<%= property_name %>); + } + + public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + this.<%= property_name %> = <%= property_name %>; + } + <%- end -%> + + <%- end -%> + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + <%= class_name(key) %> that = (<%= class_name(key) %>) o; + return <%- schema['properties'].each_with_index do |(property_name, property), index| %> + <%- if (schema['required'] || []).index(property_name) -%> + <%= property_name -%>.equals(that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> + <%- else -%> + java.util.Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> + <%- end -%> + <% end -%> + + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> + <%- end -%> + ); + } + + @Override + public String toString() { + return "<%= class_name(key) %>{" + + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + "<%= index == 0 ? '' : ', '%><%= property_name %>=" + <%= property_name %> + + <%- end -%> + '}'; + } + } + +<% end -%> From 2131d2a52394076817464af5de0019f0859616f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 16:19:37 +0000 Subject: [PATCH 16/63] Revert "Replace custom codegen with jsonschema2pojo-maven-plugin" This reverts commit 6b86b54556be0e32dd9a6808b9d22ede07b5c57d. --- messages/java/Makefile | 12 + messages/java/pom.xml | 22 - .../java/io/cucumber/messages/Messages.java | 4599 +++++++++++++++++ .../messages/NdjsonToMessageIterable.java | 3 +- .../io/cucumber/messages/TimeConversion.java | 3 +- .../MessageSerializationContract.java | 12 +- .../messages/NdjsonSerializationTest.java | 10 +- .../cucumber/messages/TimeConversionTest.java | 3 +- 8 files changed, 4623 insertions(+), 41 deletions(-) create mode 100644 messages/java/src/main/java/io/cucumber/messages/Messages.java diff --git a/messages/java/Makefile b/messages/java/Makefile index 551e68e27a..23bb1961dd 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -1 +1,13 @@ include default.mk + +JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") + +.codegen: src/main/java/io/cucumber/messages/Messages.java + +src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/java.java.erb ../jsonschema/scripts/templates/java.enum.java.erb + echo "package io.cucumber.messages;" > $@ + echo >> $@ + echo "public class Messages {" >> $@ + ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.java.erb >> $@ + ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> $@ + echo "}" >> $@ diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 2dc5e98792..0b4bdf2765 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -77,28 +77,6 @@ - - org.jsonschema2pojo - jsonschema2pojo-maven-plugin - 1.1.1 - - ${basedir}/../jsonschema - *.json - none - true - true - false - true - io.cucumber.messages.types - - - - - generate - - - - org.apache.maven.plugins maven-shade-plugin diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java new file mode 100644 index 0000000000..bb006a6ce9 --- /dev/null +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -0,0 +1,4599 @@ +package io.cucumber.messages; + +public class Messages { + + public static class Attachment { + private String body; + private AttachmentContentEncoding contentEncoding; + private String fileName; + private String mediaType; + private Source source; + private String testCaseStartedId; + private String testStepId; + private String url; + + public Attachment() {} + + public Attachment( + String body, + AttachmentContentEncoding contentEncoding, + String fileName, + String mediaType, + Source source, + String testCaseStartedId, + String testStepId, + String url + ) { + this.body = java.util.Objects.requireNonNull(body); + this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); + this.fileName = fileName; + this.mediaType = java.util.Objects.requireNonNull(mediaType); + this.source = source; + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.url = url; + } + + public String getBody() { + return java.util.Objects.requireNonNull(body); + } + + public void setBody(String body) { + this.body = java.util.Objects.requireNonNull(body); + } + + public AttachmentContentEncoding getContentEncoding() { + return java.util.Objects.requireNonNull(contentEncoding); + } + + public void setContentEncoding(AttachmentContentEncoding contentEncoding) { + this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); + } + + public java.util.Optional getFileName() { + return java.util.Optional.ofNullable(fileName); + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getMediaType() { + return java.util.Objects.requireNonNull(mediaType); + } + + public void setMediaType(String mediaType) { + this.mediaType = java.util.Objects.requireNonNull(mediaType); + } + + public java.util.Optional getSource() { + return java.util.Optional.ofNullable(source); + } + + public void setSource(Source source) { + this.source = source; + } + + public java.util.Optional getTestCaseStartedId() { + return java.util.Optional.ofNullable(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = testCaseStartedId; + } + + public java.util.Optional getTestStepId() { + return java.util.Optional.ofNullable(testStepId); + } + + public void setTestStepId(String testStepId) { + this.testStepId = testStepId; + } + + public java.util.Optional getUrl() { + return java.util.Optional.ofNullable(url); + } + + public void setUrl(String url) { + this.url = url; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Attachment that = (Attachment) o; + return + body.equals(that.body) && + contentEncoding.equals(that.contentEncoding) && + java.util.Objects.equals(fileName, that.fileName) && + mediaType.equals(that.mediaType) && + java.util.Objects.equals(source, that.source) && + java.util.Objects.equals(testCaseStartedId, that.testCaseStartedId) && + java.util.Objects.equals(testStepId, that.testStepId) && + java.util.Objects.equals(url, that.url); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + body, + contentEncoding, + fileName, + mediaType, + source, + testCaseStartedId, + testStepId, + url + ); + } + + @Override + public String toString() { + return "Attachment{" + + "body=" + body + + ", contentEncoding=" + contentEncoding + + ", fileName=" + fileName + + ", mediaType=" + mediaType + + ", source=" + source + + ", testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", url=" + url + + '}'; + } + } + + + public static class Duration { + private Long seconds; + private Long nanos; + + public Duration() {} + + public Duration( + Long seconds, + Long nanos + ) { + this.seconds = java.util.Objects.requireNonNull(seconds); + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + public Long getSeconds() { + return java.util.Objects.requireNonNull(seconds); + } + + public void setSeconds(Long seconds) { + this.seconds = java.util.Objects.requireNonNull(seconds); + } + + public Long getNanos() { + return java.util.Objects.requireNonNull(nanos); + } + + public void setNanos(Long nanos) { + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Duration that = (Duration) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + seconds, + nanos + ); + } + + @Override + public String toString() { + return "Duration{" + + "seconds=" + seconds + + ", nanos=" + nanos + + '}'; + } + } + + + public static class Envelope { + private Attachment attachment; + private GherkinDocument gherkinDocument; + private Hook hook; + private Meta meta; + private ParameterType parameterType; + private ParseError parseError; + private Pickle pickle; + private Source source; + private StepDefinition stepDefinition; + private TestCase testCase; + private TestCaseFinished testCaseFinished; + private TestCaseStarted testCaseStarted; + private TestRunFinished testRunFinished; + private TestRunStarted testRunStarted; + private TestStepFinished testStepFinished; + private TestStepStarted testStepStarted; + private UndefinedParameterType undefinedParameterType; + + public Envelope() {} + + public Envelope( + Attachment attachment, + GherkinDocument gherkinDocument, + Hook hook, + Meta meta, + ParameterType parameterType, + ParseError parseError, + Pickle pickle, + Source source, + StepDefinition stepDefinition, + TestCase testCase, + TestCaseFinished testCaseFinished, + TestCaseStarted testCaseStarted, + TestRunFinished testRunFinished, + TestRunStarted testRunStarted, + TestStepFinished testStepFinished, + TestStepStarted testStepStarted, + UndefinedParameterType undefinedParameterType + ) { + this.attachment = attachment; + this.gherkinDocument = gherkinDocument; + this.hook = hook; + this.meta = meta; + this.parameterType = parameterType; + this.parseError = parseError; + this.pickle = pickle; + this.source = source; + this.stepDefinition = stepDefinition; + this.testCase = testCase; + this.testCaseFinished = testCaseFinished; + this.testCaseStarted = testCaseStarted; + this.testRunFinished = testRunFinished; + this.testRunStarted = testRunStarted; + this.testStepFinished = testStepFinished; + this.testStepStarted = testStepStarted; + this.undefinedParameterType = undefinedParameterType; + } + + public java.util.Optional getAttachment() { + return java.util.Optional.ofNullable(attachment); + } + + public void setAttachment(Attachment attachment) { + this.attachment = attachment; + } + + public java.util.Optional getGherkinDocument() { + return java.util.Optional.ofNullable(gherkinDocument); + } + + public void setGherkinDocument(GherkinDocument gherkinDocument) { + this.gherkinDocument = gherkinDocument; + } + + public java.util.Optional getHook() { + return java.util.Optional.ofNullable(hook); + } + + public void setHook(Hook hook) { + this.hook = hook; + } + + public java.util.Optional getMeta() { + return java.util.Optional.ofNullable(meta); + } + + public void setMeta(Meta meta) { + this.meta = meta; + } + + public java.util.Optional getParameterType() { + return java.util.Optional.ofNullable(parameterType); + } + + public void setParameterType(ParameterType parameterType) { + this.parameterType = parameterType; + } + + public java.util.Optional getParseError() { + return java.util.Optional.ofNullable(parseError); + } + + public void setParseError(ParseError parseError) { + this.parseError = parseError; + } + + public java.util.Optional getPickle() { + return java.util.Optional.ofNullable(pickle); + } + + public void setPickle(Pickle pickle) { + this.pickle = pickle; + } + + public java.util.Optional getSource() { + return java.util.Optional.ofNullable(source); + } + + public void setSource(Source source) { + this.source = source; + } + + public java.util.Optional getStepDefinition() { + return java.util.Optional.ofNullable(stepDefinition); + } + + public void setStepDefinition(StepDefinition stepDefinition) { + this.stepDefinition = stepDefinition; + } + + public java.util.Optional getTestCase() { + return java.util.Optional.ofNullable(testCase); + } + + public void setTestCase(TestCase testCase) { + this.testCase = testCase; + } + + public java.util.Optional getTestCaseFinished() { + return java.util.Optional.ofNullable(testCaseFinished); + } + + public void setTestCaseFinished(TestCaseFinished testCaseFinished) { + this.testCaseFinished = testCaseFinished; + } + + public java.util.Optional getTestCaseStarted() { + return java.util.Optional.ofNullable(testCaseStarted); + } + + public void setTestCaseStarted(TestCaseStarted testCaseStarted) { + this.testCaseStarted = testCaseStarted; + } + + public java.util.Optional getTestRunFinished() { + return java.util.Optional.ofNullable(testRunFinished); + } + + public void setTestRunFinished(TestRunFinished testRunFinished) { + this.testRunFinished = testRunFinished; + } + + public java.util.Optional getTestRunStarted() { + return java.util.Optional.ofNullable(testRunStarted); + } + + public void setTestRunStarted(TestRunStarted testRunStarted) { + this.testRunStarted = testRunStarted; + } + + public java.util.Optional getTestStepFinished() { + return java.util.Optional.ofNullable(testStepFinished); + } + + public void setTestStepFinished(TestStepFinished testStepFinished) { + this.testStepFinished = testStepFinished; + } + + public java.util.Optional getTestStepStarted() { + return java.util.Optional.ofNullable(testStepStarted); + } + + public void setTestStepStarted(TestStepStarted testStepStarted) { + this.testStepStarted = testStepStarted; + } + + public java.util.Optional getUndefinedParameterType() { + return java.util.Optional.ofNullable(undefinedParameterType); + } + + public void setUndefinedParameterType(UndefinedParameterType undefinedParameterType) { + this.undefinedParameterType = undefinedParameterType; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Envelope that = (Envelope) o; + return + java.util.Objects.equals(attachment, that.attachment) && + java.util.Objects.equals(gherkinDocument, that.gherkinDocument) && + java.util.Objects.equals(hook, that.hook) && + java.util.Objects.equals(meta, that.meta) && + java.util.Objects.equals(parameterType, that.parameterType) && + java.util.Objects.equals(parseError, that.parseError) && + java.util.Objects.equals(pickle, that.pickle) && + java.util.Objects.equals(source, that.source) && + java.util.Objects.equals(stepDefinition, that.stepDefinition) && + java.util.Objects.equals(testCase, that.testCase) && + java.util.Objects.equals(testCaseFinished, that.testCaseFinished) && + java.util.Objects.equals(testCaseStarted, that.testCaseStarted) && + java.util.Objects.equals(testRunFinished, that.testRunFinished) && + java.util.Objects.equals(testRunStarted, that.testRunStarted) && + java.util.Objects.equals(testStepFinished, that.testStepFinished) && + java.util.Objects.equals(testStepStarted, that.testStepStarted) && + java.util.Objects.equals(undefinedParameterType, that.undefinedParameterType); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + attachment, + gherkinDocument, + hook, + meta, + parameterType, + parseError, + pickle, + source, + stepDefinition, + testCase, + testCaseFinished, + testCaseStarted, + testRunFinished, + testRunStarted, + testStepFinished, + testStepStarted, + undefinedParameterType + ); + } + + @Override + public String toString() { + return "Envelope{" + + "attachment=" + attachment + + ", gherkinDocument=" + gherkinDocument + + ", hook=" + hook + + ", meta=" + meta + + ", parameterType=" + parameterType + + ", parseError=" + parseError + + ", pickle=" + pickle + + ", source=" + source + + ", stepDefinition=" + stepDefinition + + ", testCase=" + testCase + + ", testCaseFinished=" + testCaseFinished + + ", testCaseStarted=" + testCaseStarted + + ", testRunFinished=" + testRunFinished + + ", testRunStarted=" + testRunStarted + + ", testStepFinished=" + testStepFinished + + ", testStepStarted=" + testStepStarted + + ", undefinedParameterType=" + undefinedParameterType + + '}'; + } + } + + + public static class GherkinDocument { + private String uri; + private Feature feature; + private java.util.List comments = new java.util.ArrayList<>(); + + public GherkinDocument() {} + + public GherkinDocument( + String uri, + Feature feature, + java.util.List comments + ) { + this.uri = uri; + this.feature = feature; + this.comments = java.util.Objects.requireNonNull(comments); + } + + public java.util.Optional getUri() { + return java.util.Optional.ofNullable(uri); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public java.util.Optional getFeature() { + return java.util.Optional.ofNullable(feature); + } + + public void setFeature(Feature feature) { + this.feature = feature; + } + + public java.util.List getComments() { + return java.util.Objects.requireNonNull(comments); + } + + public void setComments(java.util.List comments) { + this.comments = java.util.Objects.requireNonNull(comments); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GherkinDocument that = (GherkinDocument) o; + return + java.util.Objects.equals(uri, that.uri) && + java.util.Objects.equals(feature, that.feature) && + comments.equals(that.comments); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + uri, + feature, + comments + ); + } + + @Override + public String toString() { + return "GherkinDocument{" + + "uri=" + uri + + ", feature=" + feature + + ", comments=" + comments + + '}'; + } + } + + + public static class Background { + private Location location; + private String keyword; + private String name; + private String description; + private java.util.List steps = new java.util.ArrayList<>(); + private String id; + + public Background() {} + + public Background( + Location location, + String keyword, + String name, + String description, + java.util.List steps, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.steps = java.util.Objects.requireNonNull(steps); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getSteps() { + return java.util.Objects.requireNonNull(steps); + } + + public void setSteps(java.util.List steps) { + this.steps = java.util.Objects.requireNonNull(steps); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Background that = (Background) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + keyword, + name, + description, + steps, + id + ); + } + + @Override + public String toString() { + return "Background{" + + "location=" + location + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", steps=" + steps + + ", id=" + id + + '}'; + } + } + + + public static class Comment { + private Location location; + private String text; + + public Comment() {} + + public Comment( + Location location, + String text + ) { + this.location = java.util.Objects.requireNonNull(location); + this.text = java.util.Objects.requireNonNull(text); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getText() { + return java.util.Objects.requireNonNull(text); + } + + public void setText(String text) { + this.text = java.util.Objects.requireNonNull(text); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Comment that = (Comment) o; + return + location.equals(that.location) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + text + ); + } + + @Override + public String toString() { + return "Comment{" + + "location=" + location + + ", text=" + text + + '}'; + } + } + + + public static class DataTable { + private Location location; + private java.util.List rows = new java.util.ArrayList<>(); + + public DataTable() {} + + public DataTable( + Location location, + java.util.List rows + ) { + this.location = java.util.Objects.requireNonNull(location); + this.rows = java.util.Objects.requireNonNull(rows); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getRows() { + return java.util.Objects.requireNonNull(rows); + } + + public void setRows(java.util.List rows) { + this.rows = java.util.Objects.requireNonNull(rows); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DataTable that = (DataTable) o; + return + location.equals(that.location) && + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + rows + ); + } + + @Override + public String toString() { + return "DataTable{" + + "location=" + location + + ", rows=" + rows + + '}'; + } + } + + + public static class DocString { + private Location location; + private String mediaType; + private String content; + private String delimiter; + + public DocString() {} + + public DocString( + Location location, + String mediaType, + String content, + String delimiter + ) { + this.location = java.util.Objects.requireNonNull(location); + this.mediaType = mediaType; + this.content = java.util.Objects.requireNonNull(content); + this.delimiter = java.util.Objects.requireNonNull(delimiter); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.Optional getMediaType() { + return java.util.Optional.ofNullable(mediaType); + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getContent() { + return java.util.Objects.requireNonNull(content); + } + + public void setContent(String content) { + this.content = java.util.Objects.requireNonNull(content); + } + + public String getDelimiter() { + return java.util.Objects.requireNonNull(delimiter); + } + + public void setDelimiter(String delimiter) { + this.delimiter = java.util.Objects.requireNonNull(delimiter); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DocString that = (DocString) o; + return + location.equals(that.location) && + java.util.Objects.equals(mediaType, that.mediaType) && + content.equals(that.content) && + delimiter.equals(that.delimiter); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + mediaType, + content, + delimiter + ); + } + + @Override + public String toString() { + return "DocString{" + + "location=" + location + + ", mediaType=" + mediaType + + ", content=" + content + + ", delimiter=" + delimiter + + '}'; + } + } + + + public static class Examples { + private Location location; + private java.util.List tags = new java.util.ArrayList<>(); + private String keyword; + private String name; + private String description; + private TableRow tableHeader; + private java.util.List tableBody = new java.util.ArrayList<>(); + private String id; + + public Examples() {} + + public Examples( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + TableRow tableHeader, + java.util.List tableBody, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.tableHeader = tableHeader; + this.tableBody = java.util.Objects.requireNonNull(tableBody); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.Optional getTableHeader() { + return java.util.Optional.ofNullable(tableHeader); + } + + public void setTableHeader(TableRow tableHeader) { + this.tableHeader = tableHeader; + } + + public java.util.List getTableBody() { + return java.util.Objects.requireNonNull(tableBody); + } + + public void setTableBody(java.util.List tableBody) { + this.tableBody = java.util.Objects.requireNonNull(tableBody); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Examples that = (Examples) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + java.util.Objects.equals(tableHeader, that.tableHeader) && + tableBody.equals(that.tableBody) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + keyword, + name, + description, + tableHeader, + tableBody, + id + ); + } + + @Override + public String toString() { + return "Examples{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", tableHeader=" + tableHeader + + ", tableBody=" + tableBody + + ", id=" + id + + '}'; + } + } + + + public static class Feature { + private Location location; + private java.util.List tags = new java.util.ArrayList<>(); + private String language; + private String keyword; + private String name; + private String description; + private java.util.List children = new java.util.ArrayList<>(); + + public Feature() {} + + public Feature( + Location location, + java.util.List tags, + String language, + String keyword, + String name, + String description, + java.util.List children + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.language = java.util.Objects.requireNonNull(language); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.children = java.util.Objects.requireNonNull(children); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getLanguage() { + return java.util.Objects.requireNonNull(language); + } + + public void setLanguage(String language) { + this.language = java.util.Objects.requireNonNull(language); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getChildren() { + return java.util.Objects.requireNonNull(children); + } + + public void setChildren(java.util.List children) { + this.children = java.util.Objects.requireNonNull(children); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Feature that = (Feature) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + language.equals(that.language) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + language, + keyword, + name, + description, + children + ); + } + + @Override + public String toString() { + return "Feature{" + + "location=" + location + + ", tags=" + tags + + ", language=" + language + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", children=" + children + + '}'; + } + } + + + public static class FeatureChild { + private Rule rule; + private Background background; + private Scenario scenario; + + public FeatureChild() {} + + public FeatureChild( + Rule rule, + Background background, + Scenario scenario + ) { + this.rule = rule; + this.background = background; + this.scenario = scenario; + } + + public java.util.Optional getRule() { + return java.util.Optional.ofNullable(rule); + } + + public void setRule(Rule rule) { + this.rule = rule; + } + + public java.util.Optional getBackground() { + return java.util.Optional.ofNullable(background); + } + + public void setBackground(Background background) { + this.background = background; + } + + public java.util.Optional getScenario() { + return java.util.Optional.ofNullable(scenario); + } + + public void setScenario(Scenario scenario) { + this.scenario = scenario; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + FeatureChild that = (FeatureChild) o; + return + java.util.Objects.equals(rule, that.rule) && + java.util.Objects.equals(background, that.background) && + java.util.Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + rule, + background, + scenario + ); + } + + @Override + public String toString() { + return "FeatureChild{" + + "rule=" + rule + + ", background=" + background + + ", scenario=" + scenario + + '}'; + } + } + + + public static class Rule { + private Location location; + private java.util.List tags = new java.util.ArrayList<>(); + private String keyword; + private String name; + private String description; + private java.util.List children = new java.util.ArrayList<>(); + private String id; + + public Rule() {} + + public Rule( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + java.util.List children, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.children = java.util.Objects.requireNonNull(children); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getChildren() { + return java.util.Objects.requireNonNull(children); + } + + public void setChildren(java.util.List children) { + this.children = java.util.Objects.requireNonNull(children); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Rule that = (Rule) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + keyword, + name, + description, + children, + id + ); + } + + @Override + public String toString() { + return "Rule{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", children=" + children + + ", id=" + id + + '}'; + } + } + + + public static class RuleChild { + private Background background; + private Scenario scenario; + + public RuleChild() {} + + public RuleChild( + Background background, + Scenario scenario + ) { + this.background = background; + this.scenario = scenario; + } + + public java.util.Optional getBackground() { + return java.util.Optional.ofNullable(background); + } + + public void setBackground(Background background) { + this.background = background; + } + + public java.util.Optional getScenario() { + return java.util.Optional.ofNullable(scenario); + } + + public void setScenario(Scenario scenario) { + this.scenario = scenario; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RuleChild that = (RuleChild) o; + return + java.util.Objects.equals(background, that.background) && + java.util.Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + background, + scenario + ); + } + + @Override + public String toString() { + return "RuleChild{" + + "background=" + background + + ", scenario=" + scenario + + '}'; + } + } + + + public static class Scenario { + private Location location; + private java.util.List tags = new java.util.ArrayList<>(); + private String keyword; + private String name; + private String description; + private java.util.List steps = new java.util.ArrayList<>(); + private java.util.List examples = new java.util.ArrayList<>(); + private String id; + + public Scenario() {} + + public Scenario( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + java.util.List steps, + java.util.List examples, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.tags = java.util.Objects.requireNonNull(tags); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.name = java.util.Objects.requireNonNull(name); + this.description = java.util.Objects.requireNonNull(description); + this.steps = java.util.Objects.requireNonNull(steps); + this.examples = java.util.Objects.requireNonNull(examples); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getDescription() { + return java.util.Objects.requireNonNull(description); + } + + public void setDescription(String description) { + this.description = java.util.Objects.requireNonNull(description); + } + + public java.util.List getSteps() { + return java.util.Objects.requireNonNull(steps); + } + + public void setSteps(java.util.List steps) { + this.steps = java.util.Objects.requireNonNull(steps); + } + + public java.util.List getExamples() { + return java.util.Objects.requireNonNull(examples); + } + + public void setExamples(java.util.List examples) { + this.examples = java.util.Objects.requireNonNull(examples); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Scenario that = (Scenario) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + examples.equals(that.examples) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + tags, + keyword, + name, + description, + steps, + examples, + id + ); + } + + @Override + public String toString() { + return "Scenario{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", steps=" + steps + + ", examples=" + examples + + ", id=" + id + + '}'; + } + } + + + public static class Step { + private Location location; + private String keyword; + private String text; + private DocString docString; + private DataTable dataTable; + private String id; + + public Step() {} + + public Step( + Location location, + String keyword, + String text, + DocString docString, + DataTable dataTable, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.keyword = java.util.Objects.requireNonNull(keyword); + this.text = java.util.Objects.requireNonNull(text); + this.docString = docString; + this.dataTable = dataTable; + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getKeyword() { + return java.util.Objects.requireNonNull(keyword); + } + + public void setKeyword(String keyword) { + this.keyword = java.util.Objects.requireNonNull(keyword); + } + + public String getText() { + return java.util.Objects.requireNonNull(text); + } + + public void setText(String text) { + this.text = java.util.Objects.requireNonNull(text); + } + + public java.util.Optional getDocString() { + return java.util.Optional.ofNullable(docString); + } + + public void setDocString(DocString docString) { + this.docString = docString; + } + + public java.util.Optional getDataTable() { + return java.util.Optional.ofNullable(dataTable); + } + + public void setDataTable(DataTable dataTable) { + this.dataTable = dataTable; + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Step that = (Step) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + text.equals(that.text) && + java.util.Objects.equals(docString, that.docString) && + java.util.Objects.equals(dataTable, that.dataTable) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + keyword, + text, + docString, + dataTable, + id + ); + } + + @Override + public String toString() { + return "Step{" + + "location=" + location + + ", keyword=" + keyword + + ", text=" + text + + ", docString=" + docString + + ", dataTable=" + dataTable + + ", id=" + id + + '}'; + } + } + + + public static class TableCell { + private Location location; + private String value; + + public TableCell() {} + + public TableCell( + Location location, + String value + ) { + this.location = java.util.Objects.requireNonNull(location); + this.value = java.util.Objects.requireNonNull(value); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getValue() { + return java.util.Objects.requireNonNull(value); + } + + public void setValue(String value) { + this.value = java.util.Objects.requireNonNull(value); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableCell that = (TableCell) o; + return + location.equals(that.location) && + value.equals(that.value); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + value + ); + } + + @Override + public String toString() { + return "TableCell{" + + "location=" + location + + ", value=" + value + + '}'; + } + } + + + public static class TableRow { + private Location location; + private java.util.List cells = new java.util.ArrayList<>(); + private String id; + + public TableRow() {} + + public TableRow( + Location location, + java.util.List cells, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.cells = java.util.Objects.requireNonNull(cells); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public java.util.List getCells() { + return java.util.Objects.requireNonNull(cells); + } + + public void setCells(java.util.List cells) { + this.cells = java.util.Objects.requireNonNull(cells); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableRow that = (TableRow) o; + return + location.equals(that.location) && + cells.equals(that.cells) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + cells, + id + ); + } + + @Override + public String toString() { + return "TableRow{" + + "location=" + location + + ", cells=" + cells + + ", id=" + id + + '}'; + } + } + + + public static class Tag { + private Location location; + private String name; + private String id; + + public Tag() {} + + public Tag( + Location location, + String name, + String id + ) { + this.location = java.util.Objects.requireNonNull(location); + this.name = java.util.Objects.requireNonNull(name); + this.id = java.util.Objects.requireNonNull(id); + } + + public Location getLocation() { + return java.util.Objects.requireNonNull(location); + } + + public void setLocation(Location location) { + this.location = java.util.Objects.requireNonNull(location); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Tag that = (Tag) o; + return + location.equals(that.location) && + name.equals(that.name) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + location, + name, + id + ); + } + + @Override + public String toString() { + return "Tag{" + + "location=" + location + + ", name=" + name + + ", id=" + id + + '}'; + } + } + + + public static class Hook { + private String id; + private SourceReference sourceReference; + private String tagExpression; + + public Hook() {} + + public Hook( + String id, + SourceReference sourceReference, + String tagExpression + ) { + this.id = java.util.Objects.requireNonNull(id); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + this.tagExpression = tagExpression; + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public SourceReference getSourceReference() { + return java.util.Objects.requireNonNull(sourceReference); + } + + public void setSourceReference(SourceReference sourceReference) { + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + } + + public java.util.Optional getTagExpression() { + return java.util.Optional.ofNullable(tagExpression); + } + + public void setTagExpression(String tagExpression) { + this.tagExpression = tagExpression; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Hook that = (Hook) o; + return + id.equals(that.id) && + sourceReference.equals(that.sourceReference) && + java.util.Objects.equals(tagExpression, that.tagExpression); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + sourceReference, + tagExpression + ); + } + + @Override + public String toString() { + return "Hook{" + + "id=" + id + + ", sourceReference=" + sourceReference + + ", tagExpression=" + tagExpression + + '}'; + } + } + + + public static class Location { + private Long line; + private Long column; + + public Location() {} + + public Location( + Long line, + Long column + ) { + this.line = java.util.Objects.requireNonNull(line); + this.column = column; + } + + public Long getLine() { + return java.util.Objects.requireNonNull(line); + } + + public void setLine(Long line) { + this.line = java.util.Objects.requireNonNull(line); + } + + public java.util.Optional getColumn() { + return java.util.Optional.ofNullable(column); + } + + public void setColumn(Long column) { + this.column = column; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Location that = (Location) o; + return + line.equals(that.line) && + java.util.Objects.equals(column, that.column); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + line, + column + ); + } + + @Override + public String toString() { + return "Location{" + + "line=" + line + + ", column=" + column + + '}'; + } + } + + + public static class Meta { + private String protocolVersion; + private Product implementation; + private Product runtime; + private Product os; + private Product cpu; + private Ci ci; + + public Meta() {} + + public Meta( + String protocolVersion, + Product implementation, + Product runtime, + Product os, + Product cpu, + Ci ci + ) { + this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); + this.implementation = java.util.Objects.requireNonNull(implementation); + this.runtime = java.util.Objects.requireNonNull(runtime); + this.os = java.util.Objects.requireNonNull(os); + this.cpu = java.util.Objects.requireNonNull(cpu); + this.ci = ci; + } + + public String getProtocolVersion() { + return java.util.Objects.requireNonNull(protocolVersion); + } + + public void setProtocolVersion(String protocolVersion) { + this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); + } + + public Product getImplementation() { + return java.util.Objects.requireNonNull(implementation); + } + + public void setImplementation(Product implementation) { + this.implementation = java.util.Objects.requireNonNull(implementation); + } + + public Product getRuntime() { + return java.util.Objects.requireNonNull(runtime); + } + + public void setRuntime(Product runtime) { + this.runtime = java.util.Objects.requireNonNull(runtime); + } + + public Product getOs() { + return java.util.Objects.requireNonNull(os); + } + + public void setOs(Product os) { + this.os = java.util.Objects.requireNonNull(os); + } + + public Product getCpu() { + return java.util.Objects.requireNonNull(cpu); + } + + public void setCpu(Product cpu) { + this.cpu = java.util.Objects.requireNonNull(cpu); + } + + public java.util.Optional getCi() { + return java.util.Optional.ofNullable(ci); + } + + public void setCi(Ci ci) { + this.ci = ci; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Meta that = (Meta) o; + return + protocolVersion.equals(that.protocolVersion) && + implementation.equals(that.implementation) && + runtime.equals(that.runtime) && + os.equals(that.os) && + cpu.equals(that.cpu) && + java.util.Objects.equals(ci, that.ci); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + protocolVersion, + implementation, + runtime, + os, + cpu, + ci + ); + } + + @Override + public String toString() { + return "Meta{" + + "protocolVersion=" + protocolVersion + + ", implementation=" + implementation + + ", runtime=" + runtime + + ", os=" + os + + ", cpu=" + cpu + + ", ci=" + ci + + '}'; + } + } + + + public static class Ci { + private String name; + private String url; + private String buildNumber; + private Git git; + + public Ci() {} + + public Ci( + String name, + String url, + String buildNumber, + Git git + ) { + this.name = java.util.Objects.requireNonNull(name); + this.url = url; + this.buildNumber = buildNumber; + this.git = git; + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public java.util.Optional getUrl() { + return java.util.Optional.ofNullable(url); + } + + public void setUrl(String url) { + this.url = url; + } + + public java.util.Optional getBuildNumber() { + return java.util.Optional.ofNullable(buildNumber); + } + + public void setBuildNumber(String buildNumber) { + this.buildNumber = buildNumber; + } + + public java.util.Optional getGit() { + return java.util.Optional.ofNullable(git); + } + + public void setGit(Git git) { + this.git = git; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Ci that = (Ci) o; + return + name.equals(that.name) && + java.util.Objects.equals(url, that.url) && + java.util.Objects.equals(buildNumber, that.buildNumber) && + java.util.Objects.equals(git, that.git); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + url, + buildNumber, + git + ); + } + + @Override + public String toString() { + return "Ci{" + + "name=" + name + + ", url=" + url + + ", buildNumber=" + buildNumber + + ", git=" + git + + '}'; + } + } + + + public static class Git { + private String remote; + private String revision; + private String branch; + private String tag; + + public Git() {} + + public Git( + String remote, + String revision, + String branch, + String tag + ) { + this.remote = java.util.Objects.requireNonNull(remote); + this.revision = java.util.Objects.requireNonNull(revision); + this.branch = branch; + this.tag = tag; + } + + public String getRemote() { + return java.util.Objects.requireNonNull(remote); + } + + public void setRemote(String remote) { + this.remote = java.util.Objects.requireNonNull(remote); + } + + public String getRevision() { + return java.util.Objects.requireNonNull(revision); + } + + public void setRevision(String revision) { + this.revision = java.util.Objects.requireNonNull(revision); + } + + public java.util.Optional getBranch() { + return java.util.Optional.ofNullable(branch); + } + + public void setBranch(String branch) { + this.branch = branch; + } + + public java.util.Optional getTag() { + return java.util.Optional.ofNullable(tag); + } + + public void setTag(String tag) { + this.tag = tag; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Git that = (Git) o; + return + remote.equals(that.remote) && + revision.equals(that.revision) && + java.util.Objects.equals(branch, that.branch) && + java.util.Objects.equals(tag, that.tag); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + remote, + revision, + branch, + tag + ); + } + + @Override + public String toString() { + return "Git{" + + "remote=" + remote + + ", revision=" + revision + + ", branch=" + branch + + ", tag=" + tag + + '}'; + } + } + + + public static class Product { + private String name; + private String version; + + public Product() {} + + public Product( + String name, + String version + ) { + this.name = java.util.Objects.requireNonNull(name); + this.version = version; + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public java.util.Optional getVersion() { + return java.util.Optional.ofNullable(version); + } + + public void setVersion(String version) { + this.version = version; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Product that = (Product) o; + return + name.equals(that.name) && + java.util.Objects.equals(version, that.version); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + version + ); + } + + @Override + public String toString() { + return "Product{" + + "name=" + name + + ", version=" + version + + '}'; + } + } + + + public static class ParameterType { + private String name; + private java.util.List regularExpressions = new java.util.ArrayList<>(); + private Boolean preferForRegularExpressionMatch; + private Boolean useForSnippets; + private String id; + + public ParameterType() {} + + public ParameterType( + String name, + java.util.List regularExpressions, + Boolean preferForRegularExpressionMatch, + Boolean useForSnippets, + String id + ) { + this.name = java.util.Objects.requireNonNull(name); + this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); + this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); + this.id = java.util.Objects.requireNonNull(id); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public java.util.List getRegularExpressions() { + return java.util.Objects.requireNonNull(regularExpressions); + } + + public void setRegularExpressions(java.util.List regularExpressions) { + this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); + } + + public Boolean getPreferForRegularExpressionMatch() { + return java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + } + + public void setPreferForRegularExpressionMatch(Boolean preferForRegularExpressionMatch) { + this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + } + + public Boolean getUseForSnippets() { + return java.util.Objects.requireNonNull(useForSnippets); + } + + public void setUseForSnippets(Boolean useForSnippets) { + this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParameterType that = (ParameterType) o; + return + name.equals(that.name) && + regularExpressions.equals(that.regularExpressions) && + preferForRegularExpressionMatch.equals(that.preferForRegularExpressionMatch) && + useForSnippets.equals(that.useForSnippets) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + regularExpressions, + preferForRegularExpressionMatch, + useForSnippets, + id + ); + } + + @Override + public String toString() { + return "ParameterType{" + + "name=" + name + + ", regularExpressions=" + regularExpressions + + ", preferForRegularExpressionMatch=" + preferForRegularExpressionMatch + + ", useForSnippets=" + useForSnippets + + ", id=" + id + + '}'; + } + } + + + public static class ParseError { + private SourceReference source; + private String message; + + public ParseError() {} + + public ParseError( + SourceReference source, + String message + ) { + this.source = java.util.Objects.requireNonNull(source); + this.message = java.util.Objects.requireNonNull(message); + } + + public SourceReference getSource() { + return java.util.Objects.requireNonNull(source); + } + + public void setSource(SourceReference source) { + this.source = java.util.Objects.requireNonNull(source); + } + + public String getMessage() { + return java.util.Objects.requireNonNull(message); + } + + public void setMessage(String message) { + this.message = java.util.Objects.requireNonNull(message); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParseError that = (ParseError) o; + return + source.equals(that.source) && + message.equals(that.message); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + source, + message + ); + } + + @Override + public String toString() { + return "ParseError{" + + "source=" + source + + ", message=" + message + + '}'; + } + } + + + public static class Pickle { + private String id; + private String uri; + private String name; + private String language; + private java.util.List steps = new java.util.ArrayList<>(); + private java.util.List tags = new java.util.ArrayList<>(); + private java.util.List astNodeIds = new java.util.ArrayList<>(); + + public Pickle() {} + + public Pickle( + String id, + String uri, + String name, + String language, + java.util.List steps, + java.util.List tags, + java.util.List astNodeIds + ) { + this.id = java.util.Objects.requireNonNull(id); + this.uri = java.util.Objects.requireNonNull(uri); + this.name = java.util.Objects.requireNonNull(name); + this.language = java.util.Objects.requireNonNull(language); + this.steps = java.util.Objects.requireNonNull(steps); + this.tags = java.util.Objects.requireNonNull(tags); + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getUri() { + return java.util.Objects.requireNonNull(uri); + } + + public void setUri(String uri) { + this.uri = java.util.Objects.requireNonNull(uri); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getLanguage() { + return java.util.Objects.requireNonNull(language); + } + + public void setLanguage(String language) { + this.language = java.util.Objects.requireNonNull(language); + } + + public java.util.List getSteps() { + return java.util.Objects.requireNonNull(steps); + } + + public void setSteps(java.util.List steps) { + this.steps = java.util.Objects.requireNonNull(steps); + } + + public java.util.List getTags() { + return java.util.Objects.requireNonNull(tags); + } + + public void setTags(java.util.List tags) { + this.tags = java.util.Objects.requireNonNull(tags); + } + + public java.util.List getAstNodeIds() { + return java.util.Objects.requireNonNull(astNodeIds); + } + + public void setAstNodeIds(java.util.List astNodeIds) { + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pickle that = (Pickle) o; + return + id.equals(that.id) && + uri.equals(that.uri) && + name.equals(that.name) && + language.equals(that.language) && + steps.equals(that.steps) && + tags.equals(that.tags) && + astNodeIds.equals(that.astNodeIds); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + uri, + name, + language, + steps, + tags, + astNodeIds + ); + } + + @Override + public String toString() { + return "Pickle{" + + "id=" + id + + ", uri=" + uri + + ", name=" + name + + ", language=" + language + + ", steps=" + steps + + ", tags=" + tags + + ", astNodeIds=" + astNodeIds + + '}'; + } + } + + + public static class PickleDocString { + private String mediaType; + private String content; + + public PickleDocString() {} + + public PickleDocString( + String mediaType, + String content + ) { + this.mediaType = mediaType; + this.content = java.util.Objects.requireNonNull(content); + } + + public java.util.Optional getMediaType() { + return java.util.Optional.ofNullable(mediaType); + } + + public void setMediaType(String mediaType) { + this.mediaType = mediaType; + } + + public String getContent() { + return java.util.Objects.requireNonNull(content); + } + + public void setContent(String content) { + this.content = java.util.Objects.requireNonNull(content); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleDocString that = (PickleDocString) o; + return + java.util.Objects.equals(mediaType, that.mediaType) && + content.equals(that.content); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + mediaType, + content + ); + } + + @Override + public String toString() { + return "PickleDocString{" + + "mediaType=" + mediaType + + ", content=" + content + + '}'; + } + } + + + public static class PickleStep { + private PickleStepArgument argument; + private java.util.List astNodeIds = new java.util.ArrayList<>(); + private String id; + private String text; + + public PickleStep() {} + + public PickleStep( + PickleStepArgument argument, + java.util.List astNodeIds, + String id, + String text + ) { + this.argument = argument; + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + this.id = java.util.Objects.requireNonNull(id); + this.text = java.util.Objects.requireNonNull(text); + } + + public java.util.Optional getArgument() { + return java.util.Optional.ofNullable(argument); + } + + public void setArgument(PickleStepArgument argument) { + this.argument = argument; + } + + public java.util.List getAstNodeIds() { + return java.util.Objects.requireNonNull(astNodeIds); + } + + public void setAstNodeIds(java.util.List astNodeIds) { + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getText() { + return java.util.Objects.requireNonNull(text); + } + + public void setText(String text) { + this.text = java.util.Objects.requireNonNull(text); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStep that = (PickleStep) o; + return + java.util.Objects.equals(argument, that.argument) && + astNodeIds.equals(that.astNodeIds) && + id.equals(that.id) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + argument, + astNodeIds, + id, + text + ); + } + + @Override + public String toString() { + return "PickleStep{" + + "argument=" + argument + + ", astNodeIds=" + astNodeIds + + ", id=" + id + + ", text=" + text + + '}'; + } + } + + + public static class PickleStepArgument { + private PickleDocString docString; + private PickleTable dataTable; + + public PickleStepArgument() {} + + public PickleStepArgument( + PickleDocString docString, + PickleTable dataTable + ) { + this.docString = docString; + this.dataTable = dataTable; + } + + public java.util.Optional getDocString() { + return java.util.Optional.ofNullable(docString); + } + + public void setDocString(PickleDocString docString) { + this.docString = docString; + } + + public java.util.Optional getDataTable() { + return java.util.Optional.ofNullable(dataTable); + } + + public void setDataTable(PickleTable dataTable) { + this.dataTable = dataTable; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStepArgument that = (PickleStepArgument) o; + return + java.util.Objects.equals(docString, that.docString) && + java.util.Objects.equals(dataTable, that.dataTable); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + docString, + dataTable + ); + } + + @Override + public String toString() { + return "PickleStepArgument{" + + "docString=" + docString + + ", dataTable=" + dataTable + + '}'; + } + } + + + public static class PickleTable { + private java.util.List rows = new java.util.ArrayList<>(); + + public PickleTable() {} + + public PickleTable( + java.util.List rows + ) { + this.rows = java.util.Objects.requireNonNull(rows); + } + + public java.util.List getRows() { + return java.util.Objects.requireNonNull(rows); + } + + public void setRows(java.util.List rows) { + this.rows = java.util.Objects.requireNonNull(rows); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTable that = (PickleTable) o; + return + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + rows + ); + } + + @Override + public String toString() { + return "PickleTable{" + + "rows=" + rows + + '}'; + } + } + + + public static class PickleTableCell { + private String value; + + public PickleTableCell() {} + + public PickleTableCell( + String value + ) { + this.value = java.util.Objects.requireNonNull(value); + } + + public String getValue() { + return java.util.Objects.requireNonNull(value); + } + + public void setValue(String value) { + this.value = java.util.Objects.requireNonNull(value); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableCell that = (PickleTableCell) o; + return + value.equals(that.value); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + value + ); + } + + @Override + public String toString() { + return "PickleTableCell{" + + "value=" + value + + '}'; + } + } + + + public static class PickleTableRow { + private java.util.List cells = new java.util.ArrayList<>(); + + public PickleTableRow() {} + + public PickleTableRow( + java.util.List cells + ) { + this.cells = java.util.Objects.requireNonNull(cells); + } + + public java.util.List getCells() { + return java.util.Objects.requireNonNull(cells); + } + + public void setCells(java.util.List cells) { + this.cells = java.util.Objects.requireNonNull(cells); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableRow that = (PickleTableRow) o; + return + cells.equals(that.cells); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + cells + ); + } + + @Override + public String toString() { + return "PickleTableRow{" + + "cells=" + cells + + '}'; + } + } + + + public static class PickleTag { + private String name; + private String astNodeId; + + public PickleTag() {} + + public PickleTag( + String name, + String astNodeId + ) { + this.name = java.util.Objects.requireNonNull(name); + this.astNodeId = java.util.Objects.requireNonNull(astNodeId); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + public String getAstNodeId() { + return java.util.Objects.requireNonNull(astNodeId); + } + + public void setAstNodeId(String astNodeId) { + this.astNodeId = java.util.Objects.requireNonNull(astNodeId); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTag that = (PickleTag) o; + return + name.equals(that.name) && + astNodeId.equals(that.astNodeId); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + name, + astNodeId + ); + } + + @Override + public String toString() { + return "PickleTag{" + + "name=" + name + + ", astNodeId=" + astNodeId + + '}'; + } + } + + + public static class Source { + private String uri; + private String data; + private SourceMediaType mediaType; + + public Source() {} + + public Source( + String uri, + String data, + SourceMediaType mediaType + ) { + this.uri = java.util.Objects.requireNonNull(uri); + this.data = java.util.Objects.requireNonNull(data); + this.mediaType = java.util.Objects.requireNonNull(mediaType); + } + + public String getUri() { + return java.util.Objects.requireNonNull(uri); + } + + public void setUri(String uri) { + this.uri = java.util.Objects.requireNonNull(uri); + } + + public String getData() { + return java.util.Objects.requireNonNull(data); + } + + public void setData(String data) { + this.data = java.util.Objects.requireNonNull(data); + } + + public SourceMediaType getMediaType() { + return java.util.Objects.requireNonNull(mediaType); + } + + public void setMediaType(SourceMediaType mediaType) { + this.mediaType = java.util.Objects.requireNonNull(mediaType); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Source that = (Source) o; + return + uri.equals(that.uri) && + data.equals(that.data) && + mediaType.equals(that.mediaType); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + uri, + data, + mediaType + ); + } + + @Override + public String toString() { + return "Source{" + + "uri=" + uri + + ", data=" + data + + ", mediaType=" + mediaType + + '}'; + } + } + + + public static class SourceReference { + private String uri; + private JavaMethod javaMethod; + private JavaStackTraceElement javaStackTraceElement; + private Location location; + + public SourceReference() {} + + public SourceReference( + String uri, + JavaMethod javaMethod, + JavaStackTraceElement javaStackTraceElement, + Location location + ) { + this.uri = uri; + this.javaMethod = javaMethod; + this.javaStackTraceElement = javaStackTraceElement; + this.location = location; + } + + public java.util.Optional getUri() { + return java.util.Optional.ofNullable(uri); + } + + public void setUri(String uri) { + this.uri = uri; + } + + public java.util.Optional getJavaMethod() { + return java.util.Optional.ofNullable(javaMethod); + } + + public void setJavaMethod(JavaMethod javaMethod) { + this.javaMethod = javaMethod; + } + + public java.util.Optional getJavaStackTraceElement() { + return java.util.Optional.ofNullable(javaStackTraceElement); + } + + public void setJavaStackTraceElement(JavaStackTraceElement javaStackTraceElement) { + this.javaStackTraceElement = javaStackTraceElement; + } + + public java.util.Optional getLocation() { + return java.util.Optional.ofNullable(location); + } + + public void setLocation(Location location) { + this.location = location; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SourceReference that = (SourceReference) o; + return + java.util.Objects.equals(uri, that.uri) && + java.util.Objects.equals(javaMethod, that.javaMethod) && + java.util.Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && + java.util.Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + uri, + javaMethod, + javaStackTraceElement, + location + ); + } + + @Override + public String toString() { + return "SourceReference{" + + "uri=" + uri + + ", javaMethod=" + javaMethod + + ", javaStackTraceElement=" + javaStackTraceElement + + ", location=" + location + + '}'; + } + } + + + public static class JavaMethod { + private String className; + private String methodName; + private java.util.List methodParameterTypes = new java.util.ArrayList<>(); + + public JavaMethod() {} + + public JavaMethod( + String className, + String methodName, + java.util.List methodParameterTypes + ) { + this.className = java.util.Objects.requireNonNull(className); + this.methodName = java.util.Objects.requireNonNull(methodName); + this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); + } + + public String getClassName() { + return java.util.Objects.requireNonNull(className); + } + + public void setClassName(String className) { + this.className = java.util.Objects.requireNonNull(className); + } + + public String getMethodName() { + return java.util.Objects.requireNonNull(methodName); + } + + public void setMethodName(String methodName) { + this.methodName = java.util.Objects.requireNonNull(methodName); + } + + public java.util.List getMethodParameterTypes() { + return java.util.Objects.requireNonNull(methodParameterTypes); + } + + public void setMethodParameterTypes(java.util.List methodParameterTypes) { + this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaMethod that = (JavaMethod) o; + return + className.equals(that.className) && + methodName.equals(that.methodName) && + methodParameterTypes.equals(that.methodParameterTypes); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + className, + methodName, + methodParameterTypes + ); + } + + @Override + public String toString() { + return "JavaMethod{" + + "className=" + className + + ", methodName=" + methodName + + ", methodParameterTypes=" + methodParameterTypes + + '}'; + } + } + + + public static class JavaStackTraceElement { + private String className; + private String fileName; + private String methodName; + + public JavaStackTraceElement() {} + + public JavaStackTraceElement( + String className, + String fileName, + String methodName + ) { + this.className = java.util.Objects.requireNonNull(className); + this.fileName = java.util.Objects.requireNonNull(fileName); + this.methodName = java.util.Objects.requireNonNull(methodName); + } + + public String getClassName() { + return java.util.Objects.requireNonNull(className); + } + + public void setClassName(String className) { + this.className = java.util.Objects.requireNonNull(className); + } + + public String getFileName() { + return java.util.Objects.requireNonNull(fileName); + } + + public void setFileName(String fileName) { + this.fileName = java.util.Objects.requireNonNull(fileName); + } + + public String getMethodName() { + return java.util.Objects.requireNonNull(methodName); + } + + public void setMethodName(String methodName) { + this.methodName = java.util.Objects.requireNonNull(methodName); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaStackTraceElement that = (JavaStackTraceElement) o; + return + className.equals(that.className) && + fileName.equals(that.fileName) && + methodName.equals(that.methodName); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + className, + fileName, + methodName + ); + } + + @Override + public String toString() { + return "JavaStackTraceElement{" + + "className=" + className + + ", fileName=" + fileName + + ", methodName=" + methodName + + '}'; + } + } + + + public static class StepDefinition { + private String id; + private StepDefinitionPattern pattern; + private SourceReference sourceReference; + + public StepDefinition() {} + + public StepDefinition( + String id, + StepDefinitionPattern pattern, + SourceReference sourceReference + ) { + this.id = java.util.Objects.requireNonNull(id); + this.pattern = java.util.Objects.requireNonNull(pattern); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public StepDefinitionPattern getPattern() { + return java.util.Objects.requireNonNull(pattern); + } + + public void setPattern(StepDefinitionPattern pattern) { + this.pattern = java.util.Objects.requireNonNull(pattern); + } + + public SourceReference getSourceReference() { + return java.util.Objects.requireNonNull(sourceReference); + } + + public void setSourceReference(SourceReference sourceReference) { + this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinition that = (StepDefinition) o; + return + id.equals(that.id) && + pattern.equals(that.pattern) && + sourceReference.equals(that.sourceReference); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + pattern, + sourceReference + ); + } + + @Override + public String toString() { + return "StepDefinition{" + + "id=" + id + + ", pattern=" + pattern + + ", sourceReference=" + sourceReference + + '}'; + } + } + + + public static class StepDefinitionPattern { + private String source; + private StepDefinitionPatternType type; + + public StepDefinitionPattern() {} + + public StepDefinitionPattern( + String source, + StepDefinitionPatternType type + ) { + this.source = java.util.Objects.requireNonNull(source); + this.type = java.util.Objects.requireNonNull(type); + } + + public String getSource() { + return java.util.Objects.requireNonNull(source); + } + + public void setSource(String source) { + this.source = java.util.Objects.requireNonNull(source); + } + + public StepDefinitionPatternType getType() { + return java.util.Objects.requireNonNull(type); + } + + public void setType(StepDefinitionPatternType type) { + this.type = java.util.Objects.requireNonNull(type); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinitionPattern that = (StepDefinitionPattern) o; + return + source.equals(that.source) && + type.equals(that.type); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + source, + type + ); + } + + @Override + public String toString() { + return "StepDefinitionPattern{" + + "source=" + source + + ", type=" + type + + '}'; + } + } + + + public static class TestCase { + private String id; + private String pickleId; + private java.util.List testSteps = new java.util.ArrayList<>(); + + public TestCase() {} + + public TestCase( + String id, + String pickleId, + java.util.List testSteps + ) { + this.id = java.util.Objects.requireNonNull(id); + this.pickleId = java.util.Objects.requireNonNull(pickleId); + this.testSteps = java.util.Objects.requireNonNull(testSteps); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getPickleId() { + return java.util.Objects.requireNonNull(pickleId); + } + + public void setPickleId(String pickleId) { + this.pickleId = java.util.Objects.requireNonNull(pickleId); + } + + public java.util.List getTestSteps() { + return java.util.Objects.requireNonNull(testSteps); + } + + public void setTestSteps(java.util.List testSteps) { + this.testSteps = java.util.Objects.requireNonNull(testSteps); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCase that = (TestCase) o; + return + id.equals(that.id) && + pickleId.equals(that.pickleId) && + testSteps.equals(that.testSteps); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + id, + pickleId, + testSteps + ); + } + + @Override + public String toString() { + return "TestCase{" + + "id=" + id + + ", pickleId=" + pickleId + + ", testSteps=" + testSteps + + '}'; + } + } + + + public static class Group { + private java.util.List children = new java.util.ArrayList<>(); + private Long start; + private String value; + + public Group() {} + + public Group( + java.util.List children, + Long start, + String value + ) { + this.children = java.util.Objects.requireNonNull(children); + this.start = start; + this.value = value; + } + + public java.util.List getChildren() { + return java.util.Objects.requireNonNull(children); + } + + public void setChildren(java.util.List children) { + this.children = java.util.Objects.requireNonNull(children); + } + + public java.util.Optional getStart() { + return java.util.Optional.ofNullable(start); + } + + public void setStart(Long start) { + this.start = start; + } + + public java.util.Optional getValue() { + return java.util.Optional.ofNullable(value); + } + + public void setValue(String value) { + this.value = value; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Group that = (Group) o; + return + children.equals(that.children) && + java.util.Objects.equals(start, that.start) && + java.util.Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + children, + start, + value + ); + } + + @Override + public String toString() { + return "Group{" + + "children=" + children + + ", start=" + start + + ", value=" + value + + '}'; + } + } + + + public static class StepMatchArgument { + private Group group; + private String parameterTypeName; + + public StepMatchArgument() {} + + public StepMatchArgument( + Group group, + String parameterTypeName + ) { + this.group = java.util.Objects.requireNonNull(group); + this.parameterTypeName = parameterTypeName; + } + + public Group getGroup() { + return java.util.Objects.requireNonNull(group); + } + + public void setGroup(Group group) { + this.group = java.util.Objects.requireNonNull(group); + } + + public java.util.Optional getParameterTypeName() { + return java.util.Optional.ofNullable(parameterTypeName); + } + + public void setParameterTypeName(String parameterTypeName) { + this.parameterTypeName = parameterTypeName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgument that = (StepMatchArgument) o; + return + group.equals(that.group) && + java.util.Objects.equals(parameterTypeName, that.parameterTypeName); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + group, + parameterTypeName + ); + } + + @Override + public String toString() { + return "StepMatchArgument{" + + "group=" + group + + ", parameterTypeName=" + parameterTypeName + + '}'; + } + } + + + public static class StepMatchArgumentsList { + private java.util.List stepMatchArguments = new java.util.ArrayList<>(); + + public StepMatchArgumentsList() {} + + public StepMatchArgumentsList( + java.util.List stepMatchArguments + ) { + this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); + } + + public java.util.List getStepMatchArguments() { + return java.util.Objects.requireNonNull(stepMatchArguments); + } + + public void setStepMatchArguments(java.util.List stepMatchArguments) { + this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgumentsList that = (StepMatchArgumentsList) o; + return + stepMatchArguments.equals(that.stepMatchArguments); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + stepMatchArguments + ); + } + + @Override + public String toString() { + return "StepMatchArgumentsList{" + + "stepMatchArguments=" + stepMatchArguments + + '}'; + } + } + + + public static class TestStep { + private String hookId; + private String id; + private String pickleStepId; + private java.util.List stepDefinitionIds = new java.util.ArrayList<>(); + private java.util.List stepMatchArgumentsLists = new java.util.ArrayList<>(); + + public TestStep() {} + + public TestStep( + String hookId, + String id, + String pickleStepId, + java.util.List stepDefinitionIds, + java.util.List stepMatchArgumentsLists + ) { + this.hookId = hookId; + this.id = java.util.Objects.requireNonNull(id); + this.pickleStepId = pickleStepId; + this.stepDefinitionIds = stepDefinitionIds; + this.stepMatchArgumentsLists = stepMatchArgumentsLists; + } + + public java.util.Optional getHookId() { + return java.util.Optional.ofNullable(hookId); + } + + public void setHookId(String hookId) { + this.hookId = hookId; + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public java.util.Optional getPickleStepId() { + return java.util.Optional.ofNullable(pickleStepId); + } + + public void setPickleStepId(String pickleStepId) { + this.pickleStepId = pickleStepId; + } + + public java.util.Optional> getStepDefinitionIds() { + return java.util.Optional.ofNullable(stepDefinitionIds); + } + + public void setStepDefinitionIds(java.util.List stepDefinitionIds) { + this.stepDefinitionIds = stepDefinitionIds; + } + + public java.util.Optional> getStepMatchArgumentsLists() { + return java.util.Optional.ofNullable(stepMatchArgumentsLists); + } + + public void setStepMatchArgumentsLists(java.util.List stepMatchArgumentsLists) { + this.stepMatchArgumentsLists = stepMatchArgumentsLists; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStep that = (TestStep) o; + return + java.util.Objects.equals(hookId, that.hookId) && + id.equals(that.id) && + java.util.Objects.equals(pickleStepId, that.pickleStepId) && + java.util.Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && + java.util.Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + hookId, + id, + pickleStepId, + stepDefinitionIds, + stepMatchArgumentsLists + ); + } + + @Override + public String toString() { + return "TestStep{" + + "hookId=" + hookId + + ", id=" + id + + ", pickleStepId=" + pickleStepId + + ", stepDefinitionIds=" + stepDefinitionIds + + ", stepMatchArgumentsLists=" + stepMatchArgumentsLists + + '}'; + } + } + + + public static class TestCaseFinished { + private String testCaseStartedId; + private Timestamp timestamp; + private Boolean willBeRetried; + + public TestCaseFinished() {} + + public TestCaseFinished( + String testCaseStartedId, + Timestamp timestamp, + Boolean willBeRetried + ) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); + } + + public String getTestCaseStartedId() { + return java.util.Objects.requireNonNull(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public Boolean getWillBeRetried() { + return java.util.Objects.requireNonNull(willBeRetried); + } + + public void setWillBeRetried(Boolean willBeRetried) { + this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseFinished that = (TestCaseFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + timestamp.equals(that.timestamp) && + willBeRetried.equals(that.willBeRetried); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + testCaseStartedId, + timestamp, + willBeRetried + ); + } + + @Override + public String toString() { + return "TestCaseFinished{" + + "testCaseStartedId=" + testCaseStartedId + + ", timestamp=" + timestamp + + ", willBeRetried=" + willBeRetried + + '}'; + } + } + + + public static class TestCaseStarted { + private Long attempt; + private String id; + private String testCaseId; + private Timestamp timestamp; + + public TestCaseStarted() {} + + public TestCaseStarted( + Long attempt, + String id, + String testCaseId, + Timestamp timestamp + ) { + this.attempt = java.util.Objects.requireNonNull(attempt); + this.id = java.util.Objects.requireNonNull(id); + this.testCaseId = java.util.Objects.requireNonNull(testCaseId); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public Long getAttempt() { + return java.util.Objects.requireNonNull(attempt); + } + + public void setAttempt(Long attempt) { + this.attempt = java.util.Objects.requireNonNull(attempt); + } + + public String getId() { + return java.util.Objects.requireNonNull(id); + } + + public void setId(String id) { + this.id = java.util.Objects.requireNonNull(id); + } + + public String getTestCaseId() { + return java.util.Objects.requireNonNull(testCaseId); + } + + public void setTestCaseId(String testCaseId) { + this.testCaseId = java.util.Objects.requireNonNull(testCaseId); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseStarted that = (TestCaseStarted) o; + return + attempt.equals(that.attempt) && + id.equals(that.id) && + testCaseId.equals(that.testCaseId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + attempt, + id, + testCaseId, + timestamp + ); + } + + @Override + public String toString() { + return "TestCaseStarted{" + + "attempt=" + attempt + + ", id=" + id + + ", testCaseId=" + testCaseId + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class TestRunFinished { + private String message; + private Boolean success; + private Timestamp timestamp; + + public TestRunFinished() {} + + public TestRunFinished( + String message, + Boolean success, + Timestamp timestamp + ) { + this.message = message; + this.success = java.util.Objects.requireNonNull(success); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public java.util.Optional getMessage() { + return java.util.Optional.ofNullable(message); + } + + public void setMessage(String message) { + this.message = message; + } + + public Boolean getSuccess() { + return java.util.Objects.requireNonNull(success); + } + + public void setSuccess(Boolean success) { + this.success = java.util.Objects.requireNonNull(success); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunFinished that = (TestRunFinished) o; + return + java.util.Objects.equals(message, that.message) && + success.equals(that.success) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + message, + success, + timestamp + ); + } + + @Override + public String toString() { + return "TestRunFinished{" + + "message=" + message + + ", success=" + success + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class TestRunStarted { + private Timestamp timestamp; + + public TestRunStarted() {} + + public TestRunStarted( + Timestamp timestamp + ) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunStarted that = (TestRunStarted) o; + return + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + timestamp + ); + } + + @Override + public String toString() { + return "TestRunStarted{" + + "timestamp=" + timestamp + + '}'; + } + } + + + public static class TestStepFinished { + private String testCaseStartedId; + private String testStepId; + private TestStepResult testStepResult; + private Timestamp timestamp; + + public TestStepFinished() {} + + public TestStepFinished( + String testCaseStartedId, + String testStepId, + TestStepResult testStepResult, + Timestamp timestamp + ) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.testStepId = java.util.Objects.requireNonNull(testStepId); + this.testStepResult = java.util.Objects.requireNonNull(testStepResult); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public String getTestCaseStartedId() { + return java.util.Objects.requireNonNull(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + } + + public String getTestStepId() { + return java.util.Objects.requireNonNull(testStepId); + } + + public void setTestStepId(String testStepId) { + this.testStepId = java.util.Objects.requireNonNull(testStepId); + } + + public TestStepResult getTestStepResult() { + return java.util.Objects.requireNonNull(testStepResult); + } + + public void setTestStepResult(TestStepResult testStepResult) { + this.testStepResult = java.util.Objects.requireNonNull(testStepResult); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepFinished that = (TestStepFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + testStepResult.equals(that.testStepResult) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + testCaseStartedId, + testStepId, + testStepResult, + timestamp + ); + } + + @Override + public String toString() { + return "TestStepFinished{" + + "testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", testStepResult=" + testStepResult + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class TestStepResult { + private Duration duration; + private String message; + private TestStepResultStatus status; + + public TestStepResult() {} + + public TestStepResult( + Duration duration, + String message, + TestStepResultStatus status + ) { + this.duration = java.util.Objects.requireNonNull(duration); + this.message = message; + this.status = java.util.Objects.requireNonNull(status); + } + + public Duration getDuration() { + return java.util.Objects.requireNonNull(duration); + } + + public void setDuration(Duration duration) { + this.duration = java.util.Objects.requireNonNull(duration); + } + + public java.util.Optional getMessage() { + return java.util.Optional.ofNullable(message); + } + + public void setMessage(String message) { + this.message = message; + } + + public TestStepResultStatus getStatus() { + return java.util.Objects.requireNonNull(status); + } + + public void setStatus(TestStepResultStatus status) { + this.status = java.util.Objects.requireNonNull(status); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepResult that = (TestStepResult) o; + return + duration.equals(that.duration) && + java.util.Objects.equals(message, that.message) && + status.equals(that.status); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + duration, + message, + status + ); + } + + @Override + public String toString() { + return "TestStepResult{" + + "duration=" + duration + + ", message=" + message + + ", status=" + status + + '}'; + } + } + + + public static class TestStepStarted { + private String testCaseStartedId; + private String testStepId; + private Timestamp timestamp; + + public TestStepStarted() {} + + public TestStepStarted( + String testCaseStartedId, + String testStepId, + Timestamp timestamp + ) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.testStepId = java.util.Objects.requireNonNull(testStepId); + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + public String getTestCaseStartedId() { + return java.util.Objects.requireNonNull(testCaseStartedId); + } + + public void setTestCaseStartedId(String testCaseStartedId) { + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + } + + public String getTestStepId() { + return java.util.Objects.requireNonNull(testStepId); + } + + public void setTestStepId(String testStepId) { + this.testStepId = java.util.Objects.requireNonNull(testStepId); + } + + public Timestamp getTimestamp() { + return java.util.Objects.requireNonNull(timestamp); + } + + public void setTimestamp(Timestamp timestamp) { + this.timestamp = java.util.Objects.requireNonNull(timestamp); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepStarted that = (TestStepStarted) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + testCaseStartedId, + testStepId, + timestamp + ); + } + + @Override + public String toString() { + return "TestStepStarted{" + + "testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", timestamp=" + timestamp + + '}'; + } + } + + + public static class Timestamp { + private Long seconds; + private Long nanos; + + public Timestamp() {} + + public Timestamp( + Long seconds, + Long nanos + ) { + this.seconds = java.util.Objects.requireNonNull(seconds); + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + public Long getSeconds() { + return java.util.Objects.requireNonNull(seconds); + } + + public void setSeconds(Long seconds) { + this.seconds = java.util.Objects.requireNonNull(seconds); + } + + public Long getNanos() { + return java.util.Objects.requireNonNull(nanos); + } + + public void setNanos(Long nanos) { + this.nanos = java.util.Objects.requireNonNull(nanos); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Timestamp that = (Timestamp) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + seconds, + nanos + ); + } + + @Override + public String toString() { + return "Timestamp{" + + "seconds=" + seconds + + ", nanos=" + nanos + + '}'; + } + } + + + public static class UndefinedParameterType { + private String expression; + private String name; + + public UndefinedParameterType() {} + + public UndefinedParameterType( + String expression, + String name + ) { + this.expression = java.util.Objects.requireNonNull(expression); + this.name = java.util.Objects.requireNonNull(name); + } + + public String getExpression() { + return java.util.Objects.requireNonNull(expression); + } + + public void setExpression(String expression) { + this.expression = java.util.Objects.requireNonNull(expression); + } + + public String getName() { + return java.util.Objects.requireNonNull(name); + } + + public void setName(String name) { + this.name = java.util.Objects.requireNonNull(name); + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UndefinedParameterType that = (UndefinedParameterType) o; + return + expression.equals(that.expression) && + name.equals(that.name); + } + + @Override + public int hashCode() { + return java.util.Objects.hash( + expression, + name + ); + } + + @Override + public String toString() { + return "UndefinedParameterType{" + + "expression=" + expression + + ", name=" + name + + '}'; + } + } + + public enum AttachmentContentEncoding { + IDENTITY("IDENTITY"), + BASE64("BASE64"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (AttachmentContentEncoding c: values()) { + CONSTANTS.put(c.value, c); + } + } + + AttachmentContentEncoding(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static AttachmentContentEncoding fromValue(String value) { + AttachmentContentEncoding constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + + public enum SourceMediaType { + TEXT_X_CUCUMBER_GHERKIN_PLAIN("text/x.cucumber.gherkin+plain"), + TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (SourceMediaType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + SourceMediaType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static SourceMediaType fromValue(String value) { + SourceMediaType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + + public enum StepDefinitionPatternType { + CUCUMBER_EXPRESSION("CUCUMBER_EXPRESSION"), + REGULAR_EXPRESSION("REGULAR_EXPRESSION"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (StepDefinitionPatternType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + StepDefinitionPatternType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static StepDefinitionPatternType fromValue(String value) { + StepDefinitionPatternType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + + public enum TestStepResultStatus { + UNKNOWN("UNKNOWN"), + PASSED("PASSED"), + SKIPPED("SKIPPED"), + PENDING("PENDING"), + UNDEFINED("UNDEFINED"), + AMBIGUOUS("AMBIGUOUS"), + FAILED("FAILED"); + + private final String value; + private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); + + static { + for (TestStepResultStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + TestStepResultStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static TestStepResultStatus fromValue(String value) { + TestStepResultStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + } + +} diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index ef3fb36b24..1a1175f315 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import io.cucumber.messages.types.Envelope; import java.io.BufferedReader; import java.io.IOException; @@ -12,6 +11,8 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; +import static io.cucumber.messages.Messages.*; + /** * Iterates over messages read from a stream. Client code should not depend on this class * directly, but rather on a {@code Iterable} object. diff --git a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java index 89a522f25e..a394a8ff15 100644 --- a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java +++ b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java @@ -1,7 +1,6 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Duration; -import io.cucumber.messages.types.Timestamp; +import static io.cucumber.messages.Messages.*; public final class TimeConversion { diff --git a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java index e8d97f2735..334641ae2b 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java @@ -1,11 +1,5 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Attachment; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.Feature; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Location; -import io.cucumber.messages.types.Source; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -13,9 +7,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import static io.cucumber.messages.Messages.*; import static java.util.Collections.emptyList; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -26,14 +22,14 @@ void can_serialise_messages_over_a_stream() throws IOException { List outgoingMessages = new ArrayList<>(); { Envelope envelope = new Envelope(); - envelope.setSource(new Source("hello.feature", "Feature: Hello", Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + envelope.setSource(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); outgoingMessages.add(envelope); } { Envelope envelope = new Envelope(); Attachment attachment = new Attachment(); attachment.setBody("the body"); - attachment.setContentEncoding(Attachment.ContentEncoding.IDENTITY); + attachment.setContentEncoding(AttachmentContentEncoding.IDENTITY); attachment.setMediaType("text/plain"); envelope.setAttachment(attachment); outgoingMessages.add(envelope); diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index 87cbca0242..c982f5f4bd 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -1,8 +1,5 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Attachment; -import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.Source; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; @@ -14,6 +11,7 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; +import static io.cucumber.messages.Messages.*; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -27,7 +25,7 @@ protected MessageWriter makeMessageWriter(OutputStream output) { } @Override - protected Iterable makeMessageIterable(InputStream input) { + protected Iterable makeMessageIterable(InputStream input) { return new NdjsonToMessageIterable(input); } @@ -35,7 +33,7 @@ protected Iterable makeMessageIterable(InputStream input) { void writes_source_envelope() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); MessageWriter writer = makeMessageWriter(output); - writer.write(new Source("uri", "data", Source.MediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + writer.write(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); String json = new String(output.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}\n", json); } @@ -80,7 +78,7 @@ void handles_enums() { Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); - assertEquals(Attachment.ContentEncoding.BASE_64, envelope.getAttachment().get().getContentEncoding()); + assertEquals(AttachmentContentEncoding.BASE64, envelope.getAttachment().get().getContentEncoding()); assertFalse(iterator.hasNext()); } diff --git a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java index 23e4a850d9..b62c38af95 100644 --- a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java @@ -1,9 +1,8 @@ package io.cucumber.messages; -import io.cucumber.messages.types.Duration; -import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; +import static io.cucumber.messages.Messages.*; import static io.cucumber.messages.TimeConversion.durationToJavaDuration; import static io.cucumber.messages.TimeConversion.javaDurationToDuration; import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp; From 2fa22b6e39ba7326da01250129d0b87cfe9f080d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 16:28:22 +0000 Subject: [PATCH 17/63] Fix compile error --- .../src/test/java/io/cucumber/gherkin/MessageVersionTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java index 63eecf708e..efa0771ed1 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.Messages; import org.junit.Test; import static org.junit.Assert.assertNotNull; @@ -10,6 +10,6 @@ public class MessageVersionTest { @Test public void message_library_has_version() { - assertNotNull(Envelope.class.getPackage().getImplementationVersion()); + assertNotNull(Messages.Envelope.class.getPackage().getImplementationVersion()); } } From 4c69c403dc88bf91b5d9d5d24b920d0f5f19e974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 17:40:44 +0000 Subject: [PATCH 18/63] Restore custom code generation with validation --- .../java/io/cucumber/messages/Messages.java | 337 ++++++++++++++++++ messages/jsonschema/scripts/codegen.rb | 1 + .../scripts/templates/java.java.erb | 18 + 3 files changed, 356 insertions(+) diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index bb006a6ce9..094ba78f68 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -98,6 +98,12 @@ public void setUrl(String url) { this.url = url; } + public void validate() { + java.util.Objects.requireNonNull(body); + java.util.Objects.requireNonNull(contentEncoding); + java.util.Objects.requireNonNull(mediaType); + if (source != null) source.validate(); + } @Override public boolean equals(Object o) { @@ -175,6 +181,10 @@ public void setNanos(Long nanos) { this.nanos = java.util.Objects.requireNonNull(nanos); } + public void validate() { + java.util.Objects.requireNonNull(seconds); + java.util.Objects.requireNonNull(nanos); + } @Override public boolean equals(Object o) { @@ -399,6 +409,25 @@ public void setUndefinedParameterType(UndefinedParameterType undefinedParameterT this.undefinedParameterType = undefinedParameterType; } + public void validate() { + if (attachment != null) attachment.validate(); + if (gherkinDocument != null) gherkinDocument.validate(); + if (hook != null) hook.validate(); + if (meta != null) meta.validate(); + if (parameterType != null) parameterType.validate(); + if (parseError != null) parseError.validate(); + if (pickle != null) pickle.validate(); + if (source != null) source.validate(); + if (stepDefinition != null) stepDefinition.validate(); + if (testCase != null) testCase.validate(); + if (testCaseFinished != null) testCaseFinished.validate(); + if (testCaseStarted != null) testCaseStarted.validate(); + if (testRunFinished != null) testRunFinished.validate(); + if (testRunStarted != null) testRunStarted.validate(); + if (testStepFinished != null) testStepFinished.validate(); + if (testStepStarted != null) testStepStarted.validate(); + if (undefinedParameterType != null) undefinedParameterType.validate(); + } @Override public boolean equals(Object o) { @@ -514,6 +543,11 @@ public void setComments(java.util.List comments) { this.comments = java.util.Objects.requireNonNull(comments); } + public void validate() { + if (feature != null) feature.validate(); + java.util.Objects.requireNonNull(comments); + comments.forEach(Comment::validate); + } @Override public boolean equals(Object o) { @@ -620,6 +654,16 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(keyword); + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(description); + java.util.Objects.requireNonNull(steps); + steps.forEach(Step::validate); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -691,6 +735,11 @@ public void setText(String text) { this.text = java.util.Objects.requireNonNull(text); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(text); + } @Override public boolean equals(Object o) { @@ -750,6 +799,12 @@ public void setRows(java.util.List rows) { this.rows = java.util.Objects.requireNonNull(rows); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(rows); + rows.forEach(TableRow::validate); + } @Override public boolean equals(Object o) { @@ -831,6 +886,12 @@ public void setDelimiter(String delimiter) { this.delimiter = java.util.Objects.requireNonNull(delimiter); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(content); + java.util.Objects.requireNonNull(delimiter); + } @Override public boolean equals(Object o) { @@ -962,6 +1023,19 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(tags); + tags.forEach(Tag::validate); + java.util.Objects.requireNonNull(keyword); + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(description); + if (tableHeader != null) tableHeader.validate(); + java.util.Objects.requireNonNull(tableBody); + tableBody.forEach(TableRow::validate); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -1094,6 +1168,18 @@ public void setChildren(java.util.List children) { this.children = java.util.Objects.requireNonNull(children); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(tags); + tags.forEach(Tag::validate); + java.util.Objects.requireNonNull(language); + java.util.Objects.requireNonNull(keyword); + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(description); + java.util.Objects.requireNonNull(children); + children.forEach(FeatureChild::validate); + } @Override public boolean equals(Object o) { @@ -1179,6 +1265,11 @@ public void setScenario(Scenario scenario) { this.scenario = scenario; } + public void validate() { + if (rule != null) rule.validate(); + if (background != null) background.validate(); + if (scenario != null) scenario.validate(); + } @Override public boolean equals(Object o) { @@ -1296,6 +1387,18 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(tags); + tags.forEach(Tag::validate); + java.util.Objects.requireNonNull(keyword); + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(description); + java.util.Objects.requireNonNull(children); + children.forEach(RuleChild::validate); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -1370,6 +1473,10 @@ public void setScenario(Scenario scenario) { this.scenario = scenario; } + public void validate() { + if (background != null) background.validate(); + if (scenario != null) scenario.validate(); + } @Override public boolean equals(Object o) { @@ -1495,6 +1602,20 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(tags); + tags.forEach(Tag::validate); + java.util.Objects.requireNonNull(keyword); + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(description); + java.util.Objects.requireNonNull(steps); + steps.forEach(Step::validate); + java.util.Objects.requireNonNull(examples); + examples.forEach(Examples::validate); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -1616,6 +1737,15 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(keyword); + java.util.Objects.requireNonNull(text); + if (docString != null) docString.validate(); + if (dataTable != null) dataTable.validate(); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -1687,6 +1817,11 @@ public void setValue(String value) { this.value = java.util.Objects.requireNonNull(value); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(value); + } @Override public boolean equals(Object o) { @@ -1757,6 +1892,13 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(cells); + cells.forEach(TableCell::validate); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -1830,6 +1972,12 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(location); + location.validate(); + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -1903,6 +2051,11 @@ public void setTagExpression(String tagExpression) { this.tagExpression = tagExpression; } + public void validate() { + java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(sourceReference); + sourceReference.validate(); + } @Override public boolean equals(Object o) { @@ -1965,6 +2118,9 @@ public void setColumn(Long column) { this.column = column; } + public void validate() { + java.util.Objects.requireNonNull(line); + } @Override public boolean equals(Object o) { @@ -2068,6 +2224,18 @@ public void setCi(Ci ci) { this.ci = ci; } + public void validate() { + java.util.Objects.requireNonNull(protocolVersion); + java.util.Objects.requireNonNull(implementation); + implementation.validate(); + java.util.Objects.requireNonNull(runtime); + runtime.validate(); + java.util.Objects.requireNonNull(os); + os.validate(); + java.util.Objects.requireNonNull(cpu); + cpu.validate(); + if (ci != null) ci.validate(); + } @Override public boolean equals(Object o) { @@ -2161,6 +2329,10 @@ public void setGit(Git git) { this.git = git; } + public void validate() { + java.util.Objects.requireNonNull(name); + if (git != null) git.validate(); + } @Override public boolean equals(Object o) { @@ -2248,6 +2420,10 @@ public void setTag(String tag) { this.tag = tag; } + public void validate() { + java.util.Objects.requireNonNull(remote); + java.util.Objects.requireNonNull(revision); + } @Override public boolean equals(Object o) { @@ -2313,6 +2489,9 @@ public void setVersion(String version) { this.version = version; } + public void validate() { + java.util.Objects.requireNonNull(name); + } @Override public boolean equals(Object o) { @@ -2405,6 +2584,14 @@ public void setId(String id) { this.id = java.util.Objects.requireNonNull(id); } + public void validate() { + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(regularExpressions); + regularExpressions.forEach(java.util.Objects::requireNonNull); + java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + java.util.Objects.requireNonNull(useForSnippets); + java.util.Objects.requireNonNull(id); + } @Override public boolean equals(Object o) { @@ -2473,6 +2660,11 @@ public void setMessage(String message) { this.message = java.util.Objects.requireNonNull(message); } + public void validate() { + java.util.Objects.requireNonNull(source); + source.validate(); + java.util.Objects.requireNonNull(message); + } @Override public boolean equals(Object o) { @@ -2587,6 +2779,18 @@ public void setAstNodeIds(java.util.List astNodeIds) { this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); } + public void validate() { + java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(uri); + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(language); + java.util.Objects.requireNonNull(steps); + steps.forEach(PickleStep::validate); + java.util.Objects.requireNonNull(tags); + tags.forEach(PickleTag::validate); + java.util.Objects.requireNonNull(astNodeIds); + astNodeIds.forEach(java.util.Objects::requireNonNull); + } @Override public boolean equals(Object o) { @@ -2661,6 +2865,9 @@ public void setContent(String content) { this.content = java.util.Objects.requireNonNull(content); } + public void validate() { + java.util.Objects.requireNonNull(content); + } @Override public boolean equals(Object o) { @@ -2742,6 +2949,13 @@ public void setText(String text) { this.text = java.util.Objects.requireNonNull(text); } + public void validate() { + if (argument != null) argument.validate(); + java.util.Objects.requireNonNull(astNodeIds); + astNodeIds.forEach(java.util.Objects::requireNonNull); + java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(text); + } @Override public boolean equals(Object o) { @@ -2807,6 +3021,10 @@ public void setDataTable(PickleTable dataTable) { this.dataTable = dataTable; } + public void validate() { + if (docString != null) docString.validate(); + if (dataTable != null) dataTable.validate(); + } @Override public boolean equals(Object o) { @@ -2855,6 +3073,10 @@ public void setRows(java.util.List rows) { this.rows = java.util.Objects.requireNonNull(rows); } + public void validate() { + java.util.Objects.requireNonNull(rows); + rows.forEach(PickleTableRow::validate); + } @Override public boolean equals(Object o) { @@ -2900,6 +3122,9 @@ public void setValue(String value) { this.value = java.util.Objects.requireNonNull(value); } + public void validate() { + java.util.Objects.requireNonNull(value); + } @Override public boolean equals(Object o) { @@ -2945,6 +3170,10 @@ public void setCells(java.util.List cells) { this.cells = java.util.Objects.requireNonNull(cells); } + public void validate() { + java.util.Objects.requireNonNull(cells); + cells.forEach(PickleTableCell::validate); + } @Override public boolean equals(Object o) { @@ -3001,6 +3230,10 @@ public void setAstNodeId(String astNodeId) { this.astNodeId = java.util.Objects.requireNonNull(astNodeId); } + public void validate() { + java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(astNodeId); + } @Override public boolean equals(Object o) { @@ -3071,6 +3304,11 @@ public void setMediaType(SourceMediaType mediaType) { this.mediaType = java.util.Objects.requireNonNull(mediaType); } + public void validate() { + java.util.Objects.requireNonNull(uri); + java.util.Objects.requireNonNull(data); + java.util.Objects.requireNonNull(mediaType); + } @Override public boolean equals(Object o) { @@ -3155,6 +3393,11 @@ public void setLocation(Location location) { this.location = location; } + public void validate() { + if (javaMethod != null) javaMethod.validate(); + if (javaStackTraceElement != null) javaStackTraceElement.validate(); + if (location != null) location.validate(); + } @Override public boolean equals(Object o) { @@ -3231,6 +3474,12 @@ public void setMethodParameterTypes(java.util.List methodParameterTypes) this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); } + public void validate() { + java.util.Objects.requireNonNull(className); + java.util.Objects.requireNonNull(methodName); + java.util.Objects.requireNonNull(methodParameterTypes); + methodParameterTypes.forEach(java.util.Objects::requireNonNull); + } @Override public boolean equals(Object o) { @@ -3304,6 +3553,11 @@ public void setMethodName(String methodName) { this.methodName = java.util.Objects.requireNonNull(methodName); } + public void validate() { + java.util.Objects.requireNonNull(className); + java.util.Objects.requireNonNull(fileName); + java.util.Objects.requireNonNull(methodName); + } @Override public boolean equals(Object o) { @@ -3377,6 +3631,13 @@ public void setSourceReference(SourceReference sourceReference) { this.sourceReference = java.util.Objects.requireNonNull(sourceReference); } + public void validate() { + java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(pattern); + pattern.validate(); + java.util.Objects.requireNonNull(sourceReference); + sourceReference.validate(); + } @Override public boolean equals(Object o) { @@ -3439,6 +3700,10 @@ public void setType(StepDefinitionPatternType type) { this.type = java.util.Objects.requireNonNull(type); } + public void validate() { + java.util.Objects.requireNonNull(source); + java.util.Objects.requireNonNull(type); + } @Override public boolean equals(Object o) { @@ -3509,6 +3774,12 @@ public void setTestSteps(java.util.List testSteps) { this.testSteps = java.util.Objects.requireNonNull(testSteps); } + public void validate() { + java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(pickleId); + java.util.Objects.requireNonNull(testSteps); + testSteps.forEach(TestStep::validate); + } @Override public boolean equals(Object o) { @@ -3582,6 +3853,10 @@ public void setValue(String value) { this.value = value; } + public void validate() { + java.util.Objects.requireNonNull(children); + children.forEach(Group::validate); + } @Override public boolean equals(Object o) { @@ -3644,6 +3919,10 @@ public void setParameterTypeName(String parameterTypeName) { this.parameterTypeName = parameterTypeName; } + public void validate() { + java.util.Objects.requireNonNull(group); + group.validate(); + } @Override public boolean equals(Object o) { @@ -3692,6 +3971,10 @@ public void setStepMatchArguments(java.util.List stepMatchArg this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); } + public void validate() { + java.util.Objects.requireNonNull(stepMatchArguments); + stepMatchArguments.forEach(StepMatchArgument::validate); + } @Override public boolean equals(Object o) { @@ -3781,6 +4064,11 @@ public void setStepMatchArgumentsLists(java.util.List st this.stepMatchArgumentsLists = stepMatchArgumentsLists; } + public void validate() { + java.util.Objects.requireNonNull(id); + if (stepDefinitionIds != null) stepDefinitionIds.forEach(java.util.Objects::requireNonNull); + if (stepMatchArgumentsLists != null) stepMatchArgumentsLists.forEach(StepMatchArgumentsList::validate); + } @Override public boolean equals(Object o) { @@ -3860,6 +4148,12 @@ public void setWillBeRetried(Boolean willBeRetried) { this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); } + public void validate() { + java.util.Objects.requireNonNull(testCaseStartedId); + java.util.Objects.requireNonNull(timestamp); + timestamp.validate(); + java.util.Objects.requireNonNull(willBeRetried); + } @Override public boolean equals(Object o) { @@ -3944,6 +4238,13 @@ public void setTimestamp(Timestamp timestamp) { this.timestamp = java.util.Objects.requireNonNull(timestamp); } + public void validate() { + java.util.Objects.requireNonNull(attempt); + java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(testCaseId); + java.util.Objects.requireNonNull(timestamp); + timestamp.validate(); + } @Override public boolean equals(Object o) { @@ -4020,6 +4321,11 @@ public void setTimestamp(Timestamp timestamp) { this.timestamp = java.util.Objects.requireNonNull(timestamp); } + public void validate() { + java.util.Objects.requireNonNull(success); + java.util.Objects.requireNonNull(timestamp); + timestamp.validate(); + } @Override public boolean equals(Object o) { @@ -4071,6 +4377,10 @@ public void setTimestamp(Timestamp timestamp) { this.timestamp = java.util.Objects.requireNonNull(timestamp); } + public void validate() { + java.util.Objects.requireNonNull(timestamp); + timestamp.validate(); + } @Override public boolean equals(Object o) { @@ -4149,6 +4459,14 @@ public void setTimestamp(Timestamp timestamp) { this.timestamp = java.util.Objects.requireNonNull(timestamp); } + public void validate() { + java.util.Objects.requireNonNull(testCaseStartedId); + java.util.Objects.requireNonNull(testStepId); + java.util.Objects.requireNonNull(testStepResult); + testStepResult.validate(); + java.util.Objects.requireNonNull(timestamp); + timestamp.validate(); + } @Override public boolean equals(Object o) { @@ -4225,6 +4543,11 @@ public void setStatus(TestStepResultStatus status) { this.status = java.util.Objects.requireNonNull(status); } + public void validate() { + java.util.Objects.requireNonNull(duration); + duration.validate(); + java.util.Objects.requireNonNull(status); + } @Override public boolean equals(Object o) { @@ -4298,6 +4621,12 @@ public void setTimestamp(Timestamp timestamp) { this.timestamp = java.util.Objects.requireNonNull(timestamp); } + public void validate() { + java.util.Objects.requireNonNull(testCaseStartedId); + java.util.Objects.requireNonNull(testStepId); + java.util.Objects.requireNonNull(timestamp); + timestamp.validate(); + } @Override public boolean equals(Object o) { @@ -4360,6 +4689,10 @@ public void setNanos(Long nanos) { this.nanos = java.util.Objects.requireNonNull(nanos); } + public void validate() { + java.util.Objects.requireNonNull(seconds); + java.util.Objects.requireNonNull(nanos); + } @Override public boolean equals(Object o) { @@ -4419,6 +4752,10 @@ public void setName(String name) { this.name = java.util.Objects.requireNonNull(name); } + public void validate() { + java.util.Objects.requireNonNull(expression); + java.util.Objects.requireNonNull(name); + } @Override public boolean equals(Object o) { diff --git a/messages/jsonschema/scripts/codegen.rb b/messages/jsonschema/scripts/codegen.rb index f1f903afe7..65957d05df 100644 --- a/messages/jsonschema/scripts/codegen.rb +++ b/messages/jsonschema/scripts/codegen.rb @@ -51,6 +51,7 @@ def add_schema(key, schema) end def native_type?(type_name) + STDERR.puts "NATIVE #{type_name}" @language_type_by_schema_type.values.include?(type_name) end diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index f2bc0f6b52..98330fc5e8 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -40,6 +40,24 @@ <%- end -%> <%- end -%> + public void validate() { + <%- schema['properties'].each do |property_name, property| + required = (schema['required'] || []).index(property_name) + -%> + <%- if required -%> + java.util.Objects.requireNonNull(<%= property_name -%>); + <%- end -%> + <%- if property['type'] == 'array' -%> + <%- if property['items']['type'] -%> + <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(java.util.Objects::requireNonNull); + <%- else -%> + <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(<%= type_for(key, nil, property['items']) %>::validate); + <%- end -%> + <%- elsif property['$ref'] -%> + <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.validate(); + <%- end -%> + <%- end -%> + } @Override public boolean equals(Object o) { From 1486592bb3b4735903a8195f8e743c7f02181bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 17:44:45 +0000 Subject: [PATCH 19/63] Expand imports --- .../main/java/io/cucumber/gherkin/Gherkin.java | 8 +++++++- .../cucumber/gherkin/GherkinDocumentBuilder.java | 16 +++++++++++++++- .../src/main/java/io/cucumber/gherkin/Main.java | 2 +- .../gherkin/GherkinDocumentBuilderTest.java | 6 +++++- .../java/io/cucumber/gherkin/GherkinTest.java | 7 ++++++- .../java/io/cucumber/gherkin/ParserTest.java | 2 +- .../java/io/cucumber/htmlformatter/Main.java | 3 ++- .../htmlformatter/MessagesToHtmlWriter.java | 4 ++-- .../htmlformatter/MessagesToHtmlWriterTest.java | 4 +++- 9 files changed, 42 insertions(+), 10 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index fbd0f28722..014a0186c9 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -14,8 +14,14 @@ import java.util.function.Function; import java.util.stream.Stream; +import static io.cucumber.messages.Messages.Envelope; +import static io.cucumber.messages.Messages.GherkinDocument; +import static io.cucumber.messages.Messages.ParseError; +import static io.cucumber.messages.Messages.Pickle; +import static io.cucumber.messages.Messages.Source; +import static io.cucumber.messages.Messages.SourceMediaType; +import static io.cucumber.messages.Messages.SourceReference; import static java.util.Collections.emptyList; -import static io.cucumber.messages.Messages.*; /** * Main entry point for the Gherkin library diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index 4ea2aee790..78663f139e 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -9,10 +9,24 @@ import java.util.List; import java.util.stream.Collectors; -import static io.cucumber.messages.Messages.*; import static io.cucumber.gherkin.Parser.Builder; import static io.cucumber.gherkin.Parser.RuleType; import static io.cucumber.gherkin.Parser.TokenType; +import static io.cucumber.messages.Messages.Background; +import static io.cucumber.messages.Messages.Comment; +import static io.cucumber.messages.Messages.DataTable; +import static io.cucumber.messages.Messages.DocString; +import static io.cucumber.messages.Messages.Examples; +import static io.cucumber.messages.Messages.Feature; +import static io.cucumber.messages.Messages.FeatureChild; +import static io.cucumber.messages.Messages.GherkinDocument; +import static io.cucumber.messages.Messages.Rule; +import static io.cucumber.messages.Messages.RuleChild; +import static io.cucumber.messages.Messages.Scenario; +import static io.cucumber.messages.Messages.Step; +import static io.cucumber.messages.Messages.TableCell; +import static io.cucumber.messages.Messages.TableRow; +import static io.cucumber.messages.Messages.Tag; public class GherkinDocumentBuilder implements Builder { private final IdGenerator idGenerator; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java index e60e41a3fe..d7f4ece34f 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java @@ -9,7 +9,7 @@ import java.util.List; import java.util.stream.Stream; -import static io.cucumber.messages.Messages.*; +import static io.cucumber.messages.Messages.Envelope; import static java.util.Arrays.asList; public class Main { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index 8751f14df6..de74da34c2 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -6,7 +6,11 @@ import java.util.List; -import static io.cucumber.messages.Messages.*; +import static io.cucumber.messages.Messages.Comment; +import static io.cucumber.messages.Messages.FeatureChild; +import static io.cucumber.messages.Messages.GherkinDocument; +import static io.cucumber.messages.Messages.Pickle; +import static io.cucumber.messages.Messages.TableRow; import static org.junit.Assert.assertEquals; public class GherkinDocumentBuilderTest { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java index fde2a60bb2..28ce13f796 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java @@ -6,8 +6,13 @@ import java.util.List; import java.util.stream.Collectors; -import static io.cucumber.messages.Messages.*; import static io.cucumber.gherkin.Gherkin.makeSourceEnvelope; +import static io.cucumber.messages.Messages.Envelope; +import static io.cucumber.messages.Messages.Feature; +import static io.cucumber.messages.Messages.GherkinDocument; +import static io.cucumber.messages.Messages.Pickle; +import static io.cucumber.messages.Messages.PickleStep; +import static io.cucumber.messages.Messages.Scenario; import static java.util.Collections.singletonList; import static org.junit.Assert.assertEquals; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index b3d20996fa..d0e26679a5 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -1,9 +1,9 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; -import static io.cucumber.messages.Messages.*; import org.junit.Test; +import static io.cucumber.messages.Messages.GherkinDocument; import static org.junit.Assert.assertEquals; public class ParserTest { diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java index 167afbf18b..5c3d4ef294 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java @@ -1,7 +1,8 @@ package io.cucumber.htmlformatter; import io.cucumber.messages.NdjsonToMessageIterable; -import static io.cucumber.messages.Messages.*; + +import static io.cucumber.messages.Messages.Envelope; import java.io.OutputStreamWriter; diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index fca9b7278c..caf80edaa3 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -11,7 +11,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; -import static io.cucumber.messages.Messages.*; +import static io.cucumber.messages.Messages.Envelope; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; @@ -79,7 +79,7 @@ public void write(Envelope envelope) throws IOException { */ @Override public void close() throws IOException { - if(streamClosed){ + if (streamClosed) { return; } diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index b4d6abcfe3..b92fea8198 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -9,7 +9,9 @@ import java.io.OutputStreamWriter; import java.time.Instant; -import static io.cucumber.messages.Messages.*; +import static io.cucumber.messages.Messages.Envelope; +import static io.cucumber.messages.Messages.TestRunFinished; +import static io.cucumber.messages.Messages.TestRunStarted; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; From f393af5c28ba7777dbe53339c5a06fc7d3d4bc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 19:19:52 +0000 Subject: [PATCH 20/63] Test validate() --- .../java/io/cucumber/messages/Messages.java | 1122 ++++++++--------- .../io/cucumber/messages/MessagesTest.java | 19 + .../scripts/templates/java.java.erb | 10 +- 3 files changed, 585 insertions(+), 566 deletions(-) create mode 100644 messages/java/src/test/java/io/cucumber/messages/MessagesTest.java diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 094ba78f68..22b90e4afe 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -24,10 +24,10 @@ public Attachment( String testStepId, String url ) { - this.body = java.util.Objects.requireNonNull(body); - this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); + this.body = java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); + this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); this.fileName = fileName; - this.mediaType = java.util.Objects.requireNonNull(mediaType); + this.mediaType = java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); this.source = source; this.testCaseStartedId = testCaseStartedId; this.testStepId = testStepId; @@ -35,19 +35,19 @@ public Attachment( } public String getBody() { - return java.util.Objects.requireNonNull(body); + return java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); } public void setBody(String body) { - this.body = java.util.Objects.requireNonNull(body); + this.body = java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); } public AttachmentContentEncoding getContentEncoding() { - return java.util.Objects.requireNonNull(contentEncoding); + return java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); } public void setContentEncoding(AttachmentContentEncoding contentEncoding) { - this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding); + this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); } public java.util.Optional getFileName() { @@ -59,11 +59,11 @@ public void setFileName(String fileName) { } public String getMediaType() { - return java.util.Objects.requireNonNull(mediaType); + return java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); } public void setMediaType(String mediaType) { - this.mediaType = java.util.Objects.requireNonNull(mediaType); + this.mediaType = java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); } public java.util.Optional getSource() { @@ -99,9 +99,9 @@ public void setUrl(String url) { } public void validate() { - java.util.Objects.requireNonNull(body); - java.util.Objects.requireNonNull(contentEncoding); - java.util.Objects.requireNonNull(mediaType); + java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); + java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); + java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); if (source != null) source.validate(); } @@ -161,29 +161,29 @@ public Duration( Long seconds, Long nanos ) { - this.seconds = java.util.Objects.requireNonNull(seconds); - this.nanos = java.util.Objects.requireNonNull(nanos); + this.seconds = java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); + this.nanos = java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); } public Long getSeconds() { - return java.util.Objects.requireNonNull(seconds); + return java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); } public void setSeconds(Long seconds) { - this.seconds = java.util.Objects.requireNonNull(seconds); + this.seconds = java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); } public Long getNanos() { - return java.util.Objects.requireNonNull(nanos); + return java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); } public void setNanos(Long nanos) { - this.nanos = java.util.Objects.requireNonNull(nanos); + this.nanos = java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(seconds); - java.util.Objects.requireNonNull(nanos); + java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); + java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); } @Override @@ -516,7 +516,7 @@ public GherkinDocument( ) { this.uri = uri; this.feature = feature; - this.comments = java.util.Objects.requireNonNull(comments); + this.comments = java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); } public java.util.Optional getUri() { @@ -536,16 +536,16 @@ public void setFeature(Feature feature) { } public java.util.List getComments() { - return java.util.Objects.requireNonNull(comments); + return java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); } public void setComments(java.util.List comments) { - this.comments = java.util.Objects.requireNonNull(comments); + this.comments = java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); } public void validate() { if (feature != null) feature.validate(); - java.util.Objects.requireNonNull(comments); + java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); comments.forEach(Comment::validate); } @@ -598,71 +598,71 @@ public Background( java.util.List steps, String id ) { - this.location = java.util.Objects.requireNonNull(location); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.steps = java.util.Objects.requireNonNull(steps); - this.id = java.util.Objects.requireNonNull(id); + this.location = java.util.Objects.requireNonNull(location, "Background.location cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Background.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Background.description cannot be null"); + this.steps = java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "Background.id cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Background.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Background.location cannot be null"); } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); + return java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); } public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); + this.keyword = java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Background.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Background.name cannot be null"); } public String getDescription() { - return java.util.Objects.requireNonNull(description); + return java.util.Objects.requireNonNull(description, "Background.description cannot be null"); } public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); + this.description = java.util.Objects.requireNonNull(description, "Background.description cannot be null"); } public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps); + return java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); } public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps); + this.steps = java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Background.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Background.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Background.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(keyword); - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(description); - java.util.Objects.requireNonNull(steps); + java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); + java.util.Objects.requireNonNull(name, "Background.name cannot be null"); + java.util.Objects.requireNonNull(description, "Background.description cannot be null"); + java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); steps.forEach(Step::validate); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(id, "Background.id cannot be null"); } @Override @@ -715,30 +715,30 @@ public Comment( Location location, String text ) { - this.location = java.util.Objects.requireNonNull(location); - this.text = java.util.Objects.requireNonNull(text); + this.location = java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); + this.text = java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); } public String getText() { - return java.util.Objects.requireNonNull(text); + return java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); } public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text); + this.text = java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(text); + java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); } @Override @@ -779,30 +779,30 @@ public DataTable( Location location, java.util.List rows ) { - this.location = java.util.Objects.requireNonNull(location); - this.rows = java.util.Objects.requireNonNull(rows); + this.location = java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); + this.rows = java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); } public java.util.List getRows() { - return java.util.Objects.requireNonNull(rows); + return java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); } public void setRows(java.util.List rows) { - this.rows = java.util.Objects.requireNonNull(rows); + this.rows = java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(rows); + java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); rows.forEach(TableRow::validate); } @@ -848,18 +848,18 @@ public DocString( String content, String delimiter ) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content); - this.delimiter = java.util.Objects.requireNonNull(delimiter); + this.content = java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); + this.delimiter = java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); } public java.util.Optional getMediaType() { @@ -871,26 +871,26 @@ public void setMediaType(String mediaType) { } public String getContent() { - return java.util.Objects.requireNonNull(content); + return java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); } public void setContent(String content) { - this.content = java.util.Objects.requireNonNull(content); + this.content = java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); } public String getDelimiter() { - return java.util.Objects.requireNonNull(delimiter); + return java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); } public void setDelimiter(String delimiter) { - this.delimiter = java.util.Objects.requireNonNull(delimiter); + this.delimiter = java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(content); - java.util.Objects.requireNonNull(delimiter); + java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); + java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); } @Override @@ -949,54 +949,54 @@ public Examples( java.util.List tableBody, String id ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); + this.location = java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); + this.tags = java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); this.tableHeader = tableHeader; - this.tableBody = java.util.Objects.requireNonNull(tableBody); - this.id = java.util.Objects.requireNonNull(id); + this.tableBody = java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); + return java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); } public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); + this.tags = java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); + return java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); } public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); + this.keyword = java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); } public String getDescription() { - return java.util.Objects.requireNonNull(description); + return java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); } public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); + this.description = java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); } public java.util.Optional getTableHeader() { @@ -1008,33 +1008,33 @@ public void setTableHeader(TableRow tableHeader) { } public java.util.List getTableBody() { - return java.util.Objects.requireNonNull(tableBody); + return java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); } public void setTableBody(java.util.List tableBody) { - this.tableBody = java.util.Objects.requireNonNull(tableBody); + this.tableBody = java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(tags); + java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(keyword); - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(description); + java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); + java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); + java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); if (tableHeader != null) tableHeader.validate(); - java.util.Objects.requireNonNull(tableBody); + java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); tableBody.forEach(TableRow::validate); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); } @Override @@ -1103,81 +1103,81 @@ public Feature( String description, java.util.List children ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.language = java.util.Objects.requireNonNull(language); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.children = java.util.Objects.requireNonNull(children); + this.location = java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); + this.tags = java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); + this.language = java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); + this.children = java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); + return java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); } public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); + this.tags = java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); } public String getLanguage() { - return java.util.Objects.requireNonNull(language); + return java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); } public void setLanguage(String language) { - this.language = java.util.Objects.requireNonNull(language); + this.language = java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); + return java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); } public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); + this.keyword = java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); } public String getDescription() { - return java.util.Objects.requireNonNull(description); + return java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); } public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); + this.description = java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); } public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children); + return java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); } public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children); + this.children = java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(tags); + java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(language); - java.util.Objects.requireNonNull(keyword); - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(description); - java.util.Objects.requireNonNull(children); + java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); + java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); + java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); + java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); + java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); children.forEach(FeatureChild::validate); } @@ -1322,82 +1322,82 @@ public Rule( java.util.List children, String id ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.children = java.util.Objects.requireNonNull(children); - this.id = java.util.Objects.requireNonNull(id); + this.location = java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); + this.tags = java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); + this.children = java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); + return java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); } public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); + this.tags = java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); + return java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); } public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); + this.keyword = java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); } public String getDescription() { - return java.util.Objects.requireNonNull(description); + return java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); } public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); + this.description = java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); } public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children); + return java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); } public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children); + this.children = java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(tags); + java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(keyword); - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(description); - java.util.Objects.requireNonNull(children); + java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); + java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); + java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); + java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); children.forEach(RuleChild::validate); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); } @Override @@ -1528,93 +1528,93 @@ public Scenario( java.util.List examples, String id ) { - this.location = java.util.Objects.requireNonNull(location); - this.tags = java.util.Objects.requireNonNull(tags); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.name = java.util.Objects.requireNonNull(name); - this.description = java.util.Objects.requireNonNull(description); - this.steps = java.util.Objects.requireNonNull(steps); - this.examples = java.util.Objects.requireNonNull(examples); - this.id = java.util.Objects.requireNonNull(id); + this.location = java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); + this.tags = java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); + this.steps = java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); + this.examples = java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); + return java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); } public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); + this.tags = java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); + return java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); } public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); + this.keyword = java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); } public String getDescription() { - return java.util.Objects.requireNonNull(description); + return java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); } public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description); + this.description = java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); } public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps); + return java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); } public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps); + this.steps = java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); } public java.util.List getExamples() { - return java.util.Objects.requireNonNull(examples); + return java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); } public void setExamples(java.util.List examples) { - this.examples = java.util.Objects.requireNonNull(examples); + this.examples = java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(tags); + java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(keyword); - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(description); - java.util.Objects.requireNonNull(steps); + java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); + java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); + java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); + java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); steps.forEach(Step::validate); - java.util.Objects.requireNonNull(examples); + java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); examples.forEach(Examples::validate); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); } @Override @@ -1681,36 +1681,36 @@ public Step( DataTable dataTable, String id ) { - this.location = java.util.Objects.requireNonNull(location); - this.keyword = java.util.Objects.requireNonNull(keyword); - this.text = java.util.Objects.requireNonNull(text); + this.location = java.util.Objects.requireNonNull(location, "Step.location cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); + this.text = java.util.Objects.requireNonNull(text, "Step.text cannot be null"); this.docString = docString; this.dataTable = dataTable; - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Step.id cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Step.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Step.location cannot be null"); } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword); + return java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); } public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword); + this.keyword = java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); } public String getText() { - return java.util.Objects.requireNonNull(text); + return java.util.Objects.requireNonNull(text, "Step.text cannot be null"); } public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text); + this.text = java.util.Objects.requireNonNull(text, "Step.text cannot be null"); } public java.util.Optional getDocString() { @@ -1730,21 +1730,21 @@ public void setDataTable(DataTable dataTable) { } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Step.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Step.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Step.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(keyword); - java.util.Objects.requireNonNull(text); + java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); + java.util.Objects.requireNonNull(text, "Step.text cannot be null"); if (docString != null) docString.validate(); if (dataTable != null) dataTable.validate(); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(id, "Step.id cannot be null"); } @Override @@ -1797,30 +1797,30 @@ public TableCell( Location location, String value ) { - this.location = java.util.Objects.requireNonNull(location); - this.value = java.util.Objects.requireNonNull(value); + this.location = java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); + this.value = java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); } public String getValue() { - return java.util.Objects.requireNonNull(value); + return java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); } public void setValue(String value) { - this.value = java.util.Objects.requireNonNull(value); + this.value = java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(value); + java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); } @Override @@ -1863,41 +1863,41 @@ public TableRow( java.util.List cells, String id ) { - this.location = java.util.Objects.requireNonNull(location); - this.cells = java.util.Objects.requireNonNull(cells); - this.id = java.util.Objects.requireNonNull(id); + this.location = java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); + this.cells = java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); } public java.util.List getCells() { - return java.util.Objects.requireNonNull(cells); + return java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); } public void setCells(java.util.List cells) { - this.cells = java.util.Objects.requireNonNull(cells); + this.cells = java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(cells); + java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); cells.forEach(TableCell::validate); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); } @Override @@ -1943,40 +1943,40 @@ public Tag( String name, String id ) { - this.location = java.util.Objects.requireNonNull(location); - this.name = java.util.Objects.requireNonNull(name); - this.id = java.util.Objects.requireNonNull(id); + this.location = java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); } public Location getLocation() { - return java.util.Objects.requireNonNull(location); + return java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); } public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location); + this.location = java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(location); + java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); location.validate(); - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); + java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); } @Override @@ -2022,25 +2022,25 @@ public Hook( SourceReference sourceReference, String tagExpression ) { - this.id = java.util.Objects.requireNonNull(id); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + this.id = java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); this.tagExpression = tagExpression; } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); } public SourceReference getSourceReference() { - return java.util.Objects.requireNonNull(sourceReference); + return java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); } public void setSourceReference(SourceReference sourceReference) { - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); } public java.util.Optional getTagExpression() { @@ -2052,8 +2052,8 @@ public void setTagExpression(String tagExpression) { } public void validate() { - java.util.Objects.requireNonNull(id); - java.util.Objects.requireNonNull(sourceReference); + java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); + java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); sourceReference.validate(); } @@ -2098,16 +2098,16 @@ public Location( Long line, Long column ) { - this.line = java.util.Objects.requireNonNull(line); + this.line = java.util.Objects.requireNonNull(line, "Location.line cannot be null"); this.column = column; } public Long getLine() { - return java.util.Objects.requireNonNull(line); + return java.util.Objects.requireNonNull(line, "Location.line cannot be null"); } public void setLine(Long line) { - this.line = java.util.Objects.requireNonNull(line); + this.line = java.util.Objects.requireNonNull(line, "Location.line cannot be null"); } public java.util.Optional getColumn() { @@ -2119,7 +2119,7 @@ public void setColumn(Long column) { } public void validate() { - java.util.Objects.requireNonNull(line); + java.util.Objects.requireNonNull(line, "Location.line cannot be null"); } @Override @@ -2168,52 +2168,52 @@ public Meta( Product cpu, Ci ci ) { - this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); - this.implementation = java.util.Objects.requireNonNull(implementation); - this.runtime = java.util.Objects.requireNonNull(runtime); - this.os = java.util.Objects.requireNonNull(os); - this.cpu = java.util.Objects.requireNonNull(cpu); + this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); + this.implementation = java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); + this.runtime = java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); + this.os = java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); + this.cpu = java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); this.ci = ci; } public String getProtocolVersion() { - return java.util.Objects.requireNonNull(protocolVersion); + return java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); } public void setProtocolVersion(String protocolVersion) { - this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion); + this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); } public Product getImplementation() { - return java.util.Objects.requireNonNull(implementation); + return java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); } public void setImplementation(Product implementation) { - this.implementation = java.util.Objects.requireNonNull(implementation); + this.implementation = java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); } public Product getRuntime() { - return java.util.Objects.requireNonNull(runtime); + return java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); } public void setRuntime(Product runtime) { - this.runtime = java.util.Objects.requireNonNull(runtime); + this.runtime = java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); } public Product getOs() { - return java.util.Objects.requireNonNull(os); + return java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); } public void setOs(Product os) { - this.os = java.util.Objects.requireNonNull(os); + this.os = java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); } public Product getCpu() { - return java.util.Objects.requireNonNull(cpu); + return java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); } public void setCpu(Product cpu) { - this.cpu = java.util.Objects.requireNonNull(cpu); + this.cpu = java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); } public java.util.Optional getCi() { @@ -2225,14 +2225,14 @@ public void setCi(Ci ci) { } public void validate() { - java.util.Objects.requireNonNull(protocolVersion); - java.util.Objects.requireNonNull(implementation); + java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); + java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); implementation.validate(); - java.util.Objects.requireNonNull(runtime); + java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); runtime.validate(); - java.util.Objects.requireNonNull(os); + java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); os.validate(); - java.util.Objects.requireNonNull(cpu); + java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); cpu.validate(); if (ci != null) ci.validate(); } @@ -2291,18 +2291,18 @@ public Ci( String buildNumber, Git git ) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); this.url = url; this.buildNumber = buildNumber; this.git = git; } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); } public java.util.Optional getUrl() { @@ -2330,7 +2330,7 @@ public void setGit(Git git) { } public void validate() { - java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); if (git != null) git.validate(); } @@ -2382,26 +2382,26 @@ public Git( String branch, String tag ) { - this.remote = java.util.Objects.requireNonNull(remote); - this.revision = java.util.Objects.requireNonNull(revision); + this.remote = java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); + this.revision = java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); this.branch = branch; this.tag = tag; } public String getRemote() { - return java.util.Objects.requireNonNull(remote); + return java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); } public void setRemote(String remote) { - this.remote = java.util.Objects.requireNonNull(remote); + this.remote = java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); } public String getRevision() { - return java.util.Objects.requireNonNull(revision); + return java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); } public void setRevision(String revision) { - this.revision = java.util.Objects.requireNonNull(revision); + this.revision = java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); } public java.util.Optional getBranch() { @@ -2421,8 +2421,8 @@ public void setTag(String tag) { } public void validate() { - java.util.Objects.requireNonNull(remote); - java.util.Objects.requireNonNull(revision); + java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); + java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); } @Override @@ -2469,16 +2469,16 @@ public Product( String name, String version ) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Product.name cannot be null"); this.version = version; } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Product.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Product.name cannot be null"); } public java.util.Optional getVersion() { @@ -2490,7 +2490,7 @@ public void setVersion(String version) { } public void validate() { - java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(name, "Product.name cannot be null"); } @Override @@ -2537,60 +2537,60 @@ public ParameterType( Boolean useForSnippets, String id ) { - this.name = java.util.Objects.requireNonNull(name); - this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); - this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); - this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); - this.id = java.util.Objects.requireNonNull(id); + this.name = java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); + this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); + this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); + this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); } public java.util.List getRegularExpressions() { - return java.util.Objects.requireNonNull(regularExpressions); + return java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); } public void setRegularExpressions(java.util.List regularExpressions) { - this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions); + this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); } public Boolean getPreferForRegularExpressionMatch() { - return java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + return java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); } public void setPreferForRegularExpressionMatch(Boolean preferForRegularExpressionMatch) { - this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch); + this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); } public Boolean getUseForSnippets() { - return java.util.Objects.requireNonNull(useForSnippets); + return java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); } public void setUseForSnippets(Boolean useForSnippets) { - this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets); + this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(regularExpressions); - regularExpressions.forEach(java.util.Objects::requireNonNull); - java.util.Objects.requireNonNull(preferForRegularExpressionMatch); - java.util.Objects.requireNonNull(useForSnippets); - java.util.Objects.requireNonNull(id); + java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); + java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); + regularExpressions.forEach(e -> java.util.Objects.requireNonNull(e, "ParameterType.regularExpressions elements cannot be null")); + java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); + java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); + java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); } @Override @@ -2640,30 +2640,30 @@ public ParseError( SourceReference source, String message ) { - this.source = java.util.Objects.requireNonNull(source); - this.message = java.util.Objects.requireNonNull(message); + this.source = java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); + this.message = java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); } public SourceReference getSource() { - return java.util.Objects.requireNonNull(source); + return java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); } public void setSource(SourceReference source) { - this.source = java.util.Objects.requireNonNull(source); + this.source = java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); } public String getMessage() { - return java.util.Objects.requireNonNull(message); + return java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); } public void setMessage(String message) { - this.message = java.util.Objects.requireNonNull(message); + this.message = java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(source); + java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); source.validate(); - java.util.Objects.requireNonNull(message); + java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); } @Override @@ -2714,82 +2714,82 @@ public Pickle( java.util.List tags, java.util.List astNodeIds ) { - this.id = java.util.Objects.requireNonNull(id); - this.uri = java.util.Objects.requireNonNull(uri); - this.name = java.util.Objects.requireNonNull(name); - this.language = java.util.Objects.requireNonNull(language); - this.steps = java.util.Objects.requireNonNull(steps); - this.tags = java.util.Objects.requireNonNull(tags); - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + this.id = java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); + this.uri = java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); + this.language = java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); + this.steps = java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); + this.tags = java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); } public String getUri() { - return java.util.Objects.requireNonNull(uri); + return java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); } public void setUri(String uri) { - this.uri = java.util.Objects.requireNonNull(uri); + this.uri = java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); } public String getLanguage() { - return java.util.Objects.requireNonNull(language); + return java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); } public void setLanguage(String language) { - this.language = java.util.Objects.requireNonNull(language); + this.language = java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); } public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps); + return java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); } public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps); + this.steps = java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags); + return java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); } public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags); + this.tags = java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); } public java.util.List getAstNodeIds() { - return java.util.Objects.requireNonNull(astNodeIds); + return java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); } public void setAstNodeIds(java.util.List astNodeIds) { - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(id); - java.util.Objects.requireNonNull(uri); - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(language); - java.util.Objects.requireNonNull(steps); + java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); + java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); + java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); + java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); + java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); steps.forEach(PickleStep::validate); - java.util.Objects.requireNonNull(tags); + java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); tags.forEach(PickleTag::validate); - java.util.Objects.requireNonNull(astNodeIds); - astNodeIds.forEach(java.util.Objects::requireNonNull); + java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); + astNodeIds.forEach(e -> java.util.Objects.requireNonNull(e, "Pickle.astNodeIds elements cannot be null")); } @Override @@ -2846,7 +2846,7 @@ public PickleDocString( String content ) { this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content); + this.content = java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); } public java.util.Optional getMediaType() { @@ -2858,15 +2858,15 @@ public void setMediaType(String mediaType) { } public String getContent() { - return java.util.Objects.requireNonNull(content); + return java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); } public void setContent(String content) { - this.content = java.util.Objects.requireNonNull(content); + this.content = java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(content); + java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); } @Override @@ -2912,9 +2912,9 @@ public PickleStep( String text ) { this.argument = argument; - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); - this.id = java.util.Objects.requireNonNull(id); - this.text = java.util.Objects.requireNonNull(text); + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); + this.text = java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); } public java.util.Optional getArgument() { @@ -2926,35 +2926,35 @@ public void setArgument(PickleStepArgument argument) { } public java.util.List getAstNodeIds() { - return java.util.Objects.requireNonNull(astNodeIds); + return java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); } public void setAstNodeIds(java.util.List astNodeIds) { - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds); + this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); } public String getText() { - return java.util.Objects.requireNonNull(text); + return java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); } public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text); + this.text = java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); } public void validate() { if (argument != null) argument.validate(); - java.util.Objects.requireNonNull(astNodeIds); - astNodeIds.forEach(java.util.Objects::requireNonNull); - java.util.Objects.requireNonNull(id); - java.util.Objects.requireNonNull(text); + java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); + astNodeIds.forEach(e -> java.util.Objects.requireNonNull(e, "PickleStep.astNodeIds elements cannot be null")); + java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); + java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); } @Override @@ -3062,19 +3062,19 @@ public PickleTable() {} public PickleTable( java.util.List rows ) { - this.rows = java.util.Objects.requireNonNull(rows); + this.rows = java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); } public java.util.List getRows() { - return java.util.Objects.requireNonNull(rows); + return java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); } public void setRows(java.util.List rows) { - this.rows = java.util.Objects.requireNonNull(rows); + this.rows = java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(rows); + java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); rows.forEach(PickleTableRow::validate); } @@ -3111,19 +3111,19 @@ public PickleTableCell() {} public PickleTableCell( String value ) { - this.value = java.util.Objects.requireNonNull(value); + this.value = java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); } public String getValue() { - return java.util.Objects.requireNonNull(value); + return java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); } public void setValue(String value) { - this.value = java.util.Objects.requireNonNull(value); + this.value = java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(value); + java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); } @Override @@ -3159,19 +3159,19 @@ public PickleTableRow() {} public PickleTableRow( java.util.List cells ) { - this.cells = java.util.Objects.requireNonNull(cells); + this.cells = java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); } public java.util.List getCells() { - return java.util.Objects.requireNonNull(cells); + return java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); } public void setCells(java.util.List cells) { - this.cells = java.util.Objects.requireNonNull(cells); + this.cells = java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(cells); + java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); cells.forEach(PickleTableCell::validate); } @@ -3210,29 +3210,29 @@ public PickleTag( String name, String astNodeId ) { - this.name = java.util.Objects.requireNonNull(name); - this.astNodeId = java.util.Objects.requireNonNull(astNodeId); + this.name = java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); + this.astNodeId = java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); } public String getAstNodeId() { - return java.util.Objects.requireNonNull(astNodeId); + return java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); } public void setAstNodeId(String astNodeId) { - this.astNodeId = java.util.Objects.requireNonNull(astNodeId); + this.astNodeId = java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(name); - java.util.Objects.requireNonNull(astNodeId); + java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); + java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); } @Override @@ -3275,39 +3275,39 @@ public Source( String data, SourceMediaType mediaType ) { - this.uri = java.util.Objects.requireNonNull(uri); - this.data = java.util.Objects.requireNonNull(data); - this.mediaType = java.util.Objects.requireNonNull(mediaType); + this.uri = java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); + this.data = java.util.Objects.requireNonNull(data, "Source.data cannot be null"); + this.mediaType = java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); } public String getUri() { - return java.util.Objects.requireNonNull(uri); + return java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); } public void setUri(String uri) { - this.uri = java.util.Objects.requireNonNull(uri); + this.uri = java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); } public String getData() { - return java.util.Objects.requireNonNull(data); + return java.util.Objects.requireNonNull(data, "Source.data cannot be null"); } public void setData(String data) { - this.data = java.util.Objects.requireNonNull(data); + this.data = java.util.Objects.requireNonNull(data, "Source.data cannot be null"); } public SourceMediaType getMediaType() { - return java.util.Objects.requireNonNull(mediaType); + return java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); } public void setMediaType(SourceMediaType mediaType) { - this.mediaType = java.util.Objects.requireNonNull(mediaType); + this.mediaType = java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(uri); - java.util.Objects.requireNonNull(data); - java.util.Objects.requireNonNull(mediaType); + java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); + java.util.Objects.requireNonNull(data, "Source.data cannot be null"); + java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); } @Override @@ -3445,40 +3445,40 @@ public JavaMethod( String methodName, java.util.List methodParameterTypes ) { - this.className = java.util.Objects.requireNonNull(className); - this.methodName = java.util.Objects.requireNonNull(methodName); - this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); + this.className = java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); + this.methodName = java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); + this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); } public String getClassName() { - return java.util.Objects.requireNonNull(className); + return java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); } public void setClassName(String className) { - this.className = java.util.Objects.requireNonNull(className); + this.className = java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); } public String getMethodName() { - return java.util.Objects.requireNonNull(methodName); + return java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); } public void setMethodName(String methodName) { - this.methodName = java.util.Objects.requireNonNull(methodName); + this.methodName = java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); } public java.util.List getMethodParameterTypes() { - return java.util.Objects.requireNonNull(methodParameterTypes); + return java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); } public void setMethodParameterTypes(java.util.List methodParameterTypes) { - this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes); + this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(className); - java.util.Objects.requireNonNull(methodName); - java.util.Objects.requireNonNull(methodParameterTypes); - methodParameterTypes.forEach(java.util.Objects::requireNonNull); + java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); + java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); + java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); + methodParameterTypes.forEach(e -> java.util.Objects.requireNonNull(e, "JavaMethod.methodParameterTypes elements cannot be null")); } @Override @@ -3524,39 +3524,39 @@ public JavaStackTraceElement( String fileName, String methodName ) { - this.className = java.util.Objects.requireNonNull(className); - this.fileName = java.util.Objects.requireNonNull(fileName); - this.methodName = java.util.Objects.requireNonNull(methodName); + this.className = java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); + this.fileName = java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); + this.methodName = java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); } public String getClassName() { - return java.util.Objects.requireNonNull(className); + return java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); } public void setClassName(String className) { - this.className = java.util.Objects.requireNonNull(className); + this.className = java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); } public String getFileName() { - return java.util.Objects.requireNonNull(fileName); + return java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); } public void setFileName(String fileName) { - this.fileName = java.util.Objects.requireNonNull(fileName); + this.fileName = java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); } public String getMethodName() { - return java.util.Objects.requireNonNull(methodName); + return java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); } public void setMethodName(String methodName) { - this.methodName = java.util.Objects.requireNonNull(methodName); + this.methodName = java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(className); - java.util.Objects.requireNonNull(fileName); - java.util.Objects.requireNonNull(methodName); + java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); + java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); + java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); } @Override @@ -3602,40 +3602,40 @@ public StepDefinition( StepDefinitionPattern pattern, SourceReference sourceReference ) { - this.id = java.util.Objects.requireNonNull(id); - this.pattern = java.util.Objects.requireNonNull(pattern); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + this.id = java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); + this.pattern = java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); } public StepDefinitionPattern getPattern() { - return java.util.Objects.requireNonNull(pattern); + return java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); } public void setPattern(StepDefinitionPattern pattern) { - this.pattern = java.util.Objects.requireNonNull(pattern); + this.pattern = java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); } public SourceReference getSourceReference() { - return java.util.Objects.requireNonNull(sourceReference); + return java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); } public void setSourceReference(SourceReference sourceReference) { - this.sourceReference = java.util.Objects.requireNonNull(sourceReference); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(id); - java.util.Objects.requireNonNull(pattern); + java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); + java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); pattern.validate(); - java.util.Objects.requireNonNull(sourceReference); + java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); sourceReference.validate(); } @@ -3680,29 +3680,29 @@ public StepDefinitionPattern( String source, StepDefinitionPatternType type ) { - this.source = java.util.Objects.requireNonNull(source); - this.type = java.util.Objects.requireNonNull(type); + this.source = java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); + this.type = java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); } public String getSource() { - return java.util.Objects.requireNonNull(source); + return java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); } public void setSource(String source) { - this.source = java.util.Objects.requireNonNull(source); + this.source = java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); } public StepDefinitionPatternType getType() { - return java.util.Objects.requireNonNull(type); + return java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); } public void setType(StepDefinitionPatternType type) { - this.type = java.util.Objects.requireNonNull(type); + this.type = java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(source); - java.util.Objects.requireNonNull(type); + java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); + java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); } @Override @@ -3745,39 +3745,39 @@ public TestCase( String pickleId, java.util.List testSteps ) { - this.id = java.util.Objects.requireNonNull(id); - this.pickleId = java.util.Objects.requireNonNull(pickleId); - this.testSteps = java.util.Objects.requireNonNull(testSteps); + this.id = java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); + this.pickleId = java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); + this.testSteps = java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); } public String getPickleId() { - return java.util.Objects.requireNonNull(pickleId); + return java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); } public void setPickleId(String pickleId) { - this.pickleId = java.util.Objects.requireNonNull(pickleId); + this.pickleId = java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); } public java.util.List getTestSteps() { - return java.util.Objects.requireNonNull(testSteps); + return java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); } public void setTestSteps(java.util.List testSteps) { - this.testSteps = java.util.Objects.requireNonNull(testSteps); + this.testSteps = java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(id); - java.util.Objects.requireNonNull(pickleId); - java.util.Objects.requireNonNull(testSteps); + java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); + java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); + java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); testSteps.forEach(TestStep::validate); } @@ -3824,17 +3824,17 @@ public Group( Long start, String value ) { - this.children = java.util.Objects.requireNonNull(children); + this.children = java.util.Objects.requireNonNull(children, "Group.children cannot be null"); this.start = start; this.value = value; } public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children); + return java.util.Objects.requireNonNull(children, "Group.children cannot be null"); } public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children); + this.children = java.util.Objects.requireNonNull(children, "Group.children cannot be null"); } public java.util.Optional getStart() { @@ -3854,7 +3854,7 @@ public void setValue(String value) { } public void validate() { - java.util.Objects.requireNonNull(children); + java.util.Objects.requireNonNull(children, "Group.children cannot be null"); children.forEach(Group::validate); } @@ -3899,16 +3899,16 @@ public StepMatchArgument( Group group, String parameterTypeName ) { - this.group = java.util.Objects.requireNonNull(group); + this.group = java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); this.parameterTypeName = parameterTypeName; } public Group getGroup() { - return java.util.Objects.requireNonNull(group); + return java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); } public void setGroup(Group group) { - this.group = java.util.Objects.requireNonNull(group); + this.group = java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); } public java.util.Optional getParameterTypeName() { @@ -3920,7 +3920,7 @@ public void setParameterTypeName(String parameterTypeName) { } public void validate() { - java.util.Objects.requireNonNull(group); + java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); group.validate(); } @@ -3960,19 +3960,19 @@ public StepMatchArgumentsList() {} public StepMatchArgumentsList( java.util.List stepMatchArguments ) { - this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); + this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); } public java.util.List getStepMatchArguments() { - return java.util.Objects.requireNonNull(stepMatchArguments); + return java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); } public void setStepMatchArguments(java.util.List stepMatchArguments) { - this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments); + this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(stepMatchArguments); + java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); stepMatchArguments.forEach(StepMatchArgument::validate); } @@ -4018,7 +4018,7 @@ public TestStep( java.util.List stepMatchArgumentsLists ) { this.hookId = hookId; - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); this.pickleStepId = pickleStepId; this.stepDefinitionIds = stepDefinitionIds; this.stepMatchArgumentsLists = stepMatchArgumentsLists; @@ -4033,11 +4033,11 @@ public void setHookId(String hookId) { } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); } public java.util.Optional getPickleStepId() { @@ -4065,8 +4065,8 @@ public void setStepMatchArgumentsLists(java.util.List st } public void validate() { - java.util.Objects.requireNonNull(id); - if (stepDefinitionIds != null) stepDefinitionIds.forEach(java.util.Objects::requireNonNull); + java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); + if (stepDefinitionIds != null) stepDefinitionIds.forEach(e -> java.util.Objects.requireNonNull(e, "TestStep.stepDefinitionIds elements cannot be null")); if (stepMatchArgumentsLists != null) stepMatchArgumentsLists.forEach(StepMatchArgumentsList::validate); } @@ -4119,40 +4119,40 @@ public TestCaseFinished( Timestamp timestamp, Boolean willBeRetried ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - this.timestamp = java.util.Objects.requireNonNull(timestamp); - this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); + this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); } public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId); + return java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); } public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); + return java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); } public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); } public Boolean getWillBeRetried() { - return java.util.Objects.requireNonNull(willBeRetried); + return java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); } public void setWillBeRetried(Boolean willBeRetried) { - this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried); + this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(testCaseStartedId); - java.util.Objects.requireNonNull(timestamp); + java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); + java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); timestamp.validate(); - java.util.Objects.requireNonNull(willBeRetried); + java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); } @Override @@ -4200,49 +4200,49 @@ public TestCaseStarted( String testCaseId, Timestamp timestamp ) { - this.attempt = java.util.Objects.requireNonNull(attempt); - this.id = java.util.Objects.requireNonNull(id); - this.testCaseId = java.util.Objects.requireNonNull(testCaseId); - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.attempt = java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); + this.testCaseId = java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); } public Long getAttempt() { - return java.util.Objects.requireNonNull(attempt); + return java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); } public void setAttempt(Long attempt) { - this.attempt = java.util.Objects.requireNonNull(attempt); + this.attempt = java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); } public String getId() { - return java.util.Objects.requireNonNull(id); + return java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); } public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id); + this.id = java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); } public String getTestCaseId() { - return java.util.Objects.requireNonNull(testCaseId); + return java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); } public void setTestCaseId(String testCaseId) { - this.testCaseId = java.util.Objects.requireNonNull(testCaseId); + this.testCaseId = java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); + return java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); } public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(attempt); - java.util.Objects.requireNonNull(id); - java.util.Objects.requireNonNull(testCaseId); - java.util.Objects.requireNonNull(timestamp); + java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); + java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); + java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); + java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); timestamp.validate(); } @@ -4293,8 +4293,8 @@ public TestRunFinished( Timestamp timestamp ) { this.message = message; - this.success = java.util.Objects.requireNonNull(success); - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.success = java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); } public java.util.Optional getMessage() { @@ -4306,24 +4306,24 @@ public void setMessage(String message) { } public Boolean getSuccess() { - return java.util.Objects.requireNonNull(success); + return java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); } public void setSuccess(Boolean success) { - this.success = java.util.Objects.requireNonNull(success); + this.success = java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); + return java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); } public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(success); - java.util.Objects.requireNonNull(timestamp); + java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); + java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); timestamp.validate(); } @@ -4366,19 +4366,19 @@ public TestRunStarted() {} public TestRunStarted( Timestamp timestamp ) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); + return java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); } public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(timestamp); + java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); timestamp.validate(); } @@ -4421,50 +4421,50 @@ public TestStepFinished( TestStepResult testStepResult, Timestamp timestamp ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - this.testStepId = java.util.Objects.requireNonNull(testStepId); - this.testStepResult = java.util.Objects.requireNonNull(testStepResult); - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); + this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); + this.testStepResult = java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); } public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId); + return java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); } public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); } public String getTestStepId() { - return java.util.Objects.requireNonNull(testStepId); + return java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); } public void setTestStepId(String testStepId) { - this.testStepId = java.util.Objects.requireNonNull(testStepId); + this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); } public TestStepResult getTestStepResult() { - return java.util.Objects.requireNonNull(testStepResult); + return java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); } public void setTestStepResult(TestStepResult testStepResult) { - this.testStepResult = java.util.Objects.requireNonNull(testStepResult); + this.testStepResult = java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); + return java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); } public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(testCaseStartedId); - java.util.Objects.requireNonNull(testStepId); - java.util.Objects.requireNonNull(testStepResult); + java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); + java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); + java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); testStepResult.validate(); - java.util.Objects.requireNonNull(timestamp); + java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); timestamp.validate(); } @@ -4514,17 +4514,17 @@ public TestStepResult( String message, TestStepResultStatus status ) { - this.duration = java.util.Objects.requireNonNull(duration); + this.duration = java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); this.message = message; - this.status = java.util.Objects.requireNonNull(status); + this.status = java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); } public Duration getDuration() { - return java.util.Objects.requireNonNull(duration); + return java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); } public void setDuration(Duration duration) { - this.duration = java.util.Objects.requireNonNull(duration); + this.duration = java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); } public java.util.Optional getMessage() { @@ -4536,17 +4536,17 @@ public void setMessage(String message) { } public TestStepResultStatus getStatus() { - return java.util.Objects.requireNonNull(status); + return java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); } public void setStatus(TestStepResultStatus status) { - this.status = java.util.Objects.requireNonNull(status); + this.status = java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(duration); + java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); duration.validate(); - java.util.Objects.requireNonNull(status); + java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); } @Override @@ -4592,39 +4592,39 @@ public TestStepStarted( String testStepId, Timestamp timestamp ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); - this.testStepId = java.util.Objects.requireNonNull(testStepId); - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); + this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); } public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId); + return java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); } public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); } public String getTestStepId() { - return java.util.Objects.requireNonNull(testStepId); + return java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); } public void setTestStepId(String testStepId) { - this.testStepId = java.util.Objects.requireNonNull(testStepId); + this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp); + return java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); } public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(testCaseStartedId); - java.util.Objects.requireNonNull(testStepId); - java.util.Objects.requireNonNull(timestamp); + java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); + java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); + java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); timestamp.validate(); } @@ -4669,29 +4669,29 @@ public Timestamp( Long seconds, Long nanos ) { - this.seconds = java.util.Objects.requireNonNull(seconds); - this.nanos = java.util.Objects.requireNonNull(nanos); + this.seconds = java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); + this.nanos = java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); } public Long getSeconds() { - return java.util.Objects.requireNonNull(seconds); + return java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); } public void setSeconds(Long seconds) { - this.seconds = java.util.Objects.requireNonNull(seconds); + this.seconds = java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); } public Long getNanos() { - return java.util.Objects.requireNonNull(nanos); + return java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); } public void setNanos(Long nanos) { - this.nanos = java.util.Objects.requireNonNull(nanos); + this.nanos = java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(seconds); - java.util.Objects.requireNonNull(nanos); + java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); + java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); } @Override @@ -4732,29 +4732,29 @@ public UndefinedParameterType( String expression, String name ) { - this.expression = java.util.Objects.requireNonNull(expression); - this.name = java.util.Objects.requireNonNull(name); + this.expression = java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); } public String getExpression() { - return java.util.Objects.requireNonNull(expression); + return java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); } public void setExpression(String expression) { - this.expression = java.util.Objects.requireNonNull(expression); + this.expression = java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); } public String getName() { - return java.util.Objects.requireNonNull(name); + return java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); } public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name); + this.name = java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); } public void validate() { - java.util.Objects.requireNonNull(expression); - java.util.Objects.requireNonNull(name); + java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); + java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); } @Override diff --git a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java new file mode 100644 index 0000000000..015a424a33 --- /dev/null +++ b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java @@ -0,0 +1,19 @@ +package io.cucumber.messages; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class MessagesTest { + @Test + void is_invalid_when_required_fields_are_missing() { + Messages.Envelope envelope = new Messages.Envelope(); + envelope.setAttachment(new Messages.Attachment()); + assertThrows(NullPointerException.class, envelope::validate, "Attachment.body cannot be null"); + } + + @Test + void is_valid_when_no_required_fields_are_missing() { + new Messages.Envelope().validate(); + } +} diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 98330fc5e8..9f4b257e78 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -13,7 +13,7 @@ ) { <%- schema['properties'].each_with_index do |(property_name, property), index| -%> <%- if (schema['required'] || []).index(property_name) -%> - this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); + this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); <%- else -%> this.<%= property_name %> = <%= property_name %>; <%- end -%> @@ -23,11 +23,11 @@ <%- schema['properties'].each do |property_name, property| -%> <%- if (schema['required'] || []).index(property_name) -%> public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { - return java.util.Objects.requireNonNull(<%= property_name %>); + return java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); } public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>); + this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); } <%- else -%> public java.util.Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { @@ -45,11 +45,11 @@ required = (schema['required'] || []).index(property_name) -%> <%- if required -%> - java.util.Objects.requireNonNull(<%= property_name -%>); + java.util.Objects.requireNonNull(<%= property_name -%>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); <%- end -%> <%- if property['type'] == 'array' -%> <%- if property['items']['type'] -%> - <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(java.util.Objects::requireNonNull); + <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(e -> java.util.Objects.requireNonNull(e, "<%= class_name(key) %>.<%= property_name %> elements cannot be null")); <%- else -%> <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(<%= type_for(key, nil, property['items']) %>::validate); <%- end -%> From 6289e0c4925d007e151bb85a2ccf54a66e044fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Thu, 6 Jan 2022 19:26:17 +0000 Subject: [PATCH 21/63] Update changelog --- messages/CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/messages/CHANGELOG.md b/messages/CHANGELOG.md index 9844581c40..e7c6198d58 100644 --- a/messages/CHANGELOG.md +++ b/messages/CHANGELOG.md @@ -11,6 +11,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Support for EcmaScript modules (aka ESM) ([#1756](https://github.com/cucumber/common/pull/1756)) +* [Java] Add a `validate()` method to all messages. This will throw a `NullPointerException` + with a detailed message if a `required` field is `null`. This works recursively + for all non-null values (including non-required fields). + Argument constructors, getters and setters also throw `NullPointerException` + if a required `field` is `null`, but they don't validate recursively. + ([#1858](https://github.com/cucumber/common/pull/1858) [aslakhellesoy]) + ### Changed From 5daf24a7bd2c364213d7cb9c52fbfe135d49169d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 12 Jan 2022 21:31:40 +0000 Subject: [PATCH 22/63] Improve generated messages * Setters are removed * Classes without required fields have static fromXxx factory methods for each field * Only classes without required fields have a public constructor --- gherkin/CHANGELOG.md | 2 + gherkin/java/gherkin-java.razor | 32 +- .../io/cucumber/gherkin/GenerateTokens.java | 2 +- .../java/io/cucumber/gherkin/Gherkin.java | 27 +- .../gherkin/GherkinDocumentBuilder.java | 20 +- .../java/io/cucumber/gherkin/GherkinLine.java | 1 - .../main/java/io/cucumber/gherkin/Parser.java | 32 +- .../gherkin/TokenFormatterBuilder.java | 2 +- .../gherkin/pickles/PickleCompiler.java | 33 +- .../gherkin/GherkinDocumentBuilderTest.java | 20 +- .../java/io/cucumber/gherkin/ParserTest.java | 4 +- .../MessagesToHtmlWriterTest.java | 11 +- .../java/io/cucumber/messages/Messages.java | 1860 ++++++----------- .../MessageSerializationContract.java | 25 +- .../io/cucumber/messages/MessagesTest.java | 8 +- .../scripts/templates/java.java.erb | 34 +- 16 files changed, 812 insertions(+), 1301 deletions(-) diff --git a/gherkin/CHANGELOG.md b/gherkin/CHANGELOG.md index 9010d5f792..a185635aa0 100644 --- a/gherkin/CHANGELOG.md +++ b/gherkin/CHANGELOG.md @@ -13,6 +13,8 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt ### Changed +* [Java] the `Parser.parse` methods now require an `uri` parameter to be passed in. + ### Deprecated ### Removed diff --git a/gherkin/java/gherkin-java.razor b/gherkin/java/gherkin-java.razor index ffa07a3dff..d6b7edd4a2 100644 --- a/gherkin/java/gherkin-java.razor +++ b/gherkin/java/gherkin-java.razor @@ -70,7 +70,7 @@ public class @Model.ParserClassName { public boolean stopAtFirstError; - class ParserContext { + static class ParserContext { public final ITokenScanner tokenScanner; public final ITokenMatcher tokenMatcher; public final Queue tokenQueue; @@ -88,35 +88,35 @@ public class @Model.ParserClassName { this.builder = builder; } - public T parse(String source) { - return parse(new StringReader(source)); + public T parse(String source, String uri) { + return parse(new StringReader(source), uri); } - public T parse(Reader source) { - return parse(new TokenScanner(source)); + public T parse(Reader source, String uri) { + return parse(new TokenScanner(source), uri); } - public T parse(ITokenScanner tokenScanner) { - return parse(tokenScanner, new TokenMatcher()); + public T parse(ITokenScanner tokenScanner, String uri) { + return parse(tokenScanner, new TokenMatcher(), uri); } - public T parse(String source, ITokenMatcher tokenMatcher) { - return parse(new StringReader(source), tokenMatcher); + public T parse(String source, ITokenMatcher tokenMatcher, String uri) { + return parse(new StringReader(source), tokenMatcher, uri); } - public T parse(Reader source, ITokenMatcher tokenMatcher) { - return parse(new TokenScanner(source), tokenMatcher); + public T parse(Reader source, ITokenMatcher tokenMatcher, String uri) { + return parse(new TokenScanner(source), tokenMatcher, uri); } - public T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher) { - builder.reset(); + public T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, String uri) { + builder.reset(uri); tokenMatcher.reset(); ParserContext context = new ParserContext( tokenScanner, tokenMatcher, - new LinkedList(), - new ArrayList() + new LinkedList<>(), + new ArrayList<>() ); startRule(context, RuleType.@Model.RuleSet.StartRule.Name); @@ -303,7 +303,7 @@ public class @Model.ParserClassName { void startRule(RuleType ruleType); void endRule(RuleType ruleType); T getResult(); - void reset(); + void reset(String uri); } public interface ITokenScanner { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java index 4c0ff70cb2..23dc7a59f8 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java @@ -13,7 +13,7 @@ public static void main(String[] args) throws FileNotFoundException { TokenMatcher matcher = new TokenMatcher(); for (String fileName : args) { Reader in = new InputStreamReader(new FileInputStream(fileName), StandardCharsets.UTF_8); - String result = parser.parse(in, matcher); + String result = parser.parse(in, matcher, fileName); Stdio.out.print(result); Stdio.out.flush(); // print doesn't autoflush } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index 014a0186c9..f8bbfb9c8a 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -52,9 +52,7 @@ public static Stream fromSources(List envelopes, boolean inc } public static Envelope makeSourceEnvelope(String data, String uri) { - Envelope envelope = new Envelope(); - envelope.setSource(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); - return envelope; + return Envelope.fromSource(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); } public Stream messages() { @@ -106,33 +104,27 @@ private List parseSource(Envelope envelope, boolean includeGherkinDocu } private List parseSource(boolean includeGherkinDocument, boolean includePickles, Source source) { - List messages = new ArrayList<>(); - - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); String uri = source.getUri(); String data = source.getData(); + List messages = new ArrayList<>(); + + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, uri)); try { GherkinDocument gherkinDocument = null; if (includeGherkinDocument) { - gherkinDocument = parser.parse(data); - gherkinDocument.setUri(uri); - Envelope gherkinDocumentEnvelope = new Envelope(); - gherkinDocumentEnvelope.setGherkinDocument(gherkinDocument); - messages.add(gherkinDocumentEnvelope); + gherkinDocument = parser.parse(data, uri); + messages.add(Envelope.fromGherkinDocument(gherkinDocument)); } if (includePickles) { if (gherkinDocument == null) { - gherkinDocument = parser.parse(data); - gherkinDocument.setUri(uri); + gherkinDocument = parser.parse(data, uri); } PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); List pickles = pickleCompiler.compile(gherkinDocument, uri); for (Pickle pickle : pickles) { - Envelope pickleEnvelope = new Envelope(); - pickleEnvelope.setPickle(pickle); - messages.add(pickleEnvelope); + messages.add(Envelope.fromPickle(pickle)); } } } catch (ParserException.CompositeParserException e) { @@ -162,8 +154,7 @@ private void addParseError(List messages, ParserException e, String ur ), e.getMessage() ); - Envelope envelope = new Envelope(); - envelope.setParseError(parseError); + Envelope envelope = Envelope.fromParseError(parseError); messages.add(envelope); } } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index 78663f139e..beca7eb5c1 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -29,21 +29,22 @@ import static io.cucumber.messages.Messages.Tag; public class GherkinDocumentBuilder implements Builder { + private final List comments = new ArrayList<>(); private final IdGenerator idGenerator; + private String uri; private Deque stack; - private GherkinDocument gherkinDocument; - public GherkinDocumentBuilder(IdGenerator idGenerator) { + public GherkinDocumentBuilder(IdGenerator idGenerator, String uri) { this.idGenerator = idGenerator; - reset(); + reset(uri); } @Override - public void reset() { + public void reset(String uri) { + this.uri = uri; stack = new ArrayDeque<>(); stack.push(new AstNode(RuleType.None)); - gherkinDocument = new GherkinDocument(); } private AstNode currentNode() { @@ -55,8 +56,7 @@ public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { Comment comment = new Comment(getLocation(token, 0), token.matchedText); - // TODO: Init list - gherkinDocument.getComments().add(comment); + comments.add(comment); } else { currentNode().add(ruleType, token); } @@ -234,11 +234,7 @@ private Object getTransformedNode(AstNode node) { } case GherkinDocument: { Feature feature = node.getSingle(RuleType.Feature, null); - - if (feature != null) - gherkinDocument.setFeature(feature); - - return gherkinDocument; + return new GherkinDocument(uri, feature, comments); } } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java index 7ed303d254..5c0a01505d 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java @@ -3,7 +3,6 @@ import java.util.ArrayList; import java.util.List; import java.util.PrimitiveIterator; -import java.util.Scanner; import static io.cucumber.gherkin.GherkinLanguageConstants.COMMENT_PREFIX; import static io.cucumber.gherkin.GherkinLanguageConstants.TAG_PREFIX; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java index 5c7509dc1c..4bc0baff5d 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java @@ -81,7 +81,7 @@ public static RuleType cast(TokenType tokenType) { public boolean stopAtFirstError; - class ParserContext { + static class ParserContext { public final ITokenScanner tokenScanner; public final ITokenMatcher tokenMatcher; public final Queue tokenQueue; @@ -99,35 +99,35 @@ public Parser(Builder builder) { this.builder = builder; } - public T parse(String source) { - return parse(new StringReader(source)); + public T parse(String source, String uri) { + return parse(new StringReader(source), uri); } - public T parse(Reader source) { - return parse(new TokenScanner(source)); + public T parse(Reader source, String uri) { + return parse(new TokenScanner(source), uri); } - public T parse(ITokenScanner tokenScanner) { - return parse(tokenScanner, new TokenMatcher()); + public T parse(ITokenScanner tokenScanner, String uri) { + return parse(tokenScanner, new TokenMatcher(), uri); } - public T parse(String source, ITokenMatcher tokenMatcher) { - return parse(new StringReader(source), tokenMatcher); + public T parse(String source, ITokenMatcher tokenMatcher, String uri) { + return parse(new StringReader(source), tokenMatcher, uri); } - public T parse(Reader source, ITokenMatcher tokenMatcher) { - return parse(new TokenScanner(source), tokenMatcher); + public T parse(Reader source, ITokenMatcher tokenMatcher, String uri) { + return parse(new TokenScanner(source), tokenMatcher, uri); } - public T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher) { - builder.reset(); + public T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, String uri) { + builder.reset(uri); tokenMatcher.reset(); ParserContext context = new ParserContext( tokenScanner, tokenMatcher, - new LinkedList(), - new ArrayList() + new LinkedList<>(), + new ArrayList<>() ); startRule(context, RuleType.GherkinDocument); @@ -4764,7 +4764,7 @@ public interface Builder { void startRule(RuleType ruleType); void endRule(RuleType ruleType); T getResult(); - void reset(); + void reset(String uri); } public interface ITokenScanner { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java index 7e9a6b3548..247badaa17 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java @@ -23,6 +23,6 @@ public String getResult() { } @Override - public void reset() { + public void reset(String uri) { } } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java index 02eaca1455..f76f153272 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java @@ -185,25 +185,32 @@ private PickleStep pickleStep(Step step, List variableCells, TableRow List valueCells = valuesRow == null ? Collections.emptyList() : valuesRow.getCells(); String stepText = interpolate(step.getText(), variableCells, valueCells); - PickleStep pickleStep = new PickleStep(); - pickleStep.setId(idGenerator.newId()); - pickleStep.setAstNodeIds(singletonList(step.getId())); - pickleStep.setText(stepText); + PickleStepArgument argument = null; + if (step.getDataTable().isPresent()) { + argument = new PickleStepArgument(null, pickleDataTable(step.getDataTable().get(), variableCells, valueCells)); + } + + if (step.getDocString().isPresent()) { + argument = new PickleStepArgument(pickleDocString(step.getDocString().get(), variableCells, valueCells), null); + } + + + List astNodeIds; if (valuesRow != null) { - List astNodeIds = Stream.of(pickleStep.getAstNodeIds(), singletonList(valuesRow.getId())) + astNodeIds = Stream.of(singletonList(step.getId()), singletonList(valuesRow.getId())) .flatMap(Collection::stream) .collect(Collectors.toList()); - pickleStep.setAstNodeIds(astNodeIds); - } - if (step.getDataTable().isPresent()) { - pickleStep.setArgument(new PickleStepArgument(null, pickleDataTable(step.getDataTable().get(), variableCells, valueCells))); + } else { + astNodeIds = singletonList(step.getId()); } - if (step.getDocString().isPresent()) { - pickleStep.setArgument(new PickleStepArgument(pickleDocString(step.getDocString().get(), variableCells, valueCells), null)); - } - return pickleStep; + return new PickleStep( + argument, + astNodeIds, + idGenerator.newId(), + stepText + ); } private List pickleSteps(List steps) { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index de74da34c2..7de3a975e5 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -18,11 +18,11 @@ public class GherkinDocumentBuilderTest { @Test public void is_reusable() { - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, "test.feature")); TokenMatcher matcher = new TokenMatcher(); - GherkinDocument d1 = parser.parse("Feature: 1", matcher); - GherkinDocument d2 = parser.parse("Feature: 2", matcher); + GherkinDocument d1 = parser.parse("Feature: 1", matcher, "1.feature"); + GherkinDocument d2 = parser.parse("Feature: 2", matcher, "2.feature"); assertEquals("1", d1.getFeature().get().getName()); assertEquals("2", d2.getFeature().get().getName()); @@ -30,7 +30,7 @@ public void is_reusable() { @Test public void parses_rules() { - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, "test.feature")); String data = "" + "Feature: Some rules\n" + "\n" + @@ -51,7 +51,7 @@ public void parses_rules() { "\n" + " Example: Example B\n" + " Given b"; - GherkinDocument doc = parser.parse(data); + GherkinDocument doc = parser.parse(data, "test.feature"); List children = doc.getFeature().get().getChildren(); assertEquals(3, children.size()); @@ -68,21 +68,21 @@ public void parses_rules() { @Test public void parses_just_comments() { - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); - GherkinDocument doc = parser.parse("" + - "# Just a comment"); + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, "test.feature")); + GherkinDocument doc = parser.parse("# Just a comment", "test.feature"); List children = doc.getComments(); assertEquals(1, children.size()); } @Test public void sets_empty_table_cells() { - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, "test.feature")); GherkinDocument doc = parser.parse("" + "Feature:\n" + " Scenario:\n" + " Given a table\n" + - " |a||b|" + " |a||b|", + "test.feature" ); TableRow row = doc.getFeature().get().getChildren().get(0).getScenario().get().getSteps().get(0).getDataTable().get().getRows().get(0); assertEquals("a", row.getCells().get(0).getValue()); diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index d0e26679a5..db529feb88 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -12,9 +12,9 @@ public class ParserTest { public void change_default_language() { TokenMatcher matcher = new TokenMatcher("no"); IdGenerator idGenerator = new IdGenerator.Incrementing(); - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, "test.feature")); - GherkinDocument gherkinDocument = parser.parse("Egenskap: i18n support\n", matcher); + GherkinDocument gherkinDocument = parser.parse("Egenskap: i18n support\n", matcher, "test.feature"); assertEquals("no", gherkinDocument.getFeature().get().getLanguage()); } } diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index b92fea8198..8ef6729b54 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -23,9 +23,8 @@ class MessagesToHtmlWriterTest { @Test void it_writes_one_message_to_html() throws IOException { - Envelope envelope = new Envelope(); Instant timestamp = Instant.ofEpochSecond(10); - envelope.setTestRunStarted(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); + Envelope envelope = Envelope.fromTestRunStarted(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); String html = renderAsHtml(envelope); assertThat(html, containsString("" + "window.CUCUMBER_MESSAGES = [{\"testRunStarted\":{\"timestamp\":{\"seconds\":10,\"nanos\":0}}}];")); @@ -79,13 +78,11 @@ public void close() throws IOException { @Test void it_writes_two_messages_separated_by_a_comma() throws IOException { - Envelope testRunStarted = new Envelope(); - testRunStarted.setTestRunStarted(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); + Envelope testRunStarted = Envelope.fromTestRunStarted(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); - Envelope testRunFinished = new Envelope(); - testRunFinished.setTestRunFinished(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); + Envelope envelope = Envelope.fromTestRunFinished(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); - String html = renderAsHtml(testRunStarted, testRunFinished); + String html = renderAsHtml(testRunStarted, envelope); assertThat(html, containsString("" + "window.CUCUMBER_MESSAGES = [{\"testRunStarted\":{\"timestamp\":{\"seconds\":10,\"nanos\":0}}},{\"testRunFinished\":{\"success\":true,\"timestamp\":{\"seconds\":15,\"nanos\":0}}}];")); diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 22b90e4afe..7a3d8e6892 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -12,7 +12,7 @@ public static class Attachment { private String testStepId; private String url; - public Attachment() {} + private Attachment() {} public Attachment( String body, @@ -24,81 +24,51 @@ public Attachment( String testStepId, String url ) { - this.body = java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); - this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); + this.body = body; + this.contentEncoding = contentEncoding; this.fileName = fileName; - this.mediaType = java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); + this.mediaType = mediaType; this.source = source; this.testCaseStartedId = testCaseStartedId; this.testStepId = testStepId; this.url = url; + validate(); } - public String getBody() { - return java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); - } - public void setBody(String body) { - this.body = java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); + public String getBody() { + return body; } public AttachmentContentEncoding getContentEncoding() { - return java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); - } - - public void setContentEncoding(AttachmentContentEncoding contentEncoding) { - this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); + return contentEncoding; } public java.util.Optional getFileName() { return java.util.Optional.ofNullable(fileName); } - public void setFileName(String fileName) { - this.fileName = fileName; - } - public String getMediaType() { - return java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); - } - - public void setMediaType(String mediaType) { - this.mediaType = java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); + return mediaType; } public java.util.Optional getSource() { return java.util.Optional.ofNullable(source); } - public void setSource(Source source) { - this.source = source; - } - public java.util.Optional getTestCaseStartedId() { return java.util.Optional.ofNullable(testCaseStartedId); } - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = testCaseStartedId; - } - public java.util.Optional getTestStepId() { return java.util.Optional.ofNullable(testStepId); } - public void setTestStepId(String testStepId) { - this.testStepId = testStepId; - } - public java.util.Optional getUrl() { return java.util.Optional.ofNullable(url); } - public void setUrl(String url) { - this.url = url; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); @@ -155,33 +125,27 @@ public static class Duration { private Long seconds; private Long nanos; - public Duration() {} + private Duration() {} public Duration( Long seconds, Long nanos ) { - this.seconds = java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); - this.nanos = java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); + this.seconds = seconds; + this.nanos = nanos; + validate(); } - public Long getSeconds() { - return java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); - } - public void setSeconds(Long seconds) { - this.seconds = java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); + public Long getSeconds() { + return seconds; } public Long getNanos() { - return java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); - } - - public void setNanos(Long nanos) { - this.nanos = java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); + return nanos; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); } @@ -235,6 +199,125 @@ public static class Envelope { public Envelope() {} + public static Envelope fromAttachment(Attachment attachment) { + Envelope o = new Envelope(); + o.attachment = java.util.Objects.requireNonNull(attachment, "Envelope.attachment cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromGherkinDocument(GherkinDocument gherkinDocument) { + Envelope o = new Envelope(); + o.gherkinDocument = java.util.Objects.requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromHook(Hook hook) { + Envelope o = new Envelope(); + o.hook = java.util.Objects.requireNonNull(hook, "Envelope.hook cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromMeta(Meta meta) { + Envelope o = new Envelope(); + o.meta = java.util.Objects.requireNonNull(meta, "Envelope.meta cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromParameterType(ParameterType parameterType) { + Envelope o = new Envelope(); + o.parameterType = java.util.Objects.requireNonNull(parameterType, "Envelope.parameterType cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromParseError(ParseError parseError) { + Envelope o = new Envelope(); + o.parseError = java.util.Objects.requireNonNull(parseError, "Envelope.parseError cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromPickle(Pickle pickle) { + Envelope o = new Envelope(); + o.pickle = java.util.Objects.requireNonNull(pickle, "Envelope.pickle cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromSource(Source source) { + Envelope o = new Envelope(); + o.source = java.util.Objects.requireNonNull(source, "Envelope.source cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromStepDefinition(StepDefinition stepDefinition) { + Envelope o = new Envelope(); + o.stepDefinition = java.util.Objects.requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromTestCase(TestCase testCase) { + Envelope o = new Envelope(); + o.testCase = java.util.Objects.requireNonNull(testCase, "Envelope.testCase cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromTestCaseFinished(TestCaseFinished testCaseFinished) { + Envelope o = new Envelope(); + o.testCaseFinished = java.util.Objects.requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromTestCaseStarted(TestCaseStarted testCaseStarted) { + Envelope o = new Envelope(); + o.testCaseStarted = java.util.Objects.requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromTestRunFinished(TestRunFinished testRunFinished) { + Envelope o = new Envelope(); + o.testRunFinished = java.util.Objects.requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromTestRunStarted(TestRunStarted testRunStarted) { + Envelope o = new Envelope(); + o.testRunStarted = java.util.Objects.requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromTestStepFinished(TestStepFinished testStepFinished) { + Envelope o = new Envelope(); + o.testStepFinished = java.util.Objects.requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromTestStepStarted(TestStepStarted testStepStarted) { + Envelope o = new Envelope(); + o.testStepStarted = java.util.Objects.requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"); + o.validate(); + return o; + } + + public static Envelope fromUndefinedParameterType(UndefinedParameterType undefinedParameterType) { + Envelope o = new Envelope(); + o.undefinedParameterType = java.util.Objects.requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null"); + o.validate(); + return o; + } + public Envelope( Attachment attachment, GherkinDocument gherkinDocument, @@ -271,145 +354,79 @@ public Envelope( this.testStepFinished = testStepFinished; this.testStepStarted = testStepStarted; this.undefinedParameterType = undefinedParameterType; + validate(); } + public java.util.Optional getAttachment() { return java.util.Optional.ofNullable(attachment); } - public void setAttachment(Attachment attachment) { - this.attachment = attachment; - } - public java.util.Optional getGherkinDocument() { return java.util.Optional.ofNullable(gherkinDocument); } - public void setGherkinDocument(GherkinDocument gherkinDocument) { - this.gherkinDocument = gherkinDocument; - } - public java.util.Optional getHook() { return java.util.Optional.ofNullable(hook); } - public void setHook(Hook hook) { - this.hook = hook; - } - public java.util.Optional getMeta() { return java.util.Optional.ofNullable(meta); } - public void setMeta(Meta meta) { - this.meta = meta; - } - public java.util.Optional getParameterType() { return java.util.Optional.ofNullable(parameterType); } - public void setParameterType(ParameterType parameterType) { - this.parameterType = parameterType; - } - public java.util.Optional getParseError() { return java.util.Optional.ofNullable(parseError); } - public void setParseError(ParseError parseError) { - this.parseError = parseError; - } - public java.util.Optional getPickle() { return java.util.Optional.ofNullable(pickle); } - public void setPickle(Pickle pickle) { - this.pickle = pickle; - } - public java.util.Optional getSource() { return java.util.Optional.ofNullable(source); } - public void setSource(Source source) { - this.source = source; - } - public java.util.Optional getStepDefinition() { return java.util.Optional.ofNullable(stepDefinition); } - public void setStepDefinition(StepDefinition stepDefinition) { - this.stepDefinition = stepDefinition; - } - public java.util.Optional getTestCase() { return java.util.Optional.ofNullable(testCase); } - public void setTestCase(TestCase testCase) { - this.testCase = testCase; - } - public java.util.Optional getTestCaseFinished() { return java.util.Optional.ofNullable(testCaseFinished); } - public void setTestCaseFinished(TestCaseFinished testCaseFinished) { - this.testCaseFinished = testCaseFinished; - } - public java.util.Optional getTestCaseStarted() { return java.util.Optional.ofNullable(testCaseStarted); } - public void setTestCaseStarted(TestCaseStarted testCaseStarted) { - this.testCaseStarted = testCaseStarted; - } - public java.util.Optional getTestRunFinished() { return java.util.Optional.ofNullable(testRunFinished); } - public void setTestRunFinished(TestRunFinished testRunFinished) { - this.testRunFinished = testRunFinished; - } - public java.util.Optional getTestRunStarted() { return java.util.Optional.ofNullable(testRunStarted); } - public void setTestRunStarted(TestRunStarted testRunStarted) { - this.testRunStarted = testRunStarted; - } - public java.util.Optional getTestStepFinished() { return java.util.Optional.ofNullable(testStepFinished); } - public void setTestStepFinished(TestStepFinished testStepFinished) { - this.testStepFinished = testStepFinished; - } - public java.util.Optional getTestStepStarted() { return java.util.Optional.ofNullable(testStepStarted); } - public void setTestStepStarted(TestStepStarted testStepStarted) { - this.testStepStarted = testStepStarted; - } - public java.util.Optional getUndefinedParameterType() { return java.util.Optional.ofNullable(undefinedParameterType); } - public void setUndefinedParameterType(UndefinedParameterType undefinedParameterType) { - this.undefinedParameterType = undefinedParameterType; - } - - public void validate() { + private void validate() { if (attachment != null) attachment.validate(); if (gherkinDocument != null) gherkinDocument.validate(); if (hook != null) hook.validate(); @@ -507,7 +524,7 @@ public static class GherkinDocument { private Feature feature; private java.util.List comments = new java.util.ArrayList<>(); - public GherkinDocument() {} + private GherkinDocument() {} public GherkinDocument( String uri, @@ -516,34 +533,24 @@ public GherkinDocument( ) { this.uri = uri; this.feature = feature; - this.comments = java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); + this.comments = comments; + validate(); } + public java.util.Optional getUri() { return java.util.Optional.ofNullable(uri); } - public void setUri(String uri) { - this.uri = uri; - } - public java.util.Optional getFeature() { return java.util.Optional.ofNullable(feature); } - public void setFeature(Feature feature) { - this.feature = feature; - } - public java.util.List getComments() { - return java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); - } - - public void setComments(java.util.List comments) { - this.comments = java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); + return comments; } - public void validate() { + private void validate() { if (feature != null) feature.validate(); java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); comments.forEach(Comment::validate); @@ -588,7 +595,7 @@ public static class Background { private java.util.List steps = new java.util.ArrayList<>(); private String id; - public Background() {} + private Background() {} public Background( Location location, @@ -598,63 +605,41 @@ public Background( java.util.List steps, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Background.location cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Background.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Background.description cannot be null"); - this.steps = java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "Background.id cannot be null"); + this.location = location; + this.keyword = keyword; + this.name = name; + this.description = description; + this.steps = steps; + this.id = id; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Background.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Background.location cannot be null"); + public Location getLocation() { + return location; } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); + return keyword; } public String getName() { - return java.util.Objects.requireNonNull(name, "Background.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Background.name cannot be null"); + return name; } public String getDescription() { - return java.util.Objects.requireNonNull(description, "Background.description cannot be null"); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description, "Background.description cannot be null"); + return description; } public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); - } - - public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); + return steps; } public String getId() { - return java.util.Objects.requireNonNull(id, "Background.id cannot be null"); + return id; } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Background.id cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Background.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); @@ -709,33 +694,27 @@ public static class Comment { private Location location; private String text; - public Comment() {} + private Comment() {} public Comment( Location location, String text ) { - this.location = java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); - this.text = java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); + this.location = location; + this.text = text; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); + public Location getLocation() { + return location; } public String getText() { - return java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); - } - - public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); + return text; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); @@ -773,33 +752,27 @@ public static class DataTable { private Location location; private java.util.List rows = new java.util.ArrayList<>(); - public DataTable() {} + private DataTable() {} public DataTable( Location location, java.util.List rows ) { - this.location = java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); - this.rows = java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); + this.location = location; + this.rows = rows; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); + public Location getLocation() { + return location; } public java.util.List getRows() { - return java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); - } - - public void setRows(java.util.List rows) { - this.rows = java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); + return rows; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); @@ -840,7 +813,7 @@ public static class DocString { private String content; private String delimiter; - public DocString() {} + private DocString() {} public DocString( Location location, @@ -848,45 +821,31 @@ public DocString( String content, String delimiter ) { - this.location = java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); + this.location = location; this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); - this.delimiter = java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); + this.content = content; + this.delimiter = delimiter; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); + public Location getLocation() { + return location; } public java.util.Optional getMediaType() { return java.util.Optional.ofNullable(mediaType); } - public void setMediaType(String mediaType) { - this.mediaType = mediaType; - } - public String getContent() { - return java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); - } - - public void setContent(String content) { - this.content = java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); + return content; } public String getDelimiter() { - return java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); + return delimiter; } - public void setDelimiter(String delimiter) { - this.delimiter = java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); @@ -937,7 +896,7 @@ public static class Examples { private java.util.List tableBody = new java.util.ArrayList<>(); private String id; - public Examples() {} + private Examples() {} public Examples( Location location, @@ -949,81 +908,51 @@ public Examples( java.util.List tableBody, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); - this.tags = java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); + this.location = location; + this.tags = tags; + this.keyword = keyword; + this.name = name; + this.description = description; this.tableHeader = tableHeader; - this.tableBody = java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); + this.tableBody = tableBody; + this.id = id; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); + public Location getLocation() { + return location; } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); + return tags; } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); + return keyword; } public String getName() { - return java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); + return name; } public String getDescription() { - return java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); + return description; } public java.util.Optional getTableHeader() { return java.util.Optional.ofNullable(tableHeader); } - public void setTableHeader(TableRow tableHeader) { - this.tableHeader = tableHeader; - } - public java.util.List getTableBody() { - return java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); - } - - public void setTableBody(java.util.List tableBody) { - this.tableBody = java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); + return tableBody; } public String getId() { - return java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); + return id; } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); @@ -1092,7 +1021,7 @@ public static class Feature { private String description; private java.util.List children = new java.util.ArrayList<>(); - public Feature() {} + private Feature() {} public Feature( Location location, @@ -1103,72 +1032,46 @@ public Feature( String description, java.util.List children ) { - this.location = java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); - this.tags = java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); - this.language = java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); - this.children = java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); + this.location = location; + this.tags = tags; + this.language = language; + this.keyword = keyword; + this.name = name; + this.description = description; + this.children = children; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); + public Location getLocation() { + return location; } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); + return tags; } public String getLanguage() { - return java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); - } - - public void setLanguage(String language) { - this.language = java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); + return language; } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); + return keyword; } public String getName() { - return java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); + return name; } public String getDescription() { - return java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); + return description; } public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); - } - - public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); + return children; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); @@ -1231,6 +1134,27 @@ public static class FeatureChild { public FeatureChild() {} + public static FeatureChild fromRule(Rule rule) { + FeatureChild o = new FeatureChild(); + o.rule = java.util.Objects.requireNonNull(rule, "FeatureChild.rule cannot be null"); + o.validate(); + return o; + } + + public static FeatureChild fromBackground(Background background) { + FeatureChild o = new FeatureChild(); + o.background = java.util.Objects.requireNonNull(background, "FeatureChild.background cannot be null"); + o.validate(); + return o; + } + + public static FeatureChild fromScenario(Scenario scenario) { + FeatureChild o = new FeatureChild(); + o.scenario = java.util.Objects.requireNonNull(scenario, "FeatureChild.scenario cannot be null"); + o.validate(); + return o; + } + public FeatureChild( Rule rule, Background background, @@ -1239,33 +1163,23 @@ public FeatureChild( this.rule = rule; this.background = background; this.scenario = scenario; + validate(); } + public java.util.Optional getRule() { return java.util.Optional.ofNullable(rule); } - public void setRule(Rule rule) { - this.rule = rule; - } - public java.util.Optional getBackground() { return java.util.Optional.ofNullable(background); } - public void setBackground(Background background) { - this.background = background; - } - public java.util.Optional getScenario() { return java.util.Optional.ofNullable(scenario); } - public void setScenario(Scenario scenario) { - this.scenario = scenario; - } - - public void validate() { + private void validate() { if (rule != null) rule.validate(); if (background != null) background.validate(); if (scenario != null) scenario.validate(); @@ -1311,7 +1225,7 @@ public static class Rule { private java.util.List children = new java.util.ArrayList<>(); private String id; - public Rule() {} + private Rule() {} public Rule( Location location, @@ -1322,72 +1236,46 @@ public Rule( java.util.List children, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); - this.tags = java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); - this.children = java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); + this.location = location; + this.tags = tags; + this.keyword = keyword; + this.name = name; + this.description = description; + this.children = children; + this.id = id; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); + public Location getLocation() { + return location; } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); + return tags; } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); + return keyword; } public String getName() { - return java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); + return name; } public String getDescription() { - return java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); + return description; } public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); - } - - public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); + return children; } public String getId() { - return java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); + return id; } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); @@ -1449,31 +1337,39 @@ public static class RuleChild { public RuleChild() {} + public static RuleChild fromBackground(Background background) { + RuleChild o = new RuleChild(); + o.background = java.util.Objects.requireNonNull(background, "RuleChild.background cannot be null"); + o.validate(); + return o; + } + + public static RuleChild fromScenario(Scenario scenario) { + RuleChild o = new RuleChild(); + o.scenario = java.util.Objects.requireNonNull(scenario, "RuleChild.scenario cannot be null"); + o.validate(); + return o; + } + public RuleChild( Background background, Scenario scenario ) { this.background = background; this.scenario = scenario; + validate(); } + public java.util.Optional getBackground() { return java.util.Optional.ofNullable(background); } - public void setBackground(Background background) { - this.background = background; - } - public java.util.Optional getScenario() { return java.util.Optional.ofNullable(scenario); } - public void setScenario(Scenario scenario) { - this.scenario = scenario; - } - - public void validate() { + private void validate() { if (background != null) background.validate(); if (scenario != null) scenario.validate(); } @@ -1516,7 +1412,7 @@ public static class Scenario { private java.util.List examples = new java.util.ArrayList<>(); private String id; - public Scenario() {} + private Scenario() {} public Scenario( Location location, @@ -1528,81 +1424,51 @@ public Scenario( java.util.List examples, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); - this.tags = java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); - this.steps = java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); - this.examples = java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); + this.location = location; + this.tags = tags; + this.keyword = keyword; + this.name = name; + this.description = description; + this.steps = steps; + this.examples = examples; + this.id = id; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); + public Location getLocation() { + return location; } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); + return tags; } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); + return keyword; } public String getName() { - return java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); + return name; } public String getDescription() { - return java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); - } - - public void setDescription(String description) { - this.description = java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); + return description; } public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); - } - - public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); + return steps; } public java.util.List getExamples() { - return java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); - } - - public void setExamples(java.util.List examples) { - this.examples = java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); + return examples; } public String getId() { - return java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); + return id; } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); @@ -1671,7 +1537,7 @@ public static class Step { private DataTable dataTable; private String id; - public Step() {} + private Step() {} public Step( Location location, @@ -1681,63 +1547,41 @@ public Step( DataTable dataTable, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Step.location cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); - this.text = java.util.Objects.requireNonNull(text, "Step.text cannot be null"); + this.location = location; + this.keyword = keyword; + this.text = text; this.docString = docString; this.dataTable = dataTable; - this.id = java.util.Objects.requireNonNull(id, "Step.id cannot be null"); + this.id = id; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Step.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Step.location cannot be null"); + public Location getLocation() { + return location; } public String getKeyword() { - return java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); - } - - public void setKeyword(String keyword) { - this.keyword = java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); + return keyword; } public String getText() { - return java.util.Objects.requireNonNull(text, "Step.text cannot be null"); - } - - public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text, "Step.text cannot be null"); + return text; } public java.util.Optional getDocString() { return java.util.Optional.ofNullable(docString); } - public void setDocString(DocString docString) { - this.docString = docString; - } - public java.util.Optional getDataTable() { return java.util.Optional.ofNullable(dataTable); } - public void setDataTable(DataTable dataTable) { - this.dataTable = dataTable; - } - public String getId() { - return java.util.Objects.requireNonNull(id, "Step.id cannot be null"); + return id; } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Step.id cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Step.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); @@ -1791,33 +1635,27 @@ public static class TableCell { private Location location; private String value; - public TableCell() {} + private TableCell() {} public TableCell( Location location, String value ) { - this.location = java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); - this.value = java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); + this.location = location; + this.value = value; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); + public Location getLocation() { + return location; } public String getValue() { - return java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); - } - - public void setValue(String value) { - this.value = java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); + return value; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); @@ -1856,43 +1694,33 @@ public static class TableRow { private java.util.List cells = new java.util.ArrayList<>(); private String id; - public TableRow() {} + private TableRow() {} public TableRow( Location location, java.util.List cells, String id ) { - this.location = java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); - this.cells = java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); + this.location = location; + this.cells = cells; + this.id = id; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); + public Location getLocation() { + return location; } public java.util.List getCells() { - return java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); - } - - public void setCells(java.util.List cells) { - this.cells = java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); + return cells; } public String getId() { - return java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); + return id; } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); @@ -1936,43 +1764,33 @@ public static class Tag { private String name; private String id; - public Tag() {} + private Tag() {} public Tag( Location location, String name, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); + this.location = location; + this.name = name; + this.id = id; + validate(); } - public Location getLocation() { - return java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); - } - public void setLocation(Location location) { - this.location = java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); + public Location getLocation() { + return location; } public String getName() { - return java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); + return name; } public String getId() { - return java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); + return id; } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); location.validate(); java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); @@ -2015,43 +1833,33 @@ public static class Hook { private SourceReference sourceReference; private String tagExpression; - public Hook() {} + private Hook() {} public Hook( String id, SourceReference sourceReference, String tagExpression ) { - this.id = java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); + this.id = id; + this.sourceReference = sourceReference; this.tagExpression = tagExpression; + validate(); } - public String getId() { - return java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); - } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); + public String getId() { + return id; } public SourceReference getSourceReference() { - return java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); - } - - public void setSourceReference(SourceReference sourceReference) { - this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); + return sourceReference; } public java.util.Optional getTagExpression() { return java.util.Optional.ofNullable(tagExpression); } - public void setTagExpression(String tagExpression) { - this.tagExpression = tagExpression; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); sourceReference.validate(); @@ -2092,33 +1900,27 @@ public static class Location { private Long line; private Long column; - public Location() {} + private Location() {} public Location( Long line, Long column ) { - this.line = java.util.Objects.requireNonNull(line, "Location.line cannot be null"); + this.line = line; this.column = column; + validate(); } - public Long getLine() { - return java.util.Objects.requireNonNull(line, "Location.line cannot be null"); - } - public void setLine(Long line) { - this.line = java.util.Objects.requireNonNull(line, "Location.line cannot be null"); + public Long getLine() { + return line; } public java.util.Optional getColumn() { return java.util.Optional.ofNullable(column); } - public void setColumn(Long column) { - this.column = column; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(line, "Location.line cannot be null"); } @@ -2158,7 +1960,7 @@ public static class Meta { private Product cpu; private Ci ci; - public Meta() {} + private Meta() {} public Meta( String protocolVersion, @@ -2168,63 +1970,41 @@ public Meta( Product cpu, Ci ci ) { - this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); - this.implementation = java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); - this.runtime = java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); - this.os = java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); - this.cpu = java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); + this.protocolVersion = protocolVersion; + this.implementation = implementation; + this.runtime = runtime; + this.os = os; + this.cpu = cpu; this.ci = ci; + validate(); } - public String getProtocolVersion() { - return java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); - } - public void setProtocolVersion(String protocolVersion) { - this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); + public String getProtocolVersion() { + return protocolVersion; } public Product getImplementation() { - return java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); - } - - public void setImplementation(Product implementation) { - this.implementation = java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); + return implementation; } public Product getRuntime() { - return java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); - } - - public void setRuntime(Product runtime) { - this.runtime = java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); + return runtime; } public Product getOs() { - return java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); - } - - public void setOs(Product os) { - this.os = java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); + return os; } public Product getCpu() { - return java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); - } - - public void setCpu(Product cpu) { - this.cpu = java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); + return cpu; } public java.util.Optional getCi() { return java.util.Optional.ofNullable(ci); } - public void setCi(Ci ci) { - this.ci = ci; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); implementation.validate(); @@ -2283,7 +2063,7 @@ public static class Ci { private String buildNumber; private Git git; - public Ci() {} + private Ci() {} public Ci( String name, @@ -2291,45 +2071,31 @@ public Ci( String buildNumber, Git git ) { - this.name = java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); + this.name = name; this.url = url; this.buildNumber = buildNumber; this.git = git; + validate(); } - public String getName() { - return java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); - } - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); + public String getName() { + return name; } public java.util.Optional getUrl() { return java.util.Optional.ofNullable(url); } - public void setUrl(String url) { - this.url = url; - } - public java.util.Optional getBuildNumber() { return java.util.Optional.ofNullable(buildNumber); } - public void setBuildNumber(String buildNumber) { - this.buildNumber = buildNumber; - } - public java.util.Optional getGit() { return java.util.Optional.ofNullable(git); } - public void setGit(Git git) { - this.git = git; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); if (git != null) git.validate(); } @@ -2374,7 +2140,7 @@ public static class Git { private String branch; private String tag; - public Git() {} + private Git() {} public Git( String remote, @@ -2382,45 +2148,31 @@ public Git( String branch, String tag ) { - this.remote = java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); - this.revision = java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); + this.remote = remote; + this.revision = revision; this.branch = branch; this.tag = tag; + validate(); } - public String getRemote() { - return java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); - } - - public void setRemote(String remote) { - this.remote = java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); - } - public String getRevision() { - return java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); + public String getRemote() { + return remote; } - public void setRevision(String revision) { - this.revision = java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); + public String getRevision() { + return revision; } public java.util.Optional getBranch() { return java.util.Optional.ofNullable(branch); } - public void setBranch(String branch) { - this.branch = branch; - } - public java.util.Optional getTag() { return java.util.Optional.ofNullable(tag); } - public void setTag(String tag) { - this.tag = tag; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); } @@ -2463,33 +2215,27 @@ public static class Product { private String name; private String version; - public Product() {} + private Product() {} public Product( String name, String version ) { - this.name = java.util.Objects.requireNonNull(name, "Product.name cannot be null"); + this.name = name; this.version = version; + validate(); } - public String getName() { - return java.util.Objects.requireNonNull(name, "Product.name cannot be null"); - } - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Product.name cannot be null"); + public String getName() { + return name; } public java.util.Optional getVersion() { return java.util.Optional.ofNullable(version); } - public void setVersion(String version) { - this.version = version; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(name, "Product.name cannot be null"); } @@ -2528,7 +2274,7 @@ public static class ParameterType { private Boolean useForSnippets; private String id; - public ParameterType() {} + private ParameterType() {} public ParameterType( String name, @@ -2537,54 +2283,36 @@ public ParameterType( Boolean useForSnippets, String id ) { - this.name = java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); - this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); - this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); - this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); + this.name = name; + this.regularExpressions = regularExpressions; + this.preferForRegularExpressionMatch = preferForRegularExpressionMatch; + this.useForSnippets = useForSnippets; + this.id = id; + validate(); } - public String getName() { - return java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); - } - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); + public String getName() { + return name; } public java.util.List getRegularExpressions() { - return java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); - } - - public void setRegularExpressions(java.util.List regularExpressions) { - this.regularExpressions = java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); + return regularExpressions; } public Boolean getPreferForRegularExpressionMatch() { - return java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); - } - - public void setPreferForRegularExpressionMatch(Boolean preferForRegularExpressionMatch) { - this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); + return preferForRegularExpressionMatch; } public Boolean getUseForSnippets() { - return java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); - } - - public void setUseForSnippets(Boolean useForSnippets) { - this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); + return useForSnippets; } public String getId() { - return java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); + return id; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); regularExpressions.forEach(e -> java.util.Objects.requireNonNull(e, "ParameterType.regularExpressions elements cannot be null")); @@ -2634,33 +2362,27 @@ public static class ParseError { private SourceReference source; private String message; - public ParseError() {} + private ParseError() {} public ParseError( SourceReference source, String message ) { - this.source = java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); - this.message = java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); + this.source = source; + this.message = message; + validate(); } - public SourceReference getSource() { - return java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); - } - public void setSource(SourceReference source) { - this.source = java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); + public SourceReference getSource() { + return source; } public String getMessage() { - return java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); + return message; } - public void setMessage(String message) { - this.message = java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); source.validate(); java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); @@ -2703,7 +2425,7 @@ public static class Pickle { private java.util.List tags = new java.util.ArrayList<>(); private java.util.List astNodeIds = new java.util.ArrayList<>(); - public Pickle() {} + private Pickle() {} public Pickle( String id, @@ -2714,72 +2436,46 @@ public Pickle( java.util.List tags, java.util.List astNodeIds ) { - this.id = java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); - this.uri = java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); - this.language = java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); - this.steps = java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); - this.tags = java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); + this.id = id; + this.uri = uri; + this.name = name; + this.language = language; + this.steps = steps; + this.tags = tags; + this.astNodeIds = astNodeIds; + validate(); } - public String getId() { - return java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); - } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); + public String getId() { + return id; } public String getUri() { - return java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); - } - - public void setUri(String uri) { - this.uri = java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); + return uri; } public String getName() { - return java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); + return name; } public String getLanguage() { - return java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); - } - - public void setLanguage(String language) { - this.language = java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); + return language; } public java.util.List getSteps() { - return java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); - } - - public void setSteps(java.util.List steps) { - this.steps = java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); + return steps; } public java.util.List getTags() { - return java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); - } - - public void setTags(java.util.List tags) { - this.tags = java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); + return tags; } public java.util.List getAstNodeIds() { - return java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); + return astNodeIds; } - public void setAstNodeIds(java.util.List astNodeIds) { - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); @@ -2839,33 +2535,27 @@ public static class PickleDocString { private String mediaType; private String content; - public PickleDocString() {} + private PickleDocString() {} public PickleDocString( String mediaType, String content ) { this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); + this.content = content; + validate(); } + public java.util.Optional getMediaType() { return java.util.Optional.ofNullable(mediaType); } - public void setMediaType(String mediaType) { - this.mediaType = mediaType; - } - public String getContent() { - return java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); - } - - public void setContent(String content) { - this.content = java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); + return content; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); } @@ -2903,7 +2593,7 @@ public static class PickleStep { private String id; private String text; - public PickleStep() {} + private PickleStep() {} public PickleStep( PickleStepArgument argument, @@ -2912,44 +2602,30 @@ public PickleStep( String text ) { this.argument = argument; - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); - this.text = java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); + this.astNodeIds = astNodeIds; + this.id = id; + this.text = text; + validate(); } + public java.util.Optional getArgument() { return java.util.Optional.ofNullable(argument); } - public void setArgument(PickleStepArgument argument) { - this.argument = argument; - } - public java.util.List getAstNodeIds() { - return java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); - } - - public void setAstNodeIds(java.util.List astNodeIds) { - this.astNodeIds = java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); + return astNodeIds; } public String getId() { - return java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); + return id; } public String getText() { - return java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); + return text; } - public void setText(String text) { - this.text = java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); - } - - public void validate() { + private void validate() { if (argument != null) argument.validate(); java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); astNodeIds.forEach(e -> java.util.Objects.requireNonNull(e, "PickleStep.astNodeIds elements cannot be null")); @@ -2997,31 +2673,39 @@ public static class PickleStepArgument { public PickleStepArgument() {} + public static PickleStepArgument fromDocString(PickleDocString docString) { + PickleStepArgument o = new PickleStepArgument(); + o.docString = java.util.Objects.requireNonNull(docString, "PickleStepArgument.docString cannot be null"); + o.validate(); + return o; + } + + public static PickleStepArgument fromDataTable(PickleTable dataTable) { + PickleStepArgument o = new PickleStepArgument(); + o.dataTable = java.util.Objects.requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null"); + o.validate(); + return o; + } + public PickleStepArgument( PickleDocString docString, PickleTable dataTable ) { this.docString = docString; this.dataTable = dataTable; + validate(); } + public java.util.Optional getDocString() { return java.util.Optional.ofNullable(docString); } - public void setDocString(PickleDocString docString) { - this.docString = docString; - } - public java.util.Optional getDataTable() { return java.util.Optional.ofNullable(dataTable); } - public void setDataTable(PickleTable dataTable) { - this.dataTable = dataTable; - } - - public void validate() { + private void validate() { if (docString != null) docString.validate(); if (dataTable != null) dataTable.validate(); } @@ -3057,23 +2741,21 @@ public String toString() { public static class PickleTable { private java.util.List rows = new java.util.ArrayList<>(); - public PickleTable() {} + private PickleTable() {} public PickleTable( java.util.List rows ) { - this.rows = java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); + this.rows = rows; + validate(); } - public java.util.List getRows() { - return java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); - } - public void setRows(java.util.List rows) { - this.rows = java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); + public java.util.List getRows() { + return rows; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); rows.forEach(PickleTableRow::validate); } @@ -3106,23 +2788,21 @@ public String toString() { public static class PickleTableCell { private String value; - public PickleTableCell() {} + private PickleTableCell() {} public PickleTableCell( String value ) { - this.value = java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); + this.value = value; + validate(); } - public String getValue() { - return java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); - } - public void setValue(String value) { - this.value = java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); + public String getValue() { + return value; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); } @@ -3154,23 +2834,21 @@ public String toString() { public static class PickleTableRow { private java.util.List cells = new java.util.ArrayList<>(); - public PickleTableRow() {} + private PickleTableRow() {} public PickleTableRow( java.util.List cells ) { - this.cells = java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); + this.cells = cells; + validate(); } - public java.util.List getCells() { - return java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); - } - public void setCells(java.util.List cells) { - this.cells = java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); + public java.util.List getCells() { + return cells; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); cells.forEach(PickleTableCell::validate); } @@ -3204,33 +2882,27 @@ public static class PickleTag { private String name; private String astNodeId; - public PickleTag() {} + private PickleTag() {} public PickleTag( String name, String astNodeId ) { - this.name = java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); - this.astNodeId = java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); + this.name = name; + this.astNodeId = astNodeId; + validate(); } - public String getName() { - return java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); - } - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); + public String getName() { + return name; } public String getAstNodeId() { - return java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); - } - - public void setAstNodeId(String astNodeId) { - this.astNodeId = java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); + return astNodeId; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); } @@ -3268,43 +2940,33 @@ public static class Source { private String data; private SourceMediaType mediaType; - public Source() {} + private Source() {} public Source( String uri, String data, SourceMediaType mediaType ) { - this.uri = java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); - this.data = java.util.Objects.requireNonNull(data, "Source.data cannot be null"); - this.mediaType = java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); + this.uri = uri; + this.data = data; + this.mediaType = mediaType; + validate(); } - public String getUri() { - return java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); - } - public void setUri(String uri) { - this.uri = java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); + public String getUri() { + return uri; } public String getData() { - return java.util.Objects.requireNonNull(data, "Source.data cannot be null"); - } - - public void setData(String data) { - this.data = java.util.Objects.requireNonNull(data, "Source.data cannot be null"); + return data; } public SourceMediaType getMediaType() { - return java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); - } - - public void setMediaType(SourceMediaType mediaType) { - this.mediaType = java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); + return mediaType; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); java.util.Objects.requireNonNull(data, "Source.data cannot be null"); java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); @@ -3349,6 +3011,34 @@ public static class SourceReference { public SourceReference() {} + public static SourceReference fromUri(String uri) { + SourceReference o = new SourceReference(); + o.uri = java.util.Objects.requireNonNull(uri, "SourceReference.uri cannot be null"); + o.validate(); + return o; + } + + public static SourceReference fromJavaMethod(JavaMethod javaMethod) { + SourceReference o = new SourceReference(); + o.javaMethod = java.util.Objects.requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"); + o.validate(); + return o; + } + + public static SourceReference fromJavaStackTraceElement(JavaStackTraceElement javaStackTraceElement) { + SourceReference o = new SourceReference(); + o.javaStackTraceElement = java.util.Objects.requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"); + o.validate(); + return o; + } + + public static SourceReference fromLocation(Location location) { + SourceReference o = new SourceReference(); + o.location = java.util.Objects.requireNonNull(location, "SourceReference.location cannot be null"); + o.validate(); + return o; + } + public SourceReference( String uri, JavaMethod javaMethod, @@ -3359,41 +3049,27 @@ public SourceReference( this.javaMethod = javaMethod; this.javaStackTraceElement = javaStackTraceElement; this.location = location; + validate(); } + public java.util.Optional getUri() { return java.util.Optional.ofNullable(uri); } - public void setUri(String uri) { - this.uri = uri; - } - public java.util.Optional getJavaMethod() { return java.util.Optional.ofNullable(javaMethod); } - public void setJavaMethod(JavaMethod javaMethod) { - this.javaMethod = javaMethod; - } - public java.util.Optional getJavaStackTraceElement() { return java.util.Optional.ofNullable(javaStackTraceElement); } - public void setJavaStackTraceElement(JavaStackTraceElement javaStackTraceElement) { - this.javaStackTraceElement = javaStackTraceElement; - } - public java.util.Optional getLocation() { return java.util.Optional.ofNullable(location); } - public void setLocation(Location location) { - this.location = location; - } - - public void validate() { + private void validate() { if (javaMethod != null) javaMethod.validate(); if (javaStackTraceElement != null) javaStackTraceElement.validate(); if (location != null) location.validate(); @@ -3438,43 +3114,33 @@ public static class JavaMethod { private String methodName; private java.util.List methodParameterTypes = new java.util.ArrayList<>(); - public JavaMethod() {} + private JavaMethod() {} public JavaMethod( String className, String methodName, java.util.List methodParameterTypes ) { - this.className = java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); - this.methodName = java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); - this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); + this.className = className; + this.methodName = methodName; + this.methodParameterTypes = methodParameterTypes; + validate(); } - public String getClassName() { - return java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); - } - public void setClassName(String className) { - this.className = java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); + public String getClassName() { + return className; } public String getMethodName() { - return java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); - } - - public void setMethodName(String methodName) { - this.methodName = java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); + return methodName; } public java.util.List getMethodParameterTypes() { - return java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); - } - - public void setMethodParameterTypes(java.util.List methodParameterTypes) { - this.methodParameterTypes = java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); + return methodParameterTypes; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); @@ -3517,43 +3183,33 @@ public static class JavaStackTraceElement { private String fileName; private String methodName; - public JavaStackTraceElement() {} + private JavaStackTraceElement() {} public JavaStackTraceElement( String className, String fileName, String methodName ) { - this.className = java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); - this.fileName = java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); - this.methodName = java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); + this.className = className; + this.fileName = fileName; + this.methodName = methodName; + validate(); } - public String getClassName() { - return java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); - } - public void setClassName(String className) { - this.className = java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); + public String getClassName() { + return className; } public String getFileName() { - return java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); - } - - public void setFileName(String fileName) { - this.fileName = java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); + return fileName; } public String getMethodName() { - return java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); - } - - public void setMethodName(String methodName) { - this.methodName = java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); + return methodName; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); @@ -3595,43 +3251,33 @@ public static class StepDefinition { private StepDefinitionPattern pattern; private SourceReference sourceReference; - public StepDefinition() {} + private StepDefinition() {} public StepDefinition( String id, StepDefinitionPattern pattern, SourceReference sourceReference ) { - this.id = java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); - this.pattern = java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); + this.id = id; + this.pattern = pattern; + this.sourceReference = sourceReference; + validate(); } - public String getId() { - return java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); - } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); + public String getId() { + return id; } public StepDefinitionPattern getPattern() { - return java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); - } - - public void setPattern(StepDefinitionPattern pattern) { - this.pattern = java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); + return pattern; } public SourceReference getSourceReference() { - return java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); - } - - public void setSourceReference(SourceReference sourceReference) { - this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); + return sourceReference; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); pattern.validate(); @@ -3674,33 +3320,27 @@ public static class StepDefinitionPattern { private String source; private StepDefinitionPatternType type; - public StepDefinitionPattern() {} + private StepDefinitionPattern() {} public StepDefinitionPattern( String source, StepDefinitionPatternType type ) { - this.source = java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); - this.type = java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); + this.source = source; + this.type = type; + validate(); } - public String getSource() { - return java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); - } - public void setSource(String source) { - this.source = java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); + public String getSource() { + return source; } public StepDefinitionPatternType getType() { - return java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); + return type; } - public void setType(StepDefinitionPatternType type) { - this.type = java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); } @@ -3738,43 +3378,33 @@ public static class TestCase { private String pickleId; private java.util.List testSteps = new java.util.ArrayList<>(); - public TestCase() {} + private TestCase() {} public TestCase( String id, String pickleId, java.util.List testSteps ) { - this.id = java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); - this.pickleId = java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); - this.testSteps = java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); + this.id = id; + this.pickleId = pickleId; + this.testSteps = testSteps; + validate(); } - public String getId() { - return java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); - } - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); + public String getId() { + return id; } public String getPickleId() { - return java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); - } - - public void setPickleId(String pickleId) { - this.pickleId = java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); + return pickleId; } public java.util.List getTestSteps() { - return java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); - } - - public void setTestSteps(java.util.List testSteps) { - this.testSteps = java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); + return testSteps; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); @@ -3817,43 +3447,33 @@ public static class Group { private Long start; private String value; - public Group() {} + private Group() {} public Group( java.util.List children, Long start, String value ) { - this.children = java.util.Objects.requireNonNull(children, "Group.children cannot be null"); + this.children = children; this.start = start; this.value = value; + validate(); } - public java.util.List getChildren() { - return java.util.Objects.requireNonNull(children, "Group.children cannot be null"); - } - public void setChildren(java.util.List children) { - this.children = java.util.Objects.requireNonNull(children, "Group.children cannot be null"); + public java.util.List getChildren() { + return children; } public java.util.Optional getStart() { return java.util.Optional.ofNullable(start); } - public void setStart(Long start) { - this.start = start; - } - public java.util.Optional getValue() { return java.util.Optional.ofNullable(value); } - public void setValue(String value) { - this.value = value; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(children, "Group.children cannot be null"); children.forEach(Group::validate); } @@ -3893,33 +3513,27 @@ public static class StepMatchArgument { private Group group; private String parameterTypeName; - public StepMatchArgument() {} + private StepMatchArgument() {} public StepMatchArgument( Group group, String parameterTypeName ) { - this.group = java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); + this.group = group; this.parameterTypeName = parameterTypeName; + validate(); } - public Group getGroup() { - return java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); - } - public void setGroup(Group group) { - this.group = java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); + public Group getGroup() { + return group; } public java.util.Optional getParameterTypeName() { return java.util.Optional.ofNullable(parameterTypeName); } - public void setParameterTypeName(String parameterTypeName) { - this.parameterTypeName = parameterTypeName; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); group.validate(); } @@ -3955,23 +3569,21 @@ public String toString() { public static class StepMatchArgumentsList { private java.util.List stepMatchArguments = new java.util.ArrayList<>(); - public StepMatchArgumentsList() {} + private StepMatchArgumentsList() {} public StepMatchArgumentsList( java.util.List stepMatchArguments ) { - this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); + this.stepMatchArguments = stepMatchArguments; + validate(); } - public java.util.List getStepMatchArguments() { - return java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); - } - public void setStepMatchArguments(java.util.List stepMatchArguments) { - this.stepMatchArguments = java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); + public java.util.List getStepMatchArguments() { + return stepMatchArguments; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); stepMatchArguments.forEach(StepMatchArgument::validate); } @@ -4008,7 +3620,7 @@ public static class TestStep { private java.util.List stepDefinitionIds = new java.util.ArrayList<>(); private java.util.List stepMatchArgumentsLists = new java.util.ArrayList<>(); - public TestStep() {} + private TestStep() {} public TestStep( String hookId, @@ -4018,53 +3630,35 @@ public TestStep( java.util.List stepMatchArgumentsLists ) { this.hookId = hookId; - this.id = java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); + this.id = id; this.pickleStepId = pickleStepId; this.stepDefinitionIds = stepDefinitionIds; this.stepMatchArgumentsLists = stepMatchArgumentsLists; + validate(); } + public java.util.Optional getHookId() { return java.util.Optional.ofNullable(hookId); } - public void setHookId(String hookId) { - this.hookId = hookId; - } - public String getId() { - return java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); + return id; } public java.util.Optional getPickleStepId() { return java.util.Optional.ofNullable(pickleStepId); } - public void setPickleStepId(String pickleStepId) { - this.pickleStepId = pickleStepId; - } - public java.util.Optional> getStepDefinitionIds() { return java.util.Optional.ofNullable(stepDefinitionIds); } - public void setStepDefinitionIds(java.util.List stepDefinitionIds) { - this.stepDefinitionIds = stepDefinitionIds; - } - public java.util.Optional> getStepMatchArgumentsLists() { return java.util.Optional.ofNullable(stepMatchArgumentsLists); } - public void setStepMatchArgumentsLists(java.util.List stepMatchArgumentsLists) { - this.stepMatchArgumentsLists = stepMatchArgumentsLists; - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); if (stepDefinitionIds != null) stepDefinitionIds.forEach(e -> java.util.Objects.requireNonNull(e, "TestStep.stepDefinitionIds elements cannot be null")); if (stepMatchArgumentsLists != null) stepMatchArgumentsLists.forEach(StepMatchArgumentsList::validate); @@ -4112,43 +3706,33 @@ public static class TestCaseFinished { private Timestamp timestamp; private Boolean willBeRetried; - public TestCaseFinished() {} + private TestCaseFinished() {} public TestCaseFinished( String testCaseStartedId, Timestamp timestamp, Boolean willBeRetried ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); - this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); + this.testCaseStartedId = testCaseStartedId; + this.timestamp = timestamp; + this.willBeRetried = willBeRetried; + validate(); } - public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); - } - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); + public String getTestCaseStartedId() { + return testCaseStartedId; } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); + return timestamp; } public Boolean getWillBeRetried() { - return java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); + return willBeRetried; } - public void setWillBeRetried(Boolean willBeRetried) { - this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); timestamp.validate(); @@ -4192,7 +3776,7 @@ public static class TestCaseStarted { private String testCaseId; private Timestamp timestamp; - public TestCaseStarted() {} + private TestCaseStarted() {} public TestCaseStarted( Long attempt, @@ -4200,45 +3784,31 @@ public TestCaseStarted( String testCaseId, Timestamp timestamp ) { - this.attempt = java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); - this.testCaseId = java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); + this.attempt = attempt; + this.id = id; + this.testCaseId = testCaseId; + this.timestamp = timestamp; + validate(); } - public Long getAttempt() { - return java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); - } - public void setAttempt(Long attempt) { - this.attempt = java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); + public Long getAttempt() { + return attempt; } public String getId() { - return java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); - } - - public void setId(String id) { - this.id = java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); + return id; } public String getTestCaseId() { - return java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); - } - - public void setTestCaseId(String testCaseId) { - this.testCaseId = java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); + return testCaseId; } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); + return timestamp; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); @@ -4285,7 +3855,7 @@ public static class TestRunFinished { private Boolean success; private Timestamp timestamp; - public TestRunFinished() {} + private TestRunFinished() {} public TestRunFinished( String message, @@ -4293,35 +3863,25 @@ public TestRunFinished( Timestamp timestamp ) { this.message = message; - this.success = java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); + this.success = success; + this.timestamp = timestamp; + validate(); } + public java.util.Optional getMessage() { return java.util.Optional.ofNullable(message); } - public void setMessage(String message) { - this.message = message; - } - public Boolean getSuccess() { - return java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); - } - - public void setSuccess(Boolean success) { - this.success = java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); + return success; } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); + return timestamp; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); timestamp.validate(); @@ -4361,23 +3921,21 @@ public String toString() { public static class TestRunStarted { private Timestamp timestamp; - public TestRunStarted() {} + private TestRunStarted() {} public TestRunStarted( Timestamp timestamp ) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); + this.timestamp = timestamp; + validate(); } - public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); - } - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); + public Timestamp getTimestamp() { + return timestamp; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); timestamp.validate(); } @@ -4413,7 +3971,7 @@ public static class TestStepFinished { private TestStepResult testStepResult; private Timestamp timestamp; - public TestStepFinished() {} + private TestStepFinished() {} public TestStepFinished( String testCaseStartedId, @@ -4421,45 +3979,31 @@ public TestStepFinished( TestStepResult testStepResult, Timestamp timestamp ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); - this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); - this.testStepResult = java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.testStepResult = testStepResult; + this.timestamp = timestamp; + validate(); } - public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); - } - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); + public String getTestCaseStartedId() { + return testCaseStartedId; } public String getTestStepId() { - return java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); - } - - public void setTestStepId(String testStepId) { - this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); + return testStepId; } public TestStepResult getTestStepResult() { - return java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); - } - - public void setTestStepResult(TestStepResult testStepResult) { - this.testStepResult = java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); + return testStepResult; } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); - } - - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); + return timestamp; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); @@ -4507,43 +4051,33 @@ public static class TestStepResult { private String message; private TestStepResultStatus status; - public TestStepResult() {} + private TestStepResult() {} public TestStepResult( Duration duration, String message, TestStepResultStatus status ) { - this.duration = java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); + this.duration = duration; this.message = message; - this.status = java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); + this.status = status; + validate(); } - public Duration getDuration() { - return java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); - } - public void setDuration(Duration duration) { - this.duration = java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); + public Duration getDuration() { + return duration; } public java.util.Optional getMessage() { return java.util.Optional.ofNullable(message); } - public void setMessage(String message) { - this.message = message; - } - public TestStepResultStatus getStatus() { - return java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); - } - - public void setStatus(TestStepResultStatus status) { - this.status = java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); + return status; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); duration.validate(); java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); @@ -4585,43 +4119,33 @@ public static class TestStepStarted { private String testStepId; private Timestamp timestamp; - public TestStepStarted() {} + private TestStepStarted() {} public TestStepStarted( String testCaseStartedId, String testStepId, Timestamp timestamp ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); - this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.timestamp = timestamp; + validate(); } - public String getTestCaseStartedId() { - return java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); - } - public void setTestCaseStartedId(String testCaseStartedId) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); + public String getTestCaseStartedId() { + return testCaseStartedId; } public String getTestStepId() { - return java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); - } - - public void setTestStepId(String testStepId) { - this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); + return testStepId; } public Timestamp getTimestamp() { - return java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); + return timestamp; } - public void setTimestamp(Timestamp timestamp) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); - } - - public void validate() { + private void validate() { java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); @@ -4663,33 +4187,27 @@ public static class Timestamp { private Long seconds; private Long nanos; - public Timestamp() {} + private Timestamp() {} public Timestamp( Long seconds, Long nanos ) { - this.seconds = java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); - this.nanos = java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); + this.seconds = seconds; + this.nanos = nanos; + validate(); } - public Long getSeconds() { - return java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); - } - public void setSeconds(Long seconds) { - this.seconds = java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); + public Long getSeconds() { + return seconds; } public Long getNanos() { - return java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); - } - - public void setNanos(Long nanos) { - this.nanos = java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); + return nanos; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); } @@ -4726,33 +4244,27 @@ public static class UndefinedParameterType { private String expression; private String name; - public UndefinedParameterType() {} + private UndefinedParameterType() {} public UndefinedParameterType( String expression, String name ) { - this.expression = java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); + this.expression = expression; + this.name = name; + validate(); } - public String getExpression() { - return java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); - } - public void setExpression(String expression) { - this.expression = java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); + public String getExpression() { + return expression; } public String getName() { - return java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); - } - - public void setName(String name) { - this.name = java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); + return name; } - public void validate() { + private void validate() { java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); } diff --git a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java index 334641ae2b..e6345e6550 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java @@ -7,7 +7,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -21,17 +20,22 @@ abstract class MessageSerializationContract { void can_serialise_messages_over_a_stream() throws IOException { List outgoingMessages = new ArrayList<>(); { - Envelope envelope = new Envelope(); - envelope.setSource(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + Envelope envelope = Envelope.fromSource(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); outgoingMessages.add(envelope); } { - Envelope envelope = new Envelope(); - Attachment attachment = new Attachment(); - attachment.setBody("the body"); - attachment.setContentEncoding(AttachmentContentEncoding.IDENTITY); - attachment.setMediaType("text/plain"); - envelope.setAttachment(attachment); + Envelope envelope = Envelope.fromAttachment( + new Attachment( + "the body", + AttachmentContentEncoding.IDENTITY, + null, + "text/plain", + null, + null, + null, + null + ) + ); outgoingMessages.add(envelope); } @@ -42,8 +46,7 @@ void can_serialise_messages_over_a_stream() throws IOException { void writes_empty_arrays_and_empty_strings() throws IOException { List outgoingMessages = new ArrayList<>(); { - Envelope envelope = new Envelope(); - envelope.setGherkinDocument( + Envelope envelope = Envelope.fromGherkinDocument( new GherkinDocument( "hello.feature", new Feature( diff --git a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java index 015a424a33..0d767ac2b8 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java @@ -7,13 +7,13 @@ public class MessagesTest { @Test void is_invalid_when_required_fields_are_missing() { - Messages.Envelope envelope = new Messages.Envelope(); - envelope.setAttachment(new Messages.Attachment()); - assertThrows(NullPointerException.class, envelope::validate, "Attachment.body cannot be null"); + assertThrows(NullPointerException.class, () -> { + new Messages.Attachment(null, null, null, null, null, null, null, null); + }, "Attachment.body cannot be null"); } @Test void is_valid_when_no_required_fields_are_missing() { - new Messages.Envelope().validate(); + new Messages.Envelope(); } } diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 9f4b257e78..e390301cc3 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -4,7 +4,20 @@ private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= property['items'] ? ' = new java.util.ArrayList<>()' : '' %>; <%- end -%> + <%- if (schema['required'] || []).empty? -%> public <%= class_name(key) %>() {} + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + + public static <%= class_name(key) %> from<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + <%= class_name(key) %> o = new <%= class_name(key) %>(); + o.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); + o.validate(); + return o; + } + <%- end -%> + <%- else -%> + private <%= class_name(key) %>() {} + <%- end -%> public <%= class_name(key) %>( <%- schema['properties'].each_with_index do |(property_name, property), index| -%> @@ -12,35 +25,26 @@ <%- end -%> ) { <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - <%- if (schema['required'] || []).index(property_name) -%> - this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); - <%- else -%> this.<%= property_name %> = <%= property_name %>; - <%- end -%> <%- end -%> + validate(); } <%- schema['properties'].each do |property_name, property| -%> <%- if (schema['required'] || []).index(property_name) -%> - public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { - return java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); - } - public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); + public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { + return <%= property_name %>; } <%- else -%> + public java.util.Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { return java.util.Optional.ofNullable(<%= property_name %>); } - - public void set<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - this.<%= property_name %> = <%= property_name %>; - } <%- end -%> - <%- end -%> - public void validate() { + + private void validate() { <%- schema['properties'].each do |property_name, property| required = (schema['required'] || []).index(property_name) -%> From 19d53feb023bdf84383bd86483e5efae98c07b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 12 Jan 2022 21:45:30 +0000 Subject: [PATCH 23/63] Update changelog --- messages/CHANGELOG.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/messages/CHANGELOG.md b/messages/CHANGELOG.md index e7c6198d58..6fd693d217 100644 --- a/messages/CHANGELOG.md +++ b/messages/CHANGELOG.md @@ -11,18 +11,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Support for EcmaScript modules (aka ESM) ([#1756](https://github.com/cucumber/common/pull/1756)) -* [Java] Add a `validate()` method to all messages. This will throw a `NullPointerException` - with a detailed message if a `required` field is `null`. This works recursively - for all non-null values (including non-required fields). - Argument constructors, getters and setters also throw `NullPointerException` - if a required `field` is `null`, but they don't validate recursively. - ([#1858](https://github.com/cucumber/common/pull/1858) [aslakhellesoy]) - ### Changed * Java: Generate Java code that uses `Optional` in getters. This makes the library more type safe (avoids illegal null values). To upgrade, replace `import io.cucumber.messages.types.*` with `import static io.cucumber.messages.Messages.*`. + Classes without required fields have public empty constructors, and static `fromXxx` + methods for each field. Setters are removed. Classes with required fields do + not have public empty constructors. ([#1858](https://github.com/cucumber/common/pull/1858) [aslakhellesoy]) ### Deprecated From bb6e9e45cf032943068ee21f1e3446d23406e46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 12 Jan 2022 21:58:14 +0000 Subject: [PATCH 24/63] Remove map lookup from enums --- .../java/io/cucumber/messages/Messages.java | 69 +++++-------------- .../scripts/templates/java.enum.java.erb | 17 ++--- 2 files changed, 21 insertions(+), 65 deletions(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 7a3d8e6892..515550edaf 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -4301,13 +4301,6 @@ public enum AttachmentContentEncoding { BASE64("BASE64"); private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (AttachmentContentEncoding c: values()) { - CONSTANTS.put(c.value, c); - } - } AttachmentContentEncoding(String value) { this.value = value; @@ -4323,12 +4316,9 @@ public String value() { } public static AttachmentContentEncoding fromValue(String value) { - AttachmentContentEncoding constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } + if ("IDENTITY".equals(value)) return IDENTITY; + if ("BASE64".equals(value)) return BASE64; + throw new IllegalArgumentException(value); } } @@ -4337,13 +4327,6 @@ public enum SourceMediaType { TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (SourceMediaType c: values()) { - CONSTANTS.put(c.value, c); - } - } SourceMediaType(String value) { this.value = value; @@ -4359,12 +4342,9 @@ public String value() { } public static SourceMediaType fromValue(String value) { - SourceMediaType constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } + if ("TEXT_X_CUCUMBER_GHERKIN_PLAIN".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_PLAIN; + if ("TEXT_X_CUCUMBER_GHERKIN_MARKDOWN".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_MARKDOWN; + throw new IllegalArgumentException(value); } } @@ -4373,13 +4353,6 @@ public enum StepDefinitionPatternType { REGULAR_EXPRESSION("REGULAR_EXPRESSION"); private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (StepDefinitionPatternType c: values()) { - CONSTANTS.put(c.value, c); - } - } StepDefinitionPatternType(String value) { this.value = value; @@ -4395,12 +4368,9 @@ public String value() { } public static StepDefinitionPatternType fromValue(String value) { - StepDefinitionPatternType constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } + if ("CUCUMBER_EXPRESSION".equals(value)) return CUCUMBER_EXPRESSION; + if ("REGULAR_EXPRESSION".equals(value)) return REGULAR_EXPRESSION; + throw new IllegalArgumentException(value); } } @@ -4414,13 +4384,6 @@ public enum TestStepResultStatus { FAILED("FAILED"); private final String value; - private final static java.util.Map CONSTANTS = new java.util.HashMap<>(); - - static { - for (TestStepResultStatus c: values()) { - CONSTANTS.put(c.value, c); - } - } TestStepResultStatus(String value) { this.value = value; @@ -4436,12 +4399,14 @@ public String value() { } public static TestStepResultStatus fromValue(String value) { - TestStepResultStatus constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } + if ("UNKNOWN".equals(value)) return UNKNOWN; + if ("PASSED".equals(value)) return PASSED; + if ("SKIPPED".equals(value)) return SKIPPED; + if ("PENDING".equals(value)) return PENDING; + if ("UNDEFINED".equals(value)) return UNDEFINED; + if ("AMBIGUOUS".equals(value)) return AMBIGUOUS; + if ("FAILED".equals(value)) return FAILED; + throw new IllegalArgumentException(value); } } diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb index 785fd6a492..789219d706 100644 --- a/messages/jsonschema/scripts/templates/java.enum.java.erb +++ b/messages/jsonschema/scripts/templates/java.enum.java.erb @@ -5,13 +5,6 @@ <% end -%> private final String value; - private final static java.util.Map> CONSTANTS = new java.util.HashMap<>(); - - static { - for (<%= enum[:name] %> c: values()) { - CONSTANTS.put(c.value, c); - } - } <%= enum[:name] %>(String value) { this.value = value; @@ -27,12 +20,10 @@ } public static <%= enum[:name] %> fromValue(String value) { - <%= enum[:name] %> constant = CONSTANTS.get(value); - if (constant == null) { - throw new IllegalArgumentException(value); - } else { - return constant; - } + <%- enum[:values].each do |value| -%> + if ("<%= enum_constant(value) %>".equals(value)) return <%= enum_constant(value) %>; + <%- end -%> + throw new IllegalArgumentException(value); } } From 2f6a659b51595d0b157546717a0bbd773c98a315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 12 Jan 2022 22:22:15 +0000 Subject: [PATCH 25/63] Rename static factories to just from --- .../java/io/cucumber/gherkin/Gherkin.java | 8 +-- .../MessagesToHtmlWriterTest.java | 6 +- messages/CHANGELOG.md | 2 +- .../java/io/cucumber/messages/Messages.java | 56 +++++++++---------- .../MessageSerializationContract.java | 6 +- .../scripts/templates/java.java.erb | 2 +- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index f8bbfb9c8a..237826159a 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -52,7 +52,7 @@ public static Stream fromSources(List envelopes, boolean inc } public static Envelope makeSourceEnvelope(String data, String uri) { - return Envelope.fromSource(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + return Envelope.from(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); } public Stream messages() { @@ -115,7 +115,7 @@ private List parseSource(boolean includeGherkinDocument, boolean inclu if (includeGherkinDocument) { gherkinDocument = parser.parse(data, uri); - messages.add(Envelope.fromGherkinDocument(gherkinDocument)); + messages.add(Envelope.from(gherkinDocument)); } if (includePickles) { if (gherkinDocument == null) { @@ -124,7 +124,7 @@ private List parseSource(boolean includeGherkinDocument, boolean inclu PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); List pickles = pickleCompiler.compile(gherkinDocument, uri); for (Pickle pickle : pickles) { - messages.add(Envelope.fromPickle(pickle)); + messages.add(Envelope.from(pickle)); } } } catch (ParserException.CompositeParserException e) { @@ -154,7 +154,7 @@ private void addParseError(List messages, ParserException e, String ur ), e.getMessage() ); - Envelope envelope = Envelope.fromParseError(parseError); + Envelope envelope = Envelope.from(parseError); messages.add(envelope); } } diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 8ef6729b54..349d250c90 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -24,7 +24,7 @@ class MessagesToHtmlWriterTest { @Test void it_writes_one_message_to_html() throws IOException { Instant timestamp = Instant.ofEpochSecond(10); - Envelope envelope = Envelope.fromTestRunStarted(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); + Envelope envelope = Envelope.from(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); String html = renderAsHtml(envelope); assertThat(html, containsString("" + "window.CUCUMBER_MESSAGES = [{\"testRunStarted\":{\"timestamp\":{\"seconds\":10,\"nanos\":0}}}];")); @@ -78,9 +78,9 @@ public void close() throws IOException { @Test void it_writes_two_messages_separated_by_a_comma() throws IOException { - Envelope testRunStarted = Envelope.fromTestRunStarted(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); + Envelope testRunStarted = Envelope.from(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); - Envelope envelope = Envelope.fromTestRunFinished(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); + Envelope envelope = Envelope.from(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); String html = renderAsHtml(testRunStarted, envelope); diff --git a/messages/CHANGELOG.md b/messages/CHANGELOG.md index 6fd693d217..4f181b975b 100644 --- a/messages/CHANGELOG.md +++ b/messages/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Java: Generate Java code that uses `Optional` in getters. This makes the library more type safe (avoids illegal null values). To upgrade, replace `import io.cucumber.messages.types.*` with `import static io.cucumber.messages.Messages.*`. - Classes without required fields have public empty constructors, and static `fromXxx` + Classes without required fields have public empty constructors, and static `from` methods for each field. Setters are removed. Classes with required fields do not have public empty constructors. ([#1858](https://github.com/cucumber/common/pull/1858) [aslakhellesoy]) diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 515550edaf..cf753725a8 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -199,119 +199,119 @@ public static class Envelope { public Envelope() {} - public static Envelope fromAttachment(Attachment attachment) { + public static Envelope from(Attachment attachment) { Envelope o = new Envelope(); o.attachment = java.util.Objects.requireNonNull(attachment, "Envelope.attachment cannot be null"); o.validate(); return o; } - public static Envelope fromGherkinDocument(GherkinDocument gherkinDocument) { + public static Envelope from(GherkinDocument gherkinDocument) { Envelope o = new Envelope(); o.gherkinDocument = java.util.Objects.requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"); o.validate(); return o; } - public static Envelope fromHook(Hook hook) { + public static Envelope from(Hook hook) { Envelope o = new Envelope(); o.hook = java.util.Objects.requireNonNull(hook, "Envelope.hook cannot be null"); o.validate(); return o; } - public static Envelope fromMeta(Meta meta) { + public static Envelope from(Meta meta) { Envelope o = new Envelope(); o.meta = java.util.Objects.requireNonNull(meta, "Envelope.meta cannot be null"); o.validate(); return o; } - public static Envelope fromParameterType(ParameterType parameterType) { + public static Envelope from(ParameterType parameterType) { Envelope o = new Envelope(); o.parameterType = java.util.Objects.requireNonNull(parameterType, "Envelope.parameterType cannot be null"); o.validate(); return o; } - public static Envelope fromParseError(ParseError parseError) { + public static Envelope from(ParseError parseError) { Envelope o = new Envelope(); o.parseError = java.util.Objects.requireNonNull(parseError, "Envelope.parseError cannot be null"); o.validate(); return o; } - public static Envelope fromPickle(Pickle pickle) { + public static Envelope from(Pickle pickle) { Envelope o = new Envelope(); o.pickle = java.util.Objects.requireNonNull(pickle, "Envelope.pickle cannot be null"); o.validate(); return o; } - public static Envelope fromSource(Source source) { + public static Envelope from(Source source) { Envelope o = new Envelope(); o.source = java.util.Objects.requireNonNull(source, "Envelope.source cannot be null"); o.validate(); return o; } - public static Envelope fromStepDefinition(StepDefinition stepDefinition) { + public static Envelope from(StepDefinition stepDefinition) { Envelope o = new Envelope(); o.stepDefinition = java.util.Objects.requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"); o.validate(); return o; } - public static Envelope fromTestCase(TestCase testCase) { + public static Envelope from(TestCase testCase) { Envelope o = new Envelope(); o.testCase = java.util.Objects.requireNonNull(testCase, "Envelope.testCase cannot be null"); o.validate(); return o; } - public static Envelope fromTestCaseFinished(TestCaseFinished testCaseFinished) { + public static Envelope from(TestCaseFinished testCaseFinished) { Envelope o = new Envelope(); o.testCaseFinished = java.util.Objects.requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"); o.validate(); return o; } - public static Envelope fromTestCaseStarted(TestCaseStarted testCaseStarted) { + public static Envelope from(TestCaseStarted testCaseStarted) { Envelope o = new Envelope(); o.testCaseStarted = java.util.Objects.requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"); o.validate(); return o; } - public static Envelope fromTestRunFinished(TestRunFinished testRunFinished) { + public static Envelope from(TestRunFinished testRunFinished) { Envelope o = new Envelope(); o.testRunFinished = java.util.Objects.requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"); o.validate(); return o; } - public static Envelope fromTestRunStarted(TestRunStarted testRunStarted) { + public static Envelope from(TestRunStarted testRunStarted) { Envelope o = new Envelope(); o.testRunStarted = java.util.Objects.requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"); o.validate(); return o; } - public static Envelope fromTestStepFinished(TestStepFinished testStepFinished) { + public static Envelope from(TestStepFinished testStepFinished) { Envelope o = new Envelope(); o.testStepFinished = java.util.Objects.requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"); o.validate(); return o; } - public static Envelope fromTestStepStarted(TestStepStarted testStepStarted) { + public static Envelope from(TestStepStarted testStepStarted) { Envelope o = new Envelope(); o.testStepStarted = java.util.Objects.requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"); o.validate(); return o; } - public static Envelope fromUndefinedParameterType(UndefinedParameterType undefinedParameterType) { + public static Envelope from(UndefinedParameterType undefinedParameterType) { Envelope o = new Envelope(); o.undefinedParameterType = java.util.Objects.requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null"); o.validate(); @@ -1134,21 +1134,21 @@ public static class FeatureChild { public FeatureChild() {} - public static FeatureChild fromRule(Rule rule) { + public static FeatureChild from(Rule rule) { FeatureChild o = new FeatureChild(); o.rule = java.util.Objects.requireNonNull(rule, "FeatureChild.rule cannot be null"); o.validate(); return o; } - public static FeatureChild fromBackground(Background background) { + public static FeatureChild from(Background background) { FeatureChild o = new FeatureChild(); o.background = java.util.Objects.requireNonNull(background, "FeatureChild.background cannot be null"); o.validate(); return o; } - public static FeatureChild fromScenario(Scenario scenario) { + public static FeatureChild from(Scenario scenario) { FeatureChild o = new FeatureChild(); o.scenario = java.util.Objects.requireNonNull(scenario, "FeatureChild.scenario cannot be null"); o.validate(); @@ -1337,14 +1337,14 @@ public static class RuleChild { public RuleChild() {} - public static RuleChild fromBackground(Background background) { + public static RuleChild from(Background background) { RuleChild o = new RuleChild(); o.background = java.util.Objects.requireNonNull(background, "RuleChild.background cannot be null"); o.validate(); return o; } - public static RuleChild fromScenario(Scenario scenario) { + public static RuleChild from(Scenario scenario) { RuleChild o = new RuleChild(); o.scenario = java.util.Objects.requireNonNull(scenario, "RuleChild.scenario cannot be null"); o.validate(); @@ -2673,14 +2673,14 @@ public static class PickleStepArgument { public PickleStepArgument() {} - public static PickleStepArgument fromDocString(PickleDocString docString) { + public static PickleStepArgument from(PickleDocString docString) { PickleStepArgument o = new PickleStepArgument(); o.docString = java.util.Objects.requireNonNull(docString, "PickleStepArgument.docString cannot be null"); o.validate(); return o; } - public static PickleStepArgument fromDataTable(PickleTable dataTable) { + public static PickleStepArgument from(PickleTable dataTable) { PickleStepArgument o = new PickleStepArgument(); o.dataTable = java.util.Objects.requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null"); o.validate(); @@ -3011,28 +3011,28 @@ public static class SourceReference { public SourceReference() {} - public static SourceReference fromUri(String uri) { + public static SourceReference from(String uri) { SourceReference o = new SourceReference(); o.uri = java.util.Objects.requireNonNull(uri, "SourceReference.uri cannot be null"); o.validate(); return o; } - public static SourceReference fromJavaMethod(JavaMethod javaMethod) { + public static SourceReference from(JavaMethod javaMethod) { SourceReference o = new SourceReference(); o.javaMethod = java.util.Objects.requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"); o.validate(); return o; } - public static SourceReference fromJavaStackTraceElement(JavaStackTraceElement javaStackTraceElement) { + public static SourceReference from(JavaStackTraceElement javaStackTraceElement) { SourceReference o = new SourceReference(); o.javaStackTraceElement = java.util.Objects.requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"); o.validate(); return o; } - public static SourceReference fromLocation(Location location) { + public static SourceReference from(Location location) { SourceReference o = new SourceReference(); o.location = java.util.Objects.requireNonNull(location, "SourceReference.location cannot be null"); o.validate(); diff --git a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java index e6345e6550..a7c3fff526 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java @@ -20,11 +20,11 @@ abstract class MessageSerializationContract { void can_serialise_messages_over_a_stream() throws IOException { List outgoingMessages = new ArrayList<>(); { - Envelope envelope = Envelope.fromSource(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + Envelope envelope = Envelope.from(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); outgoingMessages.add(envelope); } { - Envelope envelope = Envelope.fromAttachment( + Envelope envelope = Envelope.from( new Attachment( "the body", AttachmentContentEncoding.IDENTITY, @@ -46,7 +46,7 @@ void can_serialise_messages_over_a_stream() throws IOException { void writes_empty_arrays_and_empty_strings() throws IOException { List outgoingMessages = new ArrayList<>(); { - Envelope envelope = Envelope.fromGherkinDocument( + Envelope envelope = Envelope.from( new GherkinDocument( "hello.feature", new Feature( diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index e390301cc3..a2a50892ad 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -8,7 +8,7 @@ public <%= class_name(key) %>() {} <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - public static <%= class_name(key) %> from<%= capitalize(property_name) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + public static <%= class_name(key) %> from(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { <%= class_name(key) %> o = new <%= class_name(key) %>(); o.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); o.validate(); From 1d32170e68f2d631406ec8aadf72e8bd207f9df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 12 Jan 2022 22:42:10 +0000 Subject: [PATCH 26/63] Make all lists unmodifiable --- .../java/io/cucumber/messages/Messages.java | 104 +++++++++--------- .../scripts/templates/java.java.erb | 10 +- 2 files changed, 61 insertions(+), 53 deletions(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index cf753725a8..96019eb5f3 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -522,7 +522,7 @@ public String toString() { public static class GherkinDocument { private String uri; private Feature feature; - private java.util.List comments = new java.util.ArrayList<>(); + private java.util.List comments; private GherkinDocument() {} @@ -533,7 +533,7 @@ public GherkinDocument( ) { this.uri = uri; this.feature = feature; - this.comments = comments; + this.comments = comments == null ? null : java.util.Collections.unmodifiableList(comments); validate(); } @@ -592,7 +592,7 @@ public static class Background { private String keyword; private String name; private String description; - private java.util.List steps = new java.util.ArrayList<>(); + private java.util.List steps; private String id; private Background() {} @@ -609,7 +609,7 @@ public Background( this.keyword = keyword; this.name = name; this.description = description; - this.steps = steps; + this.steps = steps == null ? null : java.util.Collections.unmodifiableList(steps); this.id = id; validate(); } @@ -750,7 +750,7 @@ public String toString() { public static class DataTable { private Location location; - private java.util.List rows = new java.util.ArrayList<>(); + private java.util.List rows; private DataTable() {} @@ -759,7 +759,7 @@ public DataTable( java.util.List rows ) { this.location = location; - this.rows = rows; + this.rows = rows == null ? null : java.util.Collections.unmodifiableList(rows); validate(); } @@ -888,12 +888,12 @@ public String toString() { public static class Examples { private Location location; - private java.util.List tags = new java.util.ArrayList<>(); + private java.util.List tags; private String keyword; private String name; private String description; private TableRow tableHeader; - private java.util.List tableBody = new java.util.ArrayList<>(); + private java.util.List tableBody; private String id; private Examples() {} @@ -909,12 +909,12 @@ public Examples( String id ) { this.location = location; - this.tags = tags; + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); this.keyword = keyword; this.name = name; this.description = description; this.tableHeader = tableHeader; - this.tableBody = tableBody; + this.tableBody = tableBody == null ? null : java.util.Collections.unmodifiableList(tableBody); this.id = id; validate(); } @@ -1014,12 +1014,12 @@ public String toString() { public static class Feature { private Location location; - private java.util.List tags = new java.util.ArrayList<>(); + private java.util.List tags; private String language; private String keyword; private String name; private String description; - private java.util.List children = new java.util.ArrayList<>(); + private java.util.List children; private Feature() {} @@ -1033,12 +1033,12 @@ public Feature( java.util.List children ) { this.location = location; - this.tags = tags; + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); this.language = language; this.keyword = keyword; this.name = name; this.description = description; - this.children = children; + this.children = children == null ? null : java.util.Collections.unmodifiableList(children); validate(); } @@ -1218,11 +1218,11 @@ public String toString() { public static class Rule { private Location location; - private java.util.List tags = new java.util.ArrayList<>(); + private java.util.List tags; private String keyword; private String name; private String description; - private java.util.List children = new java.util.ArrayList<>(); + private java.util.List children; private String id; private Rule() {} @@ -1237,11 +1237,11 @@ public Rule( String id ) { this.location = location; - this.tags = tags; + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); this.keyword = keyword; this.name = name; this.description = description; - this.children = children; + this.children = children == null ? null : java.util.Collections.unmodifiableList(children); this.id = id; validate(); } @@ -1404,12 +1404,12 @@ public String toString() { public static class Scenario { private Location location; - private java.util.List tags = new java.util.ArrayList<>(); + private java.util.List tags; private String keyword; private String name; private String description; - private java.util.List steps = new java.util.ArrayList<>(); - private java.util.List examples = new java.util.ArrayList<>(); + private java.util.List steps; + private java.util.List examples; private String id; private Scenario() {} @@ -1425,12 +1425,12 @@ public Scenario( String id ) { this.location = location; - this.tags = tags; + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); this.keyword = keyword; this.name = name; this.description = description; - this.steps = steps; - this.examples = examples; + this.steps = steps == null ? null : java.util.Collections.unmodifiableList(steps); + this.examples = examples == null ? null : java.util.Collections.unmodifiableList(examples); this.id = id; validate(); } @@ -1691,7 +1691,7 @@ public String toString() { public static class TableRow { private Location location; - private java.util.List cells = new java.util.ArrayList<>(); + private java.util.List cells; private String id; private TableRow() {} @@ -1702,7 +1702,7 @@ public TableRow( String id ) { this.location = location; - this.cells = cells; + this.cells = cells == null ? null : java.util.Collections.unmodifiableList(cells); this.id = id; validate(); } @@ -2269,7 +2269,7 @@ public String toString() { public static class ParameterType { private String name; - private java.util.List regularExpressions = new java.util.ArrayList<>(); + private java.util.List regularExpressions; private Boolean preferForRegularExpressionMatch; private Boolean useForSnippets; private String id; @@ -2284,7 +2284,7 @@ public ParameterType( String id ) { this.name = name; - this.regularExpressions = regularExpressions; + this.regularExpressions = regularExpressions == null ? null : java.util.Collections.unmodifiableList(regularExpressions); this.preferForRegularExpressionMatch = preferForRegularExpressionMatch; this.useForSnippets = useForSnippets; this.id = id; @@ -2421,9 +2421,9 @@ public static class Pickle { private String uri; private String name; private String language; - private java.util.List steps = new java.util.ArrayList<>(); - private java.util.List tags = new java.util.ArrayList<>(); - private java.util.List astNodeIds = new java.util.ArrayList<>(); + private java.util.List steps; + private java.util.List tags; + private java.util.List astNodeIds; private Pickle() {} @@ -2440,9 +2440,9 @@ public Pickle( this.uri = uri; this.name = name; this.language = language; - this.steps = steps; - this.tags = tags; - this.astNodeIds = astNodeIds; + this.steps = steps == null ? null : java.util.Collections.unmodifiableList(steps); + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); + this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(astNodeIds); validate(); } @@ -2589,7 +2589,7 @@ public String toString() { public static class PickleStep { private PickleStepArgument argument; - private java.util.List astNodeIds = new java.util.ArrayList<>(); + private java.util.List astNodeIds; private String id; private String text; @@ -2602,7 +2602,7 @@ public PickleStep( String text ) { this.argument = argument; - this.astNodeIds = astNodeIds; + this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(astNodeIds); this.id = id; this.text = text; validate(); @@ -2739,14 +2739,14 @@ public String toString() { public static class PickleTable { - private java.util.List rows = new java.util.ArrayList<>(); + private java.util.List rows; private PickleTable() {} public PickleTable( java.util.List rows ) { - this.rows = rows; + this.rows = rows == null ? null : java.util.Collections.unmodifiableList(rows); validate(); } @@ -2832,14 +2832,14 @@ public String toString() { public static class PickleTableRow { - private java.util.List cells = new java.util.ArrayList<>(); + private java.util.List cells; private PickleTableRow() {} public PickleTableRow( java.util.List cells ) { - this.cells = cells; + this.cells = cells == null ? null : java.util.Collections.unmodifiableList(cells); validate(); } @@ -3112,7 +3112,7 @@ public String toString() { public static class JavaMethod { private String className; private String methodName; - private java.util.List methodParameterTypes = new java.util.ArrayList<>(); + private java.util.List methodParameterTypes; private JavaMethod() {} @@ -3123,7 +3123,7 @@ public JavaMethod( ) { this.className = className; this.methodName = methodName; - this.methodParameterTypes = methodParameterTypes; + this.methodParameterTypes = methodParameterTypes == null ? null : java.util.Collections.unmodifiableList(methodParameterTypes); validate(); } @@ -3376,7 +3376,7 @@ public String toString() { public static class TestCase { private String id; private String pickleId; - private java.util.List testSteps = new java.util.ArrayList<>(); + private java.util.List testSteps; private TestCase() {} @@ -3387,7 +3387,7 @@ public TestCase( ) { this.id = id; this.pickleId = pickleId; - this.testSteps = testSteps; + this.testSteps = testSteps == null ? null : java.util.Collections.unmodifiableList(testSteps); validate(); } @@ -3443,7 +3443,7 @@ public String toString() { public static class Group { - private java.util.List children = new java.util.ArrayList<>(); + private java.util.List children; private Long start; private String value; @@ -3454,7 +3454,7 @@ public Group( Long start, String value ) { - this.children = children; + this.children = children == null ? null : java.util.Collections.unmodifiableList(children); this.start = start; this.value = value; validate(); @@ -3567,14 +3567,14 @@ public String toString() { public static class StepMatchArgumentsList { - private java.util.List stepMatchArguments = new java.util.ArrayList<>(); + private java.util.List stepMatchArguments; private StepMatchArgumentsList() {} public StepMatchArgumentsList( java.util.List stepMatchArguments ) { - this.stepMatchArguments = stepMatchArguments; + this.stepMatchArguments = stepMatchArguments == null ? null : java.util.Collections.unmodifiableList(stepMatchArguments); validate(); } @@ -3617,8 +3617,8 @@ public static class TestStep { private String hookId; private String id; private String pickleStepId; - private java.util.List stepDefinitionIds = new java.util.ArrayList<>(); - private java.util.List stepMatchArgumentsLists = new java.util.ArrayList<>(); + private java.util.List stepDefinitionIds; + private java.util.List stepMatchArgumentsLists; private TestStep() {} @@ -3632,8 +3632,8 @@ public TestStep( this.hookId = hookId; this.id = id; this.pickleStepId = pickleStepId; - this.stepDefinitionIds = stepDefinitionIds; - this.stepMatchArgumentsLists = stepMatchArgumentsLists; + this.stepDefinitionIds = stepDefinitionIds == null ? null : java.util.Collections.unmodifiableList(stepDefinitionIds); + this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : java.util.Collections.unmodifiableList(stepMatchArgumentsLists); validate(); } diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index a2a50892ad..395379a717 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,7 +1,7 @@ <% @schemas.each do |key, schema| %> public static class <%= class_name(key) %> { <%- schema['properties'].each do |property_name, property| -%> - private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= property['items'] ? ' = new java.util.ArrayList<>()' : '' %>; + private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; <%- end -%> <%- if (schema['required'] || []).empty? -%> @@ -10,7 +10,11 @@ public static <%= class_name(key) %> from(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { <%= class_name(key) %> o = new <%= class_name(key) %>(); + <%- if property['items'] -%> + o.<%= property_name %> = java.util.Collections.unmodifiableList(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")); + <%- else -%> o.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); + <%- end -%> o.validate(); return o; } @@ -25,7 +29,11 @@ <%- end -%> ) { <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%- if property['items'] -%> + this.<%= property_name %> = <%= property_name %> == null ? null : java.util.Collections.unmodifiableList(<%= property_name %>); + <%- else -%> this.<%= property_name %> = <%= property_name %>; + <%- end -%> <%- end -%> validate(); } From 92202fa050b56d6c162514d9340b3563999a70a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 12 Jan 2022 23:32:42 +0000 Subject: [PATCH 27/63] Copy list before making it unmodifiable --- .../java/io/cucumber/messages/Messages.java | 52 +++++++++---------- .../scripts/templates/java.java.erb | 4 +- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 96019eb5f3..4e2bd21867 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -533,7 +533,7 @@ public GherkinDocument( ) { this.uri = uri; this.feature = feature; - this.comments = comments == null ? null : java.util.Collections.unmodifiableList(comments); + this.comments = comments == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(comments)); validate(); } @@ -609,7 +609,7 @@ public Background( this.keyword = keyword; this.name = name; this.description = description; - this.steps = steps == null ? null : java.util.Collections.unmodifiableList(steps); + this.steps = steps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(steps)); this.id = id; validate(); } @@ -759,7 +759,7 @@ public DataTable( java.util.List rows ) { this.location = location; - this.rows = rows == null ? null : java.util.Collections.unmodifiableList(rows); + this.rows = rows == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(rows)); validate(); } @@ -909,12 +909,12 @@ public Examples( String id ) { this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); this.keyword = keyword; this.name = name; this.description = description; this.tableHeader = tableHeader; - this.tableBody = tableBody == null ? null : java.util.Collections.unmodifiableList(tableBody); + this.tableBody = tableBody == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tableBody)); this.id = id; validate(); } @@ -1033,12 +1033,12 @@ public Feature( java.util.List children ) { this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); this.language = language; this.keyword = keyword; this.name = name; this.description = description; - this.children = children == null ? null : java.util.Collections.unmodifiableList(children); + this.children = children == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(children)); validate(); } @@ -1237,11 +1237,11 @@ public Rule( String id ) { this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); this.keyword = keyword; this.name = name; this.description = description; - this.children = children == null ? null : java.util.Collections.unmodifiableList(children); + this.children = children == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(children)); this.id = id; validate(); } @@ -1425,12 +1425,12 @@ public Scenario( String id ) { this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); this.keyword = keyword; this.name = name; this.description = description; - this.steps = steps == null ? null : java.util.Collections.unmodifiableList(steps); - this.examples = examples == null ? null : java.util.Collections.unmodifiableList(examples); + this.steps = steps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(steps)); + this.examples = examples == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(examples)); this.id = id; validate(); } @@ -1702,7 +1702,7 @@ public TableRow( String id ) { this.location = location; - this.cells = cells == null ? null : java.util.Collections.unmodifiableList(cells); + this.cells = cells == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(cells)); this.id = id; validate(); } @@ -2284,7 +2284,7 @@ public ParameterType( String id ) { this.name = name; - this.regularExpressions = regularExpressions == null ? null : java.util.Collections.unmodifiableList(regularExpressions); + this.regularExpressions = regularExpressions == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(regularExpressions)); this.preferForRegularExpressionMatch = preferForRegularExpressionMatch; this.useForSnippets = useForSnippets; this.id = id; @@ -2440,9 +2440,9 @@ public Pickle( this.uri = uri; this.name = name; this.language = language; - this.steps = steps == null ? null : java.util.Collections.unmodifiableList(steps); - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(tags); - this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(astNodeIds); + this.steps = steps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(steps)); + this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); + this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(astNodeIds)); validate(); } @@ -2602,7 +2602,7 @@ public PickleStep( String text ) { this.argument = argument; - this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(astNodeIds); + this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(astNodeIds)); this.id = id; this.text = text; validate(); @@ -2746,7 +2746,7 @@ private PickleTable() {} public PickleTable( java.util.List rows ) { - this.rows = rows == null ? null : java.util.Collections.unmodifiableList(rows); + this.rows = rows == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(rows)); validate(); } @@ -2839,7 +2839,7 @@ private PickleTableRow() {} public PickleTableRow( java.util.List cells ) { - this.cells = cells == null ? null : java.util.Collections.unmodifiableList(cells); + this.cells = cells == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(cells)); validate(); } @@ -3123,7 +3123,7 @@ public JavaMethod( ) { this.className = className; this.methodName = methodName; - this.methodParameterTypes = methodParameterTypes == null ? null : java.util.Collections.unmodifiableList(methodParameterTypes); + this.methodParameterTypes = methodParameterTypes == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(methodParameterTypes)); validate(); } @@ -3387,7 +3387,7 @@ public TestCase( ) { this.id = id; this.pickleId = pickleId; - this.testSteps = testSteps == null ? null : java.util.Collections.unmodifiableList(testSteps); + this.testSteps = testSteps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(testSteps)); validate(); } @@ -3454,7 +3454,7 @@ public Group( Long start, String value ) { - this.children = children == null ? null : java.util.Collections.unmodifiableList(children); + this.children = children == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(children)); this.start = start; this.value = value; validate(); @@ -3574,7 +3574,7 @@ private StepMatchArgumentsList() {} public StepMatchArgumentsList( java.util.List stepMatchArguments ) { - this.stepMatchArguments = stepMatchArguments == null ? null : java.util.Collections.unmodifiableList(stepMatchArguments); + this.stepMatchArguments = stepMatchArguments == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepMatchArguments)); validate(); } @@ -3632,8 +3632,8 @@ public TestStep( this.hookId = hookId; this.id = id; this.pickleStepId = pickleStepId; - this.stepDefinitionIds = stepDefinitionIds == null ? null : java.util.Collections.unmodifiableList(stepDefinitionIds); - this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : java.util.Collections.unmodifiableList(stepMatchArgumentsLists); + this.stepDefinitionIds = stepDefinitionIds == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepDefinitionIds)); + this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepMatchArgumentsLists)); validate(); } diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 395379a717..abcc75e950 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -11,7 +11,7 @@ public static <%= class_name(key) %> from(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { <%= class_name(key) %> o = new <%= class_name(key) %>(); <%- if property['items'] -%> - o.<%= property_name %> = java.util.Collections.unmodifiableList(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")); + o.<%= property_name %> = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))); <%- else -%> o.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); <%- end -%> @@ -30,7 +30,7 @@ ) { <%- schema['properties'].each_with_index do |(property_name, property), index| -%> <%- if property['items'] -%> - this.<%= property_name %> = <%= property_name %> == null ? null : java.util.Collections.unmodifiableList(<%= property_name %>); + this.<%= property_name %> = <%= property_name %> == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(<%= property_name %>)); <%- else -%> this.<%= property_name %> = <%= property_name %>; <%- end -%> From 29f85f7380c37d511bdbec1b54ede5e75597b31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Wed, 12 Jan 2022 23:53:44 +0000 Subject: [PATCH 28/63] Add minItems --- messages/CHANGELOG.md | 1 + .../src/main/java/io/cucumber/messages/Messages.java | 4 ++++ messages/jsonschema/ParameterType.json | 3 ++- messages/jsonschema/Pickle.json | 9 ++++++--- messages/jsonschema/scripts/templates/java.java.erb | 3 +++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/messages/CHANGELOG.md b/messages/CHANGELOG.md index 4f181b975b..866aaafc35 100644 --- a/messages/CHANGELOG.md +++ b/messages/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +* JSON Schema: some `array` fields now have `"minItems": 1`. * Java: Generate Java code that uses `Optional` in getters. This makes the library more type safe (avoids illegal null values). To upgrade, replace `import io.cucumber.messages.types.*` with `import static io.cucumber.messages.Messages.*`. Classes without required fields have public empty constructors, and static `from` diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 4e2bd21867..731c53f516 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -2316,6 +2316,7 @@ private void validate() { java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); regularExpressions.forEach(e -> java.util.Objects.requireNonNull(e, "ParameterType.regularExpressions elements cannot be null")); + if(regularExpressions.size() < 1) throw new IllegalArgumentException("ParameterType.regularExpressions must have at least 1 element"); java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); @@ -2486,6 +2487,7 @@ private void validate() { tags.forEach(PickleTag::validate); java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); astNodeIds.forEach(e -> java.util.Objects.requireNonNull(e, "Pickle.astNodeIds elements cannot be null")); + if(astNodeIds.size() < 1) throw new IllegalArgumentException("Pickle.astNodeIds must have at least 1 element"); } @Override @@ -2629,6 +2631,7 @@ private void validate() { if (argument != null) argument.validate(); java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); astNodeIds.forEach(e -> java.util.Objects.requireNonNull(e, "PickleStep.astNodeIds elements cannot be null")); + if(astNodeIds.size() < 1) throw new IllegalArgumentException("PickleStep.astNodeIds must have at least 1 element"); java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); } @@ -2851,6 +2854,7 @@ public java.util.List getCells() { private void validate() { java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); cells.forEach(PickleTableCell::validate); + if(cells.size() < 1) throw new IllegalArgumentException("PickleTableRow.cells must have at least 1 element"); } @Override diff --git a/messages/jsonschema/ParameterType.json b/messages/jsonschema/ParameterType.json index 21c86b3fd2..872d45c105 100644 --- a/messages/jsonschema/ParameterType.json +++ b/messages/jsonschema/ParameterType.json @@ -18,7 +18,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "minItems": 1 }, "preferForRegularExpressionMatch": { "type": "boolean" diff --git a/messages/jsonschema/Pickle.json b/messages/jsonschema/Pickle.json index 204ebf9f06..53518c7349 100644 --- a/messages/jsonschema/Pickle.json +++ b/messages/jsonschema/Pickle.json @@ -36,7 +36,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "minItems": 1 }, "id": { "description": "A unique ID for the PickleStep", @@ -100,7 +101,8 @@ "items": { "$ref": "#/definitions/PickleTableCell" }, - "type": "array" + "type": "array", + "minItems": 1 } }, "type": "object" @@ -171,7 +173,8 @@ "items": { "type": "string" }, - "type": "array" + "type": "array", + "minItems": 1 } }, "type": "object" diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index abcc75e950..a89d8d0303 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -65,6 +65,9 @@ <%- else -%> <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(<%= type_for(key, nil, property['items']) %>::validate); <%- end -%> + <%- if property['minItems'] -%> + <% if !required %>if (<%= property_name %> != null) <%- end %>if(<%= property_name %>.size() < <%= property['minItems'] %>) throw new IllegalArgumentException("<%= class_name(key) %>.<%= property_name %> must have at least <%= property['minItems'] %> element<%= property['minItems'] > 1 ? 's' : '' %>"); + <%- end -%> <%- elsif property['$ref'] -%> <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.validate(); <%- end -%> From ce2aebed20e9e5af78b82bf442486097f35bb7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 10:04:28 +0000 Subject: [PATCH 29/63] Use final fields --- messages/java/pom.xml | 7 + .../java/io/cucumber/messages/Messages.java | 1380 +++++++++-------- .../io/cucumber/messages/MessagesTest.java | 20 +- .../messages/NdjsonSerializationTest.java | 60 +- .../scripts/templates/java.java.erb | 47 +- 5 files changed, 826 insertions(+), 688 deletions(-) diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 0b4bdf2765..0bccfe256b 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -77,6 +77,13 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + true + + org.apache.maven.plugins maven-shade-plugin diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 731c53f516..f82709d498 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -3,16 +3,14 @@ public class Messages { public static class Attachment { - private String body; - private AttachmentContentEncoding contentEncoding; - private String fileName; - private String mediaType; - private Source source; - private String testCaseStartedId; - private String testStepId; - private String url; - - private Attachment() {} + private final String body; + private final AttachmentContentEncoding contentEncoding; + private final String fileName; + private final String mediaType; + private final Source source; + private final String testCaseStartedId; + private final String testStepId; + private final String url; public Attachment( String body, @@ -24,18 +22,16 @@ public Attachment( String testStepId, String url ) { - this.body = body; - this.contentEncoding = contentEncoding; + this.body = java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); + this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); this.fileName = fileName; - this.mediaType = mediaType; + this.mediaType = java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); this.source = source; this.testCaseStartedId = testCaseStartedId; this.testStepId = testStepId; this.url = url; - validate(); } - public String getBody() { return body; } @@ -122,21 +118,17 @@ public String toString() { public static class Duration { - private Long seconds; - private Long nanos; - - private Duration() {} + private final Long seconds; + private final Long nanos; public Duration( Long seconds, Long nanos ) { - this.seconds = seconds; - this.nanos = nanos; - validate(); + this.seconds = java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); + this.nanos = java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); } - public Long getSeconds() { return seconds; } @@ -179,143 +171,396 @@ public String toString() { public static class Envelope { - private Attachment attachment; - private GherkinDocument gherkinDocument; - private Hook hook; - private Meta meta; - private ParameterType parameterType; - private ParseError parseError; - private Pickle pickle; - private Source source; - private StepDefinition stepDefinition; - private TestCase testCase; - private TestCaseFinished testCaseFinished; - private TestCaseStarted testCaseStarted; - private TestRunFinished testRunFinished; - private TestRunStarted testRunStarted; - private TestStepFinished testStepFinished; - private TestStepStarted testStepStarted; - private UndefinedParameterType undefinedParameterType; - - public Envelope() {} + private final Attachment attachment; + private final GherkinDocument gherkinDocument; + private final Hook hook; + private final Meta meta; + private final ParameterType parameterType; + private final ParseError parseError; + private final Pickle pickle; + private final Source source; + private final StepDefinition stepDefinition; + private final TestCase testCase; + private final TestCaseFinished testCaseFinished; + private final TestCaseStarted testCaseStarted; + private final TestRunFinished testRunFinished; + private final TestRunStarted testRunStarted; + private final TestStepFinished testStepFinished; + private final TestStepStarted testStepStarted; + private final UndefinedParameterType undefinedParameterType; public static Envelope from(Attachment attachment) { - Envelope o = new Envelope(); - o.attachment = java.util.Objects.requireNonNull(attachment, "Envelope.attachment cannot be null"); - o.validate(); - return o; + return new Envelope( + java.util.Objects.requireNonNull(attachment, "Envelope.attachment cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(GherkinDocument gherkinDocument) { - Envelope o = new Envelope(); - o.gherkinDocument = java.util.Objects.requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + java.util.Objects.requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(Hook hook) { - Envelope o = new Envelope(); - o.hook = java.util.Objects.requireNonNull(hook, "Envelope.hook cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + java.util.Objects.requireNonNull(hook, "Envelope.hook cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(Meta meta) { - Envelope o = new Envelope(); - o.meta = java.util.Objects.requireNonNull(meta, "Envelope.meta cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + java.util.Objects.requireNonNull(meta, "Envelope.meta cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(ParameterType parameterType) { - Envelope o = new Envelope(); - o.parameterType = java.util.Objects.requireNonNull(parameterType, "Envelope.parameterType cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + java.util.Objects.requireNonNull(parameterType, "Envelope.parameterType cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(ParseError parseError) { - Envelope o = new Envelope(); - o.parseError = java.util.Objects.requireNonNull(parseError, "Envelope.parseError cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(parseError, "Envelope.parseError cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(Pickle pickle) { - Envelope o = new Envelope(); - o.pickle = java.util.Objects.requireNonNull(pickle, "Envelope.pickle cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(pickle, "Envelope.pickle cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(Source source) { - Envelope o = new Envelope(); - o.source = java.util.Objects.requireNonNull(source, "Envelope.source cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(source, "Envelope.source cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(StepDefinition stepDefinition) { - Envelope o = new Envelope(); - o.stepDefinition = java.util.Objects.requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(TestCase testCase) { - Envelope o = new Envelope(); - o.testCase = java.util.Objects.requireNonNull(testCase, "Envelope.testCase cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(testCase, "Envelope.testCase cannot be null"), + null, + null, + null, + null, + null, + null, + null + ); } public static Envelope from(TestCaseFinished testCaseFinished) { - Envelope o = new Envelope(); - o.testCaseFinished = java.util.Objects.requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"), + null, + null, + null, + null, + null, + null + ); } public static Envelope from(TestCaseStarted testCaseStarted) { - Envelope o = new Envelope(); - o.testCaseStarted = java.util.Objects.requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"), + null, + null, + null, + null, + null + ); } public static Envelope from(TestRunFinished testRunFinished) { - Envelope o = new Envelope(); - o.testRunFinished = java.util.Objects.requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"), + null, + null, + null, + null + ); } public static Envelope from(TestRunStarted testRunStarted) { - Envelope o = new Envelope(); - o.testRunStarted = java.util.Objects.requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"), + null, + null, + null + ); } public static Envelope from(TestStepFinished testStepFinished) { - Envelope o = new Envelope(); - o.testStepFinished = java.util.Objects.requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"), + null, + null + ); } public static Envelope from(TestStepStarted testStepStarted) { - Envelope o = new Envelope(); - o.testStepStarted = java.util.Objects.requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"), + null + ); } public static Envelope from(UndefinedParameterType undefinedParameterType) { - Envelope o = new Envelope(); - o.undefinedParameterType = java.util.Objects.requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null"); - o.validate(); - return o; + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + java.util.Objects.requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null") + ); } public Envelope( @@ -354,10 +599,8 @@ public Envelope( this.testStepFinished = testStepFinished; this.testStepStarted = testStepStarted; this.undefinedParameterType = undefinedParameterType; - validate(); } - public java.util.Optional getAttachment() { return java.util.Optional.ofNullable(attachment); } @@ -520,11 +763,9 @@ public String toString() { public static class GherkinDocument { - private String uri; - private Feature feature; - private java.util.List comments; - - private GherkinDocument() {} + private final String uri; + private final Feature feature; + private final java.util.List comments; public GherkinDocument( String uri, @@ -533,11 +774,9 @@ public GherkinDocument( ) { this.uri = uri; this.feature = feature; - this.comments = comments == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(comments)); - validate(); + this.comments = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"))); } - public java.util.Optional getUri() { return java.util.Optional.ofNullable(uri); } @@ -588,14 +827,12 @@ public String toString() { public static class Background { - private Location location; - private String keyword; - private String name; - private String description; - private java.util.List steps; - private String id; - - private Background() {} + private final Location location; + private final String keyword; + private final String name; + private final String description; + private final java.util.List steps; + private final String id; public Background( Location location, @@ -605,16 +842,14 @@ public Background( java.util.List steps, String id ) { - this.location = location; - this.keyword = keyword; - this.name = name; - this.description = description; - this.steps = steps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(steps)); - this.id = id; - validate(); + this.location = java.util.Objects.requireNonNull(location, "Background.location cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Background.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Background.description cannot be null"); + this.steps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"))); + this.id = java.util.Objects.requireNonNull(id, "Background.id cannot be null"); } - public Location getLocation() { return location; } @@ -691,21 +926,17 @@ public String toString() { public static class Comment { - private Location location; - private String text; - - private Comment() {} + private final Location location; + private final String text; public Comment( Location location, String text ) { - this.location = location; - this.text = text; - validate(); + this.location = java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); + this.text = java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); } - public Location getLocation() { return location; } @@ -749,21 +980,17 @@ public String toString() { public static class DataTable { - private Location location; - private java.util.List rows; - - private DataTable() {} + private final Location location; + private final java.util.List rows; public DataTable( Location location, java.util.List rows ) { - this.location = location; - this.rows = rows == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(rows)); - validate(); + this.location = java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); + this.rows = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"))); } - public Location getLocation() { return location; } @@ -808,12 +1035,10 @@ public String toString() { public static class DocString { - private Location location; - private String mediaType; - private String content; - private String delimiter; - - private DocString() {} + private final Location location; + private final String mediaType; + private final String content; + private final String delimiter; public DocString( Location location, @@ -821,14 +1046,12 @@ public DocString( String content, String delimiter ) { - this.location = location; + this.location = java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); this.mediaType = mediaType; - this.content = content; - this.delimiter = delimiter; - validate(); + this.content = java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); + this.delimiter = java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); } - public Location getLocation() { return location; } @@ -887,16 +1110,14 @@ public String toString() { public static class Examples { - private Location location; - private java.util.List tags; - private String keyword; - private String name; - private String description; - private TableRow tableHeader; - private java.util.List tableBody; - private String id; - - private Examples() {} + private final Location location; + private final java.util.List tags; + private final String keyword; + private final String name; + private final String description; + private final TableRow tableHeader; + private final java.util.List tableBody; + private final String id; public Examples( Location location, @@ -908,18 +1129,16 @@ public Examples( java.util.List tableBody, String id ) { - this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); - this.keyword = keyword; - this.name = name; - this.description = description; + this.location = java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); + this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"))); + this.keyword = java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); this.tableHeader = tableHeader; - this.tableBody = tableBody == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tableBody)); - this.id = id; - validate(); + this.tableBody = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"))); + this.id = java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); } - public Location getLocation() { return location; } @@ -1013,15 +1232,13 @@ public String toString() { public static class Feature { - private Location location; - private java.util.List tags; - private String language; - private String keyword; - private String name; - private String description; - private java.util.List children; - - private Feature() {} + private final Location location; + private final java.util.List tags; + private final String language; + private final String keyword; + private final String name; + private final String description; + private final java.util.List children; public Feature( Location location, @@ -1032,17 +1249,15 @@ public Feature( String description, java.util.List children ) { - this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); - this.language = language; - this.keyword = keyword; - this.name = name; - this.description = description; - this.children = children == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(children)); - validate(); + this.location = java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); + this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"))); + this.language = java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); + this.children = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(children, "Feature.children cannot be null"))); } - public Location getLocation() { return location; } @@ -1128,31 +1343,32 @@ public String toString() { public static class FeatureChild { - private Rule rule; - private Background background; - private Scenario scenario; - - public FeatureChild() {} + private final Rule rule; + private final Background background; + private final Scenario scenario; public static FeatureChild from(Rule rule) { - FeatureChild o = new FeatureChild(); - o.rule = java.util.Objects.requireNonNull(rule, "FeatureChild.rule cannot be null"); - o.validate(); - return o; + return new FeatureChild( + java.util.Objects.requireNonNull(rule, "FeatureChild.rule cannot be null"), + null, + null + ); } public static FeatureChild from(Background background) { - FeatureChild o = new FeatureChild(); - o.background = java.util.Objects.requireNonNull(background, "FeatureChild.background cannot be null"); - o.validate(); - return o; + return new FeatureChild( + null, + java.util.Objects.requireNonNull(background, "FeatureChild.background cannot be null"), + null + ); } public static FeatureChild from(Scenario scenario) { - FeatureChild o = new FeatureChild(); - o.scenario = java.util.Objects.requireNonNull(scenario, "FeatureChild.scenario cannot be null"); - o.validate(); - return o; + return new FeatureChild( + null, + null, + java.util.Objects.requireNonNull(scenario, "FeatureChild.scenario cannot be null") + ); } public FeatureChild( @@ -1163,10 +1379,8 @@ public FeatureChild( this.rule = rule; this.background = background; this.scenario = scenario; - validate(); } - public java.util.Optional getRule() { return java.util.Optional.ofNullable(rule); } @@ -1217,15 +1431,13 @@ public String toString() { public static class Rule { - private Location location; - private java.util.List tags; - private String keyword; - private String name; - private String description; - private java.util.List children; - private String id; - - private Rule() {} + private final Location location; + private final java.util.List tags; + private final String keyword; + private final String name; + private final String description; + private final java.util.List children; + private final String id; public Rule( Location location, @@ -1236,17 +1448,15 @@ public Rule( java.util.List children, String id ) { - this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); - this.keyword = keyword; - this.name = name; - this.description = description; - this.children = children == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(children)); - this.id = id; - validate(); + this.location = java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); + this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"))); + this.keyword = java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); + this.children = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(children, "Rule.children cannot be null"))); + this.id = java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); } - public Location getLocation() { return location; } @@ -1332,23 +1542,21 @@ public String toString() { public static class RuleChild { - private Background background; - private Scenario scenario; - - public RuleChild() {} + private final Background background; + private final Scenario scenario; public static RuleChild from(Background background) { - RuleChild o = new RuleChild(); - o.background = java.util.Objects.requireNonNull(background, "RuleChild.background cannot be null"); - o.validate(); - return o; + return new RuleChild( + java.util.Objects.requireNonNull(background, "RuleChild.background cannot be null"), + null + ); } public static RuleChild from(Scenario scenario) { - RuleChild o = new RuleChild(); - o.scenario = java.util.Objects.requireNonNull(scenario, "RuleChild.scenario cannot be null"); - o.validate(); - return o; + return new RuleChild( + null, + java.util.Objects.requireNonNull(scenario, "RuleChild.scenario cannot be null") + ); } public RuleChild( @@ -1357,10 +1565,8 @@ public RuleChild( ) { this.background = background; this.scenario = scenario; - validate(); } - public java.util.Optional getBackground() { return java.util.Optional.ofNullable(background); } @@ -1403,16 +1609,14 @@ public String toString() { public static class Scenario { - private Location location; - private java.util.List tags; - private String keyword; - private String name; - private String description; - private java.util.List steps; - private java.util.List examples; - private String id; - - private Scenario() {} + private final Location location; + private final java.util.List tags; + private final String keyword; + private final String name; + private final String description; + private final java.util.List steps; + private final java.util.List examples; + private final String id; public Scenario( Location location, @@ -1424,18 +1628,16 @@ public Scenario( java.util.List examples, String id ) { - this.location = location; - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); - this.keyword = keyword; - this.name = name; - this.description = description; - this.steps = steps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(steps)); - this.examples = examples == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(examples)); - this.id = id; - validate(); + this.location = java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); + this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"))); + this.keyword = java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); + this.description = java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); + this.steps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"))); + this.examples = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"))); + this.id = java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); } - public Location getLocation() { return location; } @@ -1530,14 +1732,12 @@ public String toString() { public static class Step { - private Location location; - private String keyword; - private String text; - private DocString docString; - private DataTable dataTable; - private String id; - - private Step() {} + private final Location location; + private final String keyword; + private final String text; + private final DocString docString; + private final DataTable dataTable; + private final String id; public Step( Location location, @@ -1547,16 +1747,14 @@ public Step( DataTable dataTable, String id ) { - this.location = location; - this.keyword = keyword; - this.text = text; + this.location = java.util.Objects.requireNonNull(location, "Step.location cannot be null"); + this.keyword = java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); + this.text = java.util.Objects.requireNonNull(text, "Step.text cannot be null"); this.docString = docString; this.dataTable = dataTable; - this.id = id; - validate(); + this.id = java.util.Objects.requireNonNull(id, "Step.id cannot be null"); } - public Location getLocation() { return location; } @@ -1632,21 +1830,17 @@ public String toString() { public static class TableCell { - private Location location; - private String value; - - private TableCell() {} + private final Location location; + private final String value; public TableCell( Location location, String value ) { - this.location = location; - this.value = value; - validate(); + this.location = java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); + this.value = java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); } - public Location getLocation() { return location; } @@ -1690,24 +1884,20 @@ public String toString() { public static class TableRow { - private Location location; - private java.util.List cells; - private String id; - - private TableRow() {} + private final Location location; + private final java.util.List cells; + private final String id; public TableRow( Location location, java.util.List cells, String id ) { - this.location = location; - this.cells = cells == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(cells)); - this.id = id; - validate(); + this.location = java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); + this.cells = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"))); + this.id = java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); } - public Location getLocation() { return location; } @@ -1760,24 +1950,20 @@ public String toString() { public static class Tag { - private Location location; - private String name; - private String id; - - private Tag() {} + private final Location location; + private final String name; + private final String id; public Tag( Location location, String name, String id ) { - this.location = location; - this.name = name; - this.id = id; - validate(); + this.location = java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); } - public Location getLocation() { return location; } @@ -1829,24 +2015,20 @@ public String toString() { public static class Hook { - private String id; - private SourceReference sourceReference; - private String tagExpression; - - private Hook() {} + private final String id; + private final SourceReference sourceReference; + private final String tagExpression; public Hook( String id, SourceReference sourceReference, String tagExpression ) { - this.id = id; - this.sourceReference = sourceReference; + this.id = java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); this.tagExpression = tagExpression; - validate(); } - public String getId() { return id; } @@ -1897,21 +2079,17 @@ public String toString() { public static class Location { - private Long line; - private Long column; - - private Location() {} + private final Long line; + private final Long column; public Location( Long line, Long column ) { - this.line = line; + this.line = java.util.Objects.requireNonNull(line, "Location.line cannot be null"); this.column = column; - validate(); } - public Long getLine() { return line; } @@ -1953,14 +2131,12 @@ public String toString() { public static class Meta { - private String protocolVersion; - private Product implementation; - private Product runtime; - private Product os; - private Product cpu; - private Ci ci; - - private Meta() {} + private final String protocolVersion; + private final Product implementation; + private final Product runtime; + private final Product os; + private final Product cpu; + private final Ci ci; public Meta( String protocolVersion, @@ -1970,16 +2146,14 @@ public Meta( Product cpu, Ci ci ) { - this.protocolVersion = protocolVersion; - this.implementation = implementation; - this.runtime = runtime; - this.os = os; - this.cpu = cpu; + this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); + this.implementation = java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); + this.runtime = java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); + this.os = java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); + this.cpu = java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); this.ci = ci; - validate(); } - public String getProtocolVersion() { return protocolVersion; } @@ -2058,12 +2232,10 @@ public String toString() { public static class Ci { - private String name; - private String url; - private String buildNumber; - private Git git; - - private Ci() {} + private final String name; + private final String url; + private final String buildNumber; + private final Git git; public Ci( String name, @@ -2071,14 +2243,12 @@ public Ci( String buildNumber, Git git ) { - this.name = name; + this.name = java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); this.url = url; this.buildNumber = buildNumber; this.git = git; - validate(); } - public String getName() { return name; } @@ -2135,12 +2305,10 @@ public String toString() { public static class Git { - private String remote; - private String revision; - private String branch; - private String tag; - - private Git() {} + private final String remote; + private final String revision; + private final String branch; + private final String tag; public Git( String remote, @@ -2148,14 +2316,12 @@ public Git( String branch, String tag ) { - this.remote = remote; - this.revision = revision; + this.remote = java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); + this.revision = java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); this.branch = branch; this.tag = tag; - validate(); } - public String getRemote() { return remote; } @@ -2212,21 +2378,17 @@ public String toString() { public static class Product { - private String name; - private String version; - - private Product() {} + private final String name; + private final String version; public Product( String name, String version ) { - this.name = name; + this.name = java.util.Objects.requireNonNull(name, "Product.name cannot be null"); this.version = version; - validate(); } - public String getName() { return name; } @@ -2268,13 +2430,11 @@ public String toString() { public static class ParameterType { - private String name; - private java.util.List regularExpressions; - private Boolean preferForRegularExpressionMatch; - private Boolean useForSnippets; - private String id; - - private ParameterType() {} + private final String name; + private final java.util.List regularExpressions; + private final Boolean preferForRegularExpressionMatch; + private final Boolean useForSnippets; + private final String id; public ParameterType( String name, @@ -2283,15 +2443,13 @@ public ParameterType( Boolean useForSnippets, String id ) { - this.name = name; - this.regularExpressions = regularExpressions == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(regularExpressions)); - this.preferForRegularExpressionMatch = preferForRegularExpressionMatch; - this.useForSnippets = useForSnippets; - this.id = id; - validate(); + this.name = java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); + this.regularExpressions = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"))); + this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); + this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); } - public String getName() { return name; } @@ -2360,21 +2518,17 @@ public String toString() { public static class ParseError { - private SourceReference source; - private String message; - - private ParseError() {} + private final SourceReference source; + private final String message; public ParseError( SourceReference source, String message ) { - this.source = source; - this.message = message; - validate(); + this.source = java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); + this.message = java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); } - public SourceReference getSource() { return source; } @@ -2418,15 +2572,13 @@ public String toString() { public static class Pickle { - private String id; - private String uri; - private String name; - private String language; - private java.util.List steps; - private java.util.List tags; - private java.util.List astNodeIds; - - private Pickle() {} + private final String id; + private final String uri; + private final String name; + private final String language; + private final java.util.List steps; + private final java.util.List tags; + private final java.util.List astNodeIds; public Pickle( String id, @@ -2437,17 +2589,15 @@ public Pickle( java.util.List tags, java.util.List astNodeIds ) { - this.id = id; - this.uri = uri; - this.name = name; - this.language = language; - this.steps = steps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(steps)); - this.tags = tags == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(tags)); - this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(astNodeIds)); - validate(); + this.id = java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); + this.uri = java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); + this.language = java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); + this.steps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"))); + this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"))); + this.astNodeIds = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"))); } - public String getId() { return id; } @@ -2534,21 +2684,17 @@ public String toString() { public static class PickleDocString { - private String mediaType; - private String content; - - private PickleDocString() {} + private final String mediaType; + private final String content; public PickleDocString( String mediaType, String content ) { this.mediaType = mediaType; - this.content = content; - validate(); + this.content = java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); } - public java.util.Optional getMediaType() { return java.util.Optional.ofNullable(mediaType); } @@ -2590,12 +2736,10 @@ public String toString() { public static class PickleStep { - private PickleStepArgument argument; - private java.util.List astNodeIds; - private String id; - private String text; - - private PickleStep() {} + private final PickleStepArgument argument; + private final java.util.List astNodeIds; + private final String id; + private final String text; public PickleStep( PickleStepArgument argument, @@ -2604,13 +2748,11 @@ public PickleStep( String text ) { this.argument = argument; - this.astNodeIds = astNodeIds == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(astNodeIds)); - this.id = id; - this.text = text; - validate(); + this.astNodeIds = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"))); + this.id = java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); + this.text = java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); } - public java.util.Optional getArgument() { return java.util.Optional.ofNullable(argument); } @@ -2671,23 +2813,21 @@ public String toString() { public static class PickleStepArgument { - private PickleDocString docString; - private PickleTable dataTable; - - public PickleStepArgument() {} + private final PickleDocString docString; + private final PickleTable dataTable; public static PickleStepArgument from(PickleDocString docString) { - PickleStepArgument o = new PickleStepArgument(); - o.docString = java.util.Objects.requireNonNull(docString, "PickleStepArgument.docString cannot be null"); - o.validate(); - return o; + return new PickleStepArgument( + java.util.Objects.requireNonNull(docString, "PickleStepArgument.docString cannot be null"), + null + ); } public static PickleStepArgument from(PickleTable dataTable) { - PickleStepArgument o = new PickleStepArgument(); - o.dataTable = java.util.Objects.requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null"); - o.validate(); - return o; + return new PickleStepArgument( + null, + java.util.Objects.requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null") + ); } public PickleStepArgument( @@ -2696,10 +2836,8 @@ public PickleStepArgument( ) { this.docString = docString; this.dataTable = dataTable; - validate(); } - public java.util.Optional getDocString() { return java.util.Optional.ofNullable(docString); } @@ -2742,18 +2880,14 @@ public String toString() { public static class PickleTable { - private java.util.List rows; - - private PickleTable() {} + private final java.util.List rows; public PickleTable( java.util.List rows ) { - this.rows = rows == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(rows)); - validate(); + this.rows = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"))); } - public java.util.List getRows() { return rows; } @@ -2789,18 +2923,14 @@ public String toString() { public static class PickleTableCell { - private String value; - - private PickleTableCell() {} + private final String value; public PickleTableCell( String value ) { - this.value = value; - validate(); + this.value = java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); } - public String getValue() { return value; } @@ -2835,18 +2965,14 @@ public String toString() { public static class PickleTableRow { - private java.util.List cells; - - private PickleTableRow() {} + private final java.util.List cells; public PickleTableRow( java.util.List cells ) { - this.cells = cells == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(cells)); - validate(); + this.cells = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"))); } - public java.util.List getCells() { return cells; } @@ -2883,21 +3009,17 @@ public String toString() { public static class PickleTag { - private String name; - private String astNodeId; - - private PickleTag() {} + private final String name; + private final String astNodeId; public PickleTag( String name, String astNodeId ) { - this.name = name; - this.astNodeId = astNodeId; - validate(); + this.name = java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); + this.astNodeId = java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); } - public String getName() { return name; } @@ -2940,24 +3062,20 @@ public String toString() { public static class Source { - private String uri; - private String data; - private SourceMediaType mediaType; - - private Source() {} + private final String uri; + private final String data; + private final SourceMediaType mediaType; public Source( String uri, String data, SourceMediaType mediaType ) { - this.uri = uri; - this.data = data; - this.mediaType = mediaType; - validate(); + this.uri = java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); + this.data = java.util.Objects.requireNonNull(data, "Source.data cannot be null"); + this.mediaType = java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); } - public String getUri() { return uri; } @@ -3008,39 +3126,45 @@ public String toString() { public static class SourceReference { - private String uri; - private JavaMethod javaMethod; - private JavaStackTraceElement javaStackTraceElement; - private Location location; - - public SourceReference() {} + private final String uri; + private final JavaMethod javaMethod; + private final JavaStackTraceElement javaStackTraceElement; + private final Location location; public static SourceReference from(String uri) { - SourceReference o = new SourceReference(); - o.uri = java.util.Objects.requireNonNull(uri, "SourceReference.uri cannot be null"); - o.validate(); - return o; + return new SourceReference( + java.util.Objects.requireNonNull(uri, "SourceReference.uri cannot be null"), + null, + null, + null + ); } public static SourceReference from(JavaMethod javaMethod) { - SourceReference o = new SourceReference(); - o.javaMethod = java.util.Objects.requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"); - o.validate(); - return o; + return new SourceReference( + null, + java.util.Objects.requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"), + null, + null + ); } public static SourceReference from(JavaStackTraceElement javaStackTraceElement) { - SourceReference o = new SourceReference(); - o.javaStackTraceElement = java.util.Objects.requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"); - o.validate(); - return o; + return new SourceReference( + null, + null, + java.util.Objects.requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"), + null + ); } public static SourceReference from(Location location) { - SourceReference o = new SourceReference(); - o.location = java.util.Objects.requireNonNull(location, "SourceReference.location cannot be null"); - o.validate(); - return o; + return new SourceReference( + null, + null, + null, + java.util.Objects.requireNonNull(location, "SourceReference.location cannot be null") + ); } public SourceReference( @@ -3053,10 +3177,8 @@ public SourceReference( this.javaMethod = javaMethod; this.javaStackTraceElement = javaStackTraceElement; this.location = location; - validate(); } - public java.util.Optional getUri() { return java.util.Optional.ofNullable(uri); } @@ -3114,24 +3236,20 @@ public String toString() { public static class JavaMethod { - private String className; - private String methodName; - private java.util.List methodParameterTypes; - - private JavaMethod() {} + private final String className; + private final String methodName; + private final java.util.List methodParameterTypes; public JavaMethod( String className, String methodName, java.util.List methodParameterTypes ) { - this.className = className; - this.methodName = methodName; - this.methodParameterTypes = methodParameterTypes == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(methodParameterTypes)); - validate(); + this.className = java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); + this.methodName = java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); + this.methodParameterTypes = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"))); } - public String getClassName() { return className; } @@ -3183,24 +3301,20 @@ public String toString() { public static class JavaStackTraceElement { - private String className; - private String fileName; - private String methodName; - - private JavaStackTraceElement() {} + private final String className; + private final String fileName; + private final String methodName; public JavaStackTraceElement( String className, String fileName, String methodName ) { - this.className = className; - this.fileName = fileName; - this.methodName = methodName; - validate(); + this.className = java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); + this.fileName = java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); + this.methodName = java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); } - public String getClassName() { return className; } @@ -3251,24 +3365,20 @@ public String toString() { public static class StepDefinition { - private String id; - private StepDefinitionPattern pattern; - private SourceReference sourceReference; - - private StepDefinition() {} + private final String id; + private final StepDefinitionPattern pattern; + private final SourceReference sourceReference; public StepDefinition( String id, StepDefinitionPattern pattern, SourceReference sourceReference ) { - this.id = id; - this.pattern = pattern; - this.sourceReference = sourceReference; - validate(); + this.id = java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); + this.pattern = java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); + this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); } - public String getId() { return id; } @@ -3321,21 +3431,17 @@ public String toString() { public static class StepDefinitionPattern { - private String source; - private StepDefinitionPatternType type; - - private StepDefinitionPattern() {} + private final String source; + private final StepDefinitionPatternType type; public StepDefinitionPattern( String source, StepDefinitionPatternType type ) { - this.source = source; - this.type = type; - validate(); + this.source = java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); + this.type = java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); } - public String getSource() { return source; } @@ -3378,24 +3484,20 @@ public String toString() { public static class TestCase { - private String id; - private String pickleId; - private java.util.List testSteps; - - private TestCase() {} + private final String id; + private final String pickleId; + private final java.util.List testSteps; public TestCase( String id, String pickleId, java.util.List testSteps ) { - this.id = id; - this.pickleId = pickleId; - this.testSteps = testSteps == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(testSteps)); - validate(); + this.id = java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); + this.pickleId = java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); + this.testSteps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); } - public String getId() { return id; } @@ -3447,24 +3549,20 @@ public String toString() { public static class Group { - private java.util.List children; - private Long start; - private String value; - - private Group() {} + private final java.util.List children; + private final Long start; + private final String value; public Group( java.util.List children, Long start, String value ) { - this.children = children == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(children)); + this.children = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(children, "Group.children cannot be null"))); this.start = start; this.value = value; - validate(); } - public java.util.List getChildren() { return children; } @@ -3514,21 +3612,17 @@ public String toString() { public static class StepMatchArgument { - private Group group; - private String parameterTypeName; - - private StepMatchArgument() {} + private final Group group; + private final String parameterTypeName; public StepMatchArgument( Group group, String parameterTypeName ) { - this.group = group; + this.group = java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); this.parameterTypeName = parameterTypeName; - validate(); } - public Group getGroup() { return group; } @@ -3571,18 +3665,14 @@ public String toString() { public static class StepMatchArgumentsList { - private java.util.List stepMatchArguments; - - private StepMatchArgumentsList() {} + private final java.util.List stepMatchArguments; public StepMatchArgumentsList( java.util.List stepMatchArguments ) { - this.stepMatchArguments = stepMatchArguments == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepMatchArguments)); - validate(); + this.stepMatchArguments = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"))); } - public java.util.List getStepMatchArguments() { return stepMatchArguments; } @@ -3618,13 +3708,11 @@ public String toString() { public static class TestStep { - private String hookId; - private String id; - private String pickleStepId; - private java.util.List stepDefinitionIds; - private java.util.List stepMatchArgumentsLists; - - private TestStep() {} + private final String hookId; + private final String id; + private final String pickleStepId; + private final java.util.List stepDefinitionIds; + private final java.util.List stepMatchArgumentsLists; public TestStep( String hookId, @@ -3634,14 +3722,12 @@ public TestStep( java.util.List stepMatchArgumentsLists ) { this.hookId = hookId; - this.id = id; + this.id = java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); this.pickleStepId = pickleStepId; this.stepDefinitionIds = stepDefinitionIds == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepDefinitionIds)); this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepMatchArgumentsLists)); - validate(); } - public java.util.Optional getHookId() { return java.util.Optional.ofNullable(hookId); } @@ -3706,24 +3792,20 @@ public String toString() { public static class TestCaseFinished { - private String testCaseStartedId; - private Timestamp timestamp; - private Boolean willBeRetried; - - private TestCaseFinished() {} + private final String testCaseStartedId; + private final Timestamp timestamp; + private final Boolean willBeRetried; public TestCaseFinished( String testCaseStartedId, Timestamp timestamp, Boolean willBeRetried ) { - this.testCaseStartedId = testCaseStartedId; - this.timestamp = timestamp; - this.willBeRetried = willBeRetried; - validate(); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); + this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); } - public String getTestCaseStartedId() { return testCaseStartedId; } @@ -3775,12 +3857,10 @@ public String toString() { public static class TestCaseStarted { - private Long attempt; - private String id; - private String testCaseId; - private Timestamp timestamp; - - private TestCaseStarted() {} + private final Long attempt; + private final String id; + private final String testCaseId; + private final Timestamp timestamp; public TestCaseStarted( Long attempt, @@ -3788,14 +3868,12 @@ public TestCaseStarted( String testCaseId, Timestamp timestamp ) { - this.attempt = attempt; - this.id = id; - this.testCaseId = testCaseId; - this.timestamp = timestamp; - validate(); + this.attempt = java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); + this.id = java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); + this.testCaseId = java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); } - public Long getAttempt() { return attempt; } @@ -3855,11 +3933,9 @@ public String toString() { public static class TestRunFinished { - private String message; - private Boolean success; - private Timestamp timestamp; - - private TestRunFinished() {} + private final String message; + private final Boolean success; + private final Timestamp timestamp; public TestRunFinished( String message, @@ -3867,12 +3943,10 @@ public TestRunFinished( Timestamp timestamp ) { this.message = message; - this.success = success; - this.timestamp = timestamp; - validate(); + this.success = java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); } - public java.util.Optional getMessage() { return java.util.Optional.ofNullable(message); } @@ -3923,18 +3997,14 @@ public String toString() { public static class TestRunStarted { - private Timestamp timestamp; - - private TestRunStarted() {} + private final Timestamp timestamp; public TestRunStarted( Timestamp timestamp ) { - this.timestamp = timestamp; - validate(); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); } - public Timestamp getTimestamp() { return timestamp; } @@ -3970,12 +4040,10 @@ public String toString() { public static class TestStepFinished { - private String testCaseStartedId; - private String testStepId; - private TestStepResult testStepResult; - private Timestamp timestamp; - - private TestStepFinished() {} + private final String testCaseStartedId; + private final String testStepId; + private final TestStepResult testStepResult; + private final Timestamp timestamp; public TestStepFinished( String testCaseStartedId, @@ -3983,14 +4051,12 @@ public TestStepFinished( TestStepResult testStepResult, Timestamp timestamp ) { - this.testCaseStartedId = testCaseStartedId; - this.testStepId = testStepId; - this.testStepResult = testStepResult; - this.timestamp = timestamp; - validate(); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); + this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); + this.testStepResult = java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); } - public String getTestCaseStartedId() { return testCaseStartedId; } @@ -4051,24 +4117,20 @@ public String toString() { public static class TestStepResult { - private Duration duration; - private String message; - private TestStepResultStatus status; - - private TestStepResult() {} + private final Duration duration; + private final String message; + private final TestStepResultStatus status; public TestStepResult( Duration duration, String message, TestStepResultStatus status ) { - this.duration = duration; + this.duration = java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); this.message = message; - this.status = status; - validate(); + this.status = java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); } - public Duration getDuration() { return duration; } @@ -4119,24 +4181,20 @@ public String toString() { public static class TestStepStarted { - private String testCaseStartedId; - private String testStepId; - private Timestamp timestamp; - - private TestStepStarted() {} + private final String testCaseStartedId; + private final String testStepId; + private final Timestamp timestamp; public TestStepStarted( String testCaseStartedId, String testStepId, Timestamp timestamp ) { - this.testCaseStartedId = testCaseStartedId; - this.testStepId = testStepId; - this.timestamp = timestamp; - validate(); + this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); + this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); + this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); } - public String getTestCaseStartedId() { return testCaseStartedId; } @@ -4188,21 +4246,17 @@ public String toString() { public static class Timestamp { - private Long seconds; - private Long nanos; - - private Timestamp() {} + private final Long seconds; + private final Long nanos; public Timestamp( Long seconds, Long nanos ) { - this.seconds = seconds; - this.nanos = nanos; - validate(); + this.seconds = java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); + this.nanos = java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); } - public Long getSeconds() { return seconds; } @@ -4245,21 +4299,17 @@ public String toString() { public static class UndefinedParameterType { - private String expression; - private String name; - - private UndefinedParameterType() {} + private final String expression; + private final String name; public UndefinedParameterType( String expression, String name ) { - this.expression = expression; - this.name = name; - validate(); + this.expression = java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); + this.name = java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); } - public String getExpression() { return expression; } diff --git a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java index 0d767ac2b8..1efb4637f9 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java @@ -14,6 +14,24 @@ void is_invalid_when_required_fields_are_missing() { @Test void is_valid_when_no_required_fields_are_missing() { - new Messages.Envelope(); + new Messages.Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); } } diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index c982f5f4bd..f3534db988 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -42,7 +42,25 @@ void writes_source_envelope() throws IOException { void does_not_serialize_null_fields() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(output); - JSON.writeValue(writer, new Envelope()); + JSON.writeValue(writer, new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + )); writer.flush(); assertEquals("{}", new String(output.toByteArray(), UTF_8)); } @@ -54,7 +72,25 @@ void ignores_missing_fields() { Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); - assertEquals(new Envelope(), envelope); + assertEquals(new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ), envelope); assertFalse(iterator.hasNext()); } @@ -66,7 +102,25 @@ void ignores_empty_lines() { for (int i = 0; i < 3; i++) { assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); - assertEquals(new Envelope(), envelope); + assertEquals(new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ), envelope); } assertFalse(iterator.hasNext()); } diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index a89d8d0303..42bcfae27d 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,26 +1,27 @@ <% @schemas.each do |key, schema| %> public static class <%= class_name(key) %> { <%- schema['properties'].each do |property_name, property| -%> - private <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; + private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; <%- end -%> - <%- if (schema['required'] || []).empty? -%> - public <%= class_name(key) %>() {} <%- schema['properties'].each_with_index do |(property_name, property), index| -%> public static <%= class_name(key) %> from(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - <%= class_name(key) %> o = new <%= class_name(key) %>(); - <%- if property['items'] -%> - o.<%= property_name %> = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))); - <%- else -%> - o.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); - <%- end -%> - o.validate(); - return o; + return new <%= class_name(key) %>( + <%- schema['properties'].each_with_index do |(property_name_2, property_2), index_2| -%> + <%- if property_name_2 == property_name -%> + <%- if property['items'] -%> + java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")))<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + <%- else -%> + java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + <%- end -%> + <%- else -%> + null<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + <%- end -%> + <%- end -%> + ); } <%- end -%> - <%- else -%> - private <%= class_name(key) %>() {} <%- end -%> public <%= class_name(key) %>( @@ -28,16 +29,24 @@ <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> <%- end -%> ) { - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - <%- if property['items'] -%> + <%- schema['properties'].each_with_index do |(property_name, property), index| + required = (schema['required'] || []).index(property_name) + -%> + <%- if required -%> + <%- if property['items'] -%> + this.<%= property_name %> = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))); + <%- else -%> + this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); + <%- end -%> + <%- else -%> + <%- if property['items'] -%> this.<%= property_name %> = <%= property_name %> == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(<%= property_name %>)); - <%- else -%> + <%- else -%> this.<%= property_name %> = <%= property_name %>; - <%- end -%> + <%- end -%> + <%- end -%> <%- end -%> - validate(); } - <%- schema['properties'].each do |property_name, property| -%> <%- if (schema['required'] || []).index(property_name) -%> From 8b4ae9acc12bafd18e90cbc8e7cddcc9d29f10fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 10:07:25 +0000 Subject: [PATCH 30/63] Remove validate() --- .../java/io/cucumber/messages/Messages.java | 449 ------------------ .../scripts/templates/java.java.erb | 24 +- 2 files changed, 1 insertion(+), 472 deletions(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index f82709d498..8bfa600c20 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -1,7 +1,6 @@ package io.cucumber.messages; public class Messages { - public static class Attachment { private final String body; private final AttachmentContentEncoding contentEncoding; @@ -64,13 +63,6 @@ public java.util.Optional getUrl() { return java.util.Optional.ofNullable(url); } - private void validate() { - java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); - java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); - java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); - if (source != null) source.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -116,7 +108,6 @@ public String toString() { } } - public static class Duration { private final Long seconds; private final Long nanos; @@ -137,11 +128,6 @@ public Long getNanos() { return nanos; } - private void validate() { - java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); - java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -169,7 +155,6 @@ public String toString() { } } - public static class Envelope { private final Attachment attachment; private final GherkinDocument gherkinDocument; @@ -669,26 +654,6 @@ public java.util.Optional getUndefinedParameterType() { return java.util.Optional.ofNullable(undefinedParameterType); } - private void validate() { - if (attachment != null) attachment.validate(); - if (gherkinDocument != null) gherkinDocument.validate(); - if (hook != null) hook.validate(); - if (meta != null) meta.validate(); - if (parameterType != null) parameterType.validate(); - if (parseError != null) parseError.validate(); - if (pickle != null) pickle.validate(); - if (source != null) source.validate(); - if (stepDefinition != null) stepDefinition.validate(); - if (testCase != null) testCase.validate(); - if (testCaseFinished != null) testCaseFinished.validate(); - if (testCaseStarted != null) testCaseStarted.validate(); - if (testRunFinished != null) testRunFinished.validate(); - if (testRunStarted != null) testRunStarted.validate(); - if (testStepFinished != null) testStepFinished.validate(); - if (testStepStarted != null) testStepStarted.validate(); - if (undefinedParameterType != null) undefinedParameterType.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -761,7 +726,6 @@ public String toString() { } } - public static class GherkinDocument { private final String uri; private final Feature feature; @@ -789,12 +753,6 @@ public java.util.List getComments() { return comments; } - private void validate() { - if (feature != null) feature.validate(); - java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"); - comments.forEach(Comment::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -825,7 +783,6 @@ public String toString() { } } - public static class Background { private final Location location; private final String keyword; @@ -874,17 +831,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(location, "Background.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); - java.util.Objects.requireNonNull(name, "Background.name cannot be null"); - java.util.Objects.requireNonNull(description, "Background.description cannot be null"); - java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"); - steps.forEach(Step::validate); - java.util.Objects.requireNonNull(id, "Background.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -924,7 +870,6 @@ public String toString() { } } - public static class Comment { private final Location location; private final String text; @@ -945,12 +890,6 @@ public String getText() { return text; } - private void validate() { - java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -978,7 +917,6 @@ public String toString() { } } - public static class DataTable { private final Location location; private final java.util.List rows; @@ -999,13 +937,6 @@ public java.util.List getRows() { return rows; } - private void validate() { - java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"); - rows.forEach(TableRow::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1033,7 +964,6 @@ public String toString() { } } - public static class DocString { private final Location location; private final String mediaType; @@ -1068,13 +998,6 @@ public String getDelimiter() { return delimiter; } - private void validate() { - java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); - java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1108,7 +1031,6 @@ public String toString() { } } - public static class Examples { private final Location location; private final java.util.List tags; @@ -1171,20 +1093,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"); - tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); - java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); - java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); - if (tableHeader != null) tableHeader.validate(); - java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"); - tableBody.forEach(TableRow::validate); - java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1230,7 +1138,6 @@ public String toString() { } } - public static class Feature { private final Location location; private final java.util.List tags; @@ -1286,19 +1193,6 @@ public java.util.List getChildren() { return children; } - private void validate() { - java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"); - tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); - java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); - java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); - java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); - java.util.Objects.requireNonNull(children, "Feature.children cannot be null"); - children.forEach(FeatureChild::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1341,7 +1235,6 @@ public String toString() { } } - public static class FeatureChild { private final Rule rule; private final Background background; @@ -1393,12 +1286,6 @@ public java.util.Optional getScenario() { return java.util.Optional.ofNullable(scenario); } - private void validate() { - if (rule != null) rule.validate(); - if (background != null) background.validate(); - if (scenario != null) scenario.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1429,7 +1316,6 @@ public String toString() { } } - public static class Rule { private final Location location; private final java.util.List tags; @@ -1485,19 +1371,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"); - tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); - java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); - java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); - java.util.Objects.requireNonNull(children, "Rule.children cannot be null"); - children.forEach(RuleChild::validate); - java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1540,7 +1413,6 @@ public String toString() { } } - public static class RuleChild { private final Background background; private final Scenario scenario; @@ -1575,11 +1447,6 @@ public java.util.Optional getScenario() { return java.util.Optional.ofNullable(scenario); } - private void validate() { - if (background != null) background.validate(); - if (scenario != null) scenario.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1607,7 +1474,6 @@ public String toString() { } } - public static class Scenario { private final Location location; private final java.util.List tags; @@ -1670,21 +1536,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"); - tags.forEach(Tag::validate); - java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); - java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); - java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); - java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"); - steps.forEach(Step::validate); - java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"); - examples.forEach(Examples::validate); - java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1730,7 +1581,6 @@ public String toString() { } } - public static class Step { private final Location location; private final String keyword; @@ -1779,16 +1629,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(location, "Step.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); - java.util.Objects.requireNonNull(text, "Step.text cannot be null"); - if (docString != null) docString.validate(); - if (dataTable != null) dataTable.validate(); - java.util.Objects.requireNonNull(id, "Step.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1828,7 +1668,6 @@ public String toString() { } } - public static class TableCell { private final Location location; private final String value; @@ -1849,12 +1688,6 @@ public String getValue() { return value; } - private void validate() { - java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1882,7 +1715,6 @@ public String toString() { } } - public static class TableRow { private final Location location; private final java.util.List cells; @@ -1910,14 +1742,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"); - cells.forEach(TableCell::validate); - java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -1948,7 +1772,6 @@ public String toString() { } } - public static class Tag { private final Location location; private final String name; @@ -1976,13 +1799,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); - location.validate(); - java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); - java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2013,7 +1829,6 @@ public String toString() { } } - public static class Hook { private final String id; private final SourceReference sourceReference; @@ -2041,12 +1856,6 @@ public java.util.Optional getTagExpression() { return java.util.Optional.ofNullable(tagExpression); } - private void validate() { - java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); - java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); - sourceReference.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2077,7 +1886,6 @@ public String toString() { } } - public static class Location { private final Long line; private final Long column; @@ -2098,10 +1906,6 @@ public java.util.Optional getColumn() { return java.util.Optional.ofNullable(column); } - private void validate() { - java.util.Objects.requireNonNull(line, "Location.line cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2129,7 +1933,6 @@ public String toString() { } } - public static class Meta { private final String protocolVersion; private final Product implementation; @@ -2178,19 +1981,6 @@ public java.util.Optional getCi() { return java.util.Optional.ofNullable(ci); } - private void validate() { - java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); - java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); - implementation.validate(); - java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); - runtime.validate(); - java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); - os.validate(); - java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); - cpu.validate(); - if (ci != null) ci.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2230,7 +2020,6 @@ public String toString() { } } - public static class Ci { private final String name; private final String url; @@ -2265,11 +2054,6 @@ public java.util.Optional getGit() { return java.util.Optional.ofNullable(git); } - private void validate() { - java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); - if (git != null) git.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2303,7 +2087,6 @@ public String toString() { } } - public static class Git { private final String remote; private final String revision; @@ -2338,11 +2121,6 @@ public java.util.Optional getTag() { return java.util.Optional.ofNullable(tag); } - private void validate() { - java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); - java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2376,7 +2154,6 @@ public String toString() { } } - public static class Product { private final String name; private final String version; @@ -2397,10 +2174,6 @@ public java.util.Optional getVersion() { return java.util.Optional.ofNullable(version); } - private void validate() { - java.util.Objects.requireNonNull(name, "Product.name cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2428,7 +2201,6 @@ public String toString() { } } - public static class ParameterType { private final String name; private final java.util.List regularExpressions; @@ -2470,16 +2242,6 @@ public String getId() { return id; } - private void validate() { - java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); - java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"); - regularExpressions.forEach(e -> java.util.Objects.requireNonNull(e, "ParameterType.regularExpressions elements cannot be null")); - if(regularExpressions.size() < 1) throw new IllegalArgumentException("ParameterType.regularExpressions must have at least 1 element"); - java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); - java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); - java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2516,7 +2278,6 @@ public String toString() { } } - public static class ParseError { private final SourceReference source; private final String message; @@ -2537,12 +2298,6 @@ public String getMessage() { return message; } - private void validate() { - java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); - source.validate(); - java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2570,7 +2325,6 @@ public String toString() { } } - public static class Pickle { private final String id; private final String uri; @@ -2626,20 +2380,6 @@ public java.util.List getAstNodeIds() { return astNodeIds; } - private void validate() { - java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); - java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); - java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); - java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); - java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"); - steps.forEach(PickleStep::validate); - java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"); - tags.forEach(PickleTag::validate); - java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"); - astNodeIds.forEach(e -> java.util.Objects.requireNonNull(e, "Pickle.astNodeIds elements cannot be null")); - if(astNodeIds.size() < 1) throw new IllegalArgumentException("Pickle.astNodeIds must have at least 1 element"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2682,7 +2422,6 @@ public String toString() { } } - public static class PickleDocString { private final String mediaType; private final String content; @@ -2703,10 +2442,6 @@ public String getContent() { return content; } - private void validate() { - java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2734,7 +2469,6 @@ public String toString() { } } - public static class PickleStep { private final PickleStepArgument argument; private final java.util.List astNodeIds; @@ -2769,15 +2503,6 @@ public String getText() { return text; } - private void validate() { - if (argument != null) argument.validate(); - java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"); - astNodeIds.forEach(e -> java.util.Objects.requireNonNull(e, "PickleStep.astNodeIds elements cannot be null")); - if(astNodeIds.size() < 1) throw new IllegalArgumentException("PickleStep.astNodeIds must have at least 1 element"); - java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); - java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2811,7 +2536,6 @@ public String toString() { } } - public static class PickleStepArgument { private final PickleDocString docString; private final PickleTable dataTable; @@ -2846,11 +2570,6 @@ public java.util.Optional getDataTable() { return java.util.Optional.ofNullable(dataTable); } - private void validate() { - if (docString != null) docString.validate(); - if (dataTable != null) dataTable.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2878,7 +2597,6 @@ public String toString() { } } - public static class PickleTable { private final java.util.List rows; @@ -2892,11 +2610,6 @@ public java.util.List getRows() { return rows; } - private void validate() { - java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"); - rows.forEach(PickleTableRow::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2921,7 +2634,6 @@ public String toString() { } } - public static class PickleTableCell { private final String value; @@ -2935,10 +2647,6 @@ public String getValue() { return value; } - private void validate() { - java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -2963,7 +2671,6 @@ public String toString() { } } - public static class PickleTableRow { private final java.util.List cells; @@ -2977,12 +2684,6 @@ public java.util.List getCells() { return cells; } - private void validate() { - java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"); - cells.forEach(PickleTableCell::validate); - if(cells.size() < 1) throw new IllegalArgumentException("PickleTableRow.cells must have at least 1 element"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3007,7 +2708,6 @@ public String toString() { } } - public static class PickleTag { private final String name; private final String astNodeId; @@ -3028,11 +2728,6 @@ public String getAstNodeId() { return astNodeId; } - private void validate() { - java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); - java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3060,7 +2755,6 @@ public String toString() { } } - public static class Source { private final String uri; private final String data; @@ -3088,12 +2782,6 @@ public SourceMediaType getMediaType() { return mediaType; } - private void validate() { - java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); - java.util.Objects.requireNonNull(data, "Source.data cannot be null"); - java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3124,7 +2812,6 @@ public String toString() { } } - public static class SourceReference { private final String uri; private final JavaMethod javaMethod; @@ -3195,12 +2882,6 @@ public java.util.Optional getLocation() { return java.util.Optional.ofNullable(location); } - private void validate() { - if (javaMethod != null) javaMethod.validate(); - if (javaStackTraceElement != null) javaStackTraceElement.validate(); - if (location != null) location.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3234,7 +2915,6 @@ public String toString() { } } - public static class JavaMethod { private final String className; private final String methodName; @@ -3262,13 +2942,6 @@ public java.util.List getMethodParameterTypes() { return methodParameterTypes; } - private void validate() { - java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); - java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); - java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"); - methodParameterTypes.forEach(e -> java.util.Objects.requireNonNull(e, "JavaMethod.methodParameterTypes elements cannot be null")); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3299,7 +2972,6 @@ public String toString() { } } - public static class JavaStackTraceElement { private final String className; private final String fileName; @@ -3327,12 +2999,6 @@ public String getMethodName() { return methodName; } - private void validate() { - java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); - java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); - java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3363,7 +3029,6 @@ public String toString() { } } - public static class StepDefinition { private final String id; private final StepDefinitionPattern pattern; @@ -3391,14 +3056,6 @@ public SourceReference getSourceReference() { return sourceReference; } - private void validate() { - java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); - java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); - pattern.validate(); - java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); - sourceReference.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3429,7 +3086,6 @@ public String toString() { } } - public static class StepDefinitionPattern { private final String source; private final StepDefinitionPatternType type; @@ -3450,11 +3106,6 @@ public StepDefinitionPatternType getType() { return type; } - private void validate() { - java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); - java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3482,7 +3133,6 @@ public String toString() { } } - public static class TestCase { private final String id; private final String pickleId; @@ -3510,13 +3160,6 @@ public java.util.List getTestSteps() { return testSteps; } - private void validate() { - java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); - java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); - java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"); - testSteps.forEach(TestStep::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3547,7 +3190,6 @@ public String toString() { } } - public static class Group { private final java.util.List children; private final Long start; @@ -3575,11 +3217,6 @@ public java.util.Optional getValue() { return java.util.Optional.ofNullable(value); } - private void validate() { - java.util.Objects.requireNonNull(children, "Group.children cannot be null"); - children.forEach(Group::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3610,7 +3247,6 @@ public String toString() { } } - public static class StepMatchArgument { private final Group group; private final String parameterTypeName; @@ -3631,11 +3267,6 @@ public java.util.Optional getParameterTypeName() { return java.util.Optional.ofNullable(parameterTypeName); } - private void validate() { - java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); - group.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3663,7 +3294,6 @@ public String toString() { } } - public static class StepMatchArgumentsList { private final java.util.List stepMatchArguments; @@ -3677,11 +3307,6 @@ public java.util.List getStepMatchArguments() { return stepMatchArguments; } - private void validate() { - java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"); - stepMatchArguments.forEach(StepMatchArgument::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3706,7 +3331,6 @@ public String toString() { } } - public static class TestStep { private final String hookId; private final String id; @@ -3748,12 +3372,6 @@ public java.util.Optional> getStepMatchAr return java.util.Optional.ofNullable(stepMatchArgumentsLists); } - private void validate() { - java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); - if (stepDefinitionIds != null) stepDefinitionIds.forEach(e -> java.util.Objects.requireNonNull(e, "TestStep.stepDefinitionIds elements cannot be null")); - if (stepMatchArgumentsLists != null) stepMatchArgumentsLists.forEach(StepMatchArgumentsList::validate); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3790,7 +3408,6 @@ public String toString() { } } - public static class TestCaseFinished { private final String testCaseStartedId; private final Timestamp timestamp; @@ -3818,13 +3435,6 @@ public Boolean getWillBeRetried() { return willBeRetried; } - private void validate() { - java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); - java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); - timestamp.validate(); - java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3855,7 +3465,6 @@ public String toString() { } } - public static class TestCaseStarted { private final Long attempt; private final String id; @@ -3890,14 +3499,6 @@ public Timestamp getTimestamp() { return timestamp; } - private void validate() { - java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); - java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); - java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); - java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); - timestamp.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3931,7 +3532,6 @@ public String toString() { } } - public static class TestRunFinished { private final String message; private final Boolean success; @@ -3959,12 +3559,6 @@ public Timestamp getTimestamp() { return timestamp; } - private void validate() { - java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); - java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); - timestamp.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -3995,7 +3589,6 @@ public String toString() { } } - public static class TestRunStarted { private final Timestamp timestamp; @@ -4009,11 +3602,6 @@ public Timestamp getTimestamp() { return timestamp; } - private void validate() { - java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); - timestamp.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -4038,7 +3626,6 @@ public String toString() { } } - public static class TestStepFinished { private final String testCaseStartedId; private final String testStepId; @@ -4073,15 +3660,6 @@ public Timestamp getTimestamp() { return timestamp; } - private void validate() { - java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); - java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); - java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); - testStepResult.validate(); - java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); - timestamp.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -4115,7 +3693,6 @@ public String toString() { } } - public static class TestStepResult { private final Duration duration; private final String message; @@ -4143,12 +3720,6 @@ public TestStepResultStatus getStatus() { return status; } - private void validate() { - java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); - duration.validate(); - java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -4179,7 +3750,6 @@ public String toString() { } } - public static class TestStepStarted { private final String testCaseStartedId; private final String testStepId; @@ -4207,13 +3777,6 @@ public Timestamp getTimestamp() { return timestamp; } - private void validate() { - java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); - java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); - java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); - timestamp.validate(); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -4244,7 +3807,6 @@ public String toString() { } } - public static class Timestamp { private final Long seconds; private final Long nanos; @@ -4265,11 +3827,6 @@ public Long getNanos() { return nanos; } - private void validate() { - java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); - java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; @@ -4297,7 +3854,6 @@ public String toString() { } } - public static class UndefinedParameterType { private final String expression; private final String name; @@ -4318,11 +3874,6 @@ public String getName() { return name; } - private void validate() { - java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); - java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 42bcfae27d..36f485c502 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,4 +1,4 @@ -<% @schemas.each do |key, schema| %> +<%- @schemas.each do |key, schema| -%> public static class <%= class_name(key) %> { <%- schema['properties'].each do |property_name, property| -%> private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; @@ -61,28 +61,6 @@ <%- end -%> <%- end -%> - private void validate() { - <%- schema['properties'].each do |property_name, property| - required = (schema['required'] || []).index(property_name) - -%> - <%- if required -%> - java.util.Objects.requireNonNull(<%= property_name -%>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); - <%- end -%> - <%- if property['type'] == 'array' -%> - <%- if property['items']['type'] -%> - <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(e -> java.util.Objects.requireNonNull(e, "<%= class_name(key) %>.<%= property_name %> elements cannot be null")); - <%- else -%> - <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.forEach(<%= type_for(key, nil, property['items']) %>::validate); - <%- end -%> - <%- if property['minItems'] -%> - <% if !required %>if (<%= property_name %> != null) <%- end %>if(<%= property_name %>.size() < <%= property['minItems'] %>) throw new IllegalArgumentException("<%= class_name(key) %>.<%= property_name %> must have at least <%= property['minItems'] %> element<%= property['minItems'] > 1 ? 's' : '' %>"); - <%- end -%> - <%- elsif property['$ref'] -%> - <% if !required %>if (<%= property_name %> != null) <%- end %><%= property_name %>.validate(); - <%- end -%> - <%- end -%> - } - @Override public boolean equals(Object o) { if (this == o) return true; From bc32d93c6ce7e4d5eb931c33158b845cedb6fbb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 10:47:52 +0000 Subject: [PATCH 31/63] Add Jackson parameter names module --- messages/java/pom.xml | 5 +++++ messages/java/src/main/java/io/cucumber/messages/JSON.java | 2 ++ .../java/io/cucumber/messages/NdjsonToMessageIterable.java | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 0bccfe256b..3fa0961f98 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -54,6 +54,11 @@ jackson-datatype-jdk8 + + com.fasterxml.jackson.module + jackson-module-parameter-names + + org.junit.jupiter junit-jupiter diff --git a/messages/java/src/main/java/io/cucumber/messages/JSON.java b/messages/java/src/main/java/io/cucumber/messages/JSON.java index 8d1122fce6..427e2e7b05 100644 --- a/messages/java/src/main/java/io/cucumber/messages/JSON.java +++ b/messages/java/src/main/java/io/cucumber/messages/JSON.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; import java.io.IOException; import java.io.OutputStream; @@ -13,6 +14,7 @@ public final class JSON { private static final ObjectMapper mapper = new ObjectMapper() + .registerModule(new ParameterNamesModule()) .registerModule(new Jdk8Module()) .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) .enable(WRITE_ENUMS_USING_TO_STRING) diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 1a1175f315..15c51d988a 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -43,7 +43,7 @@ public boolean hasNext() { try { next = mapper.readValue(line, Envelope.class); } catch (JsonProcessingException e) { - throw new RuntimeException(String.format("Not JSON: %s", line), e); + throw new RuntimeException(String.format("Could not parse JSON: %s", line), e); } return true; } catch (IOException e) { From 288ba0c06750542ce061bb1480c3d6ffef04a289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 11:52:38 +0000 Subject: [PATCH 32/63] Fix tests. Fix enum fromValue --- .../main/java/io/cucumber/messages/JSON.java | 42 ------------------- .../java/io/cucumber/messages/Jackson.java | 26 ++++++++++++ .../messages/MessageToNdjsonWriter.java | 2 +- .../java/io/cucumber/messages/Messages.java | 4 +- .../messages/NdjsonToMessageIterable.java | 7 +--- .../io/cucumber/messages/JacksonTest.java | 15 +++++++ .../messages/NdjsonSerializationTest.java | 6 +-- .../scripts/templates/java.enum.java.erb | 2 +- 8 files changed, 49 insertions(+), 55 deletions(-) delete mode 100644 messages/java/src/main/java/io/cucumber/messages/JSON.java create mode 100644 messages/java/src/main/java/io/cucumber/messages/Jackson.java create mode 100644 messages/java/src/test/java/io/cucumber/messages/JacksonTest.java diff --git a/messages/java/src/main/java/io/cucumber/messages/JSON.java b/messages/java/src/main/java/io/cucumber/messages/JSON.java deleted file mode 100644 index 427e2e7b05..0000000000 --- a/messages/java/src/main/java/io/cucumber/messages/JSON.java +++ /dev/null @@ -1,42 +0,0 @@ -package io.cucumber.messages; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; - -import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING; - -public final class JSON { - private static final ObjectMapper mapper = new ObjectMapper() - .registerModule(new ParameterNamesModule()) - .registerModule(new Jdk8Module()) - .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) - .enable(WRITE_ENUMS_USING_TO_STRING) - .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); - - private JSON() { - } - - public static void writeValue(OutputStream out, Object value) throws IOException { - mapper.writeValue(out, value); - } - - public static void writeValue(Writer w, Object value) throws IOException { - mapper.writeValue(w, value); - } - - public static String writeValueAsString(Object value) throws IOException { - return mapper.writeValueAsString(value); - } - - public static byte[] writeValueAsBytes(Object value) throws IOException { - return mapper.writeValueAsBytes(value); - } - -} diff --git a/messages/java/src/main/java/io/cucumber/messages/Jackson.java b/messages/java/src/main/java/io/cucumber/messages/Jackson.java new file mode 100644 index 0000000000..e9d080fc19 --- /dev/null +++ b/messages/java/src/main/java/io/cucumber/messages/Jackson.java @@ -0,0 +1,26 @@ +package io.cucumber.messages; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; + +import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; +import static com.fasterxml.jackson.databind.DeserializationFeature.READ_ENUMS_USING_TO_STRING; +import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING; + +public final class Jackson { + public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() + .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) + .registerModule(new Jdk8Module()) + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) + .enable(WRITE_ENUMS_USING_TO_STRING) + .enable(READ_ENUMS_USING_TO_STRING) + .disable(FAIL_ON_UNKNOWN_PROPERTIES) + .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); + + private Jackson() { + } +} diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java index 4a05de1323..c92932f9fc 100644 --- a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java +++ b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java @@ -15,7 +15,7 @@ public MessageToNdjsonWriter(OutputStream out) { @Override public void write(Object message) throws IOException { - JSON.writeValue(out, message); + Jackson.OBJECT_MAPPER.writeValue(out, message); out.write("\n"); out.flush(); } diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index 8bfa600c20..bf0a13e263 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -3947,8 +3947,8 @@ public String value() { } public static SourceMediaType fromValue(String value) { - if ("TEXT_X_CUCUMBER_GHERKIN_PLAIN".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_PLAIN; - if ("TEXT_X_CUCUMBER_GHERKIN_MARKDOWN".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_MARKDOWN; + if ("text/x.cucumber.gherkin+plain".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_PLAIN; + if ("text/x.cucumber.gherkin+markdown".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_MARKDOWN; throw new IllegalArgumentException(value); } } diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 15c51d988a..1108996c41 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -1,8 +1,6 @@ package io.cucumber.messages; import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; import java.io.BufferedReader; import java.io.IOException; @@ -19,9 +17,6 @@ * Tests can then use a {@code new ArrayList} which implements the same interface. */ public final class NdjsonToMessageIterable implements Iterable { - private final ObjectMapper mapper = new ObjectMapper() - .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) - .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); private final BufferedReader input; private Envelope next; @@ -41,7 +36,7 @@ public boolean hasNext() { return hasNext(); } try { - next = mapper.readValue(line, Envelope.class); + next = Jackson.OBJECT_MAPPER.readValue(line, Envelope.class); } catch (JsonProcessingException e) { throw new RuntimeException(String.format("Could not parse JSON: %s", line), e); } diff --git a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java new file mode 100644 index 0000000000..7afaab8287 --- /dev/null +++ b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java @@ -0,0 +1,15 @@ +package io.cucumber.messages; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class JacksonTest { + @Test + void can_deserialize_enum() throws JsonProcessingException { + Messages.Source source = new Messages.Source("hello.feature", "Feature: Hello", Messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN); + String json = Jackson.OBJECT_MAPPER.writeValueAsString(source); + assertEquals(source, Jackson.OBJECT_MAPPER.readValue(json, Messages.Source.class)); + } +} diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index f3534db988..f511f49d6f 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -42,7 +42,7 @@ void writes_source_envelope() throws IOException { void does_not_serialize_null_fields() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(output); - JSON.writeValue(writer, new Envelope( + Jackson.OBJECT_MAPPER.writeValue(writer, new Envelope( null, null, null, @@ -127,7 +127,7 @@ void ignores_empty_lines() { @Test void handles_enums() { - InputStream input = new ByteArrayInputStream("{\"attachment\":{\"contentEncoding\":\"BASE64\"}}\n".getBytes(UTF_8)); + InputStream input = new ByteArrayInputStream("{\"attachment\":{\"contentEncoding\":\"BASE64\", \"body\":\"the-body\", \"mediaType\":\"text/plain\"}}\n".getBytes(UTF_8)); Iterable incomingMessages = makeMessageIterable(input); Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); @@ -143,6 +143,6 @@ void includes_offending_line_in_error_message() { Iterator iterator = incomingMessages.iterator(); RuntimeException exception = assertThrows(RuntimeException.class, () -> assertTrue(iterator.hasNext())); - assertEquals(exception.getMessage(), "Not JSON: BLA BLA"); + assertEquals(exception.getMessage(), "Could not parse JSON: BLA BLA"); } } diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb index 789219d706..b0781a000b 100644 --- a/messages/jsonschema/scripts/templates/java.enum.java.erb +++ b/messages/jsonschema/scripts/templates/java.enum.java.erb @@ -21,7 +21,7 @@ public static <%= enum[:name] %> fromValue(String value) { <%- enum[:values].each do |value| -%> - if ("<%= enum_constant(value) %>".equals(value)) return <%= enum_constant(value) %>; + if ("<%= value %>".equals(value)) return <%= enum_constant(value) %>; <%- end -%> throw new IllegalArgumentException(value); } From d5f1cefbd3c5d4c2f69230334a6d187d04aa571f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 11:55:18 +0000 Subject: [PATCH 33/63] Add shading of com.fasterxml.jackson.module:jackson-module-parameter-names --- messages/java/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 3fa0961f98..4f71e39cbf 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -105,6 +105,7 @@ com.fasterxml.jackson.core:jackson-core com.fasterxml.jackson.core:jackson-annotations com.fasterxml.jackson.datatype:jackson-datatype-jdk8 + com.fasterxml.jackson.module:jackson-module-parameter-names @@ -142,6 +143,13 @@ META-INF/MANIFEST.MF + + com.fasterxml.jackson.module:jackson-module-parameter-names + + **/module-info.class + META-INF/MANIFEST.MF + + From 3a56eb49ee21b514c2ef75a84e857468537371ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 12:02:47 +0000 Subject: [PATCH 34/63] Use single-arg constructor instead of static from method --- .../java/io/cucumber/messages/Messages.java | 112 +++++++++--------- .../MessageSerializationContract.java | 6 +- .../scripts/templates/java.java.erb | 4 +- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index bf0a13e263..fd97fffcae 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -174,8 +174,8 @@ public static class Envelope { private final TestStepStarted testStepStarted; private final UndefinedParameterType undefinedParameterType; - public static Envelope from(Attachment attachment) { - return new Envelope( + public Envelope(Attachment attachment) { + this( java.util.Objects.requireNonNull(attachment, "Envelope.attachment cannot be null"), null, null, @@ -196,8 +196,8 @@ public static Envelope from(Attachment attachment) { ); } - public static Envelope from(GherkinDocument gherkinDocument) { - return new Envelope( + public Envelope(GherkinDocument gherkinDocument) { + this( null, java.util.Objects.requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"), null, @@ -218,8 +218,8 @@ public static Envelope from(GherkinDocument gherkinDocument) { ); } - public static Envelope from(Hook hook) { - return new Envelope( + public Envelope(Hook hook) { + this( null, null, java.util.Objects.requireNonNull(hook, "Envelope.hook cannot be null"), @@ -240,8 +240,8 @@ public static Envelope from(Hook hook) { ); } - public static Envelope from(Meta meta) { - return new Envelope( + public Envelope(Meta meta) { + this( null, null, null, @@ -262,8 +262,8 @@ public static Envelope from(Meta meta) { ); } - public static Envelope from(ParameterType parameterType) { - return new Envelope( + public Envelope(ParameterType parameterType) { + this( null, null, null, @@ -284,8 +284,8 @@ public static Envelope from(ParameterType parameterType) { ); } - public static Envelope from(ParseError parseError) { - return new Envelope( + public Envelope(ParseError parseError) { + this( null, null, null, @@ -306,8 +306,8 @@ public static Envelope from(ParseError parseError) { ); } - public static Envelope from(Pickle pickle) { - return new Envelope( + public Envelope(Pickle pickle) { + this( null, null, null, @@ -328,8 +328,8 @@ public static Envelope from(Pickle pickle) { ); } - public static Envelope from(Source source) { - return new Envelope( + public Envelope(Source source) { + this( null, null, null, @@ -350,8 +350,8 @@ public static Envelope from(Source source) { ); } - public static Envelope from(StepDefinition stepDefinition) { - return new Envelope( + public Envelope(StepDefinition stepDefinition) { + this( null, null, null, @@ -372,8 +372,8 @@ public static Envelope from(StepDefinition stepDefinition) { ); } - public static Envelope from(TestCase testCase) { - return new Envelope( + public Envelope(TestCase testCase) { + this( null, null, null, @@ -394,8 +394,8 @@ public static Envelope from(TestCase testCase) { ); } - public static Envelope from(TestCaseFinished testCaseFinished) { - return new Envelope( + public Envelope(TestCaseFinished testCaseFinished) { + this( null, null, null, @@ -416,8 +416,8 @@ public static Envelope from(TestCaseFinished testCaseFinished) { ); } - public static Envelope from(TestCaseStarted testCaseStarted) { - return new Envelope( + public Envelope(TestCaseStarted testCaseStarted) { + this( null, null, null, @@ -438,8 +438,8 @@ public static Envelope from(TestCaseStarted testCaseStarted) { ); } - public static Envelope from(TestRunFinished testRunFinished) { - return new Envelope( + public Envelope(TestRunFinished testRunFinished) { + this( null, null, null, @@ -460,8 +460,8 @@ public static Envelope from(TestRunFinished testRunFinished) { ); } - public static Envelope from(TestRunStarted testRunStarted) { - return new Envelope( + public Envelope(TestRunStarted testRunStarted) { + this( null, null, null, @@ -482,8 +482,8 @@ public static Envelope from(TestRunStarted testRunStarted) { ); } - public static Envelope from(TestStepFinished testStepFinished) { - return new Envelope( + public Envelope(TestStepFinished testStepFinished) { + this( null, null, null, @@ -504,8 +504,8 @@ public static Envelope from(TestStepFinished testStepFinished) { ); } - public static Envelope from(TestStepStarted testStepStarted) { - return new Envelope( + public Envelope(TestStepStarted testStepStarted) { + this( null, null, null, @@ -526,8 +526,8 @@ public static Envelope from(TestStepStarted testStepStarted) { ); } - public static Envelope from(UndefinedParameterType undefinedParameterType) { - return new Envelope( + public Envelope(UndefinedParameterType undefinedParameterType) { + this( null, null, null, @@ -1240,24 +1240,24 @@ public static class FeatureChild { private final Background background; private final Scenario scenario; - public static FeatureChild from(Rule rule) { - return new FeatureChild( + public FeatureChild(Rule rule) { + this( java.util.Objects.requireNonNull(rule, "FeatureChild.rule cannot be null"), null, null ); } - public static FeatureChild from(Background background) { - return new FeatureChild( + public FeatureChild(Background background) { + this( null, java.util.Objects.requireNonNull(background, "FeatureChild.background cannot be null"), null ); } - public static FeatureChild from(Scenario scenario) { - return new FeatureChild( + public FeatureChild(Scenario scenario) { + this( null, null, java.util.Objects.requireNonNull(scenario, "FeatureChild.scenario cannot be null") @@ -1417,15 +1417,15 @@ public static class RuleChild { private final Background background; private final Scenario scenario; - public static RuleChild from(Background background) { - return new RuleChild( + public RuleChild(Background background) { + this( java.util.Objects.requireNonNull(background, "RuleChild.background cannot be null"), null ); } - public static RuleChild from(Scenario scenario) { - return new RuleChild( + public RuleChild(Scenario scenario) { + this( null, java.util.Objects.requireNonNull(scenario, "RuleChild.scenario cannot be null") ); @@ -2540,15 +2540,15 @@ public static class PickleStepArgument { private final PickleDocString docString; private final PickleTable dataTable; - public static PickleStepArgument from(PickleDocString docString) { - return new PickleStepArgument( + public PickleStepArgument(PickleDocString docString) { + this( java.util.Objects.requireNonNull(docString, "PickleStepArgument.docString cannot be null"), null ); } - public static PickleStepArgument from(PickleTable dataTable) { - return new PickleStepArgument( + public PickleStepArgument(PickleTable dataTable) { + this( null, java.util.Objects.requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null") ); @@ -2818,8 +2818,8 @@ public static class SourceReference { private final JavaStackTraceElement javaStackTraceElement; private final Location location; - public static SourceReference from(String uri) { - return new SourceReference( + public SourceReference(String uri) { + this( java.util.Objects.requireNonNull(uri, "SourceReference.uri cannot be null"), null, null, @@ -2827,8 +2827,8 @@ public static SourceReference from(String uri) { ); } - public static SourceReference from(JavaMethod javaMethod) { - return new SourceReference( + public SourceReference(JavaMethod javaMethod) { + this( null, java.util.Objects.requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"), null, @@ -2836,8 +2836,8 @@ public static SourceReference from(JavaMethod javaMethod) { ); } - public static SourceReference from(JavaStackTraceElement javaStackTraceElement) { - return new SourceReference( + public SourceReference(JavaStackTraceElement javaStackTraceElement) { + this( null, null, java.util.Objects.requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"), @@ -2845,8 +2845,8 @@ public static SourceReference from(JavaStackTraceElement javaStackTraceElement) ); } - public static SourceReference from(Location location) { - return new SourceReference( + public SourceReference(Location location) { + this( null, null, null, diff --git a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java index a7c3fff526..aea02d4f23 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java @@ -20,11 +20,11 @@ abstract class MessageSerializationContract { void can_serialise_messages_over_a_stream() throws IOException { List outgoingMessages = new ArrayList<>(); { - Envelope envelope = Envelope.from(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + Envelope envelope = new Envelope(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); outgoingMessages.add(envelope); } { - Envelope envelope = Envelope.from( + Envelope envelope = new Envelope( new Attachment( "the body", AttachmentContentEncoding.IDENTITY, @@ -46,7 +46,7 @@ void can_serialise_messages_over_a_stream() throws IOException { void writes_empty_arrays_and_empty_strings() throws IOException { List outgoingMessages = new ArrayList<>(); { - Envelope envelope = Envelope.from( + Envelope envelope = new Envelope( new GherkinDocument( "hello.feature", new Feature( diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 36f485c502..8cea195cd0 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -6,8 +6,8 @@ <%- if (schema['required'] || []).empty? -%> <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - public static <%= class_name(key) %> from(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - return new <%= class_name(key) %>( + public <%= class_name(key) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + this( <%- schema['properties'].each_with_index do |(property_name_2, property_2), index_2| -%> <%- if property_name_2 == property_name -%> <%- if property['items'] -%> From 2242bccb5e32d5711dde2b38926a19c8c9739268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 12:10:17 +0000 Subject: [PATCH 35/63] Fix Gherkin compile errors --- .../java/src/main/java/io/cucumber/gherkin/Gherkin.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index 237826159a..d4d287d8de 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -52,7 +52,7 @@ public static Stream fromSources(List envelopes, boolean inc } public static Envelope makeSourceEnvelope(String data, String uri) { - return Envelope.from(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + return new Envelope(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); } public Stream messages() { @@ -115,7 +115,7 @@ private List parseSource(boolean includeGherkinDocument, boolean inclu if (includeGherkinDocument) { gherkinDocument = parser.parse(data, uri); - messages.add(Envelope.from(gherkinDocument)); + messages.add(new Envelope(gherkinDocument)); } if (includePickles) { if (gherkinDocument == null) { @@ -124,7 +124,7 @@ private List parseSource(boolean includeGherkinDocument, boolean inclu PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); List pickles = pickleCompiler.compile(gherkinDocument, uri); for (Pickle pickle : pickles) { - messages.add(Envelope.from(pickle)); + messages.add(new Envelope(pickle)); } } } catch (ParserException.CompositeParserException e) { @@ -154,7 +154,6 @@ private void addParseError(List messages, ParserException e, String ur ), e.getMessage() ); - Envelope envelope = Envelope.from(parseError); - messages.add(envelope); + messages.add(new Envelope(parseError)); } } From e1364dfd754b23006af977c2f3bffbd28817f483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 12:13:19 +0000 Subject: [PATCH 36/63] Fix HTML Formatter compile errors --- .../io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 349d250c90..a1a0815859 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -24,7 +24,7 @@ class MessagesToHtmlWriterTest { @Test void it_writes_one_message_to_html() throws IOException { Instant timestamp = Instant.ofEpochSecond(10); - Envelope envelope = Envelope.from(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); + Envelope envelope = new Envelope(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); String html = renderAsHtml(envelope); assertThat(html, containsString("" + "window.CUCUMBER_MESSAGES = [{\"testRunStarted\":{\"timestamp\":{\"seconds\":10,\"nanos\":0}}}];")); @@ -78,9 +78,9 @@ public void close() throws IOException { @Test void it_writes_two_messages_separated_by_a_comma() throws IOException { - Envelope testRunStarted = Envelope.from(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); + Envelope testRunStarted = new Envelope(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); - Envelope envelope = Envelope.from(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); + Envelope envelope = new Envelope(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); String html = renderAsHtml(testRunStarted, envelope); From e89151ac31eafab296de66d75f4b0c57a5929ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Mon, 17 Jan 2022 12:26:58 +0000 Subject: [PATCH 37/63] Fix another compile error --- .../java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index caf80edaa3..748ae8b43f 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -1,6 +1,6 @@ package io.cucumber.htmlformatter; -import io.cucumber.messages.JSON; +import io.cucumber.messages.Jackson; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -67,7 +67,7 @@ public void write(Envelope envelope) throws IOException { writer.write(","); } - JSON.writeValue(writer, envelope); + Jackson.OBJECT_MAPPER.writeValue(writer, envelope); } /** From fb1ba8f3c43f6f5bfa0d0c58554fe0a053e1be60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Tue, 18 Jan 2022 13:22:31 +0000 Subject: [PATCH 38/63] Decouple Jackson and make tests pass --- html-formatter/CHANGELOG.md | 2 + html-formatter/java/Makefile | 2 +- html-formatter/java/pom.xml | 37 +++- .../java/io/cucumber/htmlformatter/Main.java | 25 --- .../htmlformatter/MessagesToHtmlWriter.java | 17 +- .../io/cucumber/htmlformatter}/Jackson.java | 7 +- .../java/io/cucumber/htmlformatter/Main.java | 48 +++++ .../MessagesToHtmlWriterTest.java | 18 +- messages/java/Makefile | 7 +- messages/java/pom.xml | 75 +------- .../messages/MessageToNdjsonWriter.java | 28 ++- .../io/cucumber/messages/MessageWriter.java | 4 +- .../java/io/cucumber/messages/Messages.java | 169 ++++++++++++------ .../messages/NdjsonToMessageIterable.java | 45 +++-- .../java/io/cucumber/messages/Jackson.java | 26 +++ .../MessageSerializationContract.java | 99 ---------- .../messages/NdjsonSerializationTest.java | 55 ++++-- .../scripts/templates/java.java.erb | 3 +- 18 files changed, 362 insertions(+), 305 deletions(-) delete mode 100644 html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java rename {messages/java/src/main/java/io/cucumber/messages => html-formatter/java/src/test/java/io/cucumber/htmlformatter}/Jackson.java (85%) create mode 100644 html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java create mode 100644 messages/java/src/test/java/io/cucumber/messages/Jackson.java delete mode 100644 messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java diff --git a/html-formatter/CHANGELOG.md b/html-formatter/CHANGELOG.md index ea15eb25e3..c5c4cbf5b1 100644 --- a/html-formatter/CHANGELOG.md +++ b/html-formatter/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Removed +- [Java] the `io.cucumber.htmlformatter.Main` class is no longer part of the jar. + ### Fixed ## [17.0.0] - 2021-09-02 diff --git a/html-formatter/java/Makefile b/html-formatter/java/Makefile index b07d60f96d..cccaabb7e6 100644 --- a/html-formatter/java/Makefile +++ b/html-formatter/java/Makefile @@ -7,7 +7,7 @@ HTML_REPORTS = $(patsubst ../../compatibility-kit/javascript/features/%.ndjson,a acceptance/%.html: ../../compatibility-kit/javascript/features/%.ndjson .built mkdir -p $(@D) - cat $< | mvn --quiet --batch-mode exec:java -Dexec.mainClass=io.cucumber.htmlformatter.Main > $@ + cat $< | mvn --quiet --batch-mode exec:java -Dexec.classpathScope=test -Dexec.mainClass=io.cucumber.htmlformatter.Main > $@ .deps: target/classes/io/cucumber/htmlformatter/cucumber-html.css target/classes/io/cucumber/htmlformatter/cucumber-html.js target/classes/io/cucumber/htmlformatter/index.mustache.html diff --git a/html-formatter/java/pom.xml b/html-formatter/java/pom.xml index 588abab204..93f3d9df2e 100644 --- a/html-formatter/java/pom.xml +++ b/html-formatter/java/pom.xml @@ -34,6 +34,14 @@ pom import + + + com.fasterxml.jackson + jackson-bom + 2.13.1 + pom + import + @@ -43,17 +51,38 @@ messages [17.1.2-SNAPSHOT,18.0.0) + + + com.fasterxml.jackson.core + jackson-databind + test + + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + test + + + + com.fasterxml.jackson.module + jackson-module-parameter-names + test + + org.hamcrest hamcrest 2.2 test + org.junit.jupiter junit-jupiter-engine test + org.junit.jupiter junit-jupiter-params @@ -65,13 +94,9 @@ org.apache.maven.plugins - maven-jar-plugin + maven-compiler-plugin - - - io.cucumber.htmlformatter.Main - - + true diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java deleted file mode 100644 index 5c3d4ef294..0000000000 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/Main.java +++ /dev/null @@ -1,25 +0,0 @@ -package io.cucumber.htmlformatter; - -import io.cucumber.messages.NdjsonToMessageIterable; - -import static io.cucumber.messages.Messages.Envelope; - -import java.io.OutputStreamWriter; - -import static java.nio.charset.StandardCharsets.UTF_8; - -public final class Main { - public static void main(String[] args) { - OutputStreamWriter writer = new OutputStreamWriter(System.out, UTF_8); - NdjsonToMessageIterable envelopes = new NdjsonToMessageIterable(System.in); - try (MessagesToHtmlWriter htmlWriter = new MessagesToHtmlWriter(writer)) { - 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); - } - } -} diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index 748ae8b43f..13a0238897 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -1,15 +1,16 @@ package io.cucumber.htmlformatter; -import io.cucumber.messages.Jackson; - import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.StandardCharsets; +import java.util.function.BiConsumer; import static io.cucumber.messages.Messages.Envelope; import static java.nio.charset.StandardCharsets.UTF_8; @@ -19,17 +20,21 @@ * Writes the message output of a test run as single page html report. */ public final class MessagesToHtmlWriter implements AutoCloseable { - private final String template; - private final Writer writer; + private final BiConsumer serializer; private boolean preMessageWritten = false; private boolean postMessageWritten = false; private boolean firstMessageWritten = false; private boolean streamClosed = false; - public MessagesToHtmlWriter(Writer writer) throws IOException { + public MessagesToHtmlWriter(OutputStream outputStream, BiConsumer serializer) throws IOException { + this(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8), serializer); + } + + public MessagesToHtmlWriter(Writer writer, BiConsumer serializer) throws IOException { this.writer = writer; + this.serializer = serializer; this.template = readResource("index.mustache.html"); } @@ -67,7 +72,7 @@ public void write(Envelope envelope) throws IOException { writer.write(","); } - Jackson.OBJECT_MAPPER.writeValue(writer, envelope); + serializer.accept(writer, envelope); } /** diff --git a/messages/java/src/main/java/io/cucumber/messages/Jackson.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Jackson.java similarity index 85% rename from messages/java/src/main/java/io/cucumber/messages/Jackson.java rename to html-formatter/java/src/test/java/io/cucumber/htmlformatter/Jackson.java index e9d080fc19..348fffac23 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Jackson.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Jackson.java @@ -1,9 +1,10 @@ -package io.cucumber.messages; +package io.cucumber.htmlformatter; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.cfg.ConstructorDetector; import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; @@ -11,11 +12,12 @@ import static com.fasterxml.jackson.databind.DeserializationFeature.READ_ENUMS_USING_TO_STRING; import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING; -public final class Jackson { +final class Jackson { public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) .registerModule(new Jdk8Module()) .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) + .setConstructorDetector(ConstructorDetector.USE_PROPERTIES_BASED) .enable(WRITE_ENUMS_USING_TO_STRING) .enable(READ_ENUMS_USING_TO_STRING) .disable(FAIL_ON_UNKNOWN_PROPERTIES) @@ -24,3 +26,4 @@ public final class Jackson { private Jackson() { } } + diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java new file mode 100644 index 0000000000..7efda143ab --- /dev/null +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java @@ -0,0 +1,48 @@ +package io.cucumber.htmlformatter; + +import io.cucumber.messages.NdjsonToMessageIterable; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Writer; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; + +import static io.cucumber.messages.Messages.Envelope; + +public final class Main { + public static final BiFunction, Envelope> DESERIALIZER = (json, klass) -> { + try { + return Jackson.OBJECT_MAPPER.readValue(json, klass); + } catch (IOException e) { + throw new RuntimeException(e); + } + }; + + private static final BiConsumer SERIALIZER = (writer, envelope) -> { + try { + Jackson.OBJECT_MAPPER.writeValue(writer, envelope); + } catch (IOException e) { + throw new RuntimeException(e); + } + }; + + 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, Envelope.class, 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); + } + } + } +} diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index a1a0815859..2dd67d1971 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -7,7 +7,9 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; +import java.io.Writer; import java.time.Instant; +import java.util.function.BiConsumer; import static io.cucumber.messages.Messages.Envelope; import static io.cucumber.messages.Messages.TestRunFinished; @@ -21,6 +23,14 @@ class MessagesToHtmlWriterTest { + private static final BiConsumer SERIALIZER = (writer, message) -> { + try { + Jackson.OBJECT_MAPPER.writeValue(writer, message); + } catch (IOException e) { + throw new RuntimeException(e); + } + }; + @Test void it_writes_one_message_to_html() throws IOException { Instant timestamp = Instant.ofEpochSecond(10); @@ -42,7 +52,7 @@ void it_throws_when_writing_after_close() throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); BufferedWriter bw = new BufferedWriter(osw); - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER); messagesToHtmlWriter.close(); assertThrows(IOException.class, () -> messagesToHtmlWriter.write(null)); } @@ -52,7 +62,7 @@ void it_can_be_closed_twice() throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); BufferedWriter bw = new BufferedWriter(osw); - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER); messagesToHtmlWriter.close(); assertDoesNotThrow(messagesToHtmlWriter::close); } @@ -68,7 +78,7 @@ public void close() throws IOException { throw new IOException("Can't close this"); } }; - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER); assertThrows(IOException.class, messagesToHtmlWriter::close); byte[] before = bytes.toByteArray(); assertThrows(IOException.class, messagesToHtmlWriter::close); @@ -92,7 +102,7 @@ private static String renderAsHtml(Envelope... messages) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); BufferedWriter bw = new BufferedWriter(osw); - try (MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw)) { + try (MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER)) { for (Envelope message : messages) { messagesToHtmlWriter.write(message); } diff --git a/messages/java/Makefile b/messages/java/Makefile index 23bb1961dd..fe351874b4 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -7,7 +7,12 @@ JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/java.java.erb ../jsonschema/scripts/templates/java.enum.java.erb echo "package io.cucumber.messages;" > $@ echo >> $@ - echo "public class Messages {" >> $@ + echo "import com.fasterxml.jackson.annotation.JsonCreator;" >> $@ + echo >> $@ + echo "public final class Messages {" >> $@ + echo >> $@ + echo " private Messages() {}" >> $@ + echo >> $@ ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.java.erb >> $@ ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> $@ echo "}" >> $@ diff --git a/messages/java/pom.xml b/messages/java/pom.xml index 4f71e39cbf..e4eec6608c 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -44,19 +44,28 @@ + + com.fasterxml.jackson.core + jackson-annotations + compile + + com.fasterxml.jackson.core jackson-databind + test com.fasterxml.jackson.datatype jackson-datatype-jdk8 + test com.fasterxml.jackson.module jackson-module-parameter-names + test @@ -89,72 +98,6 @@ true - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - - - com.fasterxml.jackson.core:jackson-databind - com.fasterxml.jackson.core:jackson-core - com.fasterxml.jackson.core:jackson-annotations - com.fasterxml.jackson.datatype:jackson-datatype-jdk8 - com.fasterxml.jackson.module:jackson-module-parameter-names - - - - - com.fasterxml - io.cucumber.messages.internal.com.fasterxml - - - - - com.fasterxml.jackson.core:jackson-databind - - **/module-info.class - META-INF/MANIFEST.MF - - - - com.fasterxml.jackson.core:jackson-core - - **/module-info.class - META-INF/MANIFEST.MF - - - - com.fasterxml.jackson.core:jackson-annotations - - **/module-info.class - META-INF/MANIFEST.MF - - - - com.fasterxml.jackson.datatype:jackson-datatype-jdk8 - - **/module-info.class - META-INF/MANIFEST.MF - - - - com.fasterxml.jackson.module:jackson-module-parameter-names - - **/module-info.class - META-INF/MANIFEST.MF - - - - - - - diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java index c92932f9fc..2c2f80c0f3 100644 --- a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java +++ b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java @@ -5,18 +5,30 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.StandardCharsets; +import java.util.function.BiConsumer; -public final class MessageToNdjsonWriter implements MessageWriter { - private final Writer out; +public final class MessageToNdjsonWriter implements MessageWriter, AutoCloseable { + private final Writer writer; + private final BiConsumer serializer; - public MessageToNdjsonWriter(OutputStream out) { - this.out = new OutputStreamWriter(out, StandardCharsets.UTF_8); + public MessageToNdjsonWriter(OutputStream outputStream, BiConsumer serializer) { + this(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8), serializer); + } + + public MessageToNdjsonWriter(Writer writer, BiConsumer serializer) { + this.writer = writer; + this.serializer = serializer; + } + + @Override + public void write(T message) throws IOException { + this.serializer.accept(writer, message); + writer.write("\n"); + writer.flush(); } @Override - public void write(Object message) throws IOException { - Jackson.OBJECT_MAPPER.writeValue(out, message); - out.write("\n"); - out.flush(); + public void close() throws Exception { + this.writer.close(); } } diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageWriter.java index 201a3b32d1..e0551038d5 100644 --- a/messages/java/src/main/java/io/cucumber/messages/MessageWriter.java +++ b/messages/java/src/main/java/io/cucumber/messages/MessageWriter.java @@ -2,6 +2,6 @@ import java.io.IOException; -public interface MessageWriter { - void write(Object message) throws IOException; +public interface MessageWriter { + void write(T message) throws IOException; } diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index fd97fffcae..ea439b7c66 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -1,7 +1,12 @@ package io.cucumber.messages; -public class Messages { - public static class Attachment { +import com.fasterxml.jackson.annotation.JsonCreator; + +public final class Messages { + + private Messages() {} + + public static final class Attachment { private final String body; private final AttachmentContentEncoding contentEncoding; private final String fileName; @@ -11,6 +16,7 @@ public static class Attachment { private final String testStepId; private final String url; + @JsonCreator public Attachment( String body, AttachmentContentEncoding contentEncoding, @@ -108,10 +114,11 @@ public String toString() { } } - public static class Duration { + public static final class Duration { private final Long seconds; private final Long nanos; + @JsonCreator public Duration( Long seconds, Long nanos @@ -155,7 +162,7 @@ public String toString() { } } - public static class Envelope { + public static final class Envelope { private final Attachment attachment; private final GherkinDocument gherkinDocument; private final Hook hook; @@ -548,6 +555,7 @@ public Envelope(UndefinedParameterType undefinedParameterType) { ); } + @JsonCreator public Envelope( Attachment attachment, GherkinDocument gherkinDocument, @@ -726,11 +734,12 @@ public String toString() { } } - public static class GherkinDocument { + public static final class GherkinDocument { private final String uri; private final Feature feature; private final java.util.List comments; + @JsonCreator public GherkinDocument( String uri, Feature feature, @@ -783,7 +792,7 @@ public String toString() { } } - public static class Background { + public static final class Background { private final Location location; private final String keyword; private final String name; @@ -791,6 +800,7 @@ public static class Background { private final java.util.List steps; private final String id; + @JsonCreator public Background( Location location, String keyword, @@ -870,10 +880,11 @@ public String toString() { } } - public static class Comment { + public static final class Comment { private final Location location; private final String text; + @JsonCreator public Comment( Location location, String text @@ -917,10 +928,11 @@ public String toString() { } } - public static class DataTable { + public static final class DataTable { private final Location location; private final java.util.List rows; + @JsonCreator public DataTable( Location location, java.util.List rows @@ -964,12 +976,13 @@ public String toString() { } } - public static class DocString { + public static final class DocString { private final Location location; private final String mediaType; private final String content; private final String delimiter; + @JsonCreator public DocString( Location location, String mediaType, @@ -1031,7 +1044,7 @@ public String toString() { } } - public static class Examples { + public static final class Examples { private final Location location; private final java.util.List tags; private final String keyword; @@ -1041,6 +1054,7 @@ public static class Examples { private final java.util.List tableBody; private final String id; + @JsonCreator public Examples( Location location, java.util.List tags, @@ -1138,7 +1152,7 @@ public String toString() { } } - public static class Feature { + public static final class Feature { private final Location location; private final java.util.List tags; private final String language; @@ -1147,6 +1161,7 @@ public static class Feature { private final String description; private final java.util.List children; + @JsonCreator public Feature( Location location, java.util.List tags, @@ -1235,7 +1250,7 @@ public String toString() { } } - public static class FeatureChild { + public static final class FeatureChild { private final Rule rule; private final Background background; private final Scenario scenario; @@ -1264,6 +1279,7 @@ public FeatureChild(Scenario scenario) { ); } + @JsonCreator public FeatureChild( Rule rule, Background background, @@ -1316,7 +1332,7 @@ public String toString() { } } - public static class Rule { + public static final class Rule { private final Location location; private final java.util.List tags; private final String keyword; @@ -1325,6 +1341,7 @@ public static class Rule { private final java.util.List children; private final String id; + @JsonCreator public Rule( Location location, java.util.List tags, @@ -1413,7 +1430,7 @@ public String toString() { } } - public static class RuleChild { + public static final class RuleChild { private final Background background; private final Scenario scenario; @@ -1431,6 +1448,7 @@ public RuleChild(Scenario scenario) { ); } + @JsonCreator public RuleChild( Background background, Scenario scenario @@ -1474,7 +1492,7 @@ public String toString() { } } - public static class Scenario { + public static final class Scenario { private final Location location; private final java.util.List tags; private final String keyword; @@ -1484,6 +1502,7 @@ public static class Scenario { private final java.util.List examples; private final String id; + @JsonCreator public Scenario( Location location, java.util.List tags, @@ -1581,7 +1600,7 @@ public String toString() { } } - public static class Step { + public static final class Step { private final Location location; private final String keyword; private final String text; @@ -1589,6 +1608,7 @@ public static class Step { private final DataTable dataTable; private final String id; + @JsonCreator public Step( Location location, String keyword, @@ -1668,10 +1688,11 @@ public String toString() { } } - public static class TableCell { + public static final class TableCell { private final Location location; private final String value; + @JsonCreator public TableCell( Location location, String value @@ -1715,11 +1736,12 @@ public String toString() { } } - public static class TableRow { + public static final class TableRow { private final Location location; private final java.util.List cells; private final String id; + @JsonCreator public TableRow( Location location, java.util.List cells, @@ -1772,11 +1794,12 @@ public String toString() { } } - public static class Tag { + public static final class Tag { private final Location location; private final String name; private final String id; + @JsonCreator public Tag( Location location, String name, @@ -1829,11 +1852,12 @@ public String toString() { } } - public static class Hook { + public static final class Hook { private final String id; private final SourceReference sourceReference; private final String tagExpression; + @JsonCreator public Hook( String id, SourceReference sourceReference, @@ -1886,10 +1910,11 @@ public String toString() { } } - public static class Location { + public static final class Location { private final Long line; private final Long column; + @JsonCreator public Location( Long line, Long column @@ -1933,7 +1958,7 @@ public String toString() { } } - public static class Meta { + public static final class Meta { private final String protocolVersion; private final Product implementation; private final Product runtime; @@ -1941,6 +1966,7 @@ public static class Meta { private final Product cpu; private final Ci ci; + @JsonCreator public Meta( String protocolVersion, Product implementation, @@ -2020,12 +2046,13 @@ public String toString() { } } - public static class Ci { + public static final class Ci { private final String name; private final String url; private final String buildNumber; private final Git git; + @JsonCreator public Ci( String name, String url, @@ -2087,12 +2114,13 @@ public String toString() { } } - public static class Git { + public static final class Git { private final String remote; private final String revision; private final String branch; private final String tag; + @JsonCreator public Git( String remote, String revision, @@ -2154,10 +2182,11 @@ public String toString() { } } - public static class Product { + public static final class Product { private final String name; private final String version; + @JsonCreator public Product( String name, String version @@ -2201,13 +2230,14 @@ public String toString() { } } - public static class ParameterType { + public static final class ParameterType { private final String name; private final java.util.List regularExpressions; private final Boolean preferForRegularExpressionMatch; private final Boolean useForSnippets; private final String id; + @JsonCreator public ParameterType( String name, java.util.List regularExpressions, @@ -2278,10 +2308,11 @@ public String toString() { } } - public static class ParseError { + public static final class ParseError { private final SourceReference source; private final String message; + @JsonCreator public ParseError( SourceReference source, String message @@ -2325,7 +2356,7 @@ public String toString() { } } - public static class Pickle { + public static final class Pickle { private final String id; private final String uri; private final String name; @@ -2334,6 +2365,7 @@ public static class Pickle { private final java.util.List tags; private final java.util.List astNodeIds; + @JsonCreator public Pickle( String id, String uri, @@ -2422,10 +2454,11 @@ public String toString() { } } - public static class PickleDocString { + public static final class PickleDocString { private final String mediaType; private final String content; + @JsonCreator public PickleDocString( String mediaType, String content @@ -2469,12 +2502,13 @@ public String toString() { } } - public static class PickleStep { + public static final class PickleStep { private final PickleStepArgument argument; private final java.util.List astNodeIds; private final String id; private final String text; + @JsonCreator public PickleStep( PickleStepArgument argument, java.util.List astNodeIds, @@ -2536,7 +2570,7 @@ public String toString() { } } - public static class PickleStepArgument { + public static final class PickleStepArgument { private final PickleDocString docString; private final PickleTable dataTable; @@ -2554,6 +2588,7 @@ public PickleStepArgument(PickleTable dataTable) { ); } + @JsonCreator public PickleStepArgument( PickleDocString docString, PickleTable dataTable @@ -2597,9 +2632,10 @@ public String toString() { } } - public static class PickleTable { + public static final class PickleTable { private final java.util.List rows; + @JsonCreator public PickleTable( java.util.List rows ) { @@ -2634,9 +2670,10 @@ public String toString() { } } - public static class PickleTableCell { + public static final class PickleTableCell { private final String value; + @JsonCreator public PickleTableCell( String value ) { @@ -2671,9 +2708,10 @@ public String toString() { } } - public static class PickleTableRow { + public static final class PickleTableRow { private final java.util.List cells; + @JsonCreator public PickleTableRow( java.util.List cells ) { @@ -2708,10 +2746,11 @@ public String toString() { } } - public static class PickleTag { + public static final class PickleTag { private final String name; private final String astNodeId; + @JsonCreator public PickleTag( String name, String astNodeId @@ -2755,11 +2794,12 @@ public String toString() { } } - public static class Source { + public static final class Source { private final String uri; private final String data; private final SourceMediaType mediaType; + @JsonCreator public Source( String uri, String data, @@ -2812,7 +2852,7 @@ public String toString() { } } - public static class SourceReference { + public static final class SourceReference { private final String uri; private final JavaMethod javaMethod; private final JavaStackTraceElement javaStackTraceElement; @@ -2854,6 +2894,7 @@ public SourceReference(Location location) { ); } + @JsonCreator public SourceReference( String uri, JavaMethod javaMethod, @@ -2915,11 +2956,12 @@ public String toString() { } } - public static class JavaMethod { + public static final class JavaMethod { private final String className; private final String methodName; private final java.util.List methodParameterTypes; + @JsonCreator public JavaMethod( String className, String methodName, @@ -2972,11 +3014,12 @@ public String toString() { } } - public static class JavaStackTraceElement { + public static final class JavaStackTraceElement { private final String className; private final String fileName; private final String methodName; + @JsonCreator public JavaStackTraceElement( String className, String fileName, @@ -3029,11 +3072,12 @@ public String toString() { } } - public static class StepDefinition { + public static final class StepDefinition { private final String id; private final StepDefinitionPattern pattern; private final SourceReference sourceReference; + @JsonCreator public StepDefinition( String id, StepDefinitionPattern pattern, @@ -3086,10 +3130,11 @@ public String toString() { } } - public static class StepDefinitionPattern { + public static final class StepDefinitionPattern { private final String source; private final StepDefinitionPatternType type; + @JsonCreator public StepDefinitionPattern( String source, StepDefinitionPatternType type @@ -3133,11 +3178,12 @@ public String toString() { } } - public static class TestCase { + public static final class TestCase { private final String id; private final String pickleId; private final java.util.List testSteps; + @JsonCreator public TestCase( String id, String pickleId, @@ -3190,11 +3236,12 @@ public String toString() { } } - public static class Group { + public static final class Group { private final java.util.List children; private final Long start; private final String value; + @JsonCreator public Group( java.util.List children, Long start, @@ -3247,10 +3294,11 @@ public String toString() { } } - public static class StepMatchArgument { + public static final class StepMatchArgument { private final Group group; private final String parameterTypeName; + @JsonCreator public StepMatchArgument( Group group, String parameterTypeName @@ -3294,9 +3342,10 @@ public String toString() { } } - public static class StepMatchArgumentsList { + public static final class StepMatchArgumentsList { private final java.util.List stepMatchArguments; + @JsonCreator public StepMatchArgumentsList( java.util.List stepMatchArguments ) { @@ -3331,13 +3380,14 @@ public String toString() { } } - public static class TestStep { + public static final class TestStep { private final String hookId; private final String id; private final String pickleStepId; private final java.util.List stepDefinitionIds; private final java.util.List stepMatchArgumentsLists; + @JsonCreator public TestStep( String hookId, String id, @@ -3408,11 +3458,12 @@ public String toString() { } } - public static class TestCaseFinished { + public static final class TestCaseFinished { private final String testCaseStartedId; private final Timestamp timestamp; private final Boolean willBeRetried; + @JsonCreator public TestCaseFinished( String testCaseStartedId, Timestamp timestamp, @@ -3465,12 +3516,13 @@ public String toString() { } } - public static class TestCaseStarted { + public static final class TestCaseStarted { private final Long attempt; private final String id; private final String testCaseId; private final Timestamp timestamp; + @JsonCreator public TestCaseStarted( Long attempt, String id, @@ -3532,11 +3584,12 @@ public String toString() { } } - public static class TestRunFinished { + public static final class TestRunFinished { private final String message; private final Boolean success; private final Timestamp timestamp; + @JsonCreator public TestRunFinished( String message, Boolean success, @@ -3589,9 +3642,10 @@ public String toString() { } } - public static class TestRunStarted { + public static final class TestRunStarted { private final Timestamp timestamp; + @JsonCreator public TestRunStarted( Timestamp timestamp ) { @@ -3626,12 +3680,13 @@ public String toString() { } } - public static class TestStepFinished { + public static final class TestStepFinished { private final String testCaseStartedId; private final String testStepId; private final TestStepResult testStepResult; private final Timestamp timestamp; + @JsonCreator public TestStepFinished( String testCaseStartedId, String testStepId, @@ -3693,11 +3748,12 @@ public String toString() { } } - public static class TestStepResult { + public static final class TestStepResult { private final Duration duration; private final String message; private final TestStepResultStatus status; + @JsonCreator public TestStepResult( Duration duration, String message, @@ -3750,11 +3806,12 @@ public String toString() { } } - public static class TestStepStarted { + public static final class TestStepStarted { private final String testCaseStartedId; private final String testStepId; private final Timestamp timestamp; + @JsonCreator public TestStepStarted( String testCaseStartedId, String testStepId, @@ -3807,10 +3864,11 @@ public String toString() { } } - public static class Timestamp { + public static final class Timestamp { private final Long seconds; private final Long nanos; + @JsonCreator public Timestamp( Long seconds, Long nanos @@ -3854,10 +3912,11 @@ public String toString() { } } - public static class UndefinedParameterType { + public static final class UndefinedParameterType { private final String expression; private final String name; + @JsonCreator public UndefinedParameterType( String expression, String name diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 1108996c41..edf02566df 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -1,43 +1,53 @@ package io.cucumber.messages; -import com.fasterxml.jackson.core.JsonProcessingException; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.Reader; import java.nio.charset.StandardCharsets; import java.util.Iterator; - -import static io.cucumber.messages.Messages.*; +import java.util.function.BiFunction; /** * Iterates over messages read from a stream. Client code should not depend on this class * directly, but rather on a {@code Iterable} object. * Tests can then use a {@code new ArrayList} which implements the same interface. */ -public final class NdjsonToMessageIterable implements Iterable { - private final BufferedReader input; - private Envelope next; +public final class NdjsonToMessageIterable implements Iterable, AutoCloseable { + private final BufferedReader reader; + private final Class klass; + private final BiFunction, T> deserializer; + private T next; - public NdjsonToMessageIterable(InputStream input) { - this.input = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)); + public NdjsonToMessageIterable(InputStream inputStream, Class klass, BiFunction, T> deserializer) { + this(new InputStreamReader(inputStream, StandardCharsets.UTF_8), klass, deserializer); + } + + public NdjsonToMessageIterable(Reader reader, Class klass, BiFunction, T> deserializer) { + this(new BufferedReader(reader), klass, deserializer); + } + + public NdjsonToMessageIterable(BufferedReader reader, Class klass, BiFunction, T> deserializer) { + this.reader = reader; + this.klass = klass; + this.deserializer = deserializer; } @Override - public Iterator iterator() { - return new Iterator() { + public Iterator iterator() { + return new Iterator() { @Override public boolean hasNext() { try { - String line = input.readLine(); + String line = reader.readLine(); if (line == null) return false; if (line.trim().equals("")) { return hasNext(); } try { - next = Jackson.OBJECT_MAPPER.readValue(line, Envelope.class); - } catch (JsonProcessingException e) { + next = deserializer.apply(line, klass); + } catch (Exception e) { throw new RuntimeException(String.format("Could not parse JSON: %s", line), e); } return true; @@ -47,7 +57,7 @@ public boolean hasNext() { } @Override - public Envelope next() { + public T next() { if (next == null) { throw new IllegalStateException("next() should only be called after a call to hasNext() that returns true"); } @@ -60,4 +70,9 @@ public void remove() { } }; } + + @Override + public void close() throws IOException { + this.reader.close(); + } } diff --git a/messages/java/src/test/java/io/cucumber/messages/Jackson.java b/messages/java/src/test/java/io/cucumber/messages/Jackson.java new file mode 100644 index 0000000000..69964a896c --- /dev/null +++ b/messages/java/src/test/java/io/cucumber/messages/Jackson.java @@ -0,0 +1,26 @@ +package io.cucumber.messages; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +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.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; + +final class Jackson { + public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() + .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) + .registerModule(new Jdk8Module()) + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) +// .setConstructorDetector(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); + + private Jackson() { + } +} diff --git a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java b/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java deleted file mode 100644 index aea02d4f23..0000000000 --- a/messages/java/src/test/java/io/cucumber/messages/MessageSerializationContract.java +++ /dev/null @@ -1,99 +0,0 @@ -package io.cucumber.messages; - -import org.junit.jupiter.api.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.List; - -import static io.cucumber.messages.Messages.*; -import static java.util.Collections.emptyList; -import static org.junit.jupiter.api.Assertions.assertEquals; - -abstract class MessageSerializationContract { - - @Test - void can_serialise_messages_over_a_stream() throws IOException { - List outgoingMessages = new ArrayList<>(); - { - Envelope envelope = new Envelope(new Source("hello.feature", "Feature: Hello", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); - outgoingMessages.add(envelope); - } - { - Envelope envelope = new Envelope( - new Attachment( - "the body", - AttachmentContentEncoding.IDENTITY, - null, - "text/plain", - null, - null, - null, - null - ) - ); - outgoingMessages.add(envelope); - } - - assertRoundtrip(outgoingMessages); - } - - @Test - void writes_empty_arrays_and_empty_strings() throws IOException { - List outgoingMessages = new ArrayList<>(); - { - Envelope envelope = new Envelope( - new GherkinDocument( - "hello.feature", - new Feature( - new Location(1L, 1L), - emptyList(), - "en", - "Given ", - "Hello", - "", - emptyList() - ), - emptyList() - ) - ); - outgoingMessages.add(envelope); - } - assertRoundtrip(outgoingMessages); - } - - private void assertRoundtrip(List outgoingMessages) throws IOException { - ByteArrayOutputStream output = new ByteArrayOutputStream(); - MessageWriter messageWriter = makeMessageWriter(output); - writeOutgoingMessages(outgoingMessages, messageWriter); - - InputStream input = new ByteArrayInputStream(output.toByteArray()); - Iterable incomingMessages = makeMessageIterable(input); - - assertEquals(outgoingMessages, toList(incomingMessages)); - } - - protected abstract MessageWriter makeMessageWriter(OutputStream output); - - protected abstract Iterable makeMessageIterable(InputStream input); - - private void writeOutgoingMessages(List messages, MessageWriter messageWriter) - throws IOException { - for (Envelope writtenMessage : messages) { - messageWriter.write(writtenMessage); - } - } - - private static List toList(Iterable iterable) { - List result = new ArrayList<>(); - for (T item : iterable) { - result.add(item); - } - return result; - } - -} diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index f511f49d6f..1590c4c00f 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -11,28 +11,43 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; -import static io.cucumber.messages.Messages.*; +import static io.cucumber.messages.Messages.AttachmentContentEncoding; +import static io.cucumber.messages.Messages.Envelope; +import static io.cucumber.messages.Messages.Source; +import static io.cucumber.messages.Messages.SourceMediaType; +import static io.cucumber.messages.Messages.TestRunStarted; +import static io.cucumber.messages.Messages.Timestamp; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -class NdjsonSerializationTest extends MessageSerializationContract { - @Override - protected MessageWriter makeMessageWriter(OutputStream output) { - return new MessageToNdjsonWriter(output); +class NdjsonSerializationTest { + protected static MessageWriter makeMessageWriter(OutputStream output) { + return new MessageToNdjsonWriter<>(output, (writer, envelope) -> { + try { + Jackson.OBJECT_MAPPER.writeValue(writer, envelope); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); } - @Override - protected Iterable makeMessageIterable(InputStream input) { - return new NdjsonToMessageIterable(input); + protected static Iterable makeMessageIterable(InputStream input, Class klass) { + return new NdjsonToMessageIterable(input, klass, (json, clazz) -> { + try { + return Jackson.OBJECT_MAPPER.readValue(json, clazz); + } catch (IOException e) { + throw new RuntimeException(e); + } + }); } @Test void writes_source_envelope() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); - MessageWriter writer = makeMessageWriter(output); + MessageWriter writer = makeMessageWriter(output); writer.write(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); String json = new String(output.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}\n", json); @@ -41,7 +56,7 @@ void writes_source_envelope() throws IOException { @Test void does_not_serialize_null_fields() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); - OutputStreamWriter writer = new OutputStreamWriter(output); + OutputStreamWriter writer = new OutputStreamWriter(output, StandardCharsets.UTF_8); Jackson.OBJECT_MAPPER.writeValue(writer, new Envelope( null, null, @@ -68,7 +83,7 @@ void does_not_serialize_null_fields() throws IOException { @Test void ignores_missing_fields() { InputStream input = new ByteArrayInputStream("{\"unused\": 99}\n".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input); + Iterable incomingMessages = makeMessageIterable(input, Envelope.class); Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); @@ -97,7 +112,7 @@ void ignores_missing_fields() { @Test void ignores_empty_lines() { InputStream input = new ByteArrayInputStream("{}\n{}\n\n{}\n".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input); + Iterable incomingMessages = makeMessageIterable(input, Envelope.class); Iterator iterator = incomingMessages.iterator(); for (int i = 0; i < 3; i++) { assertTrue(iterator.hasNext()); @@ -128,7 +143,7 @@ void ignores_empty_lines() { @Test void handles_enums() { InputStream input = new ByteArrayInputStream("{\"attachment\":{\"contentEncoding\":\"BASE64\", \"body\":\"the-body\", \"mediaType\":\"text/plain\"}}\n".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input); + Iterable incomingMessages = makeMessageIterable(input, Envelope.class); Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); @@ -136,10 +151,22 @@ void handles_enums() { assertFalse(iterator.hasNext()); } + @Test + void handles_timestamp() { + InputStream input = new ByteArrayInputStream("{\"timestamp\":{\"nanos\":0,\"seconds\":0}}\n".getBytes(UTF_8)); + Iterable incomingMessages = makeMessageIterable(input, TestRunStarted.class); + Iterator iterator = incomingMessages.iterator(); + assertTrue(iterator.hasNext()); + TestRunStarted testRunStarted = iterator.next(); + TestRunStarted expected = new TestRunStarted(new Timestamp(0L, 0L)); + assertEquals(expected, testRunStarted); + assertFalse(iterator.hasNext()); + } + @Test void includes_offending_line_in_error_message() { InputStream input = new ByteArrayInputStream("BLA BLA".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input); + Iterable incomingMessages = makeMessageIterable(input, Envelope.class); Iterator iterator = incomingMessages.iterator(); RuntimeException exception = assertThrows(RuntimeException.class, () -> assertTrue(iterator.hasNext())); diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 8cea195cd0..a15df6eecd 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,5 +1,5 @@ <%- @schemas.each do |key, schema| -%> - public static class <%= class_name(key) %> { + public static final class <%= class_name(key) %> { <%- schema['properties'].each do |property_name, property| -%> private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; <%- end -%> @@ -24,6 +24,7 @@ <%- end -%> <%- end -%> + @JsonCreator public <%= class_name(key) %>( <%- schema['properties'].each_with_index do |(property_name, property), index| -%> <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> From 9c342d387af2675e80eb8acbb1a259714110a8f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Tue, 18 Jan 2022 13:45:17 +0000 Subject: [PATCH 39/63] Remove Gherkin Main file from jar --- gherkin/CHANGELOG.md | 2 + gherkin/java/bin/gherkin | 2 +- gherkin/java/pom.xml | 42 +++++++++++++------ .../java/io/cucumber/gherkin/Jackson.java | 29 +++++++++++++ .../java/io/cucumber/gherkin/Main.java | 17 ++++++-- 5 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 gherkin/java/src/test/java/io/cucumber/gherkin/Jackson.java rename gherkin/java/src/{main => test}/java/io/cucumber/gherkin/Main.java (74%) diff --git a/gherkin/CHANGELOG.md b/gherkin/CHANGELOG.md index a185635aa0..e0a82ebdfd 100644 --- a/gherkin/CHANGELOG.md +++ b/gherkin/CHANGELOG.md @@ -19,6 +19,8 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt ### Removed +- [Java] the `io.cucumber.gherkin.Main` class is no longer part of the jar. + ### Fixed ## [22.0.0] - 2021-09-23 diff --git a/gherkin/java/bin/gherkin b/gherkin/java/bin/gherkin index 7a79a7e7cb..534d024dd2 100755 --- a/gherkin/java/bin/gherkin +++ b/gherkin/java/bin/gherkin @@ -12,5 +12,5 @@ if [ ! -f "${DIR}/classpath.txt" ] || [ "${DIR}/../pom.xml" -nt "${DIR}/classpat fi java \ - -classpath "$(cat "${DIR}/classpath.txt"):${DIR}/../target/classes" \ + -classpath "$(cat "${DIR}/classpath.txt"):${DIR}/../target/test-classes:${DIR}/../target/classes" \ io.cucumber.gherkin.Main $* diff --git a/gherkin/java/pom.xml b/gherkin/java/pom.xml index f848c21907..d1e2b70308 100644 --- a/gherkin/java/pom.xml +++ b/gherkin/java/pom.xml @@ -25,6 +25,18 @@ HEAD + + + + com.fasterxml.jackson + jackson-bom + 2.13.1 + pom + import + + + + io.cucumber @@ -38,6 +50,24 @@ 0.9.5 + + com.fasterxml.jackson.core + jackson-databind + test + + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + test + + + + com.fasterxml.jackson.module + jackson-module-parameter-names + test + + junit junit @@ -48,18 +78,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - - io.cucumber.gherkin.Main - - - - - org.apache.maven.plugins maven-shade-plugin diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/Jackson.java b/gherkin/java/src/test/java/io/cucumber/gherkin/Jackson.java new file mode 100644 index 0000000000..e963216ffb --- /dev/null +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/Jackson.java @@ -0,0 +1,29 @@ +package io.cucumber.gherkin; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.cfg.ConstructorDetector; +import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; +import com.fasterxml.jackson.module.paramnames.ParameterNamesModule; + +import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; +import static com.fasterxml.jackson.databind.DeserializationFeature.READ_ENUMS_USING_TO_STRING; +import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING; + +final class Jackson { + public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() + .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) + .registerModule(new Jdk8Module()) + .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) + .setConstructorDetector(ConstructorDetector.USE_PROPERTIES_BASED) + .enable(WRITE_ENUMS_USING_TO_STRING) + .enable(READ_ENUMS_USING_TO_STRING) + .disable(FAIL_ON_UNKNOWN_PROPERTIES) + .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); + + private Jackson() { + } +} + diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java similarity index 74% rename from gherkin/java/src/main/java/io/cucumber/gherkin/Main.java rename to gherkin/java/src/test/java/io/cucumber/gherkin/Main.java index d7f4ece34f..560f5efe88 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java @@ -5,14 +5,23 @@ import io.cucumber.messages.MessageWriter; import java.io.IOException; +import java.io.Writer; import java.util.ArrayList; import java.util.List; +import java.util.function.BiConsumer; import java.util.stream.Stream; import static io.cucumber.messages.Messages.Envelope; import static java.util.Arrays.asList; public class Main { + private static final BiConsumer SERIALIZER = (writer, envelope) -> { + try { + Jackson.OBJECT_MAPPER.writeValue(writer, envelope); + } catch (IOException e) { + throw new RuntimeException(e); + } + }; public static void main(String[] argv) { List args = new ArrayList<>(asList(argv)); @@ -48,13 +57,13 @@ public static void main(String[] argv) { idGenerator = new IdGenerator.UUID(); } - MessageWriter messageWriter = makeMessageWriter(); + MessageWriter messageWriter = makeMessageWriter(); Stream messages = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator); printMessages(messageWriter, messages); } - private static void printMessages(MessageWriter messageWriter, Stream messages) { + private static void printMessages(MessageWriter messageWriter, Stream messages) { messages.forEach(envelope -> { try { messageWriter.write(envelope); @@ -64,7 +73,7 @@ private static void printMessages(MessageWriter messageWriter, Stream }); } - private static MessageWriter makeMessageWriter() { - return new MessageToNdjsonWriter(System.out); + private static MessageWriter makeMessageWriter() { + return new MessageToNdjsonWriter<>(System.out, SERIALIZER); } } From 027c103e1f973a641503e86fc8d40ac67bdd23a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aslak=20Helles=C3=B8y?= Date: Tue, 18 Jan 2022 22:06:35 +0000 Subject: [PATCH 40/63] Rename test --- .../test/java/io/cucumber/messages/NdjsonSerializationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index 1590c4c00f..97f607100b 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -152,7 +152,7 @@ void handles_enums() { } @Test - void handles_timestamp() { + void handles_single_argument_constructors() { InputStream input = new ByteArrayInputStream("{\"timestamp\":{\"nanos\":0,\"seconds\":0}}\n".getBytes(UTF_8)); Iterable incomingMessages = makeMessageIterable(input, TestRunStarted.class); Iterator iterator = incomingMessages.iterator(); From 876eb2c90e8a32d17a1bad84594bf2716800b557 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sat, 22 Jan 2022 23:55:52 +0100 Subject: [PATCH 41/63] Make it work with jackson - use property based constructors - ensure there is only one property based constructor - clean up unused warnings - use imports to make code not look generated --- .../java/io/cucumber/gherkin/Gherkin.java | 8 +- .../MessagesToHtmlWriterTest.java | 6 +- messages/java/Makefile | 8 +- messages/java/pom.xml | 6 - .../java/io/cucumber/messages/Messages.java | 974 +++++++++--------- .../java/io/cucumber/messages/Jackson.java | 20 +- .../io/cucumber/messages/JacksonTest.java | 10 + .../scripts/templates/java.java.erb | 23 +- 8 files changed, 510 insertions(+), 545 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java index d4d287d8de..5753985fad 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java @@ -52,7 +52,7 @@ public static Stream fromSources(List envelopes, boolean inc } public static Envelope makeSourceEnvelope(String data, String uri) { - return new Envelope(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + return Envelope.of(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); } public Stream messages() { @@ -115,7 +115,7 @@ private List parseSource(boolean includeGherkinDocument, boolean inclu if (includeGherkinDocument) { gherkinDocument = parser.parse(data, uri); - messages.add(new Envelope(gherkinDocument)); + messages.add(Envelope.of(gherkinDocument)); } if (includePickles) { if (gherkinDocument == null) { @@ -124,7 +124,7 @@ private List parseSource(boolean includeGherkinDocument, boolean inclu PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); List pickles = pickleCompiler.compile(gherkinDocument, uri); for (Pickle pickle : pickles) { - messages.add(new Envelope(pickle)); + messages.add(Envelope.of(pickle)); } } } catch (ParserException.CompositeParserException e) { @@ -154,6 +154,6 @@ private void addParseError(List messages, ParserException e, String ur ), e.getMessage() ); - messages.add(new Envelope(parseError)); + messages.add(Envelope.of(parseError)); } } diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 2dd67d1971..27cdd3d2d1 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -34,7 +34,7 @@ class MessagesToHtmlWriterTest { @Test void it_writes_one_message_to_html() throws IOException { Instant timestamp = Instant.ofEpochSecond(10); - Envelope envelope = new Envelope(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); + Envelope envelope = Envelope.of(new TestRunStarted(TimeConversion.javaInstantToTimestamp(timestamp))); String html = renderAsHtml(envelope); assertThat(html, containsString("" + "window.CUCUMBER_MESSAGES = [{\"testRunStarted\":{\"timestamp\":{\"seconds\":10,\"nanos\":0}}}];")); @@ -88,9 +88,9 @@ public void close() throws IOException { @Test void it_writes_two_messages_separated_by_a_comma() throws IOException { - Envelope testRunStarted = new Envelope(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); + Envelope testRunStarted = Envelope.of(new TestRunStarted(TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(10)))); - Envelope envelope = new Envelope(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); + Envelope envelope = Envelope.of(new TestRunFinished(null, true, TimeConversion.javaInstantToTimestamp(Instant.ofEpochSecond(15)))); String html = renderAsHtml(testRunStarted, envelope); diff --git a/messages/java/Makefile b/messages/java/Makefile index fe351874b4..05a3ae5fd2 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -7,8 +7,14 @@ JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/java.java.erb ../jsonschema/scripts/templates/java.enum.java.erb echo "package io.cucumber.messages;" > $@ echo >> $@ - echo "import com.fasterxml.jackson.annotation.JsonCreator;" >> $@ + echo "import java.util.ArrayList;" >> $@ + echo "import java.util.Objects;" >> $@ + echo "import java.util.Optional;" >> $@ echo >> $@ + echo "import static java.util.Collections.unmodifiableList;" >> $@ + echo "import static java.util.Objects.requireNonNull;" >> $@ + echo >> $@ + echo "@SuppressWarnings(\"unused\")" >> $@ echo "public final class Messages {" >> $@ echo >> $@ echo " private Messages() {}" >> $@ diff --git a/messages/java/pom.xml b/messages/java/pom.xml index e4eec6608c..d302a46ee3 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -44,12 +44,6 @@ - - com.fasterxml.jackson.core - jackson-annotations - compile - - com.fasterxml.jackson.core jackson-databind diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index ea439b7c66..e5c1f0cf34 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -1,7 +1,13 @@ package io.cucumber.messages; -import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +@SuppressWarnings("unused") public final class Messages { private Messages() {} @@ -16,7 +22,6 @@ public static final class Attachment { private final String testStepId; private final String url; - @JsonCreator public Attachment( String body, AttachmentContentEncoding contentEncoding, @@ -27,10 +32,10 @@ public Attachment( String testStepId, String url ) { - this.body = java.util.Objects.requireNonNull(body, "Attachment.body cannot be null"); - this.contentEncoding = java.util.Objects.requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); + this.body = requireNonNull(body, "Attachment.body cannot be null"); + this.contentEncoding = requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); this.fileName = fileName; - this.mediaType = java.util.Objects.requireNonNull(mediaType, "Attachment.mediaType cannot be null"); + this.mediaType = requireNonNull(mediaType, "Attachment.mediaType cannot be null"); this.source = source; this.testCaseStartedId = testCaseStartedId; this.testStepId = testStepId; @@ -45,28 +50,28 @@ public AttachmentContentEncoding getContentEncoding() { return contentEncoding; } - public java.util.Optional getFileName() { - return java.util.Optional.ofNullable(fileName); + public Optional getFileName() { + return Optional.ofNullable(fileName); } public String getMediaType() { return mediaType; } - public java.util.Optional getSource() { - return java.util.Optional.ofNullable(source); + public Optional getSource() { + return Optional.ofNullable(source); } - public java.util.Optional getTestCaseStartedId() { - return java.util.Optional.ofNullable(testCaseStartedId); + public Optional getTestCaseStartedId() { + return Optional.ofNullable(testCaseStartedId); } - public java.util.Optional getTestStepId() { - return java.util.Optional.ofNullable(testStepId); + public Optional getTestStepId() { + return Optional.ofNullable(testStepId); } - public java.util.Optional getUrl() { - return java.util.Optional.ofNullable(url); + public Optional getUrl() { + return Optional.ofNullable(url); } @Override @@ -77,17 +82,17 @@ public boolean equals(Object o) { return body.equals(that.body) && contentEncoding.equals(that.contentEncoding) && - java.util.Objects.equals(fileName, that.fileName) && + Objects.equals(fileName, that.fileName) && mediaType.equals(that.mediaType) && - java.util.Objects.equals(source, that.source) && - java.util.Objects.equals(testCaseStartedId, that.testCaseStartedId) && - java.util.Objects.equals(testStepId, that.testStepId) && - java.util.Objects.equals(url, that.url); + Objects.equals(source, that.source) && + Objects.equals(testCaseStartedId, that.testCaseStartedId) && + Objects.equals(testStepId, that.testStepId) && + Objects.equals(url, that.url); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( body, contentEncoding, fileName, @@ -118,13 +123,12 @@ public static final class Duration { private final Long seconds; private final Long nanos; - @JsonCreator public Duration( Long seconds, Long nanos ) { - this.seconds = java.util.Objects.requireNonNull(seconds, "Duration.seconds cannot be null"); - this.nanos = java.util.Objects.requireNonNull(nanos, "Duration.nanos cannot be null"); + this.seconds = requireNonNull(seconds, "Duration.seconds cannot be null"); + this.nanos = requireNonNull(nanos, "Duration.nanos cannot be null"); } public Long getSeconds() { @@ -147,7 +151,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( seconds, nanos ); @@ -181,9 +185,9 @@ public static final class Envelope { private final TestStepStarted testStepStarted; private final UndefinedParameterType undefinedParameterType; - public Envelope(Attachment attachment) { - this( - java.util.Objects.requireNonNull(attachment, "Envelope.attachment cannot be null"), + public static Envelope of(Attachment attachment) { + return new Envelope( + requireNonNull(attachment, "Envelope.attachment cannot be null"), null, null, null, @@ -203,10 +207,10 @@ public Envelope(Attachment attachment) { ); } - public Envelope(GherkinDocument gherkinDocument) { - this( + public static Envelope of(GherkinDocument gherkinDocument) { + return new Envelope( null, - java.util.Objects.requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"), + requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"), null, null, null, @@ -225,11 +229,11 @@ public Envelope(GherkinDocument gherkinDocument) { ); } - public Envelope(Hook hook) { - this( + public static Envelope of(Hook hook) { + return new Envelope( null, null, - java.util.Objects.requireNonNull(hook, "Envelope.hook cannot be null"), + requireNonNull(hook, "Envelope.hook cannot be null"), null, null, null, @@ -247,12 +251,12 @@ public Envelope(Hook hook) { ); } - public Envelope(Meta meta) { - this( + public static Envelope of(Meta meta) { + return new Envelope( null, null, null, - java.util.Objects.requireNonNull(meta, "Envelope.meta cannot be null"), + requireNonNull(meta, "Envelope.meta cannot be null"), null, null, null, @@ -269,13 +273,13 @@ public Envelope(Meta meta) { ); } - public Envelope(ParameterType parameterType) { - this( + public static Envelope of(ParameterType parameterType) { + return new Envelope( null, null, null, null, - java.util.Objects.requireNonNull(parameterType, "Envelope.parameterType cannot be null"), + requireNonNull(parameterType, "Envelope.parameterType cannot be null"), null, null, null, @@ -291,14 +295,14 @@ public Envelope(ParameterType parameterType) { ); } - public Envelope(ParseError parseError) { - this( + public static Envelope of(ParseError parseError) { + return new Envelope( null, null, null, null, null, - java.util.Objects.requireNonNull(parseError, "Envelope.parseError cannot be null"), + requireNonNull(parseError, "Envelope.parseError cannot be null"), null, null, null, @@ -313,15 +317,15 @@ public Envelope(ParseError parseError) { ); } - public Envelope(Pickle pickle) { - this( + public static Envelope of(Pickle pickle) { + return new Envelope( null, null, null, null, null, null, - java.util.Objects.requireNonNull(pickle, "Envelope.pickle cannot be null"), + requireNonNull(pickle, "Envelope.pickle cannot be null"), null, null, null, @@ -335,8 +339,8 @@ public Envelope(Pickle pickle) { ); } - public Envelope(Source source) { - this( + public static Envelope of(Source source) { + return new Envelope( null, null, null, @@ -344,7 +348,7 @@ public Envelope(Source source) { null, null, null, - java.util.Objects.requireNonNull(source, "Envelope.source cannot be null"), + requireNonNull(source, "Envelope.source cannot be null"), null, null, null, @@ -357,8 +361,8 @@ public Envelope(Source source) { ); } - public Envelope(StepDefinition stepDefinition) { - this( + public static Envelope of(StepDefinition stepDefinition) { + return new Envelope( null, null, null, @@ -367,7 +371,7 @@ public Envelope(StepDefinition stepDefinition) { null, null, null, - java.util.Objects.requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"), + requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"), null, null, null, @@ -379,8 +383,8 @@ public Envelope(StepDefinition stepDefinition) { ); } - public Envelope(TestCase testCase) { - this( + public static Envelope of(TestCase testCase) { + return new Envelope( null, null, null, @@ -390,7 +394,7 @@ public Envelope(TestCase testCase) { null, null, null, - java.util.Objects.requireNonNull(testCase, "Envelope.testCase cannot be null"), + requireNonNull(testCase, "Envelope.testCase cannot be null"), null, null, null, @@ -401,8 +405,8 @@ public Envelope(TestCase testCase) { ); } - public Envelope(TestCaseFinished testCaseFinished) { - this( + public static Envelope of(TestCaseFinished testCaseFinished) { + return new Envelope( null, null, null, @@ -413,7 +417,7 @@ public Envelope(TestCaseFinished testCaseFinished) { null, null, null, - java.util.Objects.requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"), + requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"), null, null, null, @@ -423,8 +427,8 @@ public Envelope(TestCaseFinished testCaseFinished) { ); } - public Envelope(TestCaseStarted testCaseStarted) { - this( + public static Envelope of(TestCaseStarted testCaseStarted) { + return new Envelope( null, null, null, @@ -436,7 +440,7 @@ public Envelope(TestCaseStarted testCaseStarted) { null, null, null, - java.util.Objects.requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"), + requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"), null, null, null, @@ -445,8 +449,8 @@ public Envelope(TestCaseStarted testCaseStarted) { ); } - public Envelope(TestRunFinished testRunFinished) { - this( + public static Envelope of(TestRunFinished testRunFinished) { + return new Envelope( null, null, null, @@ -459,7 +463,7 @@ public Envelope(TestRunFinished testRunFinished) { null, null, null, - java.util.Objects.requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"), + requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"), null, null, null, @@ -467,8 +471,8 @@ public Envelope(TestRunFinished testRunFinished) { ); } - public Envelope(TestRunStarted testRunStarted) { - this( + public static Envelope of(TestRunStarted testRunStarted) { + return new Envelope( null, null, null, @@ -482,15 +486,15 @@ public Envelope(TestRunStarted testRunStarted) { null, null, null, - java.util.Objects.requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"), + requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"), null, null, null ); } - public Envelope(TestStepFinished testStepFinished) { - this( + public static Envelope of(TestStepFinished testStepFinished) { + return new Envelope( null, null, null, @@ -505,14 +509,14 @@ public Envelope(TestStepFinished testStepFinished) { null, null, null, - java.util.Objects.requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"), + requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"), null, null ); } - public Envelope(TestStepStarted testStepStarted) { - this( + public static Envelope of(TestStepStarted testStepStarted) { + return new Envelope( null, null, null, @@ -528,13 +532,13 @@ public Envelope(TestStepStarted testStepStarted) { null, null, null, - java.util.Objects.requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"), + requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"), null ); } - public Envelope(UndefinedParameterType undefinedParameterType) { - this( + public static Envelope of(UndefinedParameterType undefinedParameterType) { + return new Envelope( null, null, null, @@ -551,11 +555,10 @@ public Envelope(UndefinedParameterType undefinedParameterType) { null, null, null, - java.util.Objects.requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null") + requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null") ); } - @JsonCreator public Envelope( Attachment attachment, GherkinDocument gherkinDocument, @@ -594,72 +597,72 @@ public Envelope( this.undefinedParameterType = undefinedParameterType; } - public java.util.Optional getAttachment() { - return java.util.Optional.ofNullable(attachment); + public Optional getAttachment() { + return Optional.ofNullable(attachment); } - public java.util.Optional getGherkinDocument() { - return java.util.Optional.ofNullable(gherkinDocument); + public Optional getGherkinDocument() { + return Optional.ofNullable(gherkinDocument); } - public java.util.Optional getHook() { - return java.util.Optional.ofNullable(hook); + public Optional getHook() { + return Optional.ofNullable(hook); } - public java.util.Optional getMeta() { - return java.util.Optional.ofNullable(meta); + public Optional getMeta() { + return Optional.ofNullable(meta); } - public java.util.Optional getParameterType() { - return java.util.Optional.ofNullable(parameterType); + public Optional getParameterType() { + return Optional.ofNullable(parameterType); } - public java.util.Optional getParseError() { - return java.util.Optional.ofNullable(parseError); + public Optional getParseError() { + return Optional.ofNullable(parseError); } - public java.util.Optional getPickle() { - return java.util.Optional.ofNullable(pickle); + public Optional getPickle() { + return Optional.ofNullable(pickle); } - public java.util.Optional getSource() { - return java.util.Optional.ofNullable(source); + public Optional getSource() { + return Optional.ofNullable(source); } - public java.util.Optional getStepDefinition() { - return java.util.Optional.ofNullable(stepDefinition); + public Optional getStepDefinition() { + return Optional.ofNullable(stepDefinition); } - public java.util.Optional getTestCase() { - return java.util.Optional.ofNullable(testCase); + public Optional getTestCase() { + return Optional.ofNullable(testCase); } - public java.util.Optional getTestCaseFinished() { - return java.util.Optional.ofNullable(testCaseFinished); + public Optional getTestCaseFinished() { + return Optional.ofNullable(testCaseFinished); } - public java.util.Optional getTestCaseStarted() { - return java.util.Optional.ofNullable(testCaseStarted); + public Optional getTestCaseStarted() { + return Optional.ofNullable(testCaseStarted); } - public java.util.Optional getTestRunFinished() { - return java.util.Optional.ofNullable(testRunFinished); + public Optional getTestRunFinished() { + return Optional.ofNullable(testRunFinished); } - public java.util.Optional getTestRunStarted() { - return java.util.Optional.ofNullable(testRunStarted); + public Optional getTestRunStarted() { + return Optional.ofNullable(testRunStarted); } - public java.util.Optional getTestStepFinished() { - return java.util.Optional.ofNullable(testStepFinished); + public Optional getTestStepFinished() { + return Optional.ofNullable(testStepFinished); } - public java.util.Optional getTestStepStarted() { - return java.util.Optional.ofNullable(testStepStarted); + public Optional getTestStepStarted() { + return Optional.ofNullable(testStepStarted); } - public java.util.Optional getUndefinedParameterType() { - return java.util.Optional.ofNullable(undefinedParameterType); + public Optional getUndefinedParameterType() { + return Optional.ofNullable(undefinedParameterType); } @Override @@ -668,28 +671,28 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; Envelope that = (Envelope) o; return - java.util.Objects.equals(attachment, that.attachment) && - java.util.Objects.equals(gherkinDocument, that.gherkinDocument) && - java.util.Objects.equals(hook, that.hook) && - java.util.Objects.equals(meta, that.meta) && - java.util.Objects.equals(parameterType, that.parameterType) && - java.util.Objects.equals(parseError, that.parseError) && - java.util.Objects.equals(pickle, that.pickle) && - java.util.Objects.equals(source, that.source) && - java.util.Objects.equals(stepDefinition, that.stepDefinition) && - java.util.Objects.equals(testCase, that.testCase) && - java.util.Objects.equals(testCaseFinished, that.testCaseFinished) && - java.util.Objects.equals(testCaseStarted, that.testCaseStarted) && - java.util.Objects.equals(testRunFinished, that.testRunFinished) && - java.util.Objects.equals(testRunStarted, that.testRunStarted) && - java.util.Objects.equals(testStepFinished, that.testStepFinished) && - java.util.Objects.equals(testStepStarted, that.testStepStarted) && - java.util.Objects.equals(undefinedParameterType, that.undefinedParameterType); + Objects.equals(attachment, that.attachment) && + Objects.equals(gherkinDocument, that.gherkinDocument) && + Objects.equals(hook, that.hook) && + Objects.equals(meta, that.meta) && + Objects.equals(parameterType, that.parameterType) && + Objects.equals(parseError, that.parseError) && + Objects.equals(pickle, that.pickle) && + Objects.equals(source, that.source) && + Objects.equals(stepDefinition, that.stepDefinition) && + Objects.equals(testCase, that.testCase) && + Objects.equals(testCaseFinished, that.testCaseFinished) && + Objects.equals(testCaseStarted, that.testCaseStarted) && + Objects.equals(testRunFinished, that.testRunFinished) && + Objects.equals(testRunStarted, that.testRunStarted) && + Objects.equals(testStepFinished, that.testStepFinished) && + Objects.equals(testStepStarted, that.testStepStarted) && + Objects.equals(undefinedParameterType, that.undefinedParameterType); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( attachment, gherkinDocument, hook, @@ -739,7 +742,6 @@ public static final class GherkinDocument { private final Feature feature; private final java.util.List comments; - @JsonCreator public GherkinDocument( String uri, Feature feature, @@ -747,15 +749,15 @@ public GherkinDocument( ) { this.uri = uri; this.feature = feature; - this.comments = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(comments, "GherkinDocument.comments cannot be null"))); + this.comments = unmodifiableList(new ArrayList<>(requireNonNull(comments, "GherkinDocument.comments cannot be null"))); } - public java.util.Optional getUri() { - return java.util.Optional.ofNullable(uri); + public Optional getUri() { + return Optional.ofNullable(uri); } - public java.util.Optional getFeature() { - return java.util.Optional.ofNullable(feature); + public Optional getFeature() { + return Optional.ofNullable(feature); } public java.util.List getComments() { @@ -768,14 +770,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; GherkinDocument that = (GherkinDocument) o; return - java.util.Objects.equals(uri, that.uri) && - java.util.Objects.equals(feature, that.feature) && + Objects.equals(uri, that.uri) && + Objects.equals(feature, that.feature) && comments.equals(that.comments); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( uri, feature, comments @@ -800,7 +802,6 @@ public static final class Background { private final java.util.List steps; private final String id; - @JsonCreator public Background( Location location, String keyword, @@ -809,12 +810,12 @@ public Background( java.util.List steps, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Background.location cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Background.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Background.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Background.description cannot be null"); - this.steps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(steps, "Background.steps cannot be null"))); - this.id = java.util.Objects.requireNonNull(id, "Background.id cannot be null"); + this.location = requireNonNull(location, "Background.location cannot be null"); + this.keyword = requireNonNull(keyword, "Background.keyword cannot be null"); + this.name = requireNonNull(name, "Background.name cannot be null"); + this.description = requireNonNull(description, "Background.description cannot be null"); + this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Background.steps cannot be null"))); + this.id = requireNonNull(id, "Background.id cannot be null"); } public Location getLocation() { @@ -857,7 +858,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, keyword, name, @@ -884,13 +885,12 @@ public static final class Comment { private final Location location; private final String text; - @JsonCreator public Comment( Location location, String text ) { - this.location = java.util.Objects.requireNonNull(location, "Comment.location cannot be null"); - this.text = java.util.Objects.requireNonNull(text, "Comment.text cannot be null"); + this.location = requireNonNull(location, "Comment.location cannot be null"); + this.text = requireNonNull(text, "Comment.text cannot be null"); } public Location getLocation() { @@ -913,7 +913,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, text ); @@ -932,13 +932,12 @@ public static final class DataTable { private final Location location; private final java.util.List rows; - @JsonCreator public DataTable( Location location, java.util.List rows ) { - this.location = java.util.Objects.requireNonNull(location, "DataTable.location cannot be null"); - this.rows = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(rows, "DataTable.rows cannot be null"))); + this.location = requireNonNull(location, "DataTable.location cannot be null"); + this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "DataTable.rows cannot be null"))); } public Location getLocation() { @@ -961,7 +960,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, rows ); @@ -982,25 +981,24 @@ public static final class DocString { private final String content; private final String delimiter; - @JsonCreator public DocString( Location location, String mediaType, String content, String delimiter ) { - this.location = java.util.Objects.requireNonNull(location, "DocString.location cannot be null"); + this.location = requireNonNull(location, "DocString.location cannot be null"); this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content, "DocString.content cannot be null"); - this.delimiter = java.util.Objects.requireNonNull(delimiter, "DocString.delimiter cannot be null"); + this.content = requireNonNull(content, "DocString.content cannot be null"); + this.delimiter = requireNonNull(delimiter, "DocString.delimiter cannot be null"); } public Location getLocation() { return location; } - public java.util.Optional getMediaType() { - return java.util.Optional.ofNullable(mediaType); + public Optional getMediaType() { + return Optional.ofNullable(mediaType); } public String getContent() { @@ -1018,14 +1016,14 @@ public boolean equals(Object o) { DocString that = (DocString) o; return location.equals(that.location) && - java.util.Objects.equals(mediaType, that.mediaType) && + Objects.equals(mediaType, that.mediaType) && content.equals(that.content) && delimiter.equals(that.delimiter); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, mediaType, content, @@ -1054,7 +1052,6 @@ public static final class Examples { private final java.util.List tableBody; private final String id; - @JsonCreator public Examples( Location location, java.util.List tags, @@ -1065,14 +1062,14 @@ public Examples( java.util.List tableBody, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Examples.location cannot be null"); - this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Examples.tags cannot be null"))); - this.keyword = java.util.Objects.requireNonNull(keyword, "Examples.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Examples.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Examples.description cannot be null"); + this.location = requireNonNull(location, "Examples.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Examples.tags cannot be null"))); + this.keyword = requireNonNull(keyword, "Examples.keyword cannot be null"); + this.name = requireNonNull(name, "Examples.name cannot be null"); + this.description = requireNonNull(description, "Examples.description cannot be null"); this.tableHeader = tableHeader; - this.tableBody = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tableBody, "Examples.tableBody cannot be null"))); - this.id = java.util.Objects.requireNonNull(id, "Examples.id cannot be null"); + this.tableBody = unmodifiableList(new ArrayList<>(requireNonNull(tableBody, "Examples.tableBody cannot be null"))); + this.id = requireNonNull(id, "Examples.id cannot be null"); } public Location getLocation() { @@ -1095,8 +1092,8 @@ public String getDescription() { return description; } - public java.util.Optional getTableHeader() { - return java.util.Optional.ofNullable(tableHeader); + public Optional getTableHeader() { + return Optional.ofNullable(tableHeader); } public java.util.List getTableBody() { @@ -1118,14 +1115,14 @@ public boolean equals(Object o) { keyword.equals(that.keyword) && name.equals(that.name) && description.equals(that.description) && - java.util.Objects.equals(tableHeader, that.tableHeader) && + Objects.equals(tableHeader, that.tableHeader) && tableBody.equals(that.tableBody) && id.equals(that.id); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, tags, keyword, @@ -1161,7 +1158,6 @@ public static final class Feature { private final String description; private final java.util.List children; - @JsonCreator public Feature( Location location, java.util.List tags, @@ -1171,13 +1167,13 @@ public Feature( String description, java.util.List children ) { - this.location = java.util.Objects.requireNonNull(location, "Feature.location cannot be null"); - this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Feature.tags cannot be null"))); - this.language = java.util.Objects.requireNonNull(language, "Feature.language cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Feature.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Feature.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Feature.description cannot be null"); - this.children = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(children, "Feature.children cannot be null"))); + this.location = requireNonNull(location, "Feature.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Feature.tags cannot be null"))); + this.language = requireNonNull(language, "Feature.language cannot be null"); + this.keyword = requireNonNull(keyword, "Feature.keyword cannot be null"); + this.name = requireNonNull(name, "Feature.name cannot be null"); + this.description = requireNonNull(description, "Feature.description cannot be null"); + this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Feature.children cannot be null"))); } public Location getLocation() { @@ -1225,7 +1221,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, tags, language, @@ -1255,31 +1251,30 @@ public static final class FeatureChild { private final Background background; private final Scenario scenario; - public FeatureChild(Rule rule) { - this( - java.util.Objects.requireNonNull(rule, "FeatureChild.rule cannot be null"), + public static FeatureChild of(Rule rule) { + return new FeatureChild( + requireNonNull(rule, "FeatureChild.rule cannot be null"), null, null ); } - public FeatureChild(Background background) { - this( + public static FeatureChild of(Background background) { + return new FeatureChild( null, - java.util.Objects.requireNonNull(background, "FeatureChild.background cannot be null"), + requireNonNull(background, "FeatureChild.background cannot be null"), null ); } - public FeatureChild(Scenario scenario) { - this( + public static FeatureChild of(Scenario scenario) { + return new FeatureChild( null, null, - java.util.Objects.requireNonNull(scenario, "FeatureChild.scenario cannot be null") + requireNonNull(scenario, "FeatureChild.scenario cannot be null") ); } - @JsonCreator public FeatureChild( Rule rule, Background background, @@ -1290,16 +1285,16 @@ public FeatureChild( this.scenario = scenario; } - public java.util.Optional getRule() { - return java.util.Optional.ofNullable(rule); + public Optional getRule() { + return Optional.ofNullable(rule); } - public java.util.Optional getBackground() { - return java.util.Optional.ofNullable(background); + public Optional getBackground() { + return Optional.ofNullable(background); } - public java.util.Optional getScenario() { - return java.util.Optional.ofNullable(scenario); + public Optional getScenario() { + return Optional.ofNullable(scenario); } @Override @@ -1308,14 +1303,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; FeatureChild that = (FeatureChild) o; return - java.util.Objects.equals(rule, that.rule) && - java.util.Objects.equals(background, that.background) && - java.util.Objects.equals(scenario, that.scenario); + Objects.equals(rule, that.rule) && + Objects.equals(background, that.background) && + Objects.equals(scenario, that.scenario); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( rule, background, scenario @@ -1341,7 +1336,6 @@ public static final class Rule { private final java.util.List children; private final String id; - @JsonCreator public Rule( Location location, java.util.List tags, @@ -1351,13 +1345,13 @@ public Rule( java.util.List children, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Rule.location cannot be null"); - this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Rule.tags cannot be null"))); - this.keyword = java.util.Objects.requireNonNull(keyword, "Rule.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Rule.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Rule.description cannot be null"); - this.children = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(children, "Rule.children cannot be null"))); - this.id = java.util.Objects.requireNonNull(id, "Rule.id cannot be null"); + this.location = requireNonNull(location, "Rule.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Rule.tags cannot be null"))); + this.keyword = requireNonNull(keyword, "Rule.keyword cannot be null"); + this.name = requireNonNull(name, "Rule.name cannot be null"); + this.description = requireNonNull(description, "Rule.description cannot be null"); + this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Rule.children cannot be null"))); + this.id = requireNonNull(id, "Rule.id cannot be null"); } public Location getLocation() { @@ -1405,7 +1399,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, tags, keyword, @@ -1434,21 +1428,20 @@ public static final class RuleChild { private final Background background; private final Scenario scenario; - public RuleChild(Background background) { - this( - java.util.Objects.requireNonNull(background, "RuleChild.background cannot be null"), + public static RuleChild of(Background background) { + return new RuleChild( + requireNonNull(background, "RuleChild.background cannot be null"), null ); } - public RuleChild(Scenario scenario) { - this( + public static RuleChild of(Scenario scenario) { + return new RuleChild( null, - java.util.Objects.requireNonNull(scenario, "RuleChild.scenario cannot be null") + requireNonNull(scenario, "RuleChild.scenario cannot be null") ); } - @JsonCreator public RuleChild( Background background, Scenario scenario @@ -1457,12 +1450,12 @@ public RuleChild( this.scenario = scenario; } - public java.util.Optional getBackground() { - return java.util.Optional.ofNullable(background); + public Optional getBackground() { + return Optional.ofNullable(background); } - public java.util.Optional getScenario() { - return java.util.Optional.ofNullable(scenario); + public Optional getScenario() { + return Optional.ofNullable(scenario); } @Override @@ -1471,13 +1464,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; RuleChild that = (RuleChild) o; return - java.util.Objects.equals(background, that.background) && - java.util.Objects.equals(scenario, that.scenario); + Objects.equals(background, that.background) && + Objects.equals(scenario, that.scenario); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( background, scenario ); @@ -1502,7 +1495,6 @@ public static final class Scenario { private final java.util.List examples; private final String id; - @JsonCreator public Scenario( Location location, java.util.List tags, @@ -1513,14 +1505,14 @@ public Scenario( java.util.List examples, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Scenario.location cannot be null"); - this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Scenario.tags cannot be null"))); - this.keyword = java.util.Objects.requireNonNull(keyword, "Scenario.keyword cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Scenario.name cannot be null"); - this.description = java.util.Objects.requireNonNull(description, "Scenario.description cannot be null"); - this.steps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(steps, "Scenario.steps cannot be null"))); - this.examples = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(examples, "Scenario.examples cannot be null"))); - this.id = java.util.Objects.requireNonNull(id, "Scenario.id cannot be null"); + this.location = requireNonNull(location, "Scenario.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Scenario.tags cannot be null"))); + this.keyword = requireNonNull(keyword, "Scenario.keyword cannot be null"); + this.name = requireNonNull(name, "Scenario.name cannot be null"); + this.description = requireNonNull(description, "Scenario.description cannot be null"); + this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Scenario.steps cannot be null"))); + this.examples = unmodifiableList(new ArrayList<>(requireNonNull(examples, "Scenario.examples cannot be null"))); + this.id = requireNonNull(id, "Scenario.id cannot be null"); } public Location getLocation() { @@ -1573,7 +1565,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, tags, keyword, @@ -1608,7 +1600,6 @@ public static final class Step { private final DataTable dataTable; private final String id; - @JsonCreator public Step( Location location, String keyword, @@ -1617,12 +1608,12 @@ public Step( DataTable dataTable, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Step.location cannot be null"); - this.keyword = java.util.Objects.requireNonNull(keyword, "Step.keyword cannot be null"); - this.text = java.util.Objects.requireNonNull(text, "Step.text cannot be null"); + this.location = requireNonNull(location, "Step.location cannot be null"); + this.keyword = requireNonNull(keyword, "Step.keyword cannot be null"); + this.text = requireNonNull(text, "Step.text cannot be null"); this.docString = docString; this.dataTable = dataTable; - this.id = java.util.Objects.requireNonNull(id, "Step.id cannot be null"); + this.id = requireNonNull(id, "Step.id cannot be null"); } public Location getLocation() { @@ -1637,12 +1628,12 @@ public String getText() { return text; } - public java.util.Optional getDocString() { - return java.util.Optional.ofNullable(docString); + public Optional getDocString() { + return Optional.ofNullable(docString); } - public java.util.Optional getDataTable() { - return java.util.Optional.ofNullable(dataTable); + public Optional getDataTable() { + return Optional.ofNullable(dataTable); } public String getId() { @@ -1658,14 +1649,14 @@ public boolean equals(Object o) { location.equals(that.location) && keyword.equals(that.keyword) && text.equals(that.text) && - java.util.Objects.equals(docString, that.docString) && - java.util.Objects.equals(dataTable, that.dataTable) && + Objects.equals(docString, that.docString) && + Objects.equals(dataTable, that.dataTable) && id.equals(that.id); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, keyword, text, @@ -1692,13 +1683,12 @@ public static final class TableCell { private final Location location; private final String value; - @JsonCreator public TableCell( Location location, String value ) { - this.location = java.util.Objects.requireNonNull(location, "TableCell.location cannot be null"); - this.value = java.util.Objects.requireNonNull(value, "TableCell.value cannot be null"); + this.location = requireNonNull(location, "TableCell.location cannot be null"); + this.value = requireNonNull(value, "TableCell.value cannot be null"); } public Location getLocation() { @@ -1721,7 +1711,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, value ); @@ -1741,15 +1731,14 @@ public static final class TableRow { private final java.util.List cells; private final String id; - @JsonCreator public TableRow( Location location, java.util.List cells, String id ) { - this.location = java.util.Objects.requireNonNull(location, "TableRow.location cannot be null"); - this.cells = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(cells, "TableRow.cells cannot be null"))); - this.id = java.util.Objects.requireNonNull(id, "TableRow.id cannot be null"); + this.location = requireNonNull(location, "TableRow.location cannot be null"); + this.cells = unmodifiableList(new ArrayList<>(requireNonNull(cells, "TableRow.cells cannot be null"))); + this.id = requireNonNull(id, "TableRow.id cannot be null"); } public Location getLocation() { @@ -1777,7 +1766,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, cells, id @@ -1799,15 +1788,14 @@ public static final class Tag { private final String name; private final String id; - @JsonCreator public Tag( Location location, String name, String id ) { - this.location = java.util.Objects.requireNonNull(location, "Tag.location cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Tag.name cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "Tag.id cannot be null"); + this.location = requireNonNull(location, "Tag.location cannot be null"); + this.name = requireNonNull(name, "Tag.name cannot be null"); + this.id = requireNonNull(id, "Tag.id cannot be null"); } public Location getLocation() { @@ -1835,7 +1823,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( location, name, id @@ -1857,14 +1845,13 @@ public static final class Hook { private final SourceReference sourceReference; private final String tagExpression; - @JsonCreator public Hook( String id, SourceReference sourceReference, String tagExpression ) { - this.id = java.util.Objects.requireNonNull(id, "Hook.id cannot be null"); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); + this.id = requireNonNull(id, "Hook.id cannot be null"); + this.sourceReference = requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); this.tagExpression = tagExpression; } @@ -1876,8 +1863,8 @@ public SourceReference getSourceReference() { return sourceReference; } - public java.util.Optional getTagExpression() { - return java.util.Optional.ofNullable(tagExpression); + public Optional getTagExpression() { + return Optional.ofNullable(tagExpression); } @Override @@ -1888,12 +1875,12 @@ public boolean equals(Object o) { return id.equals(that.id) && sourceReference.equals(that.sourceReference) && - java.util.Objects.equals(tagExpression, that.tagExpression); + Objects.equals(tagExpression, that.tagExpression); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( id, sourceReference, tagExpression @@ -1914,12 +1901,11 @@ public static final class Location { private final Long line; private final Long column; - @JsonCreator public Location( Long line, Long column ) { - this.line = java.util.Objects.requireNonNull(line, "Location.line cannot be null"); + this.line = requireNonNull(line, "Location.line cannot be null"); this.column = column; } @@ -1927,8 +1913,8 @@ public Long getLine() { return line; } - public java.util.Optional getColumn() { - return java.util.Optional.ofNullable(column); + public Optional getColumn() { + return Optional.ofNullable(column); } @Override @@ -1938,12 +1924,12 @@ public boolean equals(Object o) { Location that = (Location) o; return line.equals(that.line) && - java.util.Objects.equals(column, that.column); + Objects.equals(column, that.column); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( line, column ); @@ -1966,7 +1952,6 @@ public static final class Meta { private final Product cpu; private final Ci ci; - @JsonCreator public Meta( String protocolVersion, Product implementation, @@ -1975,11 +1960,11 @@ public Meta( Product cpu, Ci ci ) { - this.protocolVersion = java.util.Objects.requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); - this.implementation = java.util.Objects.requireNonNull(implementation, "Meta.implementation cannot be null"); - this.runtime = java.util.Objects.requireNonNull(runtime, "Meta.runtime cannot be null"); - this.os = java.util.Objects.requireNonNull(os, "Meta.os cannot be null"); - this.cpu = java.util.Objects.requireNonNull(cpu, "Meta.cpu cannot be null"); + this.protocolVersion = requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); + this.implementation = requireNonNull(implementation, "Meta.implementation cannot be null"); + this.runtime = requireNonNull(runtime, "Meta.runtime cannot be null"); + this.os = requireNonNull(os, "Meta.os cannot be null"); + this.cpu = requireNonNull(cpu, "Meta.cpu cannot be null"); this.ci = ci; } @@ -2003,8 +1988,8 @@ public Product getCpu() { return cpu; } - public java.util.Optional getCi() { - return java.util.Optional.ofNullable(ci); + public Optional getCi() { + return Optional.ofNullable(ci); } @Override @@ -2018,12 +2003,12 @@ public boolean equals(Object o) { runtime.equals(that.runtime) && os.equals(that.os) && cpu.equals(that.cpu) && - java.util.Objects.equals(ci, that.ci); + Objects.equals(ci, that.ci); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( protocolVersion, implementation, runtime, @@ -2052,14 +2037,13 @@ public static final class Ci { private final String buildNumber; private final Git git; - @JsonCreator public Ci( String name, String url, String buildNumber, Git git ) { - this.name = java.util.Objects.requireNonNull(name, "Ci.name cannot be null"); + this.name = requireNonNull(name, "Ci.name cannot be null"); this.url = url; this.buildNumber = buildNumber; this.git = git; @@ -2069,16 +2053,16 @@ public String getName() { return name; } - public java.util.Optional getUrl() { - return java.util.Optional.ofNullable(url); + public Optional getUrl() { + return Optional.ofNullable(url); } - public java.util.Optional getBuildNumber() { - return java.util.Optional.ofNullable(buildNumber); + public Optional getBuildNumber() { + return Optional.ofNullable(buildNumber); } - public java.util.Optional getGit() { - return java.util.Optional.ofNullable(git); + public Optional getGit() { + return Optional.ofNullable(git); } @Override @@ -2088,14 +2072,14 @@ public boolean equals(Object o) { Ci that = (Ci) o; return name.equals(that.name) && - java.util.Objects.equals(url, that.url) && - java.util.Objects.equals(buildNumber, that.buildNumber) && - java.util.Objects.equals(git, that.git); + Objects.equals(url, that.url) && + Objects.equals(buildNumber, that.buildNumber) && + Objects.equals(git, that.git); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( name, url, buildNumber, @@ -2120,15 +2104,14 @@ public static final class Git { private final String branch; private final String tag; - @JsonCreator public Git( String remote, String revision, String branch, String tag ) { - this.remote = java.util.Objects.requireNonNull(remote, "Git.remote cannot be null"); - this.revision = java.util.Objects.requireNonNull(revision, "Git.revision cannot be null"); + this.remote = requireNonNull(remote, "Git.remote cannot be null"); + this.revision = requireNonNull(revision, "Git.revision cannot be null"); this.branch = branch; this.tag = tag; } @@ -2141,12 +2124,12 @@ public String getRevision() { return revision; } - public java.util.Optional getBranch() { - return java.util.Optional.ofNullable(branch); + public Optional getBranch() { + return Optional.ofNullable(branch); } - public java.util.Optional getTag() { - return java.util.Optional.ofNullable(tag); + public Optional getTag() { + return Optional.ofNullable(tag); } @Override @@ -2157,13 +2140,13 @@ public boolean equals(Object o) { return remote.equals(that.remote) && revision.equals(that.revision) && - java.util.Objects.equals(branch, that.branch) && - java.util.Objects.equals(tag, that.tag); + Objects.equals(branch, that.branch) && + Objects.equals(tag, that.tag); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( remote, revision, branch, @@ -2186,12 +2169,11 @@ public static final class Product { private final String name; private final String version; - @JsonCreator public Product( String name, String version ) { - this.name = java.util.Objects.requireNonNull(name, "Product.name cannot be null"); + this.name = requireNonNull(name, "Product.name cannot be null"); this.version = version; } @@ -2199,8 +2181,8 @@ public String getName() { return name; } - public java.util.Optional getVersion() { - return java.util.Optional.ofNullable(version); + public Optional getVersion() { + return Optional.ofNullable(version); } @Override @@ -2210,12 +2192,12 @@ public boolean equals(Object o) { Product that = (Product) o; return name.equals(that.name) && - java.util.Objects.equals(version, that.version); + Objects.equals(version, that.version); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( name, version ); @@ -2237,7 +2219,6 @@ public static final class ParameterType { private final Boolean useForSnippets; private final String id; - @JsonCreator public ParameterType( String name, java.util.List regularExpressions, @@ -2245,11 +2226,11 @@ public ParameterType( Boolean useForSnippets, String id ) { - this.name = java.util.Objects.requireNonNull(name, "ParameterType.name cannot be null"); - this.regularExpressions = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"))); - this.preferForRegularExpressionMatch = java.util.Objects.requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); - this.useForSnippets = java.util.Objects.requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "ParameterType.id cannot be null"); + this.name = requireNonNull(name, "ParameterType.name cannot be null"); + this.regularExpressions = unmodifiableList(new ArrayList<>(requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"))); + this.preferForRegularExpressionMatch = requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); + this.useForSnippets = requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); + this.id = requireNonNull(id, "ParameterType.id cannot be null"); } public String getName() { @@ -2287,7 +2268,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( name, regularExpressions, preferForRegularExpressionMatch, @@ -2312,13 +2293,12 @@ public static final class ParseError { private final SourceReference source; private final String message; - @JsonCreator public ParseError( SourceReference source, String message ) { - this.source = java.util.Objects.requireNonNull(source, "ParseError.source cannot be null"); - this.message = java.util.Objects.requireNonNull(message, "ParseError.message cannot be null"); + this.source = requireNonNull(source, "ParseError.source cannot be null"); + this.message = requireNonNull(message, "ParseError.message cannot be null"); } public SourceReference getSource() { @@ -2341,7 +2321,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( source, message ); @@ -2365,7 +2345,6 @@ public static final class Pickle { private final java.util.List tags; private final java.util.List astNodeIds; - @JsonCreator public Pickle( String id, String uri, @@ -2375,13 +2354,13 @@ public Pickle( java.util.List tags, java.util.List astNodeIds ) { - this.id = java.util.Objects.requireNonNull(id, "Pickle.id cannot be null"); - this.uri = java.util.Objects.requireNonNull(uri, "Pickle.uri cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "Pickle.name cannot be null"); - this.language = java.util.Objects.requireNonNull(language, "Pickle.language cannot be null"); - this.steps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(steps, "Pickle.steps cannot be null"))); - this.tags = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(tags, "Pickle.tags cannot be null"))); - this.astNodeIds = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"))); + this.id = requireNonNull(id, "Pickle.id cannot be null"); + this.uri = requireNonNull(uri, "Pickle.uri cannot be null"); + this.name = requireNonNull(name, "Pickle.name cannot be null"); + this.language = requireNonNull(language, "Pickle.language cannot be null"); + this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Pickle.steps cannot be null"))); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Pickle.tags cannot be null"))); + this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"))); } public String getId() { @@ -2429,7 +2408,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( id, uri, name, @@ -2458,17 +2437,16 @@ public static final class PickleDocString { private final String mediaType; private final String content; - @JsonCreator public PickleDocString( String mediaType, String content ) { this.mediaType = mediaType; - this.content = java.util.Objects.requireNonNull(content, "PickleDocString.content cannot be null"); + this.content = requireNonNull(content, "PickleDocString.content cannot be null"); } - public java.util.Optional getMediaType() { - return java.util.Optional.ofNullable(mediaType); + public Optional getMediaType() { + return Optional.ofNullable(mediaType); } public String getContent() { @@ -2481,13 +2459,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; PickleDocString that = (PickleDocString) o; return - java.util.Objects.equals(mediaType, that.mediaType) && + Objects.equals(mediaType, that.mediaType) && content.equals(that.content); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( mediaType, content ); @@ -2508,7 +2486,6 @@ public static final class PickleStep { private final String id; private final String text; - @JsonCreator public PickleStep( PickleStepArgument argument, java.util.List astNodeIds, @@ -2516,13 +2493,13 @@ public PickleStep( String text ) { this.argument = argument; - this.astNodeIds = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"))); - this.id = java.util.Objects.requireNonNull(id, "PickleStep.id cannot be null"); - this.text = java.util.Objects.requireNonNull(text, "PickleStep.text cannot be null"); + this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"))); + this.id = requireNonNull(id, "PickleStep.id cannot be null"); + this.text = requireNonNull(text, "PickleStep.text cannot be null"); } - public java.util.Optional getArgument() { - return java.util.Optional.ofNullable(argument); + public Optional getArgument() { + return Optional.ofNullable(argument); } public java.util.List getAstNodeIds() { @@ -2543,7 +2520,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; PickleStep that = (PickleStep) o; return - java.util.Objects.equals(argument, that.argument) && + Objects.equals(argument, that.argument) && astNodeIds.equals(that.astNodeIds) && id.equals(that.id) && text.equals(that.text); @@ -2551,7 +2528,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( argument, astNodeIds, id, @@ -2574,21 +2551,20 @@ public static final class PickleStepArgument { private final PickleDocString docString; private final PickleTable dataTable; - public PickleStepArgument(PickleDocString docString) { - this( - java.util.Objects.requireNonNull(docString, "PickleStepArgument.docString cannot be null"), + public static PickleStepArgument of(PickleDocString docString) { + return new PickleStepArgument( + requireNonNull(docString, "PickleStepArgument.docString cannot be null"), null ); } - public PickleStepArgument(PickleTable dataTable) { - this( + public static PickleStepArgument of(PickleTable dataTable) { + return new PickleStepArgument( null, - java.util.Objects.requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null") + requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null") ); } - @JsonCreator public PickleStepArgument( PickleDocString docString, PickleTable dataTable @@ -2597,12 +2573,12 @@ public PickleStepArgument( this.dataTable = dataTable; } - public java.util.Optional getDocString() { - return java.util.Optional.ofNullable(docString); + public Optional getDocString() { + return Optional.ofNullable(docString); } - public java.util.Optional getDataTable() { - return java.util.Optional.ofNullable(dataTable); + public Optional getDataTable() { + return Optional.ofNullable(dataTable); } @Override @@ -2611,13 +2587,13 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; PickleStepArgument that = (PickleStepArgument) o; return - java.util.Objects.equals(docString, that.docString) && - java.util.Objects.equals(dataTable, that.dataTable); + Objects.equals(docString, that.docString) && + Objects.equals(dataTable, that.dataTable); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( docString, dataTable ); @@ -2635,11 +2611,10 @@ public String toString() { public static final class PickleTable { private final java.util.List rows; - @JsonCreator public PickleTable( java.util.List rows ) { - this.rows = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(rows, "PickleTable.rows cannot be null"))); + this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "PickleTable.rows cannot be null"))); } public java.util.List getRows() { @@ -2657,7 +2632,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( rows ); } @@ -2673,11 +2648,10 @@ public String toString() { public static final class PickleTableCell { private final String value; - @JsonCreator public PickleTableCell( String value ) { - this.value = java.util.Objects.requireNonNull(value, "PickleTableCell.value cannot be null"); + this.value = requireNonNull(value, "PickleTableCell.value cannot be null"); } public String getValue() { @@ -2695,7 +2669,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( value ); } @@ -2711,11 +2685,10 @@ public String toString() { public static final class PickleTableRow { private final java.util.List cells; - @JsonCreator public PickleTableRow( java.util.List cells ) { - this.cells = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(cells, "PickleTableRow.cells cannot be null"))); + this.cells = unmodifiableList(new ArrayList<>(requireNonNull(cells, "PickleTableRow.cells cannot be null"))); } public java.util.List getCells() { @@ -2733,7 +2706,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( cells ); } @@ -2750,13 +2723,12 @@ public static final class PickleTag { private final String name; private final String astNodeId; - @JsonCreator public PickleTag( String name, String astNodeId ) { - this.name = java.util.Objects.requireNonNull(name, "PickleTag.name cannot be null"); - this.astNodeId = java.util.Objects.requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); + this.name = requireNonNull(name, "PickleTag.name cannot be null"); + this.astNodeId = requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); } public String getName() { @@ -2779,7 +2751,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( name, astNodeId ); @@ -2799,15 +2771,14 @@ public static final class Source { private final String data; private final SourceMediaType mediaType; - @JsonCreator public Source( String uri, String data, SourceMediaType mediaType ) { - this.uri = java.util.Objects.requireNonNull(uri, "Source.uri cannot be null"); - this.data = java.util.Objects.requireNonNull(data, "Source.data cannot be null"); - this.mediaType = java.util.Objects.requireNonNull(mediaType, "Source.mediaType cannot be null"); + this.uri = requireNonNull(uri, "Source.uri cannot be null"); + this.data = requireNonNull(data, "Source.data cannot be null"); + this.mediaType = requireNonNull(mediaType, "Source.mediaType cannot be null"); } public String getUri() { @@ -2835,7 +2806,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( uri, data, mediaType @@ -2858,43 +2829,42 @@ public static final class SourceReference { private final JavaStackTraceElement javaStackTraceElement; private final Location location; - public SourceReference(String uri) { - this( - java.util.Objects.requireNonNull(uri, "SourceReference.uri cannot be null"), + public static SourceReference of(String uri) { + return new SourceReference( + requireNonNull(uri, "SourceReference.uri cannot be null"), null, null, null ); } - public SourceReference(JavaMethod javaMethod) { - this( + public static SourceReference of(JavaMethod javaMethod) { + return new SourceReference( null, - java.util.Objects.requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"), + requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"), null, null ); } - public SourceReference(JavaStackTraceElement javaStackTraceElement) { - this( + public static SourceReference of(JavaStackTraceElement javaStackTraceElement) { + return new SourceReference( null, null, - java.util.Objects.requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"), + requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"), null ); } - public SourceReference(Location location) { - this( + public static SourceReference of(Location location) { + return new SourceReference( null, null, null, - java.util.Objects.requireNonNull(location, "SourceReference.location cannot be null") + requireNonNull(location, "SourceReference.location cannot be null") ); } - @JsonCreator public SourceReference( String uri, JavaMethod javaMethod, @@ -2907,20 +2877,20 @@ public SourceReference( this.location = location; } - public java.util.Optional getUri() { - return java.util.Optional.ofNullable(uri); + public Optional getUri() { + return Optional.ofNullable(uri); } - public java.util.Optional getJavaMethod() { - return java.util.Optional.ofNullable(javaMethod); + public Optional getJavaMethod() { + return Optional.ofNullable(javaMethod); } - public java.util.Optional getJavaStackTraceElement() { - return java.util.Optional.ofNullable(javaStackTraceElement); + public Optional getJavaStackTraceElement() { + return Optional.ofNullable(javaStackTraceElement); } - public java.util.Optional getLocation() { - return java.util.Optional.ofNullable(location); + public Optional getLocation() { + return Optional.ofNullable(location); } @Override @@ -2929,15 +2899,15 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; SourceReference that = (SourceReference) o; return - java.util.Objects.equals(uri, that.uri) && - java.util.Objects.equals(javaMethod, that.javaMethod) && - java.util.Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && - java.util.Objects.equals(location, that.location); + Objects.equals(uri, that.uri) && + Objects.equals(javaMethod, that.javaMethod) && + Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && + Objects.equals(location, that.location); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( uri, javaMethod, javaStackTraceElement, @@ -2961,15 +2931,14 @@ public static final class JavaMethod { private final String methodName; private final java.util.List methodParameterTypes; - @JsonCreator public JavaMethod( String className, String methodName, java.util.List methodParameterTypes ) { - this.className = java.util.Objects.requireNonNull(className, "JavaMethod.className cannot be null"); - this.methodName = java.util.Objects.requireNonNull(methodName, "JavaMethod.methodName cannot be null"); - this.methodParameterTypes = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"))); + this.className = requireNonNull(className, "JavaMethod.className cannot be null"); + this.methodName = requireNonNull(methodName, "JavaMethod.methodName cannot be null"); + this.methodParameterTypes = unmodifiableList(new ArrayList<>(requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"))); } public String getClassName() { @@ -2997,7 +2966,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( className, methodName, methodParameterTypes @@ -3019,15 +2988,14 @@ public static final class JavaStackTraceElement { private final String fileName; private final String methodName; - @JsonCreator public JavaStackTraceElement( String className, String fileName, String methodName ) { - this.className = java.util.Objects.requireNonNull(className, "JavaStackTraceElement.className cannot be null"); - this.fileName = java.util.Objects.requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); - this.methodName = java.util.Objects.requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); + this.className = requireNonNull(className, "JavaStackTraceElement.className cannot be null"); + this.fileName = requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); + this.methodName = requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); } public String getClassName() { @@ -3055,7 +3023,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( className, fileName, methodName @@ -3077,15 +3045,14 @@ public static final class StepDefinition { private final StepDefinitionPattern pattern; private final SourceReference sourceReference; - @JsonCreator public StepDefinition( String id, StepDefinitionPattern pattern, SourceReference sourceReference ) { - this.id = java.util.Objects.requireNonNull(id, "StepDefinition.id cannot be null"); - this.pattern = java.util.Objects.requireNonNull(pattern, "StepDefinition.pattern cannot be null"); - this.sourceReference = java.util.Objects.requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); + this.id = requireNonNull(id, "StepDefinition.id cannot be null"); + this.pattern = requireNonNull(pattern, "StepDefinition.pattern cannot be null"); + this.sourceReference = requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); } public String getId() { @@ -3113,7 +3080,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( id, pattern, sourceReference @@ -3134,13 +3101,12 @@ public static final class StepDefinitionPattern { private final String source; private final StepDefinitionPatternType type; - @JsonCreator public StepDefinitionPattern( String source, StepDefinitionPatternType type ) { - this.source = java.util.Objects.requireNonNull(source, "StepDefinitionPattern.source cannot be null"); - this.type = java.util.Objects.requireNonNull(type, "StepDefinitionPattern.type cannot be null"); + this.source = requireNonNull(source, "StepDefinitionPattern.source cannot be null"); + this.type = requireNonNull(type, "StepDefinitionPattern.type cannot be null"); } public String getSource() { @@ -3163,7 +3129,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( source, type ); @@ -3183,15 +3149,14 @@ public static final class TestCase { private final String pickleId; private final java.util.List testSteps; - @JsonCreator public TestCase( String id, String pickleId, java.util.List testSteps ) { - this.id = java.util.Objects.requireNonNull(id, "TestCase.id cannot be null"); - this.pickleId = java.util.Objects.requireNonNull(pickleId, "TestCase.pickleId cannot be null"); - this.testSteps = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); + this.id = requireNonNull(id, "TestCase.id cannot be null"); + this.pickleId = requireNonNull(pickleId, "TestCase.pickleId cannot be null"); + this.testSteps = unmodifiableList(new ArrayList<>(requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); } public String getId() { @@ -3219,7 +3184,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( id, pickleId, testSteps @@ -3241,13 +3206,12 @@ public static final class Group { private final Long start; private final String value; - @JsonCreator public Group( java.util.List children, Long start, String value ) { - this.children = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(children, "Group.children cannot be null"))); + this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Group.children cannot be null"))); this.start = start; this.value = value; } @@ -3256,12 +3220,12 @@ public java.util.List getChildren() { return children; } - public java.util.Optional getStart() { - return java.util.Optional.ofNullable(start); + public Optional getStart() { + return Optional.ofNullable(start); } - public java.util.Optional getValue() { - return java.util.Optional.ofNullable(value); + public Optional getValue() { + return Optional.ofNullable(value); } @Override @@ -3271,13 +3235,13 @@ public boolean equals(Object o) { Group that = (Group) o; return children.equals(that.children) && - java.util.Objects.equals(start, that.start) && - java.util.Objects.equals(value, that.value); + Objects.equals(start, that.start) && + Objects.equals(value, that.value); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( children, start, value @@ -3298,12 +3262,11 @@ public static final class StepMatchArgument { private final Group group; private final String parameterTypeName; - @JsonCreator public StepMatchArgument( Group group, String parameterTypeName ) { - this.group = java.util.Objects.requireNonNull(group, "StepMatchArgument.group cannot be null"); + this.group = requireNonNull(group, "StepMatchArgument.group cannot be null"); this.parameterTypeName = parameterTypeName; } @@ -3311,8 +3274,8 @@ public Group getGroup() { return group; } - public java.util.Optional getParameterTypeName() { - return java.util.Optional.ofNullable(parameterTypeName); + public Optional getParameterTypeName() { + return Optional.ofNullable(parameterTypeName); } @Override @@ -3322,12 +3285,12 @@ public boolean equals(Object o) { StepMatchArgument that = (StepMatchArgument) o; return group.equals(that.group) && - java.util.Objects.equals(parameterTypeName, that.parameterTypeName); + Objects.equals(parameterTypeName, that.parameterTypeName); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( group, parameterTypeName ); @@ -3345,11 +3308,10 @@ public String toString() { public static final class StepMatchArgumentsList { private final java.util.List stepMatchArguments; - @JsonCreator public StepMatchArgumentsList( java.util.List stepMatchArguments ) { - this.stepMatchArguments = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"))); + this.stepMatchArguments = unmodifiableList(new ArrayList<>(requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"))); } public java.util.List getStepMatchArguments() { @@ -3367,7 +3329,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( stepMatchArguments ); } @@ -3387,7 +3349,6 @@ public static final class TestStep { private final java.util.List stepDefinitionIds; private final java.util.List stepMatchArgumentsLists; - @JsonCreator public TestStep( String hookId, String id, @@ -3396,30 +3357,30 @@ public TestStep( java.util.List stepMatchArgumentsLists ) { this.hookId = hookId; - this.id = java.util.Objects.requireNonNull(id, "TestStep.id cannot be null"); + this.id = requireNonNull(id, "TestStep.id cannot be null"); this.pickleStepId = pickleStepId; - this.stepDefinitionIds = stepDefinitionIds == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepDefinitionIds)); - this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(stepMatchArgumentsLists)); + this.stepDefinitionIds = stepDefinitionIds == null ? null : unmodifiableList(new ArrayList<>(stepDefinitionIds)); + this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : unmodifiableList(new ArrayList<>(stepMatchArgumentsLists)); } - public java.util.Optional getHookId() { - return java.util.Optional.ofNullable(hookId); + public Optional getHookId() { + return Optional.ofNullable(hookId); } public String getId() { return id; } - public java.util.Optional getPickleStepId() { - return java.util.Optional.ofNullable(pickleStepId); + public Optional getPickleStepId() { + return Optional.ofNullable(pickleStepId); } - public java.util.Optional> getStepDefinitionIds() { - return java.util.Optional.ofNullable(stepDefinitionIds); + public Optional> getStepDefinitionIds() { + return Optional.ofNullable(stepDefinitionIds); } - public java.util.Optional> getStepMatchArgumentsLists() { - return java.util.Optional.ofNullable(stepMatchArgumentsLists); + public Optional> getStepMatchArgumentsLists() { + return Optional.ofNullable(stepMatchArgumentsLists); } @Override @@ -3428,16 +3389,16 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; TestStep that = (TestStep) o; return - java.util.Objects.equals(hookId, that.hookId) && + Objects.equals(hookId, that.hookId) && id.equals(that.id) && - java.util.Objects.equals(pickleStepId, that.pickleStepId) && - java.util.Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && - java.util.Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); + Objects.equals(pickleStepId, that.pickleStepId) && + Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && + Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( hookId, id, pickleStepId, @@ -3463,15 +3424,14 @@ public static final class TestCaseFinished { private final Timestamp timestamp; private final Boolean willBeRetried; - @JsonCreator public TestCaseFinished( String testCaseStartedId, Timestamp timestamp, Boolean willBeRetried ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); - this.willBeRetried = java.util.Objects.requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); + this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); + this.willBeRetried = requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); } public String getTestCaseStartedId() { @@ -3499,7 +3459,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( testCaseStartedId, timestamp, willBeRetried @@ -3522,17 +3482,16 @@ public static final class TestCaseStarted { private final String testCaseId; private final Timestamp timestamp; - @JsonCreator public TestCaseStarted( Long attempt, String id, String testCaseId, Timestamp timestamp ) { - this.attempt = java.util.Objects.requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); - this.id = java.util.Objects.requireNonNull(id, "TestCaseStarted.id cannot be null"); - this.testCaseId = java.util.Objects.requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); + this.attempt = requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); + this.id = requireNonNull(id, "TestCaseStarted.id cannot be null"); + this.testCaseId = requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); } public Long getAttempt() { @@ -3565,7 +3524,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( attempt, id, testCaseId, @@ -3589,19 +3548,18 @@ public static final class TestRunFinished { private final Boolean success; private final Timestamp timestamp; - @JsonCreator public TestRunFinished( String message, Boolean success, Timestamp timestamp ) { this.message = message; - this.success = java.util.Objects.requireNonNull(success, "TestRunFinished.success cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); + this.success = requireNonNull(success, "TestRunFinished.success cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); } - public java.util.Optional getMessage() { - return java.util.Optional.ofNullable(message); + public Optional getMessage() { + return Optional.ofNullable(message); } public Boolean getSuccess() { @@ -3618,14 +3576,14 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; TestRunFinished that = (TestRunFinished) o; return - java.util.Objects.equals(message, that.message) && + Objects.equals(message, that.message) && success.equals(that.success) && timestamp.equals(that.timestamp); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( message, success, timestamp @@ -3645,11 +3603,10 @@ public String toString() { public static final class TestRunStarted { private final Timestamp timestamp; - @JsonCreator public TestRunStarted( Timestamp timestamp ) { - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); } public Timestamp getTimestamp() { @@ -3667,7 +3624,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( timestamp ); } @@ -3686,17 +3643,16 @@ public static final class TestStepFinished { private final TestStepResult testStepResult; private final Timestamp timestamp; - @JsonCreator public TestStepFinished( String testCaseStartedId, String testStepId, TestStepResult testStepResult, Timestamp timestamp ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); - this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); - this.testStepResult = java.util.Objects.requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); + this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); + this.testStepId = requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); + this.testStepResult = requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); } public String getTestCaseStartedId() { @@ -3729,7 +3685,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( testCaseStartedId, testStepId, testStepResult, @@ -3753,23 +3709,22 @@ public static final class TestStepResult { private final String message; private final TestStepResultStatus status; - @JsonCreator public TestStepResult( Duration duration, String message, TestStepResultStatus status ) { - this.duration = java.util.Objects.requireNonNull(duration, "TestStepResult.duration cannot be null"); + this.duration = requireNonNull(duration, "TestStepResult.duration cannot be null"); this.message = message; - this.status = java.util.Objects.requireNonNull(status, "TestStepResult.status cannot be null"); + this.status = requireNonNull(status, "TestStepResult.status cannot be null"); } public Duration getDuration() { return duration; } - public java.util.Optional getMessage() { - return java.util.Optional.ofNullable(message); + public Optional getMessage() { + return Optional.ofNullable(message); } public TestStepResultStatus getStatus() { @@ -3783,13 +3738,13 @@ public boolean equals(Object o) { TestStepResult that = (TestStepResult) o; return duration.equals(that.duration) && - java.util.Objects.equals(message, that.message) && + Objects.equals(message, that.message) && status.equals(that.status); } @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( duration, message, status @@ -3811,15 +3766,14 @@ public static final class TestStepStarted { private final String testStepId; private final Timestamp timestamp; - @JsonCreator public TestStepStarted( String testCaseStartedId, String testStepId, Timestamp timestamp ) { - this.testCaseStartedId = java.util.Objects.requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); - this.testStepId = java.util.Objects.requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); - this.timestamp = java.util.Objects.requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); + this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); + this.testStepId = requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); } public String getTestCaseStartedId() { @@ -3847,7 +3801,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( testCaseStartedId, testStepId, timestamp @@ -3868,13 +3822,12 @@ public static final class Timestamp { private final Long seconds; private final Long nanos; - @JsonCreator public Timestamp( Long seconds, Long nanos ) { - this.seconds = java.util.Objects.requireNonNull(seconds, "Timestamp.seconds cannot be null"); - this.nanos = java.util.Objects.requireNonNull(nanos, "Timestamp.nanos cannot be null"); + this.seconds = requireNonNull(seconds, "Timestamp.seconds cannot be null"); + this.nanos = requireNonNull(nanos, "Timestamp.nanos cannot be null"); } public Long getSeconds() { @@ -3897,7 +3850,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( seconds, nanos ); @@ -3916,13 +3869,12 @@ public static final class UndefinedParameterType { private final String expression; private final String name; - @JsonCreator public UndefinedParameterType( String expression, String name ) { - this.expression = java.util.Objects.requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); - this.name = java.util.Objects.requireNonNull(name, "UndefinedParameterType.name cannot be null"); + this.expression = requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); + this.name = requireNonNull(name, "UndefinedParameterType.name cannot be null"); } public String getExpression() { @@ -3945,7 +3897,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( expression, name ); diff --git a/messages/java/src/test/java/io/cucumber/messages/Jackson.java b/messages/java/src/test/java/io/cucumber/messages/Jackson.java index 69964a896c..fad8130c5f 100644 --- a/messages/java/src/test/java/io/cucumber/messages/Jackson.java +++ b/messages/java/src/test/java/io/cucumber/messages/Jackson.java @@ -1,25 +1,29 @@ package io.cucumber.messages; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude; +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.MapperFeature; 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 = new ObjectMapper() - .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) - .registerModule(new Jdk8Module()) - .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) -// .setConstructorDetector(ConstructorDetector.USE_PROPERTIES_BASED) + 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); + .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET) + .build(); private Jackson() { } diff --git a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java index 7afaab8287..284730cb29 100644 --- a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java @@ -1,6 +1,9 @@ package io.cucumber.messages; import com.fasterxml.jackson.core.JsonProcessingException; +import io.cucumber.messages.Messages.Envelope; +import io.cucumber.messages.Messages.TestRunStarted; +import io.cucumber.messages.Messages.Timestamp; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -12,4 +15,11 @@ void can_deserialize_enum() throws JsonProcessingException { String json = Jackson.OBJECT_MAPPER.writeValueAsString(source); assertEquals(source, Jackson.OBJECT_MAPPER.readValue(json, Messages.Source.class)); } + + @Test + void can_deserialize_envelope() throws JsonProcessingException { + Messages.Envelope source = Envelope.of(new TestRunStarted(new Timestamp(3L,14L))); + String json = Jackson.OBJECT_MAPPER.writeValueAsString(source); + assertEquals(source, Jackson.OBJECT_MAPPER.readValue(json, Messages.Envelope.class)); + } } diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index a15df6eecd..dd3df0fba1 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -6,14 +6,14 @@ <%- if (schema['required'] || []).empty? -%> <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - public <%= class_name(key) %>(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - this( + public static <%= class_name(key) %> of(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + return new <%= class_name(key) %>( <%- schema['properties'].each_with_index do |(property_name_2, property_2), index_2| -%> <%- if property_name_2 == property_name -%> <%- if property['items'] -%> - java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")))<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")))<%= index_2 < schema['properties'].length-1 ? ',' : '' %> <%- else -%> - java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")<%= index_2 < schema['properties'].length-1 ? ',' : '' %> <%- end -%> <%- else -%> null<%= index_2 < schema['properties'].length-1 ? ',' : '' %> @@ -24,7 +24,6 @@ <%- end -%> <%- end -%> - @JsonCreator public <%= class_name(key) %>( <%- schema['properties'].each_with_index do |(property_name, property), index| -%> <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> @@ -35,13 +34,13 @@ -%> <%- if required -%> <%- if property['items'] -%> - this.<%= property_name %> = java.util.Collections.unmodifiableList(new java.util.ArrayList<>(java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))); + this.<%= property_name %> = unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))); <%- else -%> - this.<%= property_name %> = java.util.Objects.requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); + this.<%= property_name %> = requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); <%- end -%> <%- else -%> <%- if property['items'] -%> - this.<%= property_name %> = <%= property_name %> == null ? null : java.util.Collections.unmodifiableList(new java.util.ArrayList<>(<%= property_name %>)); + this.<%= property_name %> = <%= property_name %> == null ? null : unmodifiableList(new ArrayList<>(<%= property_name %>)); <%- else -%> this.<%= property_name %> = <%= property_name %>; <%- end -%> @@ -56,8 +55,8 @@ } <%- else -%> - public java.util.Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { - return java.util.Optional.ofNullable(<%= property_name %>); + public Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { + return Optional.ofNullable(<%= property_name %>); } <%- end -%> <%- end -%> @@ -71,7 +70,7 @@ <%- if (schema['required'] || []).index(property_name) -%> <%= property_name -%>.equals(that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> <%- else -%> - java.util.Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> + Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> <%- end -%> <% end -%> @@ -79,7 +78,7 @@ @Override public int hashCode() { - return java.util.Objects.hash( + return Objects.hash( <%- schema['properties'].each_with_index do |(property_name, property), index| -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> <%- end -%> From 55676a15996adf86192a1d4403c9a8d69c8b468d Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 00:17:00 +0100 Subject: [PATCH 42/63] Use idiomatic java for Enum.fromValue --- .../cucumber/gherkin/MessageVersionTest.java | 1 - .../java/io/cucumber/messages/Messages.java | 33 +++++++++++-------- .../io/cucumber/messages/JacksonTest.java | 18 +++++++--- .../scripts/templates/java.enum.java.erb | 8 +++-- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java index efa0771ed1..f676df6f99 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java @@ -1,6 +1,5 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Messages; import org.junit.Test; import static org.junit.Assert.assertNotNull; diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index e5c1f0cf34..b5fcb5734b 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -3932,8 +3932,11 @@ public String value() { } public static AttachmentContentEncoding fromValue(String value) { - if ("IDENTITY".equals(value)) return IDENTITY; - if ("BASE64".equals(value)) return BASE64; + for (AttachmentContentEncoding v : values()) { + if (v.value.equals(value)) { + return v; + } + } throw new IllegalArgumentException(value); } } @@ -3958,8 +3961,11 @@ public String value() { } public static SourceMediaType fromValue(String value) { - if ("text/x.cucumber.gherkin+plain".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_PLAIN; - if ("text/x.cucumber.gherkin+markdown".equals(value)) return TEXT_X_CUCUMBER_GHERKIN_MARKDOWN; + for (SourceMediaType v : values()) { + if (v.value.equals(value)) { + return v; + } + } throw new IllegalArgumentException(value); } } @@ -3984,8 +3990,11 @@ public String value() { } public static StepDefinitionPatternType fromValue(String value) { - if ("CUCUMBER_EXPRESSION".equals(value)) return CUCUMBER_EXPRESSION; - if ("REGULAR_EXPRESSION".equals(value)) return REGULAR_EXPRESSION; + for (StepDefinitionPatternType v : values()) { + if (v.value.equals(value)) { + return v; + } + } throw new IllegalArgumentException(value); } } @@ -4015,13 +4024,11 @@ public String value() { } public static TestStepResultStatus fromValue(String value) { - if ("UNKNOWN".equals(value)) return UNKNOWN; - if ("PASSED".equals(value)) return PASSED; - if ("SKIPPED".equals(value)) return SKIPPED; - if ("PENDING".equals(value)) return PENDING; - if ("UNDEFINED".equals(value)) return UNDEFINED; - if ("AMBIGUOUS".equals(value)) return AMBIGUOUS; - if ("FAILED".equals(value)) return FAILED; + for (TestStepResultStatus v : values()) { + if (v.value.equals(value)) { + return v; + } + } throw new IllegalArgumentException(value); } } diff --git a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java index 284730cb29..bd3d4b31b8 100644 --- a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java @@ -6,20 +6,28 @@ import io.cucumber.messages.Messages.Timestamp; import org.junit.jupiter.api.Test; +import static io.cucumber.messages.Jackson.OBJECT_MAPPER; +import static io.cucumber.messages.Messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.jupiter.api.Assertions.assertEquals; class JacksonTest { @Test void can_deserialize_enum() throws JsonProcessingException { - Messages.Source source = new Messages.Source("hello.feature", "Feature: Hello", Messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN); - String json = Jackson.OBJECT_MAPPER.writeValueAsString(source); - assertEquals(source, Jackson.OBJECT_MAPPER.readValue(json, Messages.Source.class)); + Messages.Source source = new Messages.Source("hello.feature", "Feature: Hello", TEXT_X_CUCUMBER_GHERKIN_PLAIN); + String json = OBJECT_MAPPER.writeValueAsString(source); + assertEquals(source, OBJECT_MAPPER.readValue(json, Messages.Source.class)); + } + + @Test + void serialize_enums_using_value() throws JsonProcessingException { + assertEquals("\"text/x.cucumber.gherkin+plain\"", + OBJECT_MAPPER.writeValueAsString(TEXT_X_CUCUMBER_GHERKIN_PLAIN)); } @Test void can_deserialize_envelope() throws JsonProcessingException { Messages.Envelope source = Envelope.of(new TestRunStarted(new Timestamp(3L,14L))); - String json = Jackson.OBJECT_MAPPER.writeValueAsString(source); - assertEquals(source, Jackson.OBJECT_MAPPER.readValue(json, Messages.Envelope.class)); + String json = OBJECT_MAPPER.writeValueAsString(source); + assertEquals(source, OBJECT_MAPPER.readValue(json, Messages.Envelope.class)); } } diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb index b0781a000b..ece2163d56 100644 --- a/messages/jsonschema/scripts/templates/java.enum.java.erb +++ b/messages/jsonschema/scripts/templates/java.enum.java.erb @@ -20,9 +20,11 @@ } public static <%= enum[:name] %> fromValue(String value) { - <%- enum[:values].each do |value| -%> - if ("<%= value %>".equals(value)) return <%= enum_constant(value) %>; - <%- end -%> + for (<%= enum[:name] %> v : values()) { + if (v.value.equals(value)) { + return v; + } + } throw new IllegalArgumentException(value); } } From 21bd79f7fd3e9854bcc6161b06f35f41f51b2198 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 00:52:16 +0100 Subject: [PATCH 43/63] Use idiomatic java for serializer and deserializer --- .../test/java/io/cucumber/gherkin/Main.java | 36 +++++----------- .../htmlformatter/MessagesToHtmlWriter.java | 16 ++++--- .../io/cucumber/htmlformatter/Jackson.java | 31 +++++++------- .../java/io/cucumber/htmlformatter/Main.java | 37 ++++++---------- .../MessagesToHtmlWriterTest.java | 19 +++------ .../messages/MessageToNdjsonWriter.java | 27 +++++++----- .../io/cucumber/messages/MessageWriter.java | 7 ---- .../messages/NdjsonToMessageIterable.java | 38 ++++++++++------- .../messages/NdjsonSerializationTest.java | 42 +++++++------------ 9 files changed, 110 insertions(+), 143 deletions(-) delete mode 100644 messages/java/src/main/java/io/cucumber/messages/MessageWriter.java diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java index 560f5efe88..9d8bacb771 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java @@ -2,28 +2,19 @@ import io.cucumber.messages.IdGenerator; import io.cucumber.messages.MessageToNdjsonWriter; -import io.cucumber.messages.MessageWriter; import java.io.IOException; -import java.io.Writer; import java.util.ArrayList; import java.util.List; -import java.util.function.BiConsumer; import java.util.stream.Stream; +import static io.cucumber.gherkin.Jackson.OBJECT_MAPPER; import static io.cucumber.messages.Messages.Envelope; import static java.util.Arrays.asList; public class Main { - private static final BiConsumer SERIALIZER = (writer, envelope) -> { - try { - Jackson.OBJECT_MAPPER.writeValue(writer, envelope); - } catch (IOException e) { - throw new RuntimeException(e); - } - }; - public static void main(String[] argv) { + public static void main(String[] argv) throws IOException { List args = new ArrayList<>(asList(argv)); List paths = new ArrayList<>(); @@ -57,23 +48,18 @@ public static void main(String[] argv) { idGenerator = new IdGenerator.UUID(); } - MessageWriter messageWriter = makeMessageWriter(); - Stream messages = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator); - printMessages(messageWriter, messages); + try (MessageToNdjsonWriter writer = new MessageToNdjsonWriter(System.out, OBJECT_MAPPER::writeValue)) { + messages.forEach(envelope -> printMessages(writer, envelope)); + } } - private static void printMessages(MessageWriter messageWriter, Stream messages) { - messages.forEach(envelope -> { - try { - messageWriter.write(envelope); - } catch (IOException e) { - throw new GherkinException("Couldn't print messages", e); - } - }); + private static void printMessages(MessageToNdjsonWriter writer, Envelope envelope) { + try { + writer.write(envelope); + } catch (IOException e) { + throw new GherkinException("Couldn't print messages", e); + } } - private static MessageWriter makeMessageWriter() { - return new MessageToNdjsonWriter<>(System.out, SERIALIZER); - } } diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index 13a0238897..aedf9cc700 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -10,7 +10,6 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.StandardCharsets; -import java.util.function.BiConsumer; import static io.cucumber.messages.Messages.Envelope; import static java.nio.charset.StandardCharsets.UTF_8; @@ -22,17 +21,17 @@ public final class MessagesToHtmlWriter implements AutoCloseable { private final String template; private final Writer writer; - private final BiConsumer serializer; + private final Serializer serializer; private boolean preMessageWritten = false; private boolean postMessageWritten = false; private boolean firstMessageWritten = false; private boolean streamClosed = false; - public MessagesToHtmlWriter(OutputStream outputStream, BiConsumer serializer) throws IOException { + public MessagesToHtmlWriter(OutputStream outputStream, Serializer serializer) throws IOException { this(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8), serializer); } - public MessagesToHtmlWriter(Writer writer, BiConsumer serializer) throws IOException { + public MessagesToHtmlWriter(Writer writer, Serializer serializer) throws IOException { this.writer = writer; this.serializer = serializer; this.template = readResource("index.mustache.html"); @@ -72,7 +71,7 @@ public void write(Envelope envelope) throws IOException { writer.write(","); } - serializer.accept(writer, envelope); + serializer.writeValue(writer, envelope); } /** @@ -125,4 +124,11 @@ private static String readResource(String name) throws IOException { } return new String(baos.toByteArray(), UTF_8); } + + @FunctionalInterface + public interface Serializer { + + void writeValue(Writer writer, Envelope value) throws IOException; + + } } diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Jackson.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Jackson.java index 348fffac23..60407c657c 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Jackson.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Jackson.java @@ -1,27 +1,28 @@ package io.cucumber.htmlformatter; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude; +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; -import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; -import static com.fasterxml.jackson.databind.DeserializationFeature.READ_ENUMS_USING_TO_STRING; -import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_ENUMS_USING_TO_STRING; - final class Jackson { - public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() - .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) - .registerModule(new Jdk8Module()) - .setSerializationInclusion(JsonInclude.Include.NON_ABSENT) - .setConstructorDetector(ConstructorDetector.USE_PROPERTIES_BASED) - .enable(WRITE_ENUMS_USING_TO_STRING) - .enable(READ_ENUMS_USING_TO_STRING) - .disable(FAIL_ON_UNKNOWN_PROPERTIES) - .disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET); + 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() { } diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java index 7efda143ab..fcb99d7850 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java @@ -1,48 +1,35 @@ package io.cucumber.htmlformatter; +import io.cucumber.htmlformatter.MessagesToHtmlWriter.Serializer; import io.cucumber.messages.NdjsonToMessageIterable; +import io.cucumber.messages.NdjsonToMessageIterable.Deserializer; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.Writer; -import java.util.function.BiConsumer; -import java.util.function.BiFunction; +import static io.cucumber.htmlformatter.Jackson.OBJECT_MAPPER; import static io.cucumber.messages.Messages.Envelope; public final class Main { - public static final BiFunction, Envelope> DESERIALIZER = (json, klass) -> { - try { - return Jackson.OBJECT_MAPPER.readValue(json, klass); - } catch (IOException e) { - throw new RuntimeException(e); - } - }; - - private static final BiConsumer SERIALIZER = (writer, envelope) -> { - try { - Jackson.OBJECT_MAPPER.writeValue(writer, envelope); - } catch (IOException e) { - throw new RuntimeException(e); - } - }; + 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) { + if (args.length == 1) { in = new FileInputStream(args[0]); } - try (NdjsonToMessageIterable envelopes = new NdjsonToMessageIterable<>(in, Envelope.class, DESERIALIZER)) { - try (MessagesToHtmlWriter htmlWriter = new MessagesToHtmlWriter(System.out, SERIALIZER)) { + 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); } + } catch (Throwable e) { + // Workaround for https://github.com/mojohaus/exec-maven-plugin/issues/141 + e.printStackTrace(); + System.exit(1); } } } diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 27cdd3d2d1..fca676ecb3 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -1,5 +1,6 @@ package io.cucumber.htmlformatter; +import io.cucumber.htmlformatter.MessagesToHtmlWriter.Serializer; import io.cucumber.messages.TimeConversion; import org.junit.jupiter.api.Test; @@ -7,9 +8,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; -import java.io.Writer; import java.time.Instant; -import java.util.function.BiConsumer; import static io.cucumber.messages.Messages.Envelope; import static io.cucumber.messages.Messages.TestRunFinished; @@ -23,13 +22,7 @@ class MessagesToHtmlWriterTest { - private static final BiConsumer SERIALIZER = (writer, message) -> { - try { - Jackson.OBJECT_MAPPER.writeValue(writer, message); - } catch (IOException e) { - throw new RuntimeException(e); - } - }; + static final Serializer serializer = Jackson.OBJECT_MAPPER::writeValue; @Test void it_writes_one_message_to_html() throws IOException { @@ -52,7 +45,7 @@ void it_throws_when_writing_after_close() throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); BufferedWriter bw = new BufferedWriter(osw); - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer); messagesToHtmlWriter.close(); assertThrows(IOException.class, () -> messagesToHtmlWriter.write(null)); } @@ -62,7 +55,7 @@ void it_can_be_closed_twice() throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); BufferedWriter bw = new BufferedWriter(osw); - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer); messagesToHtmlWriter.close(); assertDoesNotThrow(messagesToHtmlWriter::close); } @@ -78,7 +71,7 @@ public void close() throws IOException { throw new IOException("Can't close this"); } }; - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer); assertThrows(IOException.class, messagesToHtmlWriter::close); byte[] before = bytes.toByteArray(); assertThrows(IOException.class, messagesToHtmlWriter::close); @@ -102,7 +95,7 @@ private static String renderAsHtml(Envelope... messages) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); BufferedWriter bw = new BufferedWriter(osw); - try (MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, SERIALIZER)) { + try (MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer)) { for (Envelope message : messages) { messagesToHtmlWriter.write(message); } diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java index 2c2f80c0f3..107078a595 100644 --- a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java +++ b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java @@ -1,34 +1,41 @@ package io.cucumber.messages; +import io.cucumber.messages.Messages.Envelope; + import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.StandardCharsets; -import java.util.function.BiConsumer; -public final class MessageToNdjsonWriter implements MessageWriter, AutoCloseable { +public final class MessageToNdjsonWriter implements AutoCloseable { private final Writer writer; - private final BiConsumer serializer; + private final Serializer serializer; - public MessageToNdjsonWriter(OutputStream outputStream, BiConsumer serializer) { + public MessageToNdjsonWriter(OutputStream outputStream, Serializer serializer) { this(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8), serializer); } - public MessageToNdjsonWriter(Writer writer, BiConsumer serializer) { + public MessageToNdjsonWriter(Writer writer, Serializer serializer) { this.writer = writer; this.serializer = serializer; } - @Override - public void write(T message) throws IOException { - this.serializer.accept(writer, message); + public void write(Envelope message) throws IOException { + serializer.writeValue(writer, message); writer.write("\n"); writer.flush(); } @Override - public void close() throws Exception { - this.writer.close(); + public void close() throws IOException { + writer.close(); + } + + @FunctionalInterface + public interface Serializer { + + void writeValue(Writer writer, Envelope value) throws IOException; + } } diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageWriter.java deleted file mode 100644 index e0551038d5..0000000000 --- a/messages/java/src/main/java/io/cucumber/messages/MessageWriter.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.cucumber.messages; - -import java.io.IOException; - -public interface MessageWriter { - void write(T message) throws IOException; -} diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index edf02566df..9bafcc4920 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -1,5 +1,7 @@ package io.cucumber.messages; +import io.cucumber.messages.Messages.Envelope; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -7,36 +9,33 @@ import java.io.Reader; import java.nio.charset.StandardCharsets; import java.util.Iterator; -import java.util.function.BiFunction; /** * Iterates over messages read from a stream. Client code should not depend on this class * directly, but rather on a {@code Iterable} object. * Tests can then use a {@code new ArrayList} which implements the same interface. */ -public final class NdjsonToMessageIterable implements Iterable, AutoCloseable { +public final class NdjsonToMessageIterable implements Iterable, AutoCloseable { private final BufferedReader reader; - private final Class klass; - private final BiFunction, T> deserializer; - private T next; + private final Deserializer deserializer; + private Envelope next; - public NdjsonToMessageIterable(InputStream inputStream, Class klass, BiFunction, T> deserializer) { - this(new InputStreamReader(inputStream, StandardCharsets.UTF_8), klass, deserializer); + public NdjsonToMessageIterable(InputStream inputStream, Deserializer deserializer) { + this(new InputStreamReader(inputStream, StandardCharsets.UTF_8), deserializer); } - public NdjsonToMessageIterable(Reader reader, Class klass, BiFunction, T> deserializer) { - this(new BufferedReader(reader), klass, deserializer); + public NdjsonToMessageIterable(Reader reader, Deserializer deserializer) { + this(new BufferedReader(reader), deserializer); } - public NdjsonToMessageIterable(BufferedReader reader, Class klass, BiFunction, T> deserializer) { + public NdjsonToMessageIterable(BufferedReader reader, Deserializer deserializer) { this.reader = reader; - this.klass = klass; this.deserializer = deserializer; } @Override - public Iterator iterator() { - return new Iterator() { + public Iterator iterator() { + return new Iterator() { @Override public boolean hasNext() { try { @@ -46,8 +45,8 @@ public boolean hasNext() { return hasNext(); } try { - next = deserializer.apply(line, klass); - } catch (Exception e) { + next = deserializer.readValue(line); + } catch (IOException e) { throw new RuntimeException(String.format("Could not parse JSON: %s", line), e); } return true; @@ -57,7 +56,7 @@ public boolean hasNext() { } @Override - public T next() { + public Envelope next() { if (next == null) { throw new IllegalStateException("next() should only be called after a call to hasNext() that returns true"); } @@ -75,4 +74,11 @@ public void remove() { public void close() throws IOException { this.reader.close(); } + + @FunctionalInterface + public interface Deserializer { + + Envelope readValue(String json) throws IOException; + + } } diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index 97f607100b..74e6d03a1b 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -24,31 +24,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue; class NdjsonSerializationTest { - protected static MessageWriter makeMessageWriter(OutputStream output) { - return new MessageToNdjsonWriter<>(output, (writer, envelope) -> { - try { - Jackson.OBJECT_MAPPER.writeValue(writer, envelope); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + static MessageToNdjsonWriter createMessageWriter(OutputStream output) { + return new MessageToNdjsonWriter(output, Jackson.OBJECT_MAPPER::writeValue); } - protected static Iterable makeMessageIterable(InputStream input, Class klass) { - return new NdjsonToMessageIterable(input, klass, (json, clazz) -> { - try { - return Jackson.OBJECT_MAPPER.readValue(json, clazz); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + static Iterable createMessageIterable(InputStream input) { + return new NdjsonToMessageIterable(input, (json) -> Jackson.OBJECT_MAPPER.readValue(json, Envelope.class)); } @Test void writes_source_envelope() throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); - MessageWriter writer = makeMessageWriter(output); - writer.write(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + MessageToNdjsonWriter writer = createMessageWriter(output); + writer.write(Envelope.of(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN))); String json = new String(output.toByteArray(), StandardCharsets.UTF_8); assertEquals("{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}\n", json); } @@ -83,7 +71,7 @@ void does_not_serialize_null_fields() throws IOException { @Test void ignores_missing_fields() { InputStream input = new ByteArrayInputStream("{\"unused\": 99}\n".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input, Envelope.class); + Iterable incomingMessages = createMessageIterable(input); Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); @@ -112,7 +100,7 @@ void ignores_missing_fields() { @Test void ignores_empty_lines() { InputStream input = new ByteArrayInputStream("{}\n{}\n\n{}\n".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input, Envelope.class); + Iterable incomingMessages = createMessageIterable(input); Iterator iterator = incomingMessages.iterator(); for (int i = 0; i < 3; i++) { assertTrue(iterator.hasNext()); @@ -143,7 +131,7 @@ void ignores_empty_lines() { @Test void handles_enums() { InputStream input = new ByteArrayInputStream("{\"attachment\":{\"contentEncoding\":\"BASE64\", \"body\":\"the-body\", \"mediaType\":\"text/plain\"}}\n".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input, Envelope.class); + Iterable incomingMessages = createMessageIterable(input); Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); Envelope envelope = iterator.next(); @@ -153,12 +141,12 @@ void handles_enums() { @Test void handles_single_argument_constructors() { - InputStream input = new ByteArrayInputStream("{\"timestamp\":{\"nanos\":0,\"seconds\":0}}\n".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input, TestRunStarted.class); - Iterator iterator = incomingMessages.iterator(); + InputStream input = new ByteArrayInputStream("{\"testRunStarted\": {\"timestamp\":{\"nanos\":0,\"seconds\":0}}}\n".getBytes(UTF_8)); + Iterable incomingMessages = createMessageIterable(input); + Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); - TestRunStarted testRunStarted = iterator.next(); - TestRunStarted expected = new TestRunStarted(new Timestamp(0L, 0L)); + Envelope testRunStarted = iterator.next(); + Envelope expected = Envelope.of(new TestRunStarted(new Timestamp(0L, 0L))); assertEquals(expected, testRunStarted); assertFalse(iterator.hasNext()); } @@ -166,7 +154,7 @@ void handles_single_argument_constructors() { @Test void includes_offending_line_in_error_message() { InputStream input = new ByteArrayInputStream("BLA BLA".getBytes(UTF_8)); - Iterable incomingMessages = makeMessageIterable(input, Envelope.class); + Iterable incomingMessages = createMessageIterable(input); Iterator iterator = incomingMessages.iterator(); RuntimeException exception = assertThrows(RuntimeException.class, () -> assertTrue(iterator.hasNext())); From bc00c4ff54fac7cbc2171cbe8c8031a2acbec199 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 01:50:55 +0100 Subject: [PATCH 44/63] Clean up gherkin parser - Rename Gherkin to GherkinParser to reflect intent - Use builder pattern to configure parser - Push IO operations from parser to Main class. - Limit parser to parsing single envelopes --- .../java/io/cucumber/gherkin/Gherkin.java | 159 ------------------ .../io/cucumber/gherkin/GherkinParser.java | 142 ++++++++++++++++ .../gherkin/GherkinDocumentBuilderTest.java | 4 +- ...herkinTest.java => GherkinParserTest.java} | 53 +++--- .../gherkin/IncrementingIdGenerator.java | 13 ++ .../test/java/io/cucumber/gherkin/Main.java | 40 +++-- .../cucumber/gherkin/MessageVersionTest.java | 1 + .../java/io/cucumber/gherkin/ParserTest.java | 2 +- .../io/cucumber/messages/IdGenerator.java | 16 -- 9 files changed, 214 insertions(+), 216 deletions(-) delete mode 100644 gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java create mode 100644 gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java rename gherkin/java/src/test/java/io/cucumber/gherkin/{GherkinTest.java => GherkinParserTest.java} (58%) create mode 100644 gherkin/java/src/test/java/io/cucumber/gherkin/IncrementingIdGenerator.java diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java deleted file mode 100644 index 5753985fad..0000000000 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Gherkin.java +++ /dev/null @@ -1,159 +0,0 @@ -package io.cucumber.gherkin; - -import io.cucumber.gherkin.pickles.PickleCompiler; -import io.cucumber.messages.IdGenerator; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Stream; - -import static io.cucumber.messages.Messages.Envelope; -import static io.cucumber.messages.Messages.GherkinDocument; -import static io.cucumber.messages.Messages.ParseError; -import static io.cucumber.messages.Messages.Pickle; -import static io.cucumber.messages.Messages.Source; -import static io.cucumber.messages.Messages.SourceMediaType; -import static io.cucumber.messages.Messages.SourceReference; -import static java.util.Collections.emptyList; - -/** - * Main entry point for the Gherkin library - */ -public class Gherkin { - private final List paths; - private final List envelopes; - private final boolean includeSource; - private final boolean includeAst; - private final boolean includePickles; - private final IdGenerator idGenerator; - - private Gherkin(List paths, List envelopes, boolean includeSource, boolean includeAst, boolean includePickles, IdGenerator idGenerator) { - this.paths = paths; - this.envelopes = envelopes; - this.includeSource = includeSource; - this.includeAst = includeAst; - this.includePickles = includePickles; - this.idGenerator = idGenerator; - } - - public static Stream fromPaths(List paths, boolean includeSource, boolean includeAst, boolean includePickles, IdGenerator idGenerator) { - return new Gherkin(paths, null, includeSource, includeAst, includePickles, idGenerator).messages(); - } - - public static Stream fromSources(List envelopes, boolean includeSource, boolean includeAst, boolean includePickles, IdGenerator idGenerator) { - return new Gherkin(Collections.emptyList(), envelopes, includeSource, includeAst, includePickles, idGenerator).messages(); - } - - public static Envelope makeSourceEnvelope(String data, String uri) { - return Envelope.of(new Source(uri, data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); - } - - public Stream messages() { - Stream envelopeStream = envelopes != null ? envelopes.stream() : envelopeStreamFromPaths(paths); - return envelopeStream - .flatMap((Function>) envelope -> parserMessageStream(envelope, includeSource, includeAst, includePickles)); - } - - private Stream envelopeStreamFromPaths(List paths) { - return paths.stream().map(this::envelopeFromPath); - } - - private Envelope envelopeFromPath(String path) { - try { - String data = read(new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8)); - return makeSourceEnvelope(data, path); - } catch (IOException e) { - throw new GherkinException(e.getMessage(), e); - } - } - - private static String read(Reader reader) throws IOException { - final char[] buffer = new char[0x10000]; - StringBuilder sb = new StringBuilder(); - int read; - do { - read = reader.read(buffer, 0, buffer.length); - if (read > 0) { - sb.append(buffer, 0, read); - } - } while (read >= 0); - return sb.toString(); - } - - private Stream parserMessageStream(Envelope envelope, boolean includeSource, boolean includeGherkinDocument, boolean includePickles) { - List messages = new ArrayList<>(); - - if (includeSource) { - messages.add(envelope); - } - messages.addAll(parseSource(envelope, includeGherkinDocument, includePickles)); - return messages.stream(); - } - - private List parseSource(Envelope envelope, boolean includeGherkinDocument, boolean includePickles) { - return envelope.getSource() - .map(source -> parseSource(includeGherkinDocument, includePickles, source)) - .orElse(emptyList()); - } - - private List parseSource(boolean includeGherkinDocument, boolean includePickles, Source source) { - String uri = source.getUri(); - String data = source.getData(); - List messages = new ArrayList<>(); - - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, uri)); - - try { - GherkinDocument gherkinDocument = null; - - if (includeGherkinDocument) { - gherkinDocument = parser.parse(data, uri); - messages.add(Envelope.of(gherkinDocument)); - } - if (includePickles) { - if (gherkinDocument == null) { - gherkinDocument = parser.parse(data, uri); - } - PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); - List pickles = pickleCompiler.compile(gherkinDocument, uri); - for (Pickle pickle : pickles) { - messages.add(Envelope.of(pickle)); - } - } - } catch (ParserException.CompositeParserException e) { - for (ParserException error : e.errors) { - addParseError(messages, error, uri); - } - } catch (ParserException e) { - addParseError(messages, e, uri); - } - - return messages; - } - - private void addParseError(List messages, ParserException e, String uri) { - long line = e.location.getLine(); - long column = e.location.getColumn(); - ParseError parseError = new ParseError( - new SourceReference( - uri, - null, null, - // We want 0 values not to be serialised, which is why we set them to null - // This is a legacy requirement brought over from old protobuf behaviour - new io.cucumber.messages.Messages.Location( - line, - column == 0 ? null : column - ) - ), - e.getMessage() - ); - messages.add(Envelope.of(parseError)); - } -} diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java new file mode 100644 index 0000000000..0c9cea299e --- /dev/null +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -0,0 +1,142 @@ +package io.cucumber.gherkin; + +import io.cucumber.gherkin.pickles.PickleCompiler; +import io.cucumber.messages.IdGenerator; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; +import java.util.stream.Stream; + +import static io.cucumber.messages.Messages.Envelope; +import static io.cucumber.messages.Messages.GherkinDocument; +import static io.cucumber.messages.Messages.ParseError; +import static io.cucumber.messages.Messages.Pickle; +import static io.cucumber.messages.Messages.Source; +import static io.cucumber.messages.Messages.SourceReference; +import static java.util.Objects.requireNonNull; + +/** + * Main entry point for the Gherkin library + */ +public class GherkinParser { + + public static class Builder { + private boolean includeSource = true; + private boolean includeGherkinDocument = true; + private boolean includePickles = true; + private IdGenerator idGenerator = () -> UUID.randomUUID().toString(); + + private Builder(){ + + } + + public Builder includeSource(boolean includeSource) { + this.includeSource = includeSource; + return this; + } + + public Builder includeGherkinDocument(boolean includeGherkinDocument) { + this.includeGherkinDocument = includeGherkinDocument; + return this; + } + + public Builder includePickles(boolean includePickles) { + this.includePickles = includePickles; + return this; + } + + public Builder idGenerator(IdGenerator idGenerator) { + this.idGenerator = requireNonNull(idGenerator); + return this; + } + + public GherkinParser build(){ + return new GherkinParser(includeSource, includeGherkinDocument, includePickles, idGenerator); + } + } + + private final boolean includeSource; + private final boolean includeGherkinDocument; + private final boolean includePickles; + private final IdGenerator idGenerator; + + private GherkinParser(boolean includeSource, boolean includeGherkinDocument, boolean includePickles, IdGenerator idGenerator) { + this.includeSource = includeSource; + this.includeGherkinDocument = includeGherkinDocument; + this.includePickles = includePickles; + this.idGenerator = requireNonNull(idGenerator); + } + + public static Builder builder(){ + return new Builder(); + } + + public Stream parse(Envelope envelope) { + List messages = new ArrayList<>(); + + if (includeSource) { + messages.add(envelope); + } + + envelope.getSource() + .map(this::parseSource) + .ifPresent(messages::addAll); + + return messages.stream(); + } + + private List parseSource(Source source) { + String uri = source.getUri(); + String data = source.getData(); + List messages = new ArrayList<>(); + + Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, uri)); + + try { + GherkinDocument gherkinDocument = null; + + if (includeGherkinDocument) { + gherkinDocument = parser.parse(data, uri); + messages.add(Envelope.of(gherkinDocument)); + } + if (includePickles) { + if (gherkinDocument == null) { + gherkinDocument = parser.parse(data, uri); + } + PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); + List pickles = pickleCompiler.compile(gherkinDocument, uri); + for (Pickle pickle : pickles) { + messages.add(Envelope.of(pickle)); + } + } + } catch (ParserException.CompositeParserException e) { + for (ParserException error : e.errors) { + addParseError(messages, error, uri); + } + } catch (ParserException e) { + addParseError(messages, e, uri); + } + + return messages; + } + + private void addParseError(List messages, ParserException e, String uri) { + long line = e.location.getLine(); + long column = e.location.getColumn(); + ParseError parseError = new ParseError( + new SourceReference( + uri, + null, null, + // We want 0 values not to be serialised, which is why we set them to null + // This is a legacy requirement brought over from old protobuf behaviour + new io.cucumber.messages.Messages.Location( + line, + column == 0 ? null : column + ) + ), + e.getMessage() + ); + messages.add(Envelope.of(parseError)); + } +} diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index 7de3a975e5..658dc64f83 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -14,7 +14,7 @@ import static org.junit.Assert.assertEquals; public class GherkinDocumentBuilderTest { - private final IdGenerator idGenerator = new IdGenerator.Incrementing(); + private final IdGenerator idGenerator = new IncrementingIdGenerator(); @Test public void is_reusable() { @@ -56,7 +56,7 @@ public void parses_rules() { List children = doc.getFeature().get().getChildren(); assertEquals(3, children.size()); - IdGenerator idGenerator = new IdGenerator.Incrementing(); + IdGenerator idGenerator = new IncrementingIdGenerator(); PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); List pickles = pickleCompiler.compile(doc, "hello.feature"); assertEquals(2, pickles.size()); diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java similarity index 58% rename from gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java rename to gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java index 28ce13f796..6d5767a50f 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java @@ -1,31 +1,34 @@ package io.cucumber.gherkin; -import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.Messages.Source; import org.junit.Test; import java.util.List; import java.util.stream.Collectors; -import static io.cucumber.gherkin.Gherkin.makeSourceEnvelope; import static io.cucumber.messages.Messages.Envelope; import static io.cucumber.messages.Messages.Feature; import static io.cucumber.messages.Messages.GherkinDocument; import static io.cucumber.messages.Messages.Pickle; import static io.cucumber.messages.Messages.PickleStep; import static io.cucumber.messages.Messages.Scenario; -import static java.util.Collections.singletonList; +import static io.cucumber.messages.Messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.Assert.assertEquals; -public class GherkinTest { - private final IdGenerator idGenerator = new IdGenerator.Incrementing(); +public class GherkinParserTest { + final Envelope envelope = Envelope.of(new Source("test.feature", + "Feature: Minimal\n" + + "\n" + + " Scenario: minimalistic\n" + + " Given the minimalism\n", + TEXT_X_CUCUMBER_GHERKIN_PLAIN)); @Test public void use_this_in_readme() { - List paths = singletonList("testdata/good/minimal.feature"); - boolean includeSource = false; - boolean includeAst = true; - boolean includePickles = true; - String name = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator) + String name = GherkinParser.builder() + .includeSource(false) + .build() + .parse(envelope) .filter(envelope -> envelope.getPickle().isPresent()) .findFirst().get() .getPickle().get() @@ -33,14 +36,14 @@ public void use_this_in_readme() { assertEquals("minimalistic", name); } - @Test public void provides_access_to_the_ast() { - List paths = singletonList("testdata/good/minimal.feature"); - boolean includeSource = false; - boolean includeAst = true; - boolean includePickles = false; - List envelopes = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator).collect(Collectors.toList()); + List envelopes = GherkinParser.builder() + .includeSource(false) + .includePickles(false) + .build() + .parse(envelope) + .collect(Collectors.toList()); // Get the AST GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument().get(); @@ -56,8 +59,11 @@ public void provides_access_to_the_ast() { @Test public void provides_access_to_pickles_which_are_compiled_from_the_ast() { - List envelopes = Gherkin.fromPaths(singletonList("testdata/good/scenario_outline.feature") - , false, false, true, idGenerator) + List envelopes = GherkinParser.builder() + .includeSource(false) + .includeGherkinDocument(false) + .build() + .parse(envelope) .collect(Collectors.toList()); // Get the first pickle @@ -70,11 +76,12 @@ public void provides_access_to_pickles_which_are_compiled_from_the_ast() { @Test public void parses_supplied_source() { - Envelope envelope = makeSourceEnvelope("Feature: Minimal\n" + - "\n" + - " Scenario: minimalistic\n" + - " Given the minimalism\n", "test.feature"); - List envelopes = Gherkin.fromSources(singletonList(envelope), false, true, false, idGenerator).collect(Collectors.toList()); + List envelopes = GherkinParser.builder() + .includeSource(false) + .includePickles(false) + .build() + .parse(envelope) + .collect(Collectors.toList()); GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument().get(); Feature feature = gherkinDocument.getFeature().get(); diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/IncrementingIdGenerator.java b/gherkin/java/src/test/java/io/cucumber/gherkin/IncrementingIdGenerator.java new file mode 100644 index 0000000000..1a3bf7a199 --- /dev/null +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/IncrementingIdGenerator.java @@ -0,0 +1,13 @@ +package io.cucumber.gherkin; + +import io.cucumber.messages.IdGenerator; + +class IncrementingIdGenerator implements IdGenerator { + private int next = 0; + + @Override + public String newId() { + return Integer.toString(next++); + } + +} diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java index 9d8bacb771..61d71f4be6 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java @@ -1,12 +1,16 @@ package io.cucumber.gherkin; -import io.cucumber.messages.IdGenerator; import io.cucumber.messages.MessageToNdjsonWriter; +import io.cucumber.messages.Messages.Source; +import io.cucumber.messages.Messages.SourceMediaType; import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import java.util.stream.Stream; import static io.cucumber.gherkin.Jackson.OBJECT_MAPPER; import static io.cucumber.messages.Messages.Envelope; @@ -18,39 +22,36 @@ public static void main(String[] argv) throws IOException { List args = new ArrayList<>(asList(argv)); List paths = new ArrayList<>(); - boolean includeSource = true; - boolean includeAst = true; - boolean includePickles = true; - IdGenerator idGenerator = null; + GherkinParser.Builder builder = GherkinParser.builder(); while (!args.isEmpty()) { String arg = args.remove(0).trim(); switch (arg) { case "--no-source": - includeSource = false; + builder.includeSource(false); break; case "--no-ast": - includeAst = false; + builder.includeGherkinDocument(false); break; case "--no-pickles": - includePickles = false; + builder.includePickles(false); break; case "--predictable-ids": - idGenerator = new IdGenerator.Incrementing(); + builder.idGenerator(new IncrementingIdGenerator()); break; default: paths.add(arg); } } - if (idGenerator == null) { - idGenerator = new IdGenerator.UUID(); - } + GherkinParser parser = builder.build(); - Stream messages = Gherkin.fromPaths(paths, includeSource, includeAst, includePickles, idGenerator); try (MessageToNdjsonWriter writer = new MessageToNdjsonWriter(System.out, OBJECT_MAPPER::writeValue)) { - messages.forEach(envelope -> printMessages(writer, envelope)); + paths.stream() + .map(Paths::get) + .map(Main::envelopeFromPath) + .flatMap(parser::parse).forEach(envelope -> printMessages(writer, envelope)); } } @@ -62,4 +63,13 @@ private static void printMessages(MessageToNdjsonWriter writer, Envelope envelop } } + private static Envelope envelopeFromPath(Path path) { + try { + byte[] bytes = Files.readAllBytes(path); + String data = new String(bytes, StandardCharsets.UTF_8); + return Envelope.of(new Source(path.toString(), data, SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + } catch (IOException e) { + throw new GherkinException(e.getMessage(), e); + } + } } diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java index f676df6f99..efa0771ed1 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java @@ -1,5 +1,6 @@ package io.cucumber.gherkin; +import io.cucumber.messages.Messages; import org.junit.Test; import static org.junit.Assert.assertNotNull; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index db529feb88..6260bb53b5 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -11,7 +11,7 @@ public class ParserTest { @Test public void change_default_language() { TokenMatcher matcher = new TokenMatcher("no"); - IdGenerator idGenerator = new IdGenerator.Incrementing(); + IdGenerator idGenerator = new IncrementingIdGenerator(); Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, "test.feature")); GherkinDocument gherkinDocument = parser.parse("Egenskap: i18n support\n", matcher, "test.feature"); diff --git a/messages/java/src/main/java/io/cucumber/messages/IdGenerator.java b/messages/java/src/main/java/io/cucumber/messages/IdGenerator.java index c9d3a14d95..edf7a2f330 100644 --- a/messages/java/src/main/java/io/cucumber/messages/IdGenerator.java +++ b/messages/java/src/main/java/io/cucumber/messages/IdGenerator.java @@ -2,20 +2,4 @@ public interface IdGenerator { String newId(); - - class Incrementing implements IdGenerator { - private int next = 0; - - @Override - public String newId() { - return Integer.toString(next++); - } - } - - class UUID implements IdGenerator { - @Override - public String newId() { - return java.util.UUID.randomUUID().toString(); - } - } } From 603c350a12a2d21f340d458ba941970d76aa8d0f Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 01:52:00 +0100 Subject: [PATCH 45/63] Fix test --- .../test/java/io/cucumber/messages/NdjsonSerializationTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index 74e6d03a1b..ca6ee322e2 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -38,7 +38,7 @@ void writes_source_envelope() throws IOException { MessageToNdjsonWriter writer = createMessageWriter(output); writer.write(Envelope.of(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN))); String json = new String(output.toByteArray(), StandardCharsets.UTF_8); - assertEquals("{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}\n", json); + assertEquals("{\"source\":{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}}\n", json); } @Test From 98df16d008f9448179e7dceff37f70c577dfb4b5 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 01:54:19 +0100 Subject: [PATCH 46/63] Idiomatic java --- .../cucumber/gherkin/GherkinParserTest.java | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java index 6d5767a50f..340c263c94 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java @@ -3,9 +3,6 @@ import io.cucumber.messages.Messages.Source; import org.junit.Test; -import java.util.List; -import java.util.stream.Collectors; - import static io.cucumber.messages.Messages.Envelope; import static io.cucumber.messages.Messages.Feature; import static io.cucumber.messages.Messages.GherkinDocument; @@ -38,15 +35,14 @@ public void use_this_in_readme() { @Test public void provides_access_to_the_ast() { - List envelopes = GherkinParser.builder() + // Get the AST + GherkinDocument gherkinDocument = GherkinParser.builder() .includeSource(false) .includePickles(false) .build() .parse(envelope) - .collect(Collectors.toList()); - - // Get the AST - GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument().get(); + .findFirst().get() + .getGherkinDocument().get(); // Get the Feature node of the AST Feature feature = gherkinDocument.getFeature().get(); @@ -59,15 +55,14 @@ public void provides_access_to_the_ast() { @Test public void provides_access_to_pickles_which_are_compiled_from_the_ast() { - List envelopes = GherkinParser.builder() + // Get the first pickle + Pickle pickle = GherkinParser.builder() .includeSource(false) .includeGherkinDocument(false) .build() .parse(envelope) - .collect(Collectors.toList()); - - // Get the first pickle - Pickle pickle = envelopes.get(0).getPickle().get(); + .findFirst().get() + .getPickle().get(); // Get the first step of the pickle PickleStep step = pickle.getSteps().get(0); @@ -76,14 +71,14 @@ public void provides_access_to_pickles_which_are_compiled_from_the_ast() { @Test public void parses_supplied_source() { - List envelopes = GherkinParser.builder() + GherkinDocument gherkinDocument = GherkinParser.builder() .includeSource(false) .includePickles(false) .build() .parse(envelope) - .collect(Collectors.toList()); + .findFirst().get() + .getGherkinDocument().get(); - GherkinDocument gherkinDocument = envelopes.get(0).getGherkinDocument().get(); Feature feature = gherkinDocument.getFeature().get(); assertEquals("Minimal", feature.getName()); } From 6ca17bf2148703496dd72200bb0b6711be1986f2 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 01:55:03 +0100 Subject: [PATCH 47/63] Naming stuff --- gherkin/java/src/test/java/io/cucumber/gherkin/Main.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java index 61d71f4be6..1301cf7bd1 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java @@ -50,12 +50,13 @@ public static void main(String[] argv) throws IOException { try (MessageToNdjsonWriter writer = new MessageToNdjsonWriter(System.out, OBJECT_MAPPER::writeValue)) { paths.stream() .map(Paths::get) - .map(Main::envelopeFromPath) - .flatMap(parser::parse).forEach(envelope -> printMessages(writer, envelope)); + .map(Main::readEnvelopeFromPath) + .flatMap(parser::parse) + .forEach(envelope -> printMessage(writer, envelope)); } } - private static void printMessages(MessageToNdjsonWriter writer, Envelope envelope) { + private static void printMessage(MessageToNdjsonWriter writer, Envelope envelope) { try { writer.write(envelope); } catch (IOException e) { @@ -63,7 +64,7 @@ private static void printMessages(MessageToNdjsonWriter writer, Envelope envelop } } - private static Envelope envelopeFromPath(Path path) { + private static Envelope readEnvelopeFromPath(Path path) { try { byte[] bytes = Files.readAllBytes(path); String data = new String(bytes, StandardCharsets.UTF_8); From a61cccfacb0f6efdf469d24b4dd086663e7dcaf8 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 02:14:37 +0100 Subject: [PATCH 48/63] Reduce scope of gherkin parser public api --- gherkin/java/gherkin-java.razor | 38 +++++++++---------- .../java/io/cucumber/gherkin/AstNode.java | 2 +- .../main/java/io/cucumber/gherkin/Func.java | 2 +- .../io/cucumber/gherkin/GenerateTokens.java | 2 +- .../io/cucumber/gherkin/GherkinDialect.java | 4 +- .../gherkin/GherkinDialectProvider.java | 6 +-- .../gherkin/GherkinDocumentBuilder.java | 2 +- .../io/cucumber/gherkin/GherkinException.java | 2 +- .../gherkin/GherkinLanguageConstants.java | 2 +- .../java/io/cucumber/gherkin/GherkinLine.java | 2 +- .../io/cucumber/gherkin/GherkinLineSpan.java | 2 +- .../io/cucumber/gherkin/GherkinParser.java | 5 +-- .../io/cucumber/gherkin/IGherkinLine.java | 2 +- .../java/io/cucumber/gherkin/Location.java | 2 +- .../main/java/io/cucumber/gherkin/Parser.java | 38 +++++++++---------- .../io/cucumber/gherkin/ParserException.java | 2 +- .../gherkin/{pickles => }/PickleCompiler.java | 4 +- .../main/java/io/cucumber/gherkin/Stdio.java | 2 +- .../main/java/io/cucumber/gherkin/Token.java | 2 +- .../io/cucumber/gherkin/TokenFormatter.java | 2 +- .../gherkin/TokenFormatterBuilder.java | 2 +- .../io/cucumber/gherkin/TokenMatcher.java | 6 +-- .../io/cucumber/gherkin/TokenScanner.java | 2 +- .../gherkin/GherkinDocumentBuilderTest.java | 1 - 24 files changed, 65 insertions(+), 69 deletions(-) rename gherkin/java/src/main/java/io/cucumber/gherkin/{pickles => }/PickleCompiler.java (99%) diff --git a/gherkin/java/gherkin-java.razor b/gherkin/java/gherkin-java.razor index d6b7edd4a2..9b995fdc24 100644 --- a/gherkin/java/gherkin-java.razor +++ b/gherkin/java/gherkin-java.razor @@ -47,34 +47,34 @@ import java.util.Queue; import static java.util.Arrays.asList; -public class @Model.ParserClassName { - public enum TokenType { +class @Model.ParserClassName { + enum TokenType { None, @foreach(var rule in Model.RuleSet.TokenRules) { @rule.Name.Replace("#", ""), } ; } - public enum RuleType { + enum RuleType { None, @foreach(var rule in Model.RuleSet.Where(r => !r.TempRule)) { @rule.Name.Replace("#", "_"), // @rule.ToString(true) } ; - public static RuleType cast(TokenType tokenType) { + static RuleType cast(TokenType tokenType) { return RuleType.values()[tokenType.ordinal()]; } } private final Builder builder; - public boolean stopAtFirstError; + private boolean stopAtFirstError; static class ParserContext { - public final ITokenScanner tokenScanner; - public final ITokenMatcher tokenMatcher; - public final Queue tokenQueue; - public final List errors; + final ITokenScanner tokenScanner; + final ITokenMatcher tokenMatcher; + final Queue tokenQueue; + final List errors; ParserContext(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, Queue tokenQueue, List errors) { this.tokenScanner = tokenScanner; @@ -84,31 +84,31 @@ public class @Model.ParserClassName { } } - public Parser(Builder builder) { + Parser(Builder builder) { this.builder = builder; } - public T parse(String source, String uri) { + T parse(String source, String uri) { return parse(new StringReader(source), uri); } - public T parse(Reader source, String uri) { + T parse(Reader source, String uri) { return parse(new TokenScanner(source), uri); } - public T parse(ITokenScanner tokenScanner, String uri) { + T parse(ITokenScanner tokenScanner, String uri) { return parse(tokenScanner, new TokenMatcher(), uri); } - public T parse(String source, ITokenMatcher tokenMatcher, String uri) { + T parse(String source, ITokenMatcher tokenMatcher, String uri) { return parse(new StringReader(source), tokenMatcher, uri); } - public T parse(Reader source, ITokenMatcher tokenMatcher, String uri) { + T parse(Reader source, ITokenMatcher tokenMatcher, String uri) { return parse(new TokenScanner(source), tokenMatcher, uri); } - public T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, String uri) { + T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, String uri) { builder.reset(uri); tokenMatcher.reset(); @@ -298,7 +298,7 @@ public class @Model.ParserClassName { } - public interface Builder { + interface Builder { void build(Token token); void startRule(RuleType ruleType); void endRule(RuleType ruleType); @@ -306,11 +306,11 @@ public class @Model.ParserClassName { void reset(String uri); } - public interface ITokenScanner { + interface ITokenScanner { Token read(); } - public interface ITokenMatcher { + interface ITokenMatcher { @foreach(var rule in Model.RuleSet.TokenRules) { @:boolean match_@(rule.Name.Replace("#", ""))(Token token); diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java b/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java index 76cc337665..27490c187d 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/AstNode.java @@ -9,7 +9,7 @@ import static io.cucumber.gherkin.Parser.RuleType; import static io.cucumber.gherkin.Parser.TokenType; -public class AstNode { +class AstNode { private final Map> subItems = new HashMap>(); public final RuleType ruleType; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Func.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Func.java index c4ff0c5438..3db6a7bd41 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Func.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Func.java @@ -1,5 +1,5 @@ package io.cucumber.gherkin; -public interface Func { +interface Func { V call(); } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java index 23dc7a59f8..e358dfd10a 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java @@ -6,7 +6,7 @@ import java.io.Reader; import java.nio.charset.StandardCharsets; -public class GenerateTokens { +public final class GenerateTokens { public static void main(String[] args) throws FileNotFoundException { TokenFormatterBuilder builder = new TokenFormatterBuilder(); Parser parser = new Parser<>(builder); diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java index 01088adb22..79467b387f 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java @@ -7,9 +7,9 @@ import java.util.ArrayList; import java.util.List; -public class GherkinDialect { +public final class GherkinDialect { private final JsonObject keywords; - private String language; + private final String language; public GherkinDialect(String language, JsonObject keywords) { this.language = language; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java index e4a77891f5..76b0b7e69e 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java @@ -14,8 +14,8 @@ import static java.util.Collections.sort; import static java.util.Collections.unmodifiableList; -public class GherkinDialectProvider implements IGherkinDialectProvider { - private static JsonObject DIALECTS; +public final class GherkinDialectProvider { + private static final JsonObject DIALECTS; private final String defaultDialectName; public static final String JSON_PATH = "/io/cucumber/gherkin/gherkin-languages.json"; @@ -40,7 +40,6 @@ public GherkinDialect getDefaultDialect() { return getDialect(defaultDialectName, null); } - @Override public GherkinDialect getDialect(String language, Location location) { JsonValue languageObject = DIALECTS.get(language); if (languageObject == null) { @@ -50,7 +49,6 @@ public GherkinDialect getDialect(String language, Location location) { return new GherkinDialect(language, languageObject.asObject()); } - @Override public List getLanguages() { List languages = new ArrayList<>(DIALECTS.names()); sort(languages); diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index beca7eb5c1..4d364ac41a 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -28,7 +28,7 @@ import static io.cucumber.messages.Messages.TableRow; import static io.cucumber.messages.Messages.Tag; -public class GherkinDocumentBuilder implements Builder { +class GherkinDocumentBuilder implements Builder { private final List comments = new ArrayList<>(); private final IdGenerator idGenerator; private String uri; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinException.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinException.java index 2f45ab9ecf..15c0f06029 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinException.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinException.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -public class GherkinException extends RuntimeException { +class GherkinException extends RuntimeException { public GherkinException(String message, Throwable cause) { super(message, cause); } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLanguageConstants.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLanguageConstants.java index f45df3d1c5..03105f31a8 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLanguageConstants.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLanguageConstants.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -public interface GherkinLanguageConstants { +interface GherkinLanguageConstants { String TAG_PREFIX = "@"; String COMMENT_PREFIX = "#"; String TITLE_KEYWORD_SEPARATOR = ":"; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java index 5c0a01505d..9494c7b359 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLine.java @@ -13,7 +13,7 @@ import static io.cucumber.gherkin.StringUtils.symbolCount; import static io.cucumber.gherkin.StringUtils.trim; -public class GherkinLine implements IGherkinLine { +class GherkinLine implements IGherkinLine { // TODO: set this to 0 when/if we change to 0-indexed columns private static final int OFFSET = 1; private final String lineText; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLineSpan.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLineSpan.java index 60e0fee695..f103e602ad 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLineSpan.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinLineSpan.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -public class GherkinLineSpan { +class GherkinLineSpan { // One-based line position public final int column; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index 0c9cea299e..fb961d16a3 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -1,6 +1,5 @@ package io.cucumber.gherkin; -import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; import java.util.ArrayList; @@ -19,9 +18,9 @@ /** * Main entry point for the Gherkin library */ -public class GherkinParser { +public final class GherkinParser { - public static class Builder { + public final static class Builder { private boolean includeSource = true; private boolean includeGherkinDocument = true; private boolean includePickles = true; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinLine.java b/gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinLine.java index cb79725e5d..444159047d 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinLine.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinLine.java @@ -2,7 +2,7 @@ import java.util.List; -public interface IGherkinLine { +interface IGherkinLine { int indent(); void detach(); diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Location.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Location.java index 2035a9e09c..192e1682e2 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Location.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Location.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -public class Location { +class Location { private final int line; private final int column; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java index 4bc0baff5d..d8a3a77684 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Parser.java @@ -16,8 +16,8 @@ import static java.util.Arrays.asList; -public class Parser { - public enum TokenType { +class Parser { + enum TokenType { None, EOF, Empty, @@ -36,7 +36,7 @@ public enum TokenType { ; } - public enum RuleType { + enum RuleType { None, _EOF, // #EOF _Empty, // #Empty @@ -72,20 +72,20 @@ public enum RuleType { Description, // Description! := #Other+ ; - public static RuleType cast(TokenType tokenType) { + static RuleType cast(TokenType tokenType) { return RuleType.values()[tokenType.ordinal()]; } } private final Builder builder; - public boolean stopAtFirstError; + private boolean stopAtFirstError; static class ParserContext { - public final ITokenScanner tokenScanner; - public final ITokenMatcher tokenMatcher; - public final Queue tokenQueue; - public final List errors; + final ITokenScanner tokenScanner; + final ITokenMatcher tokenMatcher; + final Queue tokenQueue; + final List errors; ParserContext(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, Queue tokenQueue, List errors) { this.tokenScanner = tokenScanner; @@ -95,31 +95,31 @@ static class ParserContext { } } - public Parser(Builder builder) { + Parser(Builder builder) { this.builder = builder; } - public T parse(String source, String uri) { + T parse(String source, String uri) { return parse(new StringReader(source), uri); } - public T parse(Reader source, String uri) { + T parse(Reader source, String uri) { return parse(new TokenScanner(source), uri); } - public T parse(ITokenScanner tokenScanner, String uri) { + T parse(ITokenScanner tokenScanner, String uri) { return parse(tokenScanner, new TokenMatcher(), uri); } - public T parse(String source, ITokenMatcher tokenMatcher, String uri) { + T parse(String source, ITokenMatcher tokenMatcher, String uri) { return parse(new StringReader(source), tokenMatcher, uri); } - public T parse(Reader source, ITokenMatcher tokenMatcher, String uri) { + T parse(Reader source, ITokenMatcher tokenMatcher, String uri) { return parse(new TokenScanner(source), tokenMatcher, uri); } - public T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, String uri) { + T parse(ITokenScanner tokenScanner, ITokenMatcher tokenMatcher, String uri) { builder.reset(uri); tokenMatcher.reset(); @@ -4759,7 +4759,7 @@ private boolean lookahead_1(ParserContext context, Token currentToken) { return match; } - public interface Builder { + interface Builder { void build(Token token); void startRule(RuleType ruleType); void endRule(RuleType ruleType); @@ -4767,11 +4767,11 @@ public interface Builder { void reset(String uri); } - public interface ITokenScanner { + interface ITokenScanner { Token read(); } - public interface ITokenMatcher { + interface ITokenMatcher { boolean match_EOF(Token token); boolean match_Empty(Token token); boolean match_Comment(Token token); diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/ParserException.java b/gherkin/java/src/main/java/io/cucumber/gherkin/ParserException.java index 6770a8dea2..2ec08a39b0 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/ParserException.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/ParserException.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.stream.Collectors; -public class ParserException extends RuntimeException { +class ParserException extends RuntimeException { public final Location location; protected ParserException(String message) { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java b/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java similarity index 99% rename from gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java rename to gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java index f76f153272..8e87c7c7fb 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/pickles/PickleCompiler.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java @@ -1,4 +1,4 @@ -package io.cucumber.gherkin.pickles; +package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; @@ -34,7 +34,7 @@ import static java.util.Collections.singletonList; import static java.util.Collections.unmodifiableList; -public class PickleCompiler { +class PickleCompiler { private final IdGenerator idGenerator; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Stdio.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Stdio.java index 825982566a..ca2c70a64e 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Stdio.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Stdio.java @@ -4,7 +4,7 @@ import java.io.PrintWriter; import java.nio.charset.StandardCharsets; -public class Stdio { +class Stdio { /** * UTF-8 STDOUT */ diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/Token.java b/gherkin/java/src/main/java/io/cucumber/gherkin/Token.java index 8006d2a0fb..ef9200cd5e 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/Token.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/Token.java @@ -2,7 +2,7 @@ import java.util.List; -public class Token { +class Token { public final IGherkinLine line; public Parser.TokenType matchedType; public String matchedKeyword; diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatter.java b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatter.java index aeefbc0629..2a76af1d0e 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatter.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatter.java @@ -2,7 +2,7 @@ import static java.util.stream.Collectors.joining; -public class TokenFormatter { +class TokenFormatter { public String formatToken(Token token) { if (token.isEOF()) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java index 247badaa17..8c6bfa29ce 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenFormatterBuilder.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -public class TokenFormatterBuilder implements Parser.Builder { +class TokenFormatterBuilder implements Parser.Builder { private final TokenFormatter formatter = new TokenFormatter(); private final StringBuilder tokensTextBuilder = new StringBuilder(); diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenMatcher.java b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenMatcher.java index 7c53b56586..4292c3e8b7 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenMatcher.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenMatcher.java @@ -9,14 +9,14 @@ import static io.cucumber.gherkin.Parser.ITokenMatcher; import static io.cucumber.gherkin.Parser.TokenType; -public class TokenMatcher implements ITokenMatcher { +class TokenMatcher implements ITokenMatcher { private static final Pattern LANGUAGE_PATTERN = Pattern.compile("^\\s*#\\s*language\\s*:\\s*([a-zA-Z\\-_]+)\\s*$"); - private final IGherkinDialectProvider dialectProvider; + private final GherkinDialectProvider dialectProvider; private GherkinDialect currentDialect; private String activeDocStringSeparator = null; private int indentToRemove = 0; - public TokenMatcher(IGherkinDialectProvider dialectProvider) { + public TokenMatcher(GherkinDialectProvider dialectProvider) { this.dialectProvider = dialectProvider; reset(); } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenScanner.java b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenScanner.java index f1227570a7..1b2f6c36f0 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/TokenScanner.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/TokenScanner.java @@ -13,7 +13,7 @@ * If the scanner sees a # language header, it will reconfigure itself dynamically to look for * Gherkin keywords for the associated language. The keywords are defined in gherkin-languages.json.

*/ -public class TokenScanner implements Parser.ITokenScanner { +class TokenScanner implements Parser.ITokenScanner { private final BufferedReader reader; private int lineNumber; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index 658dc64f83..5a909d0134 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -1,6 +1,5 @@ package io.cucumber.gherkin; -import io.cucumber.gherkin.pickles.PickleCompiler; import io.cucumber.messages.IdGenerator; import org.junit.Test; From f600f14eb4c95b45b008ae615dfffbba43031c09 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 02:25:34 +0100 Subject: [PATCH 49/63] Idiomatic java --- .../io/cucumber/gherkin/GherkinParser.java | 38 ++++++++++--------- .../gherkin/IGherkinDialectProvider.java | 11 ------ 2 files changed, 21 insertions(+), 28 deletions(-) delete mode 100644 gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinDialectProvider.java diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index fb961d16a3..2542ba6f0c 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -1,10 +1,13 @@ package io.cucumber.gherkin; +import io.cucumber.gherkin.ParserException.CompositeParserException; import io.cucumber.messages.IdGenerator; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; import java.util.stream.Stream; import static io.cucumber.messages.Messages.Envelope; @@ -14,6 +17,7 @@ import static io.cucumber.messages.Messages.Source; import static io.cucumber.messages.Messages.SourceReference; import static java.util.Objects.requireNonNull; +import static java.util.stream.Collectors.toCollection; /** * Main entry point for the Gherkin library @@ -103,30 +107,30 @@ private List parseSource(Source source) { if (gherkinDocument == null) { gherkinDocument = parser.parse(data, uri); } - PickleCompiler pickleCompiler = new PickleCompiler(idGenerator); - List pickles = pickleCompiler.compile(gherkinDocument, uri); - for (Pickle pickle : pickles) { - messages.add(Envelope.of(pickle)); - } - } - } catch (ParserException.CompositeParserException e) { - for (ParserException error : e.errors) { - addParseError(messages, error, uri); + new PickleCompiler(idGenerator) + .compile(gherkinDocument, uri) + .stream() + .map(Envelope::of) + .collect(toCollection(() -> messages)); } - } catch (ParserException e) { - addParseError(messages, e, uri); + } catch (CompositeParserException composite) { + composite.errors.stream() + .map(error -> createParseError(error, uri)) + .collect(toCollection(() -> messages)); + } catch (ParserException error) { + messages.add(createParseError(error, uri)); } - return messages; } - private void addParseError(List messages, ParserException e, String uri) { + private Envelope createParseError(ParserException e, String uri) { long line = e.location.getLine(); long column = e.location.getColumn(); - ParseError parseError = new ParseError( + return Envelope.of(new ParseError( new SourceReference( uri, - null, null, + null, + null, // We want 0 values not to be serialised, which is why we set them to null // This is a legacy requirement brought over from old protobuf behaviour new io.cucumber.messages.Messages.Location( @@ -135,7 +139,7 @@ private void addParseError(List messages, ParserException e, String ur ) ), e.getMessage() - ); - messages.add(Envelope.of(parseError)); + )); } + } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinDialectProvider.java b/gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinDialectProvider.java deleted file mode 100644 index c75fe81630..0000000000 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/IGherkinDialectProvider.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.cucumber.gherkin; - -import java.util.List; - -public interface IGherkinDialectProvider { - GherkinDialect getDefaultDialect(); - - GherkinDialect getDialect(String language, Location location); - - List getLanguages(); -} From 40d3ef40602506e59ba7c270fae3500354351219 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 02:33:21 +0100 Subject: [PATCH 50/63] Always include parse errors No parsing would happen if neither pickles nor gherkin document were to be included in the messages stream. --- .../io/cucumber/gherkin/GherkinParser.java | 24 ++++++-------- .../cucumber/gherkin/GherkinParserTest.java | 32 ++++++++++++++++++- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index 2542ba6f0c..3b3587304d 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -4,16 +4,13 @@ import io.cucumber.messages.IdGenerator; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import java.util.stream.Stream; import static io.cucumber.messages.Messages.Envelope; import static io.cucumber.messages.Messages.GherkinDocument; import static io.cucumber.messages.Messages.ParseError; -import static io.cucumber.messages.Messages.Pickle; import static io.cucumber.messages.Messages.Source; import static io.cucumber.messages.Messages.SourceReference; import static java.util.Objects.requireNonNull; @@ -30,7 +27,7 @@ public final static class Builder { private boolean includePickles = true; private IdGenerator idGenerator = () -> UUID.randomUUID().toString(); - private Builder(){ + private Builder() { } @@ -54,9 +51,10 @@ public Builder idGenerator(IdGenerator idGenerator) { return this; } - public GherkinParser build(){ + public GherkinParser build() { return new GherkinParser(includeSource, includeGherkinDocument, includePickles, idGenerator); } + } private final boolean includeSource; @@ -64,14 +62,15 @@ public GherkinParser build(){ private final boolean includePickles; private final IdGenerator idGenerator; - private GherkinParser(boolean includeSource, boolean includeGherkinDocument, boolean includePickles, IdGenerator idGenerator) { + private GherkinParser(boolean includeSource, boolean includeGherkinDocument, boolean includePickles, + IdGenerator idGenerator) { this.includeSource = includeSource; this.includeGherkinDocument = includeGherkinDocument; this.includePickles = includePickles; this.idGenerator = requireNonNull(idGenerator); } - public static Builder builder(){ + public static Builder builder() { return new Builder(); } @@ -83,8 +82,8 @@ public Stream parse(Envelope envelope) { } envelope.getSource() - .map(this::parseSource) - .ifPresent(messages::addAll); + .map(this::parseSource) + .ifPresent(messages::addAll); return messages.stream(); } @@ -97,16 +96,11 @@ private List parseSource(Source source) { Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, uri)); try { - GherkinDocument gherkinDocument = null; - + GherkinDocument gherkinDocument = parser.parse(data, uri); if (includeGherkinDocument) { - gherkinDocument = parser.parse(data, uri); messages.add(Envelope.of(gherkinDocument)); } if (includePickles) { - if (gherkinDocument == null) { - gherkinDocument = parser.parse(data, uri); - } new PickleCompiler(idGenerator) .compile(gherkinDocument, uri) .stream() diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java index 340c263c94..366b16a56d 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java @@ -1,8 +1,13 @@ package io.cucumber.gherkin; +import io.cucumber.messages.Messages; +import io.cucumber.messages.Messages.ParseError; import io.cucumber.messages.Messages.Source; +import io.cucumber.messages.Messages.SourceReference; import org.junit.Test; +import java.util.Optional; + import static io.cucumber.messages.Messages.Envelope; import static io.cucumber.messages.Messages.Feature; import static io.cucumber.messages.Messages.GherkinDocument; @@ -11,9 +16,11 @@ import static io.cucumber.messages.Messages.Scenario; import static io.cucumber.messages.Messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class GherkinParserTest { - final Envelope envelope = Envelope.of(new Source("test.feature", + final Envelope envelope = Envelope.of(new Source("minimal.feature", "Feature: Minimal\n" + "\n" + " Scenario: minimalistic\n" + @@ -82,4 +89,27 @@ public void parses_supplied_source() { Feature feature = gherkinDocument.getFeature().get(); assertEquals("Minimal", feature.getName()); } + + @Test + public void parser_always_includes_errors() { + Envelope singleParseError = Envelope.of(new Source("single_parser_error.feature", + "\n" + + "invalid line here\n" + + "\n" + + "Feature: Single parser error\n" + + "\n" + + " Scenario: minimalistic\n" + + " Given the minimalism\n", + TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + Optional parseError = GherkinParser.builder() + .includeSource(false) + .includePickles(false) + .includeGherkinDocument(false) + .build() + .parse(singleParseError) + .findFirst().get() + .getParseError(); + + assertTrue(parseError.isPresent()); + } } From 1a2c750d4f118af4a8bf05fd41bd862c513230a9 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 02:36:22 +0100 Subject: [PATCH 51/63] Reuse pickle compiler --- .../src/main/java/io/cucumber/gherkin/GherkinParser.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index 3b3587304d..ad284cecd6 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -61,6 +61,7 @@ public GherkinParser build() { private final boolean includeGherkinDocument; private final boolean includePickles; private final IdGenerator idGenerator; + private final PickleCompiler pickleCompiler; private GherkinParser(boolean includeSource, boolean includeGherkinDocument, boolean includePickles, IdGenerator idGenerator) { @@ -68,6 +69,7 @@ private GherkinParser(boolean includeSource, boolean includeGherkinDocument, boo this.includeGherkinDocument = includeGherkinDocument; this.includePickles = includePickles; this.idGenerator = requireNonNull(idGenerator); + this.pickleCompiler = new PickleCompiler(idGenerator); } public static Builder builder() { @@ -101,8 +103,7 @@ private List parseSource(Source source) { messages.add(Envelope.of(gherkinDocument)); } if (includePickles) { - new PickleCompiler(idGenerator) - .compile(gherkinDocument, uri) + pickleCompiler.compile(gherkinDocument, uri) .stream() .map(Envelope::of) .collect(toCollection(() -> messages)); From 42f6c3ca4e792b599099debd8ace09ef493a7a36 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 02:38:52 +0100 Subject: [PATCH 52/63] Idiomatic java --- .../java/io/cucumber/gherkin/GherkinParser.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index ad284cecd6..6d858d86a1 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -84,18 +84,20 @@ public Stream parse(Envelope envelope) { } envelope.getSource() - .map(this::parseSource) + .map(this::parse) .ifPresent(messages::addAll); return messages.stream(); } - private List parseSource(Source source) { - String uri = source.getUri(); - String data = source.getData(); - List messages = new ArrayList<>(); + private List parse(Source source) { + return parse(source.getUri(), source.getData()); + } - Parser parser = new Parser<>(new GherkinDocumentBuilder(idGenerator, uri)); + private List parse(String uri, String data) { + List messages = new ArrayList<>(); + GherkinDocumentBuilder documentBuilder = new GherkinDocumentBuilder(idGenerator, uri); + Parser parser = new Parser<>(documentBuilder); try { GherkinDocument gherkinDocument = parser.parse(data, uri); From efeee2d219fd30985ad1b49502d26c4e36fe6d69 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 03:07:41 +0100 Subject: [PATCH 53/63] Signal that Messages class is generated --- messages/java/Makefile | 1 + messages/java/src/main/java/io/cucumber/messages/Messages.java | 1 + 2 files changed, 2 insertions(+) diff --git a/messages/java/Makefile b/messages/java/Makefile index 05a3ae5fd2..92fe775451 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -14,6 +14,7 @@ src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/s echo "import static java.util.Collections.unmodifiableList;" >> $@ echo "import static java.util.Objects.requireNonNull;" >> $@ echo >> $@ + echo "// Generated code" >> $@ echo "@SuppressWarnings(\"unused\")" >> $@ echo "public final class Messages {" >> $@ echo >> $@ diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java index b5fcb5734b..2a428a89b9 100644 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ b/messages/java/src/main/java/io/cucumber/messages/Messages.java @@ -7,6 +7,7 @@ import static java.util.Collections.unmodifiableList; import static java.util.Objects.requireNonNull; +// Generated code @SuppressWarnings("unused") public final class Messages { From 7e8b831ba2984dab672d53e162b4cd87763090ca Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 15:12:16 +0100 Subject: [PATCH 54/63] Nitpicking --- .../io/cucumber/messages/NdjsonToMessageIterable.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 9bafcc4920..bb04f56ffc 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -18,17 +18,16 @@ public final class NdjsonToMessageIterable implements Iterable, AutoCloseable { private final BufferedReader reader; private final Deserializer deserializer; - private Envelope next; public NdjsonToMessageIterable(InputStream inputStream, Deserializer deserializer) { this(new InputStreamReader(inputStream, StandardCharsets.UTF_8), deserializer); } - public NdjsonToMessageIterable(Reader reader, Deserializer deserializer) { + private NdjsonToMessageIterable(Reader reader, Deserializer deserializer) { this(new BufferedReader(reader), deserializer); } - public NdjsonToMessageIterable(BufferedReader reader, Deserializer deserializer) { + private NdjsonToMessageIterable(BufferedReader reader, Deserializer deserializer) { this.reader = reader; this.deserializer = deserializer; } @@ -36,6 +35,8 @@ public NdjsonToMessageIterable(BufferedReader reader, Deserializer deserializer) @Override public Iterator iterator() { return new Iterator() { + private Envelope next; + @Override public boolean hasNext() { try { @@ -72,7 +73,7 @@ public void remove() { @Override public void close() throws IOException { - this.reader.close(); + reader.close(); } @FunctionalInterface From d9044da609746714fd8ab9bf0ae6ca8158795b8a Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 15:16:37 +0100 Subject: [PATCH 55/63] Null checks --- .../cucumber/messages/MessageToNdjsonWriter.java | 12 ++++++++++-- .../messages/NdjsonToMessageIterable.java | 16 +++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java index 107078a595..9f712244fd 100644 --- a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java +++ b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java @@ -8,20 +8,28 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; +import static java.util.Objects.requireNonNull; + public final class MessageToNdjsonWriter implements AutoCloseable { private final Writer writer; private final Serializer serializer; public MessageToNdjsonWriter(OutputStream outputStream, Serializer serializer) { - this(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8), serializer); + this( + new OutputStreamWriter( + requireNonNull(outputStream), + StandardCharsets.UTF_8), + requireNonNull(serializer) + ); } - public MessageToNdjsonWriter(Writer writer, Serializer serializer) { + private MessageToNdjsonWriter(Writer writer, Serializer serializer) { this.writer = writer; this.serializer = serializer; } public void write(Envelope message) throws IOException { + requireNonNull(message); serializer.writeValue(writer, message); writer.write("\n"); writer.flush(); diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index bb04f56ffc..65c4688a5b 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -10,6 +10,8 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; +import static java.util.Objects.requireNonNull; + /** * Iterates over messages read from a stream. Client code should not depend on this class * directly, but rather on a {@code Iterable} object. @@ -20,7 +22,12 @@ public final class NdjsonToMessageIterable implements Iterable, AutoCl private final Deserializer deserializer; public NdjsonToMessageIterable(InputStream inputStream, Deserializer deserializer) { - this(new InputStreamReader(inputStream, StandardCharsets.UTF_8), deserializer); + this( + new InputStreamReader( + requireNonNull(inputStream), + StandardCharsets.UTF_8), + requireNonNull(deserializer) + ); } private NdjsonToMessageIterable(Reader reader, Deserializer deserializer) { @@ -41,7 +48,8 @@ public Iterator iterator() { public boolean hasNext() { try { String line = reader.readLine(); - if (line == null) return false; + if (line == null) + return false; if (line.trim().equals("")) { return hasNext(); } @@ -59,7 +67,8 @@ public boolean hasNext() { @Override public Envelope next() { if (next == null) { - throw new IllegalStateException("next() should only be called after a call to hasNext() that returns true"); + throw new IllegalStateException( + "next() should only be called after a call to hasNext() that returns true"); } return next; } @@ -82,4 +91,5 @@ public interface Deserializer { Envelope readValue(String json) throws IOException; } + } From a4dc2693594636bfb8d1f45aa8a389a4c92f3bce Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 15:19:46 +0100 Subject: [PATCH 56/63] Null checks --- .../main/java/io/cucumber/gherkin/GherkinDialect.java | 7 +++++-- .../io/cucumber/gherkin/GherkinDialectProvider.java | 9 +++++++-- .../main/java/io/cucumber/gherkin/GherkinParser.java | 2 ++ .../cucumber/htmlformatter/MessagesToHtmlWriter.java | 11 +++++++++-- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java index 79467b387f..31496abfd3 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java @@ -7,13 +7,15 @@ import java.util.ArrayList; import java.util.List; +import static java.util.Objects.requireNonNull; + public final class GherkinDialect { private final JsonObject keywords; private final String language; public GherkinDialect(String language, JsonObject keywords) { - this.language = language; - this.keywords = keywords; + this.language = requireNonNull(language); + this.keywords = requireNonNull(keywords); } public List getFeatureKeywords() { @@ -89,5 +91,6 @@ public List getButKeywords() { public String getLanguage() { return language; } + } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java index 76b0b7e69e..eff14486f1 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java @@ -13,6 +13,7 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Collections.sort; import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; public final class GherkinDialectProvider { private static final JsonObject DIALECTS; @@ -21,7 +22,8 @@ public final class GherkinDialectProvider { public static final String JSON_PATH = "/io/cucumber/gherkin/gherkin-languages.json"; static { - try (Reader reader = new InputStreamReader(GherkinDialectProvider.class.getResourceAsStream(JSON_PATH), UTF_8)) { + try (Reader reader = new InputStreamReader(GherkinDialectProvider.class.getResourceAsStream(JSON_PATH), + UTF_8)) { DIALECTS = Json.parse(reader).asObject(); } catch (IOException e) { throw new GherkinException("Unable to parse " + JSON_PATH, e); @@ -29,7 +31,7 @@ public final class GherkinDialectProvider { } public GherkinDialectProvider(String defaultDialectName) { - this.defaultDialectName = defaultDialectName; + this.defaultDialectName = requireNonNull(defaultDialectName); } public GherkinDialectProvider() { @@ -41,6 +43,8 @@ public GherkinDialect getDefaultDialect() { } public GherkinDialect getDialect(String language, Location location) { + requireNonNull(language); + JsonValue languageObject = DIALECTS.get(language); if (languageObject == null) { throw new ParserException.NoSuchLanguageException(language, location); @@ -54,4 +58,5 @@ public List getLanguages() { sort(languages); return unmodifiableList(languages); } + } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index 6d858d86a1..45bd2ff167 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -77,6 +77,8 @@ public static Builder builder() { } public Stream parse(Envelope envelope) { + requireNonNull(envelope); + List messages = new ArrayList<>(); if (includeSource) { diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index aedf9cc700..ae560a0fe5 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -28,7 +28,12 @@ public final class MessagesToHtmlWriter implements AutoCloseable { private boolean streamClosed = false; public MessagesToHtmlWriter(OutputStream outputStream, Serializer serializer) throws IOException { - this(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8), serializer); + this( + new OutputStreamWriter( + requireNonNull(outputStream), + StandardCharsets.UTF_8), + requireNonNull(serializer) + ); } public MessagesToHtmlWriter(Writer writer, Serializer serializer) throws IOException { @@ -101,7 +106,8 @@ public void close() throws IOException { streamClosed = true; } - private static void writeTemplateBetween(Writer writer, String template, String begin, String end) throws IOException { + private static void writeTemplateBetween(Writer writer, String template, String begin, String end) + throws IOException { int beginIndex = begin == null ? 0 : template.indexOf(begin) + begin.length(); int endIndex = end == null ? template.length() : template.indexOf(end); writer.write(template.substring(beginIndex, endIndex)); @@ -131,4 +137,5 @@ public interface Serializer { void writeValue(Writer writer, Envelope value) throws IOException; } + } From 81931511dcac4233e00fb556c12d519554e77f44 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 15:45:40 +0100 Subject: [PATCH 57/63] Remove GenerateTokens from gherkin public api --- gherkin/java/bin/gherkin-generate-tokens | 2 +- .../{main => test}/java/io/cucumber/gherkin/GenerateTokens.java | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename gherkin/java/src/{main => test}/java/io/cucumber/gherkin/GenerateTokens.java (100%) diff --git a/gherkin/java/bin/gherkin-generate-tokens b/gherkin/java/bin/gherkin-generate-tokens index af47d2b7e4..1eb1fa5395 100755 --- a/gherkin/java/bin/gherkin-generate-tokens +++ b/gherkin/java/bin/gherkin-generate-tokens @@ -12,5 +12,5 @@ if [ ! -f "${DIR}/classpath.txt" ] || [ "${DIR}/../pom.xml" -nt "${DIR}/classpat fi java \ - -classpath "$(cat "${DIR}/classpath.txt"):${DIR}/../target/classes" \ + -classpath "$(cat "${DIR}/classpath.txt"):${DIR}/../target/classes:${DIR}/../target/test-classes" \ io.cucumber.gherkin.GenerateTokens $* diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GenerateTokens.java similarity index 100% rename from gherkin/java/src/main/java/io/cucumber/gherkin/GenerateTokens.java rename to gherkin/java/src/test/java/io/cucumber/gherkin/GenerateTokens.java From 3df4d86f1df3ffdb0a7ba7d0b752c4eb18bcdd0a Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 15:57:05 +0100 Subject: [PATCH 58/63] Reduce html writer public api --- .../htmlformatter/MessagesToHtmlWriter.java | 9 +++++--- .../MessagesToHtmlWriterTest.java | 21 ++++++------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index ae560a0fe5..421c920437 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -36,7 +36,7 @@ public MessagesToHtmlWriter(OutputStream outputStream, Serializer serializer) th ); } - public MessagesToHtmlWriter(Writer writer, Serializer serializer) throws IOException { + private MessagesToHtmlWriter(Writer writer, Serializer serializer) throws IOException { this.writer = writer; this.serializer = serializer; this.template = readResource("index.mustache.html"); @@ -102,8 +102,11 @@ public void close() throws IOException { writePostMessage(); postMessageWritten = true; } - writer.close(); - streamClosed = true; + try { + writer.close(); + } finally { + streamClosed = true; + } } private static void writeTemplateBetween(Writer writer, String template, String begin, String end) diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index fca676ecb3..39643509d9 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -43,9 +43,7 @@ void it_writes_no_message_to_html() throws IOException { @Test void it_throws_when_writing_after_close() throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); - BufferedWriter bw = new BufferedWriter(osw); - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bytes, serializer); messagesToHtmlWriter.close(); assertThrows(IOException.class, () -> messagesToHtmlWriter.write(null)); } @@ -53,28 +51,23 @@ void it_throws_when_writing_after_close() throws IOException { @Test void it_can_be_closed_twice() throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); - BufferedWriter bw = new BufferedWriter(osw); - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bytes, serializer); messagesToHtmlWriter.close(); assertDoesNotThrow(messagesToHtmlWriter::close); } @Test void it_is_idempotent_under_failure_to_close() throws IOException { - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); - BufferedWriter bw = new BufferedWriter(osw) { - + ByteArrayOutputStream bytes = new ByteArrayOutputStream() { @Override public void close() throws IOException { throw new IOException("Can't close this"); } }; - MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer); + MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bytes, serializer); assertThrows(IOException.class, messagesToHtmlWriter::close); byte[] before = bytes.toByteArray(); - assertThrows(IOException.class, messagesToHtmlWriter::close); + assertDoesNotThrow(messagesToHtmlWriter::close); byte[] after = bytes.toByteArray(); assertArrayEquals(before, after); } @@ -93,9 +86,7 @@ void it_writes_two_messages_separated_by_a_comma() throws IOException { private static String renderAsHtml(Envelope... messages) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(bytes, UTF_8); - BufferedWriter bw = new BufferedWriter(osw); - try (MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bw, serializer)) { + try (MessagesToHtmlWriter messagesToHtmlWriter = new MessagesToHtmlWriter(bytes, serializer)) { for (Envelope message : messages) { messagesToHtmlWriter.write(message); } From 2a363c838973527352f80b20dcf024397d927a73 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sun, 23 Jan 2022 16:00:03 +0100 Subject: [PATCH 59/63] Update readmes --- gherkin/CHANGELOG.md | 3 ++- html-formatter/CHANGELOG.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gherkin/CHANGELOG.md b/gherkin/CHANGELOG.md index e0a82ebdfd..5e3aec2fd2 100644 --- a/gherkin/CHANGELOG.md +++ b/gherkin/CHANGELOG.md @@ -13,7 +13,8 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt ### Changed -* [Java] the `Parser.parse` methods now require an `uri` parameter to be passed in. +* [Java] Replaced `Gherkin` with a `GherkinParser` that uses a builder to construct. +* [Java] Made all internal classes package private ### Deprecated diff --git a/html-formatter/CHANGELOG.md b/html-formatter/CHANGELOG.md index c5c4cbf5b1..43c7cc374f 100644 --- a/html-formatter/CHANGELOG.md +++ b/html-formatter/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Use `auto` theme to automatically render with light or dark theme per platform preference. ### Changed +- [Java] Replaced Jackson with generic serializer in `MessagesToHtmlWriter`. ### Deprecated From 890ca1c5078dd353d367912916ffc7b353b1843c Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sat, 29 Jan 2022 02:25:45 +0100 Subject: [PATCH 60/63] Generate messages into separate files --- messages/java/Makefile | 29 +- messages/java/pom.xml | 21 +- .../java/io/cucumber/messages/Attachment.java | 117 + .../messages/AttachmentContentEncoding.java | 34 + .../java/io/cucumber/messages/Background.java | 97 + .../java/io/cucumber/messages/Ci.java | 77 + .../java/io/cucumber/messages/Comment.java | 57 + .../java/io/cucumber/messages/DataTable.java | 57 + .../java/io/cucumber/messages/DocString.java | 77 + .../java/io/cucumber/messages/Duration.java | 57 + .../java/io/cucumber/messages/Envelope.java | 581 +++ .../java/io/cucumber/messages/Examples.java | 117 + .../java/io/cucumber/messages/Feature.java | 107 + .../io/cucumber/messages/FeatureChild.java | 91 + .../io/cucumber/messages/GherkinDocument.java | 67 + .../java/io/cucumber/messages/Git.java | 77 + .../java/io/cucumber/messages/Group.java | 67 + .../java/io/cucumber/messages/Hook.java | 67 + .../java/io/cucumber/messages/JavaMethod.java | 67 + .../messages/JavaStackTraceElement.java | 67 + .../java/io/cucumber/messages/Location.java | 57 + .../java/io/cucumber/messages/Meta.java | 97 + .../io/cucumber/messages/ParameterType.java | 87 + .../java/io/cucumber/messages/ParseError.java | 57 + .../java/io/cucumber/messages/Pickle.java | 107 + .../io/cucumber/messages/PickleDocString.java | 57 + .../java/io/cucumber/messages/PickleStep.java | 77 + .../cucumber/messages/PickleStepArgument.java | 71 + .../io/cucumber/messages/PickleTable.java | 47 + .../io/cucumber/messages/PickleTableCell.java | 47 + .../io/cucumber/messages/PickleTableRow.java | 47 + .../java/io/cucumber/messages/PickleTag.java | 57 + .../java/io/cucumber/messages/Product.java | 57 + .../java/io/cucumber/messages/Rule.java | 107 + .../java/io/cucumber/messages/RuleChild.java | 71 + .../java/io/cucumber/messages/Scenario.java | 117 + .../java/io/cucumber/messages/Source.java | 67 + .../io/cucumber/messages/SourceMediaType.java | 34 + .../io/cucumber/messages/SourceReference.java | 113 + .../java/io/cucumber/messages/Step.java | 97 + .../io/cucumber/messages/StepDefinition.java | 67 + .../messages/StepDefinitionPattern.java | 57 + .../messages/StepDefinitionPatternType.java | 34 + .../cucumber/messages/StepMatchArgument.java | 57 + .../messages/StepMatchArgumentsList.java | 47 + .../java/io/cucumber/messages/TableCell.java | 57 + .../java/io/cucumber/messages/TableRow.java | 67 + .../java/io/cucumber/messages/Tag.java | 67 + .../java/io/cucumber/messages/TestCase.java | 67 + .../cucumber/messages/TestCaseFinished.java | 67 + .../io/cucumber/messages/TestCaseStarted.java | 77 + .../io/cucumber/messages/TestRunFinished.java | 67 + .../io/cucumber/messages/TestRunStarted.java | 47 + .../java/io/cucumber/messages/TestStep.java | 87 + .../cucumber/messages/TestStepFinished.java | 77 + .../io/cucumber/messages/TestStepResult.java | 67 + .../messages/TestStepResultStatus.java | 44 + .../io/cucumber/messages/TestStepStarted.java | 67 + .../java/io/cucumber/messages/Timestamp.java | 57 + .../messages/UndefinedParameterType.java | 57 + .../messages/MessageToNdjsonWriter.java | 2 - .../java/io/cucumber/messages/Messages.java | 4037 ----------------- .../messages/NdjsonToMessageIterable.java | 2 - .../io/cucumber/messages/TimeConversion.java | 2 - .../io/cucumber/messages/JacksonTest.java | 13 +- .../io/cucumber/messages/MessagesTest.java | 4 +- .../messages/NdjsonSerializationTest.java | 18 +- .../cucumber/messages/TimeConversionTest.java | 1 - .../scripts/templates/java.enum.java.erb | 47 +- .../scripts/templates/java.java.erb | 177 +- 70 files changed, 4750 insertions(+), 4189 deletions(-) create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Attachment.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/AttachmentContentEncoding.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Background.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Ci.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Comment.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/DataTable.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/DocString.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Duration.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Envelope.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Examples.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Feature.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/FeatureChild.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/GherkinDocument.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Git.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Group.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Hook.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/JavaMethod.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/JavaStackTraceElement.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Location.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Meta.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/ParameterType.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/ParseError.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Pickle.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/PickleDocString.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/PickleStep.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/PickleStepArgument.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/PickleTable.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/PickleTableCell.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/PickleTableRow.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/PickleTag.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Product.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Rule.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/RuleChild.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Scenario.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Source.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/SourceMediaType.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/SourceReference.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Step.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/StepDefinition.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPattern.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPatternType.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/StepMatchArgument.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/StepMatchArgumentsList.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TableCell.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TableRow.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Tag.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestCase.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestCaseFinished.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestCaseStarted.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestRunFinished.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestRunStarted.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestStep.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestStepFinished.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestStepResult.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestStepResultStatus.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/TestStepStarted.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/Timestamp.java create mode 100644 messages/java/src/generated/java/io/cucumber/messages/UndefinedParameterType.java delete mode 100644 messages/java/src/main/java/io/cucumber/messages/Messages.java diff --git a/messages/java/Makefile b/messages/java/Makefile index 92fe775451..c62ab7d500 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -2,24 +2,11 @@ include default.mk JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") -.codegen: src/main/java/io/cucumber/messages/Messages.java - -src/main/java/io/cucumber/messages/Messages.java: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/java.java.erb ../jsonschema/scripts/templates/java.enum.java.erb - echo "package io.cucumber.messages;" > $@ - echo >> $@ - echo "import java.util.ArrayList;" >> $@ - echo "import java.util.Objects;" >> $@ - echo "import java.util.Optional;" >> $@ - echo >> $@ - echo "import static java.util.Collections.unmodifiableList;" >> $@ - echo "import static java.util.Objects.requireNonNull;" >> $@ - echo >> $@ - echo "// Generated code" >> $@ - echo "@SuppressWarnings(\"unused\")" >> $@ - echo "public final class Messages {" >> $@ - echo >> $@ - echo " private Messages() {}" >> $@ - echo >> $@ - ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.java.erb >> $@ - ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> $@ - echo "}" >> $@ +.codegen: $(JSONSCHEMAS) ../jsonschema/scripts/codegen.rb ../jsonschema/scripts/templates/java.java.erb ../jsonschema/scripts/templates/java.enum.java.erb + ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.java.erb > Generated.java.tmp + ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> Generated.java.tmp + csplit --quiet --prefix=Generated --suffix-format=%02d.java.tmp --elide-empty-files Generated.java.tmp /^.*.java$$/ {*} + rm Generated.java.tmp + rm -rf src/generated/java/io/cucumber/messages + mkdir --parents src/generated/java/io/cucumber/messages + for file in Generated**; do tail -n +2 $$file > src/generated/java/io/cucumber/messages/$$(head -n 1 $$file); rm $$file; done diff --git a/messages/java/pom.xml b/messages/java/pom.xml index d302a46ee3..c38be0162b 100644 --- a/messages/java/pom.xml +++ b/messages/java/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 @@ -85,6 +86,24 @@ + + org.codehaus.mojo + build-helper-maven-plugin + + + add-source + generate-sources + + add-source + + + + src/generated/java + + + + + org.apache.maven.plugins maven-compiler-plugin diff --git a/messages/java/src/generated/java/io/cucumber/messages/Attachment.java b/messages/java/src/generated/java/io/cucumber/messages/Attachment.java new file mode 100644 index 0000000000..23c4d4cafe --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Attachment.java @@ -0,0 +1,117 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Attachment { + private final String body; + private final AttachmentContentEncoding contentEncoding; + private final String fileName; + private final String mediaType; + private final Source source; + private final String testCaseStartedId; + private final String testStepId; + private final String url; + + public Attachment( + String body, + AttachmentContentEncoding contentEncoding, + String fileName, + String mediaType, + Source source, + String testCaseStartedId, + String testStepId, + String url + ) { + this.body = requireNonNull(body, "Attachment.body cannot be null"); + this.contentEncoding = requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); + this.fileName = fileName; + this.mediaType = requireNonNull(mediaType, "Attachment.mediaType cannot be null"); + this.source = source; + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.url = url; + } + + public String getBody() { + return body; + } + + public AttachmentContentEncoding getContentEncoding() { + return contentEncoding; + } + + public Optional getFileName() { + return Optional.ofNullable(fileName); + } + + public String getMediaType() { + return mediaType; + } + + public Optional getSource() { + return Optional.ofNullable(source); + } + + public Optional getTestCaseStartedId() { + return Optional.ofNullable(testCaseStartedId); + } + + public Optional getTestStepId() { + return Optional.ofNullable(testStepId); + } + + public Optional getUrl() { + return Optional.ofNullable(url); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Attachment that = (Attachment) o; + return + body.equals(that.body) && + contentEncoding.equals(that.contentEncoding) && + Objects.equals(fileName, that.fileName) && + mediaType.equals(that.mediaType) && + Objects.equals(source, that.source) && + Objects.equals(testCaseStartedId, that.testCaseStartedId) && + Objects.equals(testStepId, that.testStepId) && + Objects.equals(url, that.url); + } + + @Override + public int hashCode() { + return Objects.hash( + body, + contentEncoding, + fileName, + mediaType, + source, + testCaseStartedId, + testStepId, + url + ); + } + + @Override + public String toString() { + return "Attachment{" + + "body=" + body + + ", contentEncoding=" + contentEncoding + + ", fileName=" + fileName + + ", mediaType=" + mediaType + + ", source=" + source + + ", testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", url=" + url + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/AttachmentContentEncoding.java b/messages/java/src/generated/java/io/cucumber/messages/AttachmentContentEncoding.java new file mode 100644 index 0000000000..65e155dfd2 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/AttachmentContentEncoding.java @@ -0,0 +1,34 @@ +package io.cucumber.messages; + +// Generated code +@SuppressWarnings("unused") +public enum AttachmentContentEncoding { + + IDENTITY("IDENTITY"), + + BASE64("BASE64"); + + private final String value; + + AttachmentContentEncoding(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static AttachmentContentEncoding fromValue(String value) { + for (AttachmentContentEncoding v : values()) { + if (v.value.equals(value)) { + return v; + } + } + throw new IllegalArgumentException(value); + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Background.java b/messages/java/src/generated/java/io/cucumber/messages/Background.java new file mode 100644 index 0000000000..acf5c2778d --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Background.java @@ -0,0 +1,97 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Background { + private final Location location; + private final String keyword; + private final String name; + private final String description; + private final java.util.List steps; + private final String id; + + public Background( + Location location, + String keyword, + String name, + String description, + java.util.List steps, + String id + ) { + this.location = requireNonNull(location, "Background.location cannot be null"); + this.keyword = requireNonNull(keyword, "Background.keyword cannot be null"); + this.name = requireNonNull(name, "Background.name cannot be null"); + this.description = requireNonNull(description, "Background.description cannot be null"); + this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Background.steps cannot be null"))); + this.id = requireNonNull(id, "Background.id cannot be null"); + } + + public Location getLocation() { + return location; + } + + public String getKeyword() { + return keyword; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public java.util.List getSteps() { + return steps; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Background that = (Background) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + keyword, + name, + description, + steps, + id + ); + } + + @Override + public String toString() { + return "Background{" + + "location=" + location + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", steps=" + steps + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Ci.java b/messages/java/src/generated/java/io/cucumber/messages/Ci.java new file mode 100644 index 0000000000..5b2bc2ec81 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Ci.java @@ -0,0 +1,77 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Ci { + private final String name; + private final String url; + private final String buildNumber; + private final Git git; + + public Ci( + String name, + String url, + String buildNumber, + Git git + ) { + this.name = requireNonNull(name, "Ci.name cannot be null"); + this.url = url; + this.buildNumber = buildNumber; + this.git = git; + } + + public String getName() { + return name; + } + + public Optional getUrl() { + return Optional.ofNullable(url); + } + + public Optional getBuildNumber() { + return Optional.ofNullable(buildNumber); + } + + public Optional getGit() { + return Optional.ofNullable(git); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Ci that = (Ci) o; + return + name.equals(that.name) && + Objects.equals(url, that.url) && + Objects.equals(buildNumber, that.buildNumber) && + Objects.equals(git, that.git); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + url, + buildNumber, + git + ); + } + + @Override + public String toString() { + return "Ci{" + + "name=" + name + + ", url=" + url + + ", buildNumber=" + buildNumber + + ", git=" + git + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Comment.java b/messages/java/src/generated/java/io/cucumber/messages/Comment.java new file mode 100644 index 0000000000..b45c9fee44 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Comment.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Comment { + private final Location location; + private final String text; + + public Comment( + Location location, + String text + ) { + this.location = requireNonNull(location, "Comment.location cannot be null"); + this.text = requireNonNull(text, "Comment.text cannot be null"); + } + + public Location getLocation() { + return location; + } + + public String getText() { + return text; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Comment that = (Comment) o; + return + location.equals(that.location) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + text + ); + } + + @Override + public String toString() { + return "Comment{" + + "location=" + location + + ", text=" + text + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/DataTable.java b/messages/java/src/generated/java/io/cucumber/messages/DataTable.java new file mode 100644 index 0000000000..6ec34ff0ea --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/DataTable.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class DataTable { + private final Location location; + private final java.util.List rows; + + public DataTable( + Location location, + java.util.List rows + ) { + this.location = requireNonNull(location, "DataTable.location cannot be null"); + this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "DataTable.rows cannot be null"))); + } + + public Location getLocation() { + return location; + } + + public java.util.List getRows() { + return rows; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DataTable that = (DataTable) o; + return + location.equals(that.location) && + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + rows + ); + } + + @Override + public String toString() { + return "DataTable{" + + "location=" + location + + ", rows=" + rows + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/DocString.java b/messages/java/src/generated/java/io/cucumber/messages/DocString.java new file mode 100644 index 0000000000..51c1e61200 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/DocString.java @@ -0,0 +1,77 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class DocString { + private final Location location; + private final String mediaType; + private final String content; + private final String delimiter; + + public DocString( + Location location, + String mediaType, + String content, + String delimiter + ) { + this.location = requireNonNull(location, "DocString.location cannot be null"); + this.mediaType = mediaType; + this.content = requireNonNull(content, "DocString.content cannot be null"); + this.delimiter = requireNonNull(delimiter, "DocString.delimiter cannot be null"); + } + + public Location getLocation() { + return location; + } + + public Optional getMediaType() { + return Optional.ofNullable(mediaType); + } + + public String getContent() { + return content; + } + + public String getDelimiter() { + return delimiter; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DocString that = (DocString) o; + return + location.equals(that.location) && + Objects.equals(mediaType, that.mediaType) && + content.equals(that.content) && + delimiter.equals(that.delimiter); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + mediaType, + content, + delimiter + ); + } + + @Override + public String toString() { + return "DocString{" + + "location=" + location + + ", mediaType=" + mediaType + + ", content=" + content + + ", delimiter=" + delimiter + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Duration.java b/messages/java/src/generated/java/io/cucumber/messages/Duration.java new file mode 100644 index 0000000000..bea941e063 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Duration.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Duration { + private final Long seconds; + private final Long nanos; + + public Duration( + Long seconds, + Long nanos + ) { + this.seconds = requireNonNull(seconds, "Duration.seconds cannot be null"); + this.nanos = requireNonNull(nanos, "Duration.nanos cannot be null"); + } + + public Long getSeconds() { + return seconds; + } + + public Long getNanos() { + return nanos; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Duration that = (Duration) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return Objects.hash( + seconds, + nanos + ); + } + + @Override + public String toString() { + return "Duration{" + + "seconds=" + seconds + + ", nanos=" + nanos + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Envelope.java b/messages/java/src/generated/java/io/cucumber/messages/Envelope.java new file mode 100644 index 0000000000..088dd47047 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Envelope.java @@ -0,0 +1,581 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Envelope { + private final Attachment attachment; + private final GherkinDocument gherkinDocument; + private final Hook hook; + private final Meta meta; + private final ParameterType parameterType; + private final ParseError parseError; + private final Pickle pickle; + private final Source source; + private final StepDefinition stepDefinition; + private final TestCase testCase; + private final TestCaseFinished testCaseFinished; + private final TestCaseStarted testCaseStarted; + private final TestRunFinished testRunFinished; + private final TestRunStarted testRunStarted; + private final TestStepFinished testStepFinished; + private final TestStepStarted testStepStarted; + private final UndefinedParameterType undefinedParameterType; + + public static Envelope of(Attachment attachment) { + return new Envelope( + requireNonNull(attachment, "Envelope.attachment cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(GherkinDocument gherkinDocument) { + return new Envelope( + null, + requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(Hook hook) { + return new Envelope( + null, + null, + requireNonNull(hook, "Envelope.hook cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(Meta meta) { + return new Envelope( + null, + null, + null, + requireNonNull(meta, "Envelope.meta cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(ParameterType parameterType) { + return new Envelope( + null, + null, + null, + null, + requireNonNull(parameterType, "Envelope.parameterType cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(ParseError parseError) { + return new Envelope( + null, + null, + null, + null, + null, + requireNonNull(parseError, "Envelope.parseError cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(Pickle pickle) { + return new Envelope( + null, + null, + null, + null, + null, + null, + requireNonNull(pickle, "Envelope.pickle cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(Source source) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + requireNonNull(source, "Envelope.source cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(StepDefinition stepDefinition) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"), + null, + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(TestCase testCase) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(testCase, "Envelope.testCase cannot be null"), + null, + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(TestCaseFinished testCaseFinished) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"), + null, + null, + null, + null, + null, + null + ); + } + + public static Envelope of(TestCaseStarted testCaseStarted) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"), + null, + null, + null, + null, + null + ); + } + + public static Envelope of(TestRunFinished testRunFinished) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"), + null, + null, + null, + null + ); + } + + public static Envelope of(TestRunStarted testRunStarted) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"), + null, + null, + null + ); + } + + public static Envelope of(TestStepFinished testStepFinished) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"), + null, + null + ); + } + + public static Envelope of(TestStepStarted testStepStarted) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"), + null + ); + } + + public static Envelope of(UndefinedParameterType undefinedParameterType) { + return new Envelope( + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + null, + requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null") + ); + } + + public Envelope( + Attachment attachment, + GherkinDocument gherkinDocument, + Hook hook, + Meta meta, + ParameterType parameterType, + ParseError parseError, + Pickle pickle, + Source source, + StepDefinition stepDefinition, + TestCase testCase, + TestCaseFinished testCaseFinished, + TestCaseStarted testCaseStarted, + TestRunFinished testRunFinished, + TestRunStarted testRunStarted, + TestStepFinished testStepFinished, + TestStepStarted testStepStarted, + UndefinedParameterType undefinedParameterType + ) { + this.attachment = attachment; + this.gherkinDocument = gherkinDocument; + this.hook = hook; + this.meta = meta; + this.parameterType = parameterType; + this.parseError = parseError; + this.pickle = pickle; + this.source = source; + this.stepDefinition = stepDefinition; + this.testCase = testCase; + this.testCaseFinished = testCaseFinished; + this.testCaseStarted = testCaseStarted; + this.testRunFinished = testRunFinished; + this.testRunStarted = testRunStarted; + this.testStepFinished = testStepFinished; + this.testStepStarted = testStepStarted; + this.undefinedParameterType = undefinedParameterType; + } + + public Optional getAttachment() { + return Optional.ofNullable(attachment); + } + + public Optional getGherkinDocument() { + return Optional.ofNullable(gherkinDocument); + } + + public Optional getHook() { + return Optional.ofNullable(hook); + } + + public Optional getMeta() { + return Optional.ofNullable(meta); + } + + public Optional getParameterType() { + return Optional.ofNullable(parameterType); + } + + public Optional getParseError() { + return Optional.ofNullable(parseError); + } + + public Optional getPickle() { + return Optional.ofNullable(pickle); + } + + public Optional getSource() { + return Optional.ofNullable(source); + } + + public Optional getStepDefinition() { + return Optional.ofNullable(stepDefinition); + } + + public Optional getTestCase() { + return Optional.ofNullable(testCase); + } + + public Optional getTestCaseFinished() { + return Optional.ofNullable(testCaseFinished); + } + + public Optional getTestCaseStarted() { + return Optional.ofNullable(testCaseStarted); + } + + public Optional getTestRunFinished() { + return Optional.ofNullable(testRunFinished); + } + + public Optional getTestRunStarted() { + return Optional.ofNullable(testRunStarted); + } + + public Optional getTestStepFinished() { + return Optional.ofNullable(testStepFinished); + } + + public Optional getTestStepStarted() { + return Optional.ofNullable(testStepStarted); + } + + public Optional getUndefinedParameterType() { + return Optional.ofNullable(undefinedParameterType); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Envelope that = (Envelope) o; + return + Objects.equals(attachment, that.attachment) && + Objects.equals(gherkinDocument, that.gherkinDocument) && + Objects.equals(hook, that.hook) && + Objects.equals(meta, that.meta) && + Objects.equals(parameterType, that.parameterType) && + Objects.equals(parseError, that.parseError) && + Objects.equals(pickle, that.pickle) && + Objects.equals(source, that.source) && + Objects.equals(stepDefinition, that.stepDefinition) && + Objects.equals(testCase, that.testCase) && + Objects.equals(testCaseFinished, that.testCaseFinished) && + Objects.equals(testCaseStarted, that.testCaseStarted) && + Objects.equals(testRunFinished, that.testRunFinished) && + Objects.equals(testRunStarted, that.testRunStarted) && + Objects.equals(testStepFinished, that.testStepFinished) && + Objects.equals(testStepStarted, that.testStepStarted) && + Objects.equals(undefinedParameterType, that.undefinedParameterType); + } + + @Override + public int hashCode() { + return Objects.hash( + attachment, + gherkinDocument, + hook, + meta, + parameterType, + parseError, + pickle, + source, + stepDefinition, + testCase, + testCaseFinished, + testCaseStarted, + testRunFinished, + testRunStarted, + testStepFinished, + testStepStarted, + undefinedParameterType + ); + } + + @Override + public String toString() { + return "Envelope{" + + "attachment=" + attachment + + ", gherkinDocument=" + gherkinDocument + + ", hook=" + hook + + ", meta=" + meta + + ", parameterType=" + parameterType + + ", parseError=" + parseError + + ", pickle=" + pickle + + ", source=" + source + + ", stepDefinition=" + stepDefinition + + ", testCase=" + testCase + + ", testCaseFinished=" + testCaseFinished + + ", testCaseStarted=" + testCaseStarted + + ", testRunFinished=" + testRunFinished + + ", testRunStarted=" + testRunStarted + + ", testStepFinished=" + testStepFinished + + ", testStepStarted=" + testStepStarted + + ", undefinedParameterType=" + undefinedParameterType + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Examples.java b/messages/java/src/generated/java/io/cucumber/messages/Examples.java new file mode 100644 index 0000000000..145cd57388 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Examples.java @@ -0,0 +1,117 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Examples { + private final Location location; + private final java.util.List tags; + private final String keyword; + private final String name; + private final String description; + private final TableRow tableHeader; + private final java.util.List tableBody; + private final String id; + + public Examples( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + TableRow tableHeader, + java.util.List tableBody, + String id + ) { + this.location = requireNonNull(location, "Examples.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Examples.tags cannot be null"))); + this.keyword = requireNonNull(keyword, "Examples.keyword cannot be null"); + this.name = requireNonNull(name, "Examples.name cannot be null"); + this.description = requireNonNull(description, "Examples.description cannot be null"); + this.tableHeader = tableHeader; + this.tableBody = unmodifiableList(new ArrayList<>(requireNonNull(tableBody, "Examples.tableBody cannot be null"))); + this.id = requireNonNull(id, "Examples.id cannot be null"); + } + + public Location getLocation() { + return location; + } + + public java.util.List getTags() { + return tags; + } + + public String getKeyword() { + return keyword; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public Optional getTableHeader() { + return Optional.ofNullable(tableHeader); + } + + public java.util.List getTableBody() { + return tableBody; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Examples that = (Examples) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + Objects.equals(tableHeader, that.tableHeader) && + tableBody.equals(that.tableBody) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + keyword, + name, + description, + tableHeader, + tableBody, + id + ); + } + + @Override + public String toString() { + return "Examples{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", tableHeader=" + tableHeader + + ", tableBody=" + tableBody + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Feature.java b/messages/java/src/generated/java/io/cucumber/messages/Feature.java new file mode 100644 index 0000000000..814a0c77d8 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Feature.java @@ -0,0 +1,107 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Feature { + private final Location location; + private final java.util.List tags; + private final String language; + private final String keyword; + private final String name; + private final String description; + private final java.util.List children; + + public Feature( + Location location, + java.util.List tags, + String language, + String keyword, + String name, + String description, + java.util.List children + ) { + this.location = requireNonNull(location, "Feature.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Feature.tags cannot be null"))); + this.language = requireNonNull(language, "Feature.language cannot be null"); + this.keyword = requireNonNull(keyword, "Feature.keyword cannot be null"); + this.name = requireNonNull(name, "Feature.name cannot be null"); + this.description = requireNonNull(description, "Feature.description cannot be null"); + this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Feature.children cannot be null"))); + } + + public Location getLocation() { + return location; + } + + public java.util.List getTags() { + return tags; + } + + public String getLanguage() { + return language; + } + + public String getKeyword() { + return keyword; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public java.util.List getChildren() { + return children; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Feature that = (Feature) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + language.equals(that.language) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + language, + keyword, + name, + description, + children + ); + } + + @Override + public String toString() { + return "Feature{" + + "location=" + location + + ", tags=" + tags + + ", language=" + language + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", children=" + children + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/FeatureChild.java b/messages/java/src/generated/java/io/cucumber/messages/FeatureChild.java new file mode 100644 index 0000000000..8797688818 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/FeatureChild.java @@ -0,0 +1,91 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class FeatureChild { + private final Rule rule; + private final Background background; + private final Scenario scenario; + + public static FeatureChild of(Rule rule) { + return new FeatureChild( + requireNonNull(rule, "FeatureChild.rule cannot be null"), + null, + null + ); + } + + public static FeatureChild of(Background background) { + return new FeatureChild( + null, + requireNonNull(background, "FeatureChild.background cannot be null"), + null + ); + } + + public static FeatureChild of(Scenario scenario) { + return new FeatureChild( + null, + null, + requireNonNull(scenario, "FeatureChild.scenario cannot be null") + ); + } + + public FeatureChild( + Rule rule, + Background background, + Scenario scenario + ) { + this.rule = rule; + this.background = background; + this.scenario = scenario; + } + + public Optional getRule() { + return Optional.ofNullable(rule); + } + + public Optional getBackground() { + return Optional.ofNullable(background); + } + + public Optional getScenario() { + return Optional.ofNullable(scenario); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + FeatureChild that = (FeatureChild) o; + return + Objects.equals(rule, that.rule) && + Objects.equals(background, that.background) && + Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return Objects.hash( + rule, + background, + scenario + ); + } + + @Override + public String toString() { + return "FeatureChild{" + + "rule=" + rule + + ", background=" + background + + ", scenario=" + scenario + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/GherkinDocument.java b/messages/java/src/generated/java/io/cucumber/messages/GherkinDocument.java new file mode 100644 index 0000000000..a3e5921494 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/GherkinDocument.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class GherkinDocument { + private final String uri; + private final Feature feature; + private final java.util.List comments; + + public GherkinDocument( + String uri, + Feature feature, + java.util.List comments + ) { + this.uri = uri; + this.feature = feature; + this.comments = unmodifiableList(new ArrayList<>(requireNonNull(comments, "GherkinDocument.comments cannot be null"))); + } + + public Optional getUri() { + return Optional.ofNullable(uri); + } + + public Optional getFeature() { + return Optional.ofNullable(feature); + } + + public java.util.List getComments() { + return comments; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + GherkinDocument that = (GherkinDocument) o; + return + Objects.equals(uri, that.uri) && + Objects.equals(feature, that.feature) && + comments.equals(that.comments); + } + + @Override + public int hashCode() { + return Objects.hash( + uri, + feature, + comments + ); + } + + @Override + public String toString() { + return "GherkinDocument{" + + "uri=" + uri + + ", feature=" + feature + + ", comments=" + comments + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Git.java b/messages/java/src/generated/java/io/cucumber/messages/Git.java new file mode 100644 index 0000000000..da71d1b7c9 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Git.java @@ -0,0 +1,77 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Git { + private final String remote; + private final String revision; + private final String branch; + private final String tag; + + public Git( + String remote, + String revision, + String branch, + String tag + ) { + this.remote = requireNonNull(remote, "Git.remote cannot be null"); + this.revision = requireNonNull(revision, "Git.revision cannot be null"); + this.branch = branch; + this.tag = tag; + } + + public String getRemote() { + return remote; + } + + public String getRevision() { + return revision; + } + + public Optional getBranch() { + return Optional.ofNullable(branch); + } + + public Optional getTag() { + return Optional.ofNullable(tag); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Git that = (Git) o; + return + remote.equals(that.remote) && + revision.equals(that.revision) && + Objects.equals(branch, that.branch) && + Objects.equals(tag, that.tag); + } + + @Override + public int hashCode() { + return Objects.hash( + remote, + revision, + branch, + tag + ); + } + + @Override + public String toString() { + return "Git{" + + "remote=" + remote + + ", revision=" + revision + + ", branch=" + branch + + ", tag=" + tag + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Group.java b/messages/java/src/generated/java/io/cucumber/messages/Group.java new file mode 100644 index 0000000000..312edc5f2f --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Group.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Group { + private final java.util.List children; + private final Long start; + private final String value; + + public Group( + java.util.List children, + Long start, + String value + ) { + this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Group.children cannot be null"))); + this.start = start; + this.value = value; + } + + public java.util.List getChildren() { + return children; + } + + public Optional getStart() { + return Optional.ofNullable(start); + } + + public Optional getValue() { + return Optional.ofNullable(value); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Group that = (Group) o; + return + children.equals(that.children) && + Objects.equals(start, that.start) && + Objects.equals(value, that.value); + } + + @Override + public int hashCode() { + return Objects.hash( + children, + start, + value + ); + } + + @Override + public String toString() { + return "Group{" + + "children=" + children + + ", start=" + start + + ", value=" + value + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Hook.java b/messages/java/src/generated/java/io/cucumber/messages/Hook.java new file mode 100644 index 0000000000..eba338f1dd --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Hook.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Hook { + private final String id; + private final SourceReference sourceReference; + private final String tagExpression; + + public Hook( + String id, + SourceReference sourceReference, + String tagExpression + ) { + this.id = requireNonNull(id, "Hook.id cannot be null"); + this.sourceReference = requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); + this.tagExpression = tagExpression; + } + + public String getId() { + return id; + } + + public SourceReference getSourceReference() { + return sourceReference; + } + + public Optional getTagExpression() { + return Optional.ofNullable(tagExpression); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Hook that = (Hook) o; + return + id.equals(that.id) && + sourceReference.equals(that.sourceReference) && + Objects.equals(tagExpression, that.tagExpression); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + sourceReference, + tagExpression + ); + } + + @Override + public String toString() { + return "Hook{" + + "id=" + id + + ", sourceReference=" + sourceReference + + ", tagExpression=" + tagExpression + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/JavaMethod.java b/messages/java/src/generated/java/io/cucumber/messages/JavaMethod.java new file mode 100644 index 0000000000..249c2d2c7a --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/JavaMethod.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class JavaMethod { + private final String className; + private final String methodName; + private final java.util.List methodParameterTypes; + + public JavaMethod( + String className, + String methodName, + java.util.List methodParameterTypes + ) { + this.className = requireNonNull(className, "JavaMethod.className cannot be null"); + this.methodName = requireNonNull(methodName, "JavaMethod.methodName cannot be null"); + this.methodParameterTypes = unmodifiableList(new ArrayList<>(requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"))); + } + + public String getClassName() { + return className; + } + + public String getMethodName() { + return methodName; + } + + public java.util.List getMethodParameterTypes() { + return methodParameterTypes; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaMethod that = (JavaMethod) o; + return + className.equals(that.className) && + methodName.equals(that.methodName) && + methodParameterTypes.equals(that.methodParameterTypes); + } + + @Override + public int hashCode() { + return Objects.hash( + className, + methodName, + methodParameterTypes + ); + } + + @Override + public String toString() { + return "JavaMethod{" + + "className=" + className + + ", methodName=" + methodName + + ", methodParameterTypes=" + methodParameterTypes + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/JavaStackTraceElement.java b/messages/java/src/generated/java/io/cucumber/messages/JavaStackTraceElement.java new file mode 100644 index 0000000000..4b7b9d3e47 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/JavaStackTraceElement.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class JavaStackTraceElement { + private final String className; + private final String fileName; + private final String methodName; + + public JavaStackTraceElement( + String className, + String fileName, + String methodName + ) { + this.className = requireNonNull(className, "JavaStackTraceElement.className cannot be null"); + this.fileName = requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); + this.methodName = requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); + } + + public String getClassName() { + return className; + } + + public String getFileName() { + return fileName; + } + + public String getMethodName() { + return methodName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JavaStackTraceElement that = (JavaStackTraceElement) o; + return + className.equals(that.className) && + fileName.equals(that.fileName) && + methodName.equals(that.methodName); + } + + @Override + public int hashCode() { + return Objects.hash( + className, + fileName, + methodName + ); + } + + @Override + public String toString() { + return "JavaStackTraceElement{" + + "className=" + className + + ", fileName=" + fileName + + ", methodName=" + methodName + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Location.java b/messages/java/src/generated/java/io/cucumber/messages/Location.java new file mode 100644 index 0000000000..0eeaf5b892 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Location.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Location { + private final Long line; + private final Long column; + + public Location( + Long line, + Long column + ) { + this.line = requireNonNull(line, "Location.line cannot be null"); + this.column = column; + } + + public Long getLine() { + return line; + } + + public Optional getColumn() { + return Optional.ofNullable(column); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Location that = (Location) o; + return + line.equals(that.line) && + Objects.equals(column, that.column); + } + + @Override + public int hashCode() { + return Objects.hash( + line, + column + ); + } + + @Override + public String toString() { + return "Location{" + + "line=" + line + + ", column=" + column + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Meta.java b/messages/java/src/generated/java/io/cucumber/messages/Meta.java new file mode 100644 index 0000000000..4eafe66868 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Meta.java @@ -0,0 +1,97 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Meta { + private final String protocolVersion; + private final Product implementation; + private final Product runtime; + private final Product os; + private final Product cpu; + private final Ci ci; + + public Meta( + String protocolVersion, + Product implementation, + Product runtime, + Product os, + Product cpu, + Ci ci + ) { + this.protocolVersion = requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); + this.implementation = requireNonNull(implementation, "Meta.implementation cannot be null"); + this.runtime = requireNonNull(runtime, "Meta.runtime cannot be null"); + this.os = requireNonNull(os, "Meta.os cannot be null"); + this.cpu = requireNonNull(cpu, "Meta.cpu cannot be null"); + this.ci = ci; + } + + public String getProtocolVersion() { + return protocolVersion; + } + + public Product getImplementation() { + return implementation; + } + + public Product getRuntime() { + return runtime; + } + + public Product getOs() { + return os; + } + + public Product getCpu() { + return cpu; + } + + public Optional getCi() { + return Optional.ofNullable(ci); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Meta that = (Meta) o; + return + protocolVersion.equals(that.protocolVersion) && + implementation.equals(that.implementation) && + runtime.equals(that.runtime) && + os.equals(that.os) && + cpu.equals(that.cpu) && + Objects.equals(ci, that.ci); + } + + @Override + public int hashCode() { + return Objects.hash( + protocolVersion, + implementation, + runtime, + os, + cpu, + ci + ); + } + + @Override + public String toString() { + return "Meta{" + + "protocolVersion=" + protocolVersion + + ", implementation=" + implementation + + ", runtime=" + runtime + + ", os=" + os + + ", cpu=" + cpu + + ", ci=" + ci + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/ParameterType.java b/messages/java/src/generated/java/io/cucumber/messages/ParameterType.java new file mode 100644 index 0000000000..fbfe92ab72 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/ParameterType.java @@ -0,0 +1,87 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class ParameterType { + private final String name; + private final java.util.List regularExpressions; + private final Boolean preferForRegularExpressionMatch; + private final Boolean useForSnippets; + private final String id; + + public ParameterType( + String name, + java.util.List regularExpressions, + Boolean preferForRegularExpressionMatch, + Boolean useForSnippets, + String id + ) { + this.name = requireNonNull(name, "ParameterType.name cannot be null"); + this.regularExpressions = unmodifiableList(new ArrayList<>(requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"))); + this.preferForRegularExpressionMatch = requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); + this.useForSnippets = requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); + this.id = requireNonNull(id, "ParameterType.id cannot be null"); + } + + public String getName() { + return name; + } + + public java.util.List getRegularExpressions() { + return regularExpressions; + } + + public Boolean getPreferForRegularExpressionMatch() { + return preferForRegularExpressionMatch; + } + + public Boolean getUseForSnippets() { + return useForSnippets; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParameterType that = (ParameterType) o; + return + name.equals(that.name) && + regularExpressions.equals(that.regularExpressions) && + preferForRegularExpressionMatch.equals(that.preferForRegularExpressionMatch) && + useForSnippets.equals(that.useForSnippets) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + regularExpressions, + preferForRegularExpressionMatch, + useForSnippets, + id + ); + } + + @Override + public String toString() { + return "ParameterType{" + + "name=" + name + + ", regularExpressions=" + regularExpressions + + ", preferForRegularExpressionMatch=" + preferForRegularExpressionMatch + + ", useForSnippets=" + useForSnippets + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/ParseError.java b/messages/java/src/generated/java/io/cucumber/messages/ParseError.java new file mode 100644 index 0000000000..479c339e0b --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/ParseError.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class ParseError { + private final SourceReference source; + private final String message; + + public ParseError( + SourceReference source, + String message + ) { + this.source = requireNonNull(source, "ParseError.source cannot be null"); + this.message = requireNonNull(message, "ParseError.message cannot be null"); + } + + public SourceReference getSource() { + return source; + } + + public String getMessage() { + return message; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ParseError that = (ParseError) o; + return + source.equals(that.source) && + message.equals(that.message); + } + + @Override + public int hashCode() { + return Objects.hash( + source, + message + ); + } + + @Override + public String toString() { + return "ParseError{" + + "source=" + source + + ", message=" + message + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Pickle.java b/messages/java/src/generated/java/io/cucumber/messages/Pickle.java new file mode 100644 index 0000000000..ad3027b3fa --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Pickle.java @@ -0,0 +1,107 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Pickle { + private final String id; + private final String uri; + private final String name; + private final String language; + private final java.util.List steps; + private final java.util.List tags; + private final java.util.List astNodeIds; + + public Pickle( + String id, + String uri, + String name, + String language, + java.util.List steps, + java.util.List tags, + java.util.List astNodeIds + ) { + this.id = requireNonNull(id, "Pickle.id cannot be null"); + this.uri = requireNonNull(uri, "Pickle.uri cannot be null"); + this.name = requireNonNull(name, "Pickle.name cannot be null"); + this.language = requireNonNull(language, "Pickle.language cannot be null"); + this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Pickle.steps cannot be null"))); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Pickle.tags cannot be null"))); + this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"))); + } + + public String getId() { + return id; + } + + public String getUri() { + return uri; + } + + public String getName() { + return name; + } + + public String getLanguage() { + return language; + } + + public java.util.List getSteps() { + return steps; + } + + public java.util.List getTags() { + return tags; + } + + public java.util.List getAstNodeIds() { + return astNodeIds; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pickle that = (Pickle) o; + return + id.equals(that.id) && + uri.equals(that.uri) && + name.equals(that.name) && + language.equals(that.language) && + steps.equals(that.steps) && + tags.equals(that.tags) && + astNodeIds.equals(that.astNodeIds); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + uri, + name, + language, + steps, + tags, + astNodeIds + ); + } + + @Override + public String toString() { + return "Pickle{" + + "id=" + id + + ", uri=" + uri + + ", name=" + name + + ", language=" + language + + ", steps=" + steps + + ", tags=" + tags + + ", astNodeIds=" + astNodeIds + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleDocString.java b/messages/java/src/generated/java/io/cucumber/messages/PickleDocString.java new file mode 100644 index 0000000000..c682a347e8 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/PickleDocString.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class PickleDocString { + private final String mediaType; + private final String content; + + public PickleDocString( + String mediaType, + String content + ) { + this.mediaType = mediaType; + this.content = requireNonNull(content, "PickleDocString.content cannot be null"); + } + + public Optional getMediaType() { + return Optional.ofNullable(mediaType); + } + + public String getContent() { + return content; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleDocString that = (PickleDocString) o; + return + Objects.equals(mediaType, that.mediaType) && + content.equals(that.content); + } + + @Override + public int hashCode() { + return Objects.hash( + mediaType, + content + ); + } + + @Override + public String toString() { + return "PickleDocString{" + + "mediaType=" + mediaType + + ", content=" + content + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleStep.java b/messages/java/src/generated/java/io/cucumber/messages/PickleStep.java new file mode 100644 index 0000000000..79025850f1 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/PickleStep.java @@ -0,0 +1,77 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class PickleStep { + private final PickleStepArgument argument; + private final java.util.List astNodeIds; + private final String id; + private final String text; + + public PickleStep( + PickleStepArgument argument, + java.util.List astNodeIds, + String id, + String text + ) { + this.argument = argument; + this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"))); + this.id = requireNonNull(id, "PickleStep.id cannot be null"); + this.text = requireNonNull(text, "PickleStep.text cannot be null"); + } + + public Optional getArgument() { + return Optional.ofNullable(argument); + } + + public java.util.List getAstNodeIds() { + return astNodeIds; + } + + public String getId() { + return id; + } + + public String getText() { + return text; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStep that = (PickleStep) o; + return + Objects.equals(argument, that.argument) && + astNodeIds.equals(that.astNodeIds) && + id.equals(that.id) && + text.equals(that.text); + } + + @Override + public int hashCode() { + return Objects.hash( + argument, + astNodeIds, + id, + text + ); + } + + @Override + public String toString() { + return "PickleStep{" + + "argument=" + argument + + ", astNodeIds=" + astNodeIds + + ", id=" + id + + ", text=" + text + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleStepArgument.java b/messages/java/src/generated/java/io/cucumber/messages/PickleStepArgument.java new file mode 100644 index 0000000000..5405c2fc13 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/PickleStepArgument.java @@ -0,0 +1,71 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class PickleStepArgument { + private final PickleDocString docString; + private final PickleTable dataTable; + + public static PickleStepArgument of(PickleDocString docString) { + return new PickleStepArgument( + requireNonNull(docString, "PickleStepArgument.docString cannot be null"), + null + ); + } + + public static PickleStepArgument of(PickleTable dataTable) { + return new PickleStepArgument( + null, + requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null") + ); + } + + public PickleStepArgument( + PickleDocString docString, + PickleTable dataTable + ) { + this.docString = docString; + this.dataTable = dataTable; + } + + public Optional getDocString() { + return Optional.ofNullable(docString); + } + + public Optional getDataTable() { + return Optional.ofNullable(dataTable); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleStepArgument that = (PickleStepArgument) o; + return + Objects.equals(docString, that.docString) && + Objects.equals(dataTable, that.dataTable); + } + + @Override + public int hashCode() { + return Objects.hash( + docString, + dataTable + ); + } + + @Override + public String toString() { + return "PickleStepArgument{" + + "docString=" + docString + + ", dataTable=" + dataTable + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTable.java b/messages/java/src/generated/java/io/cucumber/messages/PickleTable.java new file mode 100644 index 0000000000..93c5017cf1 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/PickleTable.java @@ -0,0 +1,47 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class PickleTable { + private final java.util.List rows; + + public PickleTable( + java.util.List rows + ) { + this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "PickleTable.rows cannot be null"))); + } + + public java.util.List getRows() { + return rows; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTable that = (PickleTable) o; + return + rows.equals(that.rows); + } + + @Override + public int hashCode() { + return Objects.hash( + rows + ); + } + + @Override + public String toString() { + return "PickleTable{" + + "rows=" + rows + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTableCell.java b/messages/java/src/generated/java/io/cucumber/messages/PickleTableCell.java new file mode 100644 index 0000000000..b3a76e4bfb --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/PickleTableCell.java @@ -0,0 +1,47 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class PickleTableCell { + private final String value; + + public PickleTableCell( + String value + ) { + this.value = requireNonNull(value, "PickleTableCell.value cannot be null"); + } + + public String getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableCell that = (PickleTableCell) o; + return + value.equals(that.value); + } + + @Override + public int hashCode() { + return Objects.hash( + value + ); + } + + @Override + public String toString() { + return "PickleTableCell{" + + "value=" + value + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTableRow.java b/messages/java/src/generated/java/io/cucumber/messages/PickleTableRow.java new file mode 100644 index 0000000000..753fb1ef8a --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/PickleTableRow.java @@ -0,0 +1,47 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class PickleTableRow { + private final java.util.List cells; + + public PickleTableRow( + java.util.List cells + ) { + this.cells = unmodifiableList(new ArrayList<>(requireNonNull(cells, "PickleTableRow.cells cannot be null"))); + } + + public java.util.List getCells() { + return cells; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTableRow that = (PickleTableRow) o; + return + cells.equals(that.cells); + } + + @Override + public int hashCode() { + return Objects.hash( + cells + ); + } + + @Override + public String toString() { + return "PickleTableRow{" + + "cells=" + cells + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTag.java b/messages/java/src/generated/java/io/cucumber/messages/PickleTag.java new file mode 100644 index 0000000000..2136822e4f --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/PickleTag.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class PickleTag { + private final String name; + private final String astNodeId; + + public PickleTag( + String name, + String astNodeId + ) { + this.name = requireNonNull(name, "PickleTag.name cannot be null"); + this.astNodeId = requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); + } + + public String getName() { + return name; + } + + public String getAstNodeId() { + return astNodeId; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PickleTag that = (PickleTag) o; + return + name.equals(that.name) && + astNodeId.equals(that.astNodeId); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + astNodeId + ); + } + + @Override + public String toString() { + return "PickleTag{" + + "name=" + name + + ", astNodeId=" + astNodeId + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Product.java b/messages/java/src/generated/java/io/cucumber/messages/Product.java new file mode 100644 index 0000000000..4b110ad4f1 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Product.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Product { + private final String name; + private final String version; + + public Product( + String name, + String version + ) { + this.name = requireNonNull(name, "Product.name cannot be null"); + this.version = version; + } + + public String getName() { + return name; + } + + public Optional getVersion() { + return Optional.ofNullable(version); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Product that = (Product) o; + return + name.equals(that.name) && + Objects.equals(version, that.version); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + version + ); + } + + @Override + public String toString() { + return "Product{" + + "name=" + name + + ", version=" + version + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Rule.java b/messages/java/src/generated/java/io/cucumber/messages/Rule.java new file mode 100644 index 0000000000..944588b329 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Rule.java @@ -0,0 +1,107 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Rule { + private final Location location; + private final java.util.List tags; + private final String keyword; + private final String name; + private final String description; + private final java.util.List children; + private final String id; + + public Rule( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + java.util.List children, + String id + ) { + this.location = requireNonNull(location, "Rule.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Rule.tags cannot be null"))); + this.keyword = requireNonNull(keyword, "Rule.keyword cannot be null"); + this.name = requireNonNull(name, "Rule.name cannot be null"); + this.description = requireNonNull(description, "Rule.description cannot be null"); + this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Rule.children cannot be null"))); + this.id = requireNonNull(id, "Rule.id cannot be null"); + } + + public Location getLocation() { + return location; + } + + public java.util.List getTags() { + return tags; + } + + public String getKeyword() { + return keyword; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public java.util.List getChildren() { + return children; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Rule that = (Rule) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + children.equals(that.children) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + keyword, + name, + description, + children, + id + ); + } + + @Override + public String toString() { + return "Rule{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", children=" + children + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/RuleChild.java b/messages/java/src/generated/java/io/cucumber/messages/RuleChild.java new file mode 100644 index 0000000000..c12eaf7fac --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/RuleChild.java @@ -0,0 +1,71 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class RuleChild { + private final Background background; + private final Scenario scenario; + + public static RuleChild of(Background background) { + return new RuleChild( + requireNonNull(background, "RuleChild.background cannot be null"), + null + ); + } + + public static RuleChild of(Scenario scenario) { + return new RuleChild( + null, + requireNonNull(scenario, "RuleChild.scenario cannot be null") + ); + } + + public RuleChild( + Background background, + Scenario scenario + ) { + this.background = background; + this.scenario = scenario; + } + + public Optional getBackground() { + return Optional.ofNullable(background); + } + + public Optional getScenario() { + return Optional.ofNullable(scenario); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + RuleChild that = (RuleChild) o; + return + Objects.equals(background, that.background) && + Objects.equals(scenario, that.scenario); + } + + @Override + public int hashCode() { + return Objects.hash( + background, + scenario + ); + } + + @Override + public String toString() { + return "RuleChild{" + + "background=" + background + + ", scenario=" + scenario + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Scenario.java b/messages/java/src/generated/java/io/cucumber/messages/Scenario.java new file mode 100644 index 0000000000..7fc00fa73c --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Scenario.java @@ -0,0 +1,117 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Scenario { + private final Location location; + private final java.util.List tags; + private final String keyword; + private final String name; + private final String description; + private final java.util.List steps; + private final java.util.List examples; + private final String id; + + public Scenario( + Location location, + java.util.List tags, + String keyword, + String name, + String description, + java.util.List steps, + java.util.List examples, + String id + ) { + this.location = requireNonNull(location, "Scenario.location cannot be null"); + this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Scenario.tags cannot be null"))); + this.keyword = requireNonNull(keyword, "Scenario.keyword cannot be null"); + this.name = requireNonNull(name, "Scenario.name cannot be null"); + this.description = requireNonNull(description, "Scenario.description cannot be null"); + this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Scenario.steps cannot be null"))); + this.examples = unmodifiableList(new ArrayList<>(requireNonNull(examples, "Scenario.examples cannot be null"))); + this.id = requireNonNull(id, "Scenario.id cannot be null"); + } + + public Location getLocation() { + return location; + } + + public java.util.List getTags() { + return tags; + } + + public String getKeyword() { + return keyword; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public java.util.List getSteps() { + return steps; + } + + public java.util.List getExamples() { + return examples; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Scenario that = (Scenario) o; + return + location.equals(that.location) && + tags.equals(that.tags) && + keyword.equals(that.keyword) && + name.equals(that.name) && + description.equals(that.description) && + steps.equals(that.steps) && + examples.equals(that.examples) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + tags, + keyword, + name, + description, + steps, + examples, + id + ); + } + + @Override + public String toString() { + return "Scenario{" + + "location=" + location + + ", tags=" + tags + + ", keyword=" + keyword + + ", name=" + name + + ", description=" + description + + ", steps=" + steps + + ", examples=" + examples + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Source.java b/messages/java/src/generated/java/io/cucumber/messages/Source.java new file mode 100644 index 0000000000..42e3cbead3 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Source.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Source { + private final String uri; + private final String data; + private final SourceMediaType mediaType; + + public Source( + String uri, + String data, + SourceMediaType mediaType + ) { + this.uri = requireNonNull(uri, "Source.uri cannot be null"); + this.data = requireNonNull(data, "Source.data cannot be null"); + this.mediaType = requireNonNull(mediaType, "Source.mediaType cannot be null"); + } + + public String getUri() { + return uri; + } + + public String getData() { + return data; + } + + public SourceMediaType getMediaType() { + return mediaType; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Source that = (Source) o; + return + uri.equals(that.uri) && + data.equals(that.data) && + mediaType.equals(that.mediaType); + } + + @Override + public int hashCode() { + return Objects.hash( + uri, + data, + mediaType + ); + } + + @Override + public String toString() { + return "Source{" + + "uri=" + uri + + ", data=" + data + + ", mediaType=" + mediaType + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/SourceMediaType.java b/messages/java/src/generated/java/io/cucumber/messages/SourceMediaType.java new file mode 100644 index 0000000000..933d46f23c --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/SourceMediaType.java @@ -0,0 +1,34 @@ +package io.cucumber.messages; + +// Generated code +@SuppressWarnings("unused") +public enum SourceMediaType { + + TEXT_X_CUCUMBER_GHERKIN_PLAIN("text/x.cucumber.gherkin+plain"), + + TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); + + private final String value; + + SourceMediaType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static SourceMediaType fromValue(String value) { + for (SourceMediaType v : values()) { + if (v.value.equals(value)) { + return v; + } + } + throw new IllegalArgumentException(value); + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/SourceReference.java b/messages/java/src/generated/java/io/cucumber/messages/SourceReference.java new file mode 100644 index 0000000000..37fcdedb4a --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/SourceReference.java @@ -0,0 +1,113 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class SourceReference { + private final String uri; + private final JavaMethod javaMethod; + private final JavaStackTraceElement javaStackTraceElement; + private final Location location; + + public static SourceReference of(String uri) { + return new SourceReference( + requireNonNull(uri, "SourceReference.uri cannot be null"), + null, + null, + null + ); + } + + public static SourceReference of(JavaMethod javaMethod) { + return new SourceReference( + null, + requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"), + null, + null + ); + } + + public static SourceReference of(JavaStackTraceElement javaStackTraceElement) { + return new SourceReference( + null, + null, + requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"), + null + ); + } + + public static SourceReference of(Location location) { + return new SourceReference( + null, + null, + null, + requireNonNull(location, "SourceReference.location cannot be null") + ); + } + + public SourceReference( + String uri, + JavaMethod javaMethod, + JavaStackTraceElement javaStackTraceElement, + Location location + ) { + this.uri = uri; + this.javaMethod = javaMethod; + this.javaStackTraceElement = javaStackTraceElement; + this.location = location; + } + + public Optional getUri() { + return Optional.ofNullable(uri); + } + + public Optional getJavaMethod() { + return Optional.ofNullable(javaMethod); + } + + public Optional getJavaStackTraceElement() { + return Optional.ofNullable(javaStackTraceElement); + } + + public Optional getLocation() { + return Optional.ofNullable(location); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + SourceReference that = (SourceReference) o; + return + Objects.equals(uri, that.uri) && + Objects.equals(javaMethod, that.javaMethod) && + Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && + Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + return Objects.hash( + uri, + javaMethod, + javaStackTraceElement, + location + ); + } + + @Override + public String toString() { + return "SourceReference{" + + "uri=" + uri + + ", javaMethod=" + javaMethod + + ", javaStackTraceElement=" + javaStackTraceElement + + ", location=" + location + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Step.java b/messages/java/src/generated/java/io/cucumber/messages/Step.java new file mode 100644 index 0000000000..e48c2dfbea --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Step.java @@ -0,0 +1,97 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Step { + private final Location location; + private final String keyword; + private final String text; + private final DocString docString; + private final DataTable dataTable; + private final String id; + + public Step( + Location location, + String keyword, + String text, + DocString docString, + DataTable dataTable, + String id + ) { + this.location = requireNonNull(location, "Step.location cannot be null"); + this.keyword = requireNonNull(keyword, "Step.keyword cannot be null"); + this.text = requireNonNull(text, "Step.text cannot be null"); + this.docString = docString; + this.dataTable = dataTable; + this.id = requireNonNull(id, "Step.id cannot be null"); + } + + public Location getLocation() { + return location; + } + + public String getKeyword() { + return keyword; + } + + public String getText() { + return text; + } + + public Optional getDocString() { + return Optional.ofNullable(docString); + } + + public Optional getDataTable() { + return Optional.ofNullable(dataTable); + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Step that = (Step) o; + return + location.equals(that.location) && + keyword.equals(that.keyword) && + text.equals(that.text) && + Objects.equals(docString, that.docString) && + Objects.equals(dataTable, that.dataTable) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + keyword, + text, + docString, + dataTable, + id + ); + } + + @Override + public String toString() { + return "Step{" + + "location=" + location + + ", keyword=" + keyword + + ", text=" + text + + ", docString=" + docString + + ", dataTable=" + dataTable + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepDefinition.java b/messages/java/src/generated/java/io/cucumber/messages/StepDefinition.java new file mode 100644 index 0000000000..7d1ad9abb1 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/StepDefinition.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class StepDefinition { + private final String id; + private final StepDefinitionPattern pattern; + private final SourceReference sourceReference; + + public StepDefinition( + String id, + StepDefinitionPattern pattern, + SourceReference sourceReference + ) { + this.id = requireNonNull(id, "StepDefinition.id cannot be null"); + this.pattern = requireNonNull(pattern, "StepDefinition.pattern cannot be null"); + this.sourceReference = requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); + } + + public String getId() { + return id; + } + + public StepDefinitionPattern getPattern() { + return pattern; + } + + public SourceReference getSourceReference() { + return sourceReference; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinition that = (StepDefinition) o; + return + id.equals(that.id) && + pattern.equals(that.pattern) && + sourceReference.equals(that.sourceReference); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + pattern, + sourceReference + ); + } + + @Override + public String toString() { + return "StepDefinition{" + + "id=" + id + + ", pattern=" + pattern + + ", sourceReference=" + sourceReference + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPattern.java b/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPattern.java new file mode 100644 index 0000000000..93c730cf8c --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPattern.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class StepDefinitionPattern { + private final String source; + private final StepDefinitionPatternType type; + + public StepDefinitionPattern( + String source, + StepDefinitionPatternType type + ) { + this.source = requireNonNull(source, "StepDefinitionPattern.source cannot be null"); + this.type = requireNonNull(type, "StepDefinitionPattern.type cannot be null"); + } + + public String getSource() { + return source; + } + + public StepDefinitionPatternType getType() { + return type; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepDefinitionPattern that = (StepDefinitionPattern) o; + return + source.equals(that.source) && + type.equals(that.type); + } + + @Override + public int hashCode() { + return Objects.hash( + source, + type + ); + } + + @Override + public String toString() { + return "StepDefinitionPattern{" + + "source=" + source + + ", type=" + type + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPatternType.java b/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPatternType.java new file mode 100644 index 0000000000..e378f2c95d --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPatternType.java @@ -0,0 +1,34 @@ +package io.cucumber.messages; + +// Generated code +@SuppressWarnings("unused") +public enum StepDefinitionPatternType { + + CUCUMBER_EXPRESSION("CUCUMBER_EXPRESSION"), + + REGULAR_EXPRESSION("REGULAR_EXPRESSION"); + + private final String value; + + StepDefinitionPatternType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static StepDefinitionPatternType fromValue(String value) { + for (StepDefinitionPatternType v : values()) { + if (v.value.equals(value)) { + return v; + } + } + throw new IllegalArgumentException(value); + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgument.java b/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgument.java new file mode 100644 index 0000000000..19112826c4 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgument.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class StepMatchArgument { + private final Group group; + private final String parameterTypeName; + + public StepMatchArgument( + Group group, + String parameterTypeName + ) { + this.group = requireNonNull(group, "StepMatchArgument.group cannot be null"); + this.parameterTypeName = parameterTypeName; + } + + public Group getGroup() { + return group; + } + + public Optional getParameterTypeName() { + return Optional.ofNullable(parameterTypeName); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgument that = (StepMatchArgument) o; + return + group.equals(that.group) && + Objects.equals(parameterTypeName, that.parameterTypeName); + } + + @Override + public int hashCode() { + return Objects.hash( + group, + parameterTypeName + ); + } + + @Override + public String toString() { + return "StepMatchArgument{" + + "group=" + group + + ", parameterTypeName=" + parameterTypeName + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgumentsList.java b/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgumentsList.java new file mode 100644 index 0000000000..64d5f68e44 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgumentsList.java @@ -0,0 +1,47 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class StepMatchArgumentsList { + private final java.util.List stepMatchArguments; + + public StepMatchArgumentsList( + java.util.List stepMatchArguments + ) { + this.stepMatchArguments = unmodifiableList(new ArrayList<>(requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"))); + } + + public java.util.List getStepMatchArguments() { + return stepMatchArguments; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + StepMatchArgumentsList that = (StepMatchArgumentsList) o; + return + stepMatchArguments.equals(that.stepMatchArguments); + } + + @Override + public int hashCode() { + return Objects.hash( + stepMatchArguments + ); + } + + @Override + public String toString() { + return "StepMatchArgumentsList{" + + "stepMatchArguments=" + stepMatchArguments + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TableCell.java b/messages/java/src/generated/java/io/cucumber/messages/TableCell.java new file mode 100644 index 0000000000..3ca369becd --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TableCell.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TableCell { + private final Location location; + private final String value; + + public TableCell( + Location location, + String value + ) { + this.location = requireNonNull(location, "TableCell.location cannot be null"); + this.value = requireNonNull(value, "TableCell.value cannot be null"); + } + + public Location getLocation() { + return location; + } + + public String getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableCell that = (TableCell) o; + return + location.equals(that.location) && + value.equals(that.value); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + value + ); + } + + @Override + public String toString() { + return "TableCell{" + + "location=" + location + + ", value=" + value + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TableRow.java b/messages/java/src/generated/java/io/cucumber/messages/TableRow.java new file mode 100644 index 0000000000..a911e92c19 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TableRow.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TableRow { + private final Location location; + private final java.util.List cells; + private final String id; + + public TableRow( + Location location, + java.util.List cells, + String id + ) { + this.location = requireNonNull(location, "TableRow.location cannot be null"); + this.cells = unmodifiableList(new ArrayList<>(requireNonNull(cells, "TableRow.cells cannot be null"))); + this.id = requireNonNull(id, "TableRow.id cannot be null"); + } + + public Location getLocation() { + return location; + } + + public java.util.List getCells() { + return cells; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TableRow that = (TableRow) o; + return + location.equals(that.location) && + cells.equals(that.cells) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + cells, + id + ); + } + + @Override + public String toString() { + return "TableRow{" + + "location=" + location + + ", cells=" + cells + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Tag.java b/messages/java/src/generated/java/io/cucumber/messages/Tag.java new file mode 100644 index 0000000000..52a675d980 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Tag.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Tag { + private final Location location; + private final String name; + private final String id; + + public Tag( + Location location, + String name, + String id + ) { + this.location = requireNonNull(location, "Tag.location cannot be null"); + this.name = requireNonNull(name, "Tag.name cannot be null"); + this.id = requireNonNull(id, "Tag.id cannot be null"); + } + + public Location getLocation() { + return location; + } + + public String getName() { + return name; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Tag that = (Tag) o; + return + location.equals(that.location) && + name.equals(that.name) && + id.equals(that.id); + } + + @Override + public int hashCode() { + return Objects.hash( + location, + name, + id + ); + } + + @Override + public String toString() { + return "Tag{" + + "location=" + location + + ", name=" + name + + ", id=" + id + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestCase.java b/messages/java/src/generated/java/io/cucumber/messages/TestCase.java new file mode 100644 index 0000000000..39c4ef1b40 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestCase.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestCase { + private final String id; + private final String pickleId; + private final java.util.List testSteps; + + public TestCase( + String id, + String pickleId, + java.util.List testSteps + ) { + this.id = requireNonNull(id, "TestCase.id cannot be null"); + this.pickleId = requireNonNull(pickleId, "TestCase.pickleId cannot be null"); + this.testSteps = unmodifiableList(new ArrayList<>(requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); + } + + public String getId() { + return id; + } + + public String getPickleId() { + return pickleId; + } + + public java.util.List getTestSteps() { + return testSteps; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCase that = (TestCase) o; + return + id.equals(that.id) && + pickleId.equals(that.pickleId) && + testSteps.equals(that.testSteps); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + pickleId, + testSteps + ); + } + + @Override + public String toString() { + return "TestCase{" + + "id=" + id + + ", pickleId=" + pickleId + + ", testSteps=" + testSteps + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestCaseFinished.java b/messages/java/src/generated/java/io/cucumber/messages/TestCaseFinished.java new file mode 100644 index 0000000000..b816b7b3e0 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestCaseFinished.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestCaseFinished { + private final String testCaseStartedId; + private final Timestamp timestamp; + private final Boolean willBeRetried; + + public TestCaseFinished( + String testCaseStartedId, + Timestamp timestamp, + Boolean willBeRetried + ) { + this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); + this.willBeRetried = requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); + } + + public String getTestCaseStartedId() { + return testCaseStartedId; + } + + public Timestamp getTimestamp() { + return timestamp; + } + + public Boolean getWillBeRetried() { + return willBeRetried; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseFinished that = (TestCaseFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + timestamp.equals(that.timestamp) && + willBeRetried.equals(that.willBeRetried); + } + + @Override + public int hashCode() { + return Objects.hash( + testCaseStartedId, + timestamp, + willBeRetried + ); + } + + @Override + public String toString() { + return "TestCaseFinished{" + + "testCaseStartedId=" + testCaseStartedId + + ", timestamp=" + timestamp + + ", willBeRetried=" + willBeRetried + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestCaseStarted.java b/messages/java/src/generated/java/io/cucumber/messages/TestCaseStarted.java new file mode 100644 index 0000000000..4b9431de22 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestCaseStarted.java @@ -0,0 +1,77 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestCaseStarted { + private final Long attempt; + private final String id; + private final String testCaseId; + private final Timestamp timestamp; + + public TestCaseStarted( + Long attempt, + String id, + String testCaseId, + Timestamp timestamp + ) { + this.attempt = requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); + this.id = requireNonNull(id, "TestCaseStarted.id cannot be null"); + this.testCaseId = requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); + } + + public Long getAttempt() { + return attempt; + } + + public String getId() { + return id; + } + + public String getTestCaseId() { + return testCaseId; + } + + public Timestamp getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestCaseStarted that = (TestCaseStarted) o; + return + attempt.equals(that.attempt) && + id.equals(that.id) && + testCaseId.equals(that.testCaseId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + attempt, + id, + testCaseId, + timestamp + ); + } + + @Override + public String toString() { + return "TestCaseStarted{" + + "attempt=" + attempt + + ", id=" + id + + ", testCaseId=" + testCaseId + + ", timestamp=" + timestamp + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestRunFinished.java b/messages/java/src/generated/java/io/cucumber/messages/TestRunFinished.java new file mode 100644 index 0000000000..610b78d05a --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestRunFinished.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestRunFinished { + private final String message; + private final Boolean success; + private final Timestamp timestamp; + + public TestRunFinished( + String message, + Boolean success, + Timestamp timestamp + ) { + this.message = message; + this.success = requireNonNull(success, "TestRunFinished.success cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); + } + + public Optional getMessage() { + return Optional.ofNullable(message); + } + + public Boolean getSuccess() { + return success; + } + + public Timestamp getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunFinished that = (TestRunFinished) o; + return + Objects.equals(message, that.message) && + success.equals(that.success) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + message, + success, + timestamp + ); + } + + @Override + public String toString() { + return "TestRunFinished{" + + "message=" + message + + ", success=" + success + + ", timestamp=" + timestamp + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestRunStarted.java b/messages/java/src/generated/java/io/cucumber/messages/TestRunStarted.java new file mode 100644 index 0000000000..08077e1249 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestRunStarted.java @@ -0,0 +1,47 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestRunStarted { + private final Timestamp timestamp; + + public TestRunStarted( + Timestamp timestamp + ) { + this.timestamp = requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); + } + + public Timestamp getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestRunStarted that = (TestRunStarted) o; + return + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + timestamp + ); + } + + @Override + public String toString() { + return "TestRunStarted{" + + "timestamp=" + timestamp + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStep.java b/messages/java/src/generated/java/io/cucumber/messages/TestStep.java new file mode 100644 index 0000000000..139b698df5 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestStep.java @@ -0,0 +1,87 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestStep { + private final String hookId; + private final String id; + private final String pickleStepId; + private final java.util.List stepDefinitionIds; + private final java.util.List stepMatchArgumentsLists; + + public TestStep( + String hookId, + String id, + String pickleStepId, + java.util.List stepDefinitionIds, + java.util.List stepMatchArgumentsLists + ) { + this.hookId = hookId; + this.id = requireNonNull(id, "TestStep.id cannot be null"); + this.pickleStepId = pickleStepId; + this.stepDefinitionIds = stepDefinitionIds == null ? null : unmodifiableList(new ArrayList<>(stepDefinitionIds)); + this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : unmodifiableList(new ArrayList<>(stepMatchArgumentsLists)); + } + + public Optional getHookId() { + return Optional.ofNullable(hookId); + } + + public String getId() { + return id; + } + + public Optional getPickleStepId() { + return Optional.ofNullable(pickleStepId); + } + + public Optional> getStepDefinitionIds() { + return Optional.ofNullable(stepDefinitionIds); + } + + public Optional> getStepMatchArgumentsLists() { + return Optional.ofNullable(stepMatchArgumentsLists); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStep that = (TestStep) o; + return + Objects.equals(hookId, that.hookId) && + id.equals(that.id) && + Objects.equals(pickleStepId, that.pickleStepId) && + Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && + Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); + } + + @Override + public int hashCode() { + return Objects.hash( + hookId, + id, + pickleStepId, + stepDefinitionIds, + stepMatchArgumentsLists + ); + } + + @Override + public String toString() { + return "TestStep{" + + "hookId=" + hookId + + ", id=" + id + + ", pickleStepId=" + pickleStepId + + ", stepDefinitionIds=" + stepDefinitionIds + + ", stepMatchArgumentsLists=" + stepMatchArgumentsLists + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepFinished.java b/messages/java/src/generated/java/io/cucumber/messages/TestStepFinished.java new file mode 100644 index 0000000000..aed5d943fc --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestStepFinished.java @@ -0,0 +1,77 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestStepFinished { + private final String testCaseStartedId; + private final String testStepId; + private final TestStepResult testStepResult; + private final Timestamp timestamp; + + public TestStepFinished( + String testCaseStartedId, + String testStepId, + TestStepResult testStepResult, + Timestamp timestamp + ) { + this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); + this.testStepId = requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); + this.testStepResult = requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); + } + + public String getTestCaseStartedId() { + return testCaseStartedId; + } + + public String getTestStepId() { + return testStepId; + } + + public TestStepResult getTestStepResult() { + return testStepResult; + } + + public Timestamp getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepFinished that = (TestStepFinished) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + testStepResult.equals(that.testStepResult) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + testCaseStartedId, + testStepId, + testStepResult, + timestamp + ); + } + + @Override + public String toString() { + return "TestStepFinished{" + + "testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", testStepResult=" + testStepResult + + ", timestamp=" + timestamp + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepResult.java b/messages/java/src/generated/java/io/cucumber/messages/TestStepResult.java new file mode 100644 index 0000000000..738ee03747 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestStepResult.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestStepResult { + private final Duration duration; + private final String message; + private final TestStepResultStatus status; + + public TestStepResult( + Duration duration, + String message, + TestStepResultStatus status + ) { + this.duration = requireNonNull(duration, "TestStepResult.duration cannot be null"); + this.message = message; + this.status = requireNonNull(status, "TestStepResult.status cannot be null"); + } + + public Duration getDuration() { + return duration; + } + + public Optional getMessage() { + return Optional.ofNullable(message); + } + + public TestStepResultStatus getStatus() { + return status; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepResult that = (TestStepResult) o; + return + duration.equals(that.duration) && + Objects.equals(message, that.message) && + status.equals(that.status); + } + + @Override + public int hashCode() { + return Objects.hash( + duration, + message, + status + ); + } + + @Override + public String toString() { + return "TestStepResult{" + + "duration=" + duration + + ", message=" + message + + ", status=" + status + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepResultStatus.java b/messages/java/src/generated/java/io/cucumber/messages/TestStepResultStatus.java new file mode 100644 index 0000000000..d22584ca83 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestStepResultStatus.java @@ -0,0 +1,44 @@ +package io.cucumber.messages; + +// Generated code +@SuppressWarnings("unused") +public enum TestStepResultStatus { + + UNKNOWN("UNKNOWN"), + + PASSED("PASSED"), + + SKIPPED("SKIPPED"), + + PENDING("PENDING"), + + UNDEFINED("UNDEFINED"), + + AMBIGUOUS("AMBIGUOUS"), + + FAILED("FAILED"); + + private final String value; + + TestStepResultStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static TestStepResultStatus fromValue(String value) { + for (TestStepResultStatus v : values()) { + if (v.value.equals(value)) { + return v; + } + } + throw new IllegalArgumentException(value); + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepStarted.java b/messages/java/src/generated/java/io/cucumber/messages/TestStepStarted.java new file mode 100644 index 0000000000..e9ad21d5ac --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/TestStepStarted.java @@ -0,0 +1,67 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class TestStepStarted { + private final String testCaseStartedId; + private final String testStepId; + private final Timestamp timestamp; + + public TestStepStarted( + String testCaseStartedId, + String testStepId, + Timestamp timestamp + ) { + this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); + this.testStepId = requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); + this.timestamp = requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); + } + + public String getTestCaseStartedId() { + return testCaseStartedId; + } + + public String getTestStepId() { + return testStepId; + } + + public Timestamp getTimestamp() { + return timestamp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestStepStarted that = (TestStepStarted) o; + return + testCaseStartedId.equals(that.testCaseStartedId) && + testStepId.equals(that.testStepId) && + timestamp.equals(that.timestamp); + } + + @Override + public int hashCode() { + return Objects.hash( + testCaseStartedId, + testStepId, + timestamp + ); + } + + @Override + public String toString() { + return "TestStepStarted{" + + "testCaseStartedId=" + testCaseStartedId + + ", testStepId=" + testStepId + + ", timestamp=" + timestamp + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/Timestamp.java b/messages/java/src/generated/java/io/cucumber/messages/Timestamp.java new file mode 100644 index 0000000000..ee1ce7620d --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/Timestamp.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class Timestamp { + private final Long seconds; + private final Long nanos; + + public Timestamp( + Long seconds, + Long nanos + ) { + this.seconds = requireNonNull(seconds, "Timestamp.seconds cannot be null"); + this.nanos = requireNonNull(nanos, "Timestamp.nanos cannot be null"); + } + + public Long getSeconds() { + return seconds; + } + + public Long getNanos() { + return nanos; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Timestamp that = (Timestamp) o; + return + seconds.equals(that.seconds) && + nanos.equals(that.nanos); + } + + @Override + public int hashCode() { + return Objects.hash( + seconds, + nanos + ); + } + + @Override + public String toString() { + return "Timestamp{" + + "seconds=" + seconds + + ", nanos=" + nanos + + '}'; + } +} diff --git a/messages/java/src/generated/java/io/cucumber/messages/UndefinedParameterType.java b/messages/java/src/generated/java/io/cucumber/messages/UndefinedParameterType.java new file mode 100644 index 0000000000..39c3eca7a8 --- /dev/null +++ b/messages/java/src/generated/java/io/cucumber/messages/UndefinedParameterType.java @@ -0,0 +1,57 @@ +package io.cucumber.messages; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; + +// Generated code +@SuppressWarnings("unused") +public final class UndefinedParameterType { + private final String expression; + private final String name; + + public UndefinedParameterType( + String expression, + String name + ) { + this.expression = requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); + this.name = requireNonNull(name, "UndefinedParameterType.name cannot be null"); + } + + public String getExpression() { + return expression; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + UndefinedParameterType that = (UndefinedParameterType) o; + return + expression.equals(that.expression) && + name.equals(that.name); + } + + @Override + public int hashCode() { + return Objects.hash( + expression, + name + ); + } + + @Override + public String toString() { + return "UndefinedParameterType{" + + "expression=" + expression + + ", name=" + name + + '}'; + } +} diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java index 9f712244fd..2734ded1a7 100644 --- a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java +++ b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java @@ -1,7 +1,5 @@ package io.cucumber.messages; -import io.cucumber.messages.Messages.Envelope; - import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; diff --git a/messages/java/src/main/java/io/cucumber/messages/Messages.java b/messages/java/src/main/java/io/cucumber/messages/Messages.java deleted file mode 100644 index 2a428a89b9..0000000000 --- a/messages/java/src/main/java/io/cucumber/messages/Messages.java +++ /dev/null @@ -1,4037 +0,0 @@ -package io.cucumber.messages; - -import java.util.ArrayList; -import java.util.Objects; -import java.util.Optional; - -import static java.util.Collections.unmodifiableList; -import static java.util.Objects.requireNonNull; - -// Generated code -@SuppressWarnings("unused") -public final class Messages { - - private Messages() {} - - public static final class Attachment { - private final String body; - private final AttachmentContentEncoding contentEncoding; - private final String fileName; - private final String mediaType; - private final Source source; - private final String testCaseStartedId; - private final String testStepId; - private final String url; - - public Attachment( - String body, - AttachmentContentEncoding contentEncoding, - String fileName, - String mediaType, - Source source, - String testCaseStartedId, - String testStepId, - String url - ) { - this.body = requireNonNull(body, "Attachment.body cannot be null"); - this.contentEncoding = requireNonNull(contentEncoding, "Attachment.contentEncoding cannot be null"); - this.fileName = fileName; - this.mediaType = requireNonNull(mediaType, "Attachment.mediaType cannot be null"); - this.source = source; - this.testCaseStartedId = testCaseStartedId; - this.testStepId = testStepId; - this.url = url; - } - - public String getBody() { - return body; - } - - public AttachmentContentEncoding getContentEncoding() { - return contentEncoding; - } - - public Optional getFileName() { - return Optional.ofNullable(fileName); - } - - public String getMediaType() { - return mediaType; - } - - public Optional getSource() { - return Optional.ofNullable(source); - } - - public Optional getTestCaseStartedId() { - return Optional.ofNullable(testCaseStartedId); - } - - public Optional getTestStepId() { - return Optional.ofNullable(testStepId); - } - - public Optional getUrl() { - return Optional.ofNullable(url); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Attachment that = (Attachment) o; - return - body.equals(that.body) && - contentEncoding.equals(that.contentEncoding) && - Objects.equals(fileName, that.fileName) && - mediaType.equals(that.mediaType) && - Objects.equals(source, that.source) && - Objects.equals(testCaseStartedId, that.testCaseStartedId) && - Objects.equals(testStepId, that.testStepId) && - Objects.equals(url, that.url); - } - - @Override - public int hashCode() { - return Objects.hash( - body, - contentEncoding, - fileName, - mediaType, - source, - testCaseStartedId, - testStepId, - url - ); - } - - @Override - public String toString() { - return "Attachment{" + - "body=" + body + - ", contentEncoding=" + contentEncoding + - ", fileName=" + fileName + - ", mediaType=" + mediaType + - ", source=" + source + - ", testCaseStartedId=" + testCaseStartedId + - ", testStepId=" + testStepId + - ", url=" + url + - '}'; - } - } - - public static final class Duration { - private final Long seconds; - private final Long nanos; - - public Duration( - Long seconds, - Long nanos - ) { - this.seconds = requireNonNull(seconds, "Duration.seconds cannot be null"); - this.nanos = requireNonNull(nanos, "Duration.nanos cannot be null"); - } - - public Long getSeconds() { - return seconds; - } - - public Long getNanos() { - return nanos; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Duration that = (Duration) o; - return - seconds.equals(that.seconds) && - nanos.equals(that.nanos); - } - - @Override - public int hashCode() { - return Objects.hash( - seconds, - nanos - ); - } - - @Override - public String toString() { - return "Duration{" + - "seconds=" + seconds + - ", nanos=" + nanos + - '}'; - } - } - - public static final class Envelope { - private final Attachment attachment; - private final GherkinDocument gherkinDocument; - private final Hook hook; - private final Meta meta; - private final ParameterType parameterType; - private final ParseError parseError; - private final Pickle pickle; - private final Source source; - private final StepDefinition stepDefinition; - private final TestCase testCase; - private final TestCaseFinished testCaseFinished; - private final TestCaseStarted testCaseStarted; - private final TestRunFinished testRunFinished; - private final TestRunStarted testRunStarted; - private final TestStepFinished testStepFinished; - private final TestStepStarted testStepStarted; - private final UndefinedParameterType undefinedParameterType; - - public static Envelope of(Attachment attachment) { - return new Envelope( - requireNonNull(attachment, "Envelope.attachment cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(GherkinDocument gherkinDocument) { - return new Envelope( - null, - requireNonNull(gherkinDocument, "Envelope.gherkinDocument cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(Hook hook) { - return new Envelope( - null, - null, - requireNonNull(hook, "Envelope.hook cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(Meta meta) { - return new Envelope( - null, - null, - null, - requireNonNull(meta, "Envelope.meta cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(ParameterType parameterType) { - return new Envelope( - null, - null, - null, - null, - requireNonNull(parameterType, "Envelope.parameterType cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(ParseError parseError) { - return new Envelope( - null, - null, - null, - null, - null, - requireNonNull(parseError, "Envelope.parseError cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(Pickle pickle) { - return new Envelope( - null, - null, - null, - null, - null, - null, - requireNonNull(pickle, "Envelope.pickle cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(Source source) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - requireNonNull(source, "Envelope.source cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(StepDefinition stepDefinition) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(stepDefinition, "Envelope.stepDefinition cannot be null"), - null, - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(TestCase testCase) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(testCase, "Envelope.testCase cannot be null"), - null, - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(TestCaseFinished testCaseFinished) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(testCaseFinished, "Envelope.testCaseFinished cannot be null"), - null, - null, - null, - null, - null, - null - ); - } - - public static Envelope of(TestCaseStarted testCaseStarted) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(testCaseStarted, "Envelope.testCaseStarted cannot be null"), - null, - null, - null, - null, - null - ); - } - - public static Envelope of(TestRunFinished testRunFinished) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(testRunFinished, "Envelope.testRunFinished cannot be null"), - null, - null, - null, - null - ); - } - - public static Envelope of(TestRunStarted testRunStarted) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(testRunStarted, "Envelope.testRunStarted cannot be null"), - null, - null, - null - ); - } - - public static Envelope of(TestStepFinished testStepFinished) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(testStepFinished, "Envelope.testStepFinished cannot be null"), - null, - null - ); - } - - public static Envelope of(TestStepStarted testStepStarted) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(testStepStarted, "Envelope.testStepStarted cannot be null"), - null - ); - } - - public static Envelope of(UndefinedParameterType undefinedParameterType) { - return new Envelope( - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - null, - requireNonNull(undefinedParameterType, "Envelope.undefinedParameterType cannot be null") - ); - } - - public Envelope( - Attachment attachment, - GherkinDocument gherkinDocument, - Hook hook, - Meta meta, - ParameterType parameterType, - ParseError parseError, - Pickle pickle, - Source source, - StepDefinition stepDefinition, - TestCase testCase, - TestCaseFinished testCaseFinished, - TestCaseStarted testCaseStarted, - TestRunFinished testRunFinished, - TestRunStarted testRunStarted, - TestStepFinished testStepFinished, - TestStepStarted testStepStarted, - UndefinedParameterType undefinedParameterType - ) { - this.attachment = attachment; - this.gherkinDocument = gherkinDocument; - this.hook = hook; - this.meta = meta; - this.parameterType = parameterType; - this.parseError = parseError; - this.pickle = pickle; - this.source = source; - this.stepDefinition = stepDefinition; - this.testCase = testCase; - this.testCaseFinished = testCaseFinished; - this.testCaseStarted = testCaseStarted; - this.testRunFinished = testRunFinished; - this.testRunStarted = testRunStarted; - this.testStepFinished = testStepFinished; - this.testStepStarted = testStepStarted; - this.undefinedParameterType = undefinedParameterType; - } - - public Optional getAttachment() { - return Optional.ofNullable(attachment); - } - - public Optional getGherkinDocument() { - return Optional.ofNullable(gherkinDocument); - } - - public Optional getHook() { - return Optional.ofNullable(hook); - } - - public Optional getMeta() { - return Optional.ofNullable(meta); - } - - public Optional getParameterType() { - return Optional.ofNullable(parameterType); - } - - public Optional getParseError() { - return Optional.ofNullable(parseError); - } - - public Optional getPickle() { - return Optional.ofNullable(pickle); - } - - public Optional getSource() { - return Optional.ofNullable(source); - } - - public Optional getStepDefinition() { - return Optional.ofNullable(stepDefinition); - } - - public Optional getTestCase() { - return Optional.ofNullable(testCase); - } - - public Optional getTestCaseFinished() { - return Optional.ofNullable(testCaseFinished); - } - - public Optional getTestCaseStarted() { - return Optional.ofNullable(testCaseStarted); - } - - public Optional getTestRunFinished() { - return Optional.ofNullable(testRunFinished); - } - - public Optional getTestRunStarted() { - return Optional.ofNullable(testRunStarted); - } - - public Optional getTestStepFinished() { - return Optional.ofNullable(testStepFinished); - } - - public Optional getTestStepStarted() { - return Optional.ofNullable(testStepStarted); - } - - public Optional getUndefinedParameterType() { - return Optional.ofNullable(undefinedParameterType); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Envelope that = (Envelope) o; - return - Objects.equals(attachment, that.attachment) && - Objects.equals(gherkinDocument, that.gherkinDocument) && - Objects.equals(hook, that.hook) && - Objects.equals(meta, that.meta) && - Objects.equals(parameterType, that.parameterType) && - Objects.equals(parseError, that.parseError) && - Objects.equals(pickle, that.pickle) && - Objects.equals(source, that.source) && - Objects.equals(stepDefinition, that.stepDefinition) && - Objects.equals(testCase, that.testCase) && - Objects.equals(testCaseFinished, that.testCaseFinished) && - Objects.equals(testCaseStarted, that.testCaseStarted) && - Objects.equals(testRunFinished, that.testRunFinished) && - Objects.equals(testRunStarted, that.testRunStarted) && - Objects.equals(testStepFinished, that.testStepFinished) && - Objects.equals(testStepStarted, that.testStepStarted) && - Objects.equals(undefinedParameterType, that.undefinedParameterType); - } - - @Override - public int hashCode() { - return Objects.hash( - attachment, - gherkinDocument, - hook, - meta, - parameterType, - parseError, - pickle, - source, - stepDefinition, - testCase, - testCaseFinished, - testCaseStarted, - testRunFinished, - testRunStarted, - testStepFinished, - testStepStarted, - undefinedParameterType - ); - } - - @Override - public String toString() { - return "Envelope{" + - "attachment=" + attachment + - ", gherkinDocument=" + gherkinDocument + - ", hook=" + hook + - ", meta=" + meta + - ", parameterType=" + parameterType + - ", parseError=" + parseError + - ", pickle=" + pickle + - ", source=" + source + - ", stepDefinition=" + stepDefinition + - ", testCase=" + testCase + - ", testCaseFinished=" + testCaseFinished + - ", testCaseStarted=" + testCaseStarted + - ", testRunFinished=" + testRunFinished + - ", testRunStarted=" + testRunStarted + - ", testStepFinished=" + testStepFinished + - ", testStepStarted=" + testStepStarted + - ", undefinedParameterType=" + undefinedParameterType + - '}'; - } - } - - public static final class GherkinDocument { - private final String uri; - private final Feature feature; - private final java.util.List comments; - - public GherkinDocument( - String uri, - Feature feature, - java.util.List comments - ) { - this.uri = uri; - this.feature = feature; - this.comments = unmodifiableList(new ArrayList<>(requireNonNull(comments, "GherkinDocument.comments cannot be null"))); - } - - public Optional getUri() { - return Optional.ofNullable(uri); - } - - public Optional getFeature() { - return Optional.ofNullable(feature); - } - - public java.util.List getComments() { - return comments; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - GherkinDocument that = (GherkinDocument) o; - return - Objects.equals(uri, that.uri) && - Objects.equals(feature, that.feature) && - comments.equals(that.comments); - } - - @Override - public int hashCode() { - return Objects.hash( - uri, - feature, - comments - ); - } - - @Override - public String toString() { - return "GherkinDocument{" + - "uri=" + uri + - ", feature=" + feature + - ", comments=" + comments + - '}'; - } - } - - public static final class Background { - private final Location location; - private final String keyword; - private final String name; - private final String description; - private final java.util.List steps; - private final String id; - - public Background( - Location location, - String keyword, - String name, - String description, - java.util.List steps, - String id - ) { - this.location = requireNonNull(location, "Background.location cannot be null"); - this.keyword = requireNonNull(keyword, "Background.keyword cannot be null"); - this.name = requireNonNull(name, "Background.name cannot be null"); - this.description = requireNonNull(description, "Background.description cannot be null"); - this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Background.steps cannot be null"))); - this.id = requireNonNull(id, "Background.id cannot be null"); - } - - public Location getLocation() { - return location; - } - - public String getKeyword() { - return keyword; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public java.util.List getSteps() { - return steps; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Background that = (Background) o; - return - location.equals(that.location) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - steps.equals(that.steps) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - keyword, - name, - description, - steps, - id - ); - } - - @Override - public String toString() { - return "Background{" + - "location=" + location + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", steps=" + steps + - ", id=" + id + - '}'; - } - } - - public static final class Comment { - private final Location location; - private final String text; - - public Comment( - Location location, - String text - ) { - this.location = requireNonNull(location, "Comment.location cannot be null"); - this.text = requireNonNull(text, "Comment.text cannot be null"); - } - - public Location getLocation() { - return location; - } - - public String getText() { - return text; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Comment that = (Comment) o; - return - location.equals(that.location) && - text.equals(that.text); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - text - ); - } - - @Override - public String toString() { - return "Comment{" + - "location=" + location + - ", text=" + text + - '}'; - } - } - - public static final class DataTable { - private final Location location; - private final java.util.List rows; - - public DataTable( - Location location, - java.util.List rows - ) { - this.location = requireNonNull(location, "DataTable.location cannot be null"); - this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "DataTable.rows cannot be null"))); - } - - public Location getLocation() { - return location; - } - - public java.util.List getRows() { - return rows; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DataTable that = (DataTable) o; - return - location.equals(that.location) && - rows.equals(that.rows); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - rows - ); - } - - @Override - public String toString() { - return "DataTable{" + - "location=" + location + - ", rows=" + rows + - '}'; - } - } - - public static final class DocString { - private final Location location; - private final String mediaType; - private final String content; - private final String delimiter; - - public DocString( - Location location, - String mediaType, - String content, - String delimiter - ) { - this.location = requireNonNull(location, "DocString.location cannot be null"); - this.mediaType = mediaType; - this.content = requireNonNull(content, "DocString.content cannot be null"); - this.delimiter = requireNonNull(delimiter, "DocString.delimiter cannot be null"); - } - - public Location getLocation() { - return location; - } - - public Optional getMediaType() { - return Optional.ofNullable(mediaType); - } - - public String getContent() { - return content; - } - - public String getDelimiter() { - return delimiter; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - DocString that = (DocString) o; - return - location.equals(that.location) && - Objects.equals(mediaType, that.mediaType) && - content.equals(that.content) && - delimiter.equals(that.delimiter); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - mediaType, - content, - delimiter - ); - } - - @Override - public String toString() { - return "DocString{" + - "location=" + location + - ", mediaType=" + mediaType + - ", content=" + content + - ", delimiter=" + delimiter + - '}'; - } - } - - public static final class Examples { - private final Location location; - private final java.util.List tags; - private final String keyword; - private final String name; - private final String description; - private final TableRow tableHeader; - private final java.util.List tableBody; - private final String id; - - public Examples( - Location location, - java.util.List tags, - String keyword, - String name, - String description, - TableRow tableHeader, - java.util.List tableBody, - String id - ) { - this.location = requireNonNull(location, "Examples.location cannot be null"); - this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Examples.tags cannot be null"))); - this.keyword = requireNonNull(keyword, "Examples.keyword cannot be null"); - this.name = requireNonNull(name, "Examples.name cannot be null"); - this.description = requireNonNull(description, "Examples.description cannot be null"); - this.tableHeader = tableHeader; - this.tableBody = unmodifiableList(new ArrayList<>(requireNonNull(tableBody, "Examples.tableBody cannot be null"))); - this.id = requireNonNull(id, "Examples.id cannot be null"); - } - - public Location getLocation() { - return location; - } - - public java.util.List getTags() { - return tags; - } - - public String getKeyword() { - return keyword; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public Optional getTableHeader() { - return Optional.ofNullable(tableHeader); - } - - public java.util.List getTableBody() { - return tableBody; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Examples that = (Examples) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - Objects.equals(tableHeader, that.tableHeader) && - tableBody.equals(that.tableBody) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - keyword, - name, - description, - tableHeader, - tableBody, - id - ); - } - - @Override - public String toString() { - return "Examples{" + - "location=" + location + - ", tags=" + tags + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", tableHeader=" + tableHeader + - ", tableBody=" + tableBody + - ", id=" + id + - '}'; - } - } - - public static final class Feature { - private final Location location; - private final java.util.List tags; - private final String language; - private final String keyword; - private final String name; - private final String description; - private final java.util.List children; - - public Feature( - Location location, - java.util.List tags, - String language, - String keyword, - String name, - String description, - java.util.List children - ) { - this.location = requireNonNull(location, "Feature.location cannot be null"); - this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Feature.tags cannot be null"))); - this.language = requireNonNull(language, "Feature.language cannot be null"); - this.keyword = requireNonNull(keyword, "Feature.keyword cannot be null"); - this.name = requireNonNull(name, "Feature.name cannot be null"); - this.description = requireNonNull(description, "Feature.description cannot be null"); - this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Feature.children cannot be null"))); - } - - public Location getLocation() { - return location; - } - - public java.util.List getTags() { - return tags; - } - - public String getLanguage() { - return language; - } - - public String getKeyword() { - return keyword; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public java.util.List getChildren() { - return children; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Feature that = (Feature) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - language.equals(that.language) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - children.equals(that.children); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - language, - keyword, - name, - description, - children - ); - } - - @Override - public String toString() { - return "Feature{" + - "location=" + location + - ", tags=" + tags + - ", language=" + language + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", children=" + children + - '}'; - } - } - - public static final class FeatureChild { - private final Rule rule; - private final Background background; - private final Scenario scenario; - - public static FeatureChild of(Rule rule) { - return new FeatureChild( - requireNonNull(rule, "FeatureChild.rule cannot be null"), - null, - null - ); - } - - public static FeatureChild of(Background background) { - return new FeatureChild( - null, - requireNonNull(background, "FeatureChild.background cannot be null"), - null - ); - } - - public static FeatureChild of(Scenario scenario) { - return new FeatureChild( - null, - null, - requireNonNull(scenario, "FeatureChild.scenario cannot be null") - ); - } - - public FeatureChild( - Rule rule, - Background background, - Scenario scenario - ) { - this.rule = rule; - this.background = background; - this.scenario = scenario; - } - - public Optional getRule() { - return Optional.ofNullable(rule); - } - - public Optional getBackground() { - return Optional.ofNullable(background); - } - - public Optional getScenario() { - return Optional.ofNullable(scenario); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - FeatureChild that = (FeatureChild) o; - return - Objects.equals(rule, that.rule) && - Objects.equals(background, that.background) && - Objects.equals(scenario, that.scenario); - } - - @Override - public int hashCode() { - return Objects.hash( - rule, - background, - scenario - ); - } - - @Override - public String toString() { - return "FeatureChild{" + - "rule=" + rule + - ", background=" + background + - ", scenario=" + scenario + - '}'; - } - } - - public static final class Rule { - private final Location location; - private final java.util.List tags; - private final String keyword; - private final String name; - private final String description; - private final java.util.List children; - private final String id; - - public Rule( - Location location, - java.util.List tags, - String keyword, - String name, - String description, - java.util.List children, - String id - ) { - this.location = requireNonNull(location, "Rule.location cannot be null"); - this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Rule.tags cannot be null"))); - this.keyword = requireNonNull(keyword, "Rule.keyword cannot be null"); - this.name = requireNonNull(name, "Rule.name cannot be null"); - this.description = requireNonNull(description, "Rule.description cannot be null"); - this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Rule.children cannot be null"))); - this.id = requireNonNull(id, "Rule.id cannot be null"); - } - - public Location getLocation() { - return location; - } - - public java.util.List getTags() { - return tags; - } - - public String getKeyword() { - return keyword; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public java.util.List getChildren() { - return children; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Rule that = (Rule) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - children.equals(that.children) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - keyword, - name, - description, - children, - id - ); - } - - @Override - public String toString() { - return "Rule{" + - "location=" + location + - ", tags=" + tags + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", children=" + children + - ", id=" + id + - '}'; - } - } - - public static final class RuleChild { - private final Background background; - private final Scenario scenario; - - public static RuleChild of(Background background) { - return new RuleChild( - requireNonNull(background, "RuleChild.background cannot be null"), - null - ); - } - - public static RuleChild of(Scenario scenario) { - return new RuleChild( - null, - requireNonNull(scenario, "RuleChild.scenario cannot be null") - ); - } - - public RuleChild( - Background background, - Scenario scenario - ) { - this.background = background; - this.scenario = scenario; - } - - public Optional getBackground() { - return Optional.ofNullable(background); - } - - public Optional getScenario() { - return Optional.ofNullable(scenario); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - RuleChild that = (RuleChild) o; - return - Objects.equals(background, that.background) && - Objects.equals(scenario, that.scenario); - } - - @Override - public int hashCode() { - return Objects.hash( - background, - scenario - ); - } - - @Override - public String toString() { - return "RuleChild{" + - "background=" + background + - ", scenario=" + scenario + - '}'; - } - } - - public static final class Scenario { - private final Location location; - private final java.util.List tags; - private final String keyword; - private final String name; - private final String description; - private final java.util.List steps; - private final java.util.List examples; - private final String id; - - public Scenario( - Location location, - java.util.List tags, - String keyword, - String name, - String description, - java.util.List steps, - java.util.List examples, - String id - ) { - this.location = requireNonNull(location, "Scenario.location cannot be null"); - this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Scenario.tags cannot be null"))); - this.keyword = requireNonNull(keyword, "Scenario.keyword cannot be null"); - this.name = requireNonNull(name, "Scenario.name cannot be null"); - this.description = requireNonNull(description, "Scenario.description cannot be null"); - this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Scenario.steps cannot be null"))); - this.examples = unmodifiableList(new ArrayList<>(requireNonNull(examples, "Scenario.examples cannot be null"))); - this.id = requireNonNull(id, "Scenario.id cannot be null"); - } - - public Location getLocation() { - return location; - } - - public java.util.List getTags() { - return tags; - } - - public String getKeyword() { - return keyword; - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } - - public java.util.List getSteps() { - return steps; - } - - public java.util.List getExamples() { - return examples; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Scenario that = (Scenario) o; - return - location.equals(that.location) && - tags.equals(that.tags) && - keyword.equals(that.keyword) && - name.equals(that.name) && - description.equals(that.description) && - steps.equals(that.steps) && - examples.equals(that.examples) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - tags, - keyword, - name, - description, - steps, - examples, - id - ); - } - - @Override - public String toString() { - return "Scenario{" + - "location=" + location + - ", tags=" + tags + - ", keyword=" + keyword + - ", name=" + name + - ", description=" + description + - ", steps=" + steps + - ", examples=" + examples + - ", id=" + id + - '}'; - } - } - - public static final class Step { - private final Location location; - private final String keyword; - private final String text; - private final DocString docString; - private final DataTable dataTable; - private final String id; - - public Step( - Location location, - String keyword, - String text, - DocString docString, - DataTable dataTable, - String id - ) { - this.location = requireNonNull(location, "Step.location cannot be null"); - this.keyword = requireNonNull(keyword, "Step.keyword cannot be null"); - this.text = requireNonNull(text, "Step.text cannot be null"); - this.docString = docString; - this.dataTable = dataTable; - this.id = requireNonNull(id, "Step.id cannot be null"); - } - - public Location getLocation() { - return location; - } - - public String getKeyword() { - return keyword; - } - - public String getText() { - return text; - } - - public Optional getDocString() { - return Optional.ofNullable(docString); - } - - public Optional getDataTable() { - return Optional.ofNullable(dataTable); - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Step that = (Step) o; - return - location.equals(that.location) && - keyword.equals(that.keyword) && - text.equals(that.text) && - Objects.equals(docString, that.docString) && - Objects.equals(dataTable, that.dataTable) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - keyword, - text, - docString, - dataTable, - id - ); - } - - @Override - public String toString() { - return "Step{" + - "location=" + location + - ", keyword=" + keyword + - ", text=" + text + - ", docString=" + docString + - ", dataTable=" + dataTable + - ", id=" + id + - '}'; - } - } - - public static final class TableCell { - private final Location location; - private final String value; - - public TableCell( - Location location, - String value - ) { - this.location = requireNonNull(location, "TableCell.location cannot be null"); - this.value = requireNonNull(value, "TableCell.value cannot be null"); - } - - public Location getLocation() { - return location; - } - - public String getValue() { - return value; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TableCell that = (TableCell) o; - return - location.equals(that.location) && - value.equals(that.value); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - value - ); - } - - @Override - public String toString() { - return "TableCell{" + - "location=" + location + - ", value=" + value + - '}'; - } - } - - public static final class TableRow { - private final Location location; - private final java.util.List cells; - private final String id; - - public TableRow( - Location location, - java.util.List cells, - String id - ) { - this.location = requireNonNull(location, "TableRow.location cannot be null"); - this.cells = unmodifiableList(new ArrayList<>(requireNonNull(cells, "TableRow.cells cannot be null"))); - this.id = requireNonNull(id, "TableRow.id cannot be null"); - } - - public Location getLocation() { - return location; - } - - public java.util.List getCells() { - return cells; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TableRow that = (TableRow) o; - return - location.equals(that.location) && - cells.equals(that.cells) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - cells, - id - ); - } - - @Override - public String toString() { - return "TableRow{" + - "location=" + location + - ", cells=" + cells + - ", id=" + id + - '}'; - } - } - - public static final class Tag { - private final Location location; - private final String name; - private final String id; - - public Tag( - Location location, - String name, - String id - ) { - this.location = requireNonNull(location, "Tag.location cannot be null"); - this.name = requireNonNull(name, "Tag.name cannot be null"); - this.id = requireNonNull(id, "Tag.id cannot be null"); - } - - public Location getLocation() { - return location; - } - - public String getName() { - return name; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Tag that = (Tag) o; - return - location.equals(that.location) && - name.equals(that.name) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - location, - name, - id - ); - } - - @Override - public String toString() { - return "Tag{" + - "location=" + location + - ", name=" + name + - ", id=" + id + - '}'; - } - } - - public static final class Hook { - private final String id; - private final SourceReference sourceReference; - private final String tagExpression; - - public Hook( - String id, - SourceReference sourceReference, - String tagExpression - ) { - this.id = requireNonNull(id, "Hook.id cannot be null"); - this.sourceReference = requireNonNull(sourceReference, "Hook.sourceReference cannot be null"); - this.tagExpression = tagExpression; - } - - public String getId() { - return id; - } - - public SourceReference getSourceReference() { - return sourceReference; - } - - public Optional getTagExpression() { - return Optional.ofNullable(tagExpression); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Hook that = (Hook) o; - return - id.equals(that.id) && - sourceReference.equals(that.sourceReference) && - Objects.equals(tagExpression, that.tagExpression); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - sourceReference, - tagExpression - ); - } - - @Override - public String toString() { - return "Hook{" + - "id=" + id + - ", sourceReference=" + sourceReference + - ", tagExpression=" + tagExpression + - '}'; - } - } - - public static final class Location { - private final Long line; - private final Long column; - - public Location( - Long line, - Long column - ) { - this.line = requireNonNull(line, "Location.line cannot be null"); - this.column = column; - } - - public Long getLine() { - return line; - } - - public Optional getColumn() { - return Optional.ofNullable(column); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Location that = (Location) o; - return - line.equals(that.line) && - Objects.equals(column, that.column); - } - - @Override - public int hashCode() { - return Objects.hash( - line, - column - ); - } - - @Override - public String toString() { - return "Location{" + - "line=" + line + - ", column=" + column + - '}'; - } - } - - public static final class Meta { - private final String protocolVersion; - private final Product implementation; - private final Product runtime; - private final Product os; - private final Product cpu; - private final Ci ci; - - public Meta( - String protocolVersion, - Product implementation, - Product runtime, - Product os, - Product cpu, - Ci ci - ) { - this.protocolVersion = requireNonNull(protocolVersion, "Meta.protocolVersion cannot be null"); - this.implementation = requireNonNull(implementation, "Meta.implementation cannot be null"); - this.runtime = requireNonNull(runtime, "Meta.runtime cannot be null"); - this.os = requireNonNull(os, "Meta.os cannot be null"); - this.cpu = requireNonNull(cpu, "Meta.cpu cannot be null"); - this.ci = ci; - } - - public String getProtocolVersion() { - return protocolVersion; - } - - public Product getImplementation() { - return implementation; - } - - public Product getRuntime() { - return runtime; - } - - public Product getOs() { - return os; - } - - public Product getCpu() { - return cpu; - } - - public Optional getCi() { - return Optional.ofNullable(ci); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Meta that = (Meta) o; - return - protocolVersion.equals(that.protocolVersion) && - implementation.equals(that.implementation) && - runtime.equals(that.runtime) && - os.equals(that.os) && - cpu.equals(that.cpu) && - Objects.equals(ci, that.ci); - } - - @Override - public int hashCode() { - return Objects.hash( - protocolVersion, - implementation, - runtime, - os, - cpu, - ci - ); - } - - @Override - public String toString() { - return "Meta{" + - "protocolVersion=" + protocolVersion + - ", implementation=" + implementation + - ", runtime=" + runtime + - ", os=" + os + - ", cpu=" + cpu + - ", ci=" + ci + - '}'; - } - } - - public static final class Ci { - private final String name; - private final String url; - private final String buildNumber; - private final Git git; - - public Ci( - String name, - String url, - String buildNumber, - Git git - ) { - this.name = requireNonNull(name, "Ci.name cannot be null"); - this.url = url; - this.buildNumber = buildNumber; - this.git = git; - } - - public String getName() { - return name; - } - - public Optional getUrl() { - return Optional.ofNullable(url); - } - - public Optional getBuildNumber() { - return Optional.ofNullable(buildNumber); - } - - public Optional getGit() { - return Optional.ofNullable(git); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Ci that = (Ci) o; - return - name.equals(that.name) && - Objects.equals(url, that.url) && - Objects.equals(buildNumber, that.buildNumber) && - Objects.equals(git, that.git); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - url, - buildNumber, - git - ); - } - - @Override - public String toString() { - return "Ci{" + - "name=" + name + - ", url=" + url + - ", buildNumber=" + buildNumber + - ", git=" + git + - '}'; - } - } - - public static final class Git { - private final String remote; - private final String revision; - private final String branch; - private final String tag; - - public Git( - String remote, - String revision, - String branch, - String tag - ) { - this.remote = requireNonNull(remote, "Git.remote cannot be null"); - this.revision = requireNonNull(revision, "Git.revision cannot be null"); - this.branch = branch; - this.tag = tag; - } - - public String getRemote() { - return remote; - } - - public String getRevision() { - return revision; - } - - public Optional getBranch() { - return Optional.ofNullable(branch); - } - - public Optional getTag() { - return Optional.ofNullable(tag); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Git that = (Git) o; - return - remote.equals(that.remote) && - revision.equals(that.revision) && - Objects.equals(branch, that.branch) && - Objects.equals(tag, that.tag); - } - - @Override - public int hashCode() { - return Objects.hash( - remote, - revision, - branch, - tag - ); - } - - @Override - public String toString() { - return "Git{" + - "remote=" + remote + - ", revision=" + revision + - ", branch=" + branch + - ", tag=" + tag + - '}'; - } - } - - public static final class Product { - private final String name; - private final String version; - - public Product( - String name, - String version - ) { - this.name = requireNonNull(name, "Product.name cannot be null"); - this.version = version; - } - - public String getName() { - return name; - } - - public Optional getVersion() { - return Optional.ofNullable(version); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Product that = (Product) o; - return - name.equals(that.name) && - Objects.equals(version, that.version); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - version - ); - } - - @Override - public String toString() { - return "Product{" + - "name=" + name + - ", version=" + version + - '}'; - } - } - - public static final class ParameterType { - private final String name; - private final java.util.List regularExpressions; - private final Boolean preferForRegularExpressionMatch; - private final Boolean useForSnippets; - private final String id; - - public ParameterType( - String name, - java.util.List regularExpressions, - Boolean preferForRegularExpressionMatch, - Boolean useForSnippets, - String id - ) { - this.name = requireNonNull(name, "ParameterType.name cannot be null"); - this.regularExpressions = unmodifiableList(new ArrayList<>(requireNonNull(regularExpressions, "ParameterType.regularExpressions cannot be null"))); - this.preferForRegularExpressionMatch = requireNonNull(preferForRegularExpressionMatch, "ParameterType.preferForRegularExpressionMatch cannot be null"); - this.useForSnippets = requireNonNull(useForSnippets, "ParameterType.useForSnippets cannot be null"); - this.id = requireNonNull(id, "ParameterType.id cannot be null"); - } - - public String getName() { - return name; - } - - public java.util.List getRegularExpressions() { - return regularExpressions; - } - - public Boolean getPreferForRegularExpressionMatch() { - return preferForRegularExpressionMatch; - } - - public Boolean getUseForSnippets() { - return useForSnippets; - } - - public String getId() { - return id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ParameterType that = (ParameterType) o; - return - name.equals(that.name) && - regularExpressions.equals(that.regularExpressions) && - preferForRegularExpressionMatch.equals(that.preferForRegularExpressionMatch) && - useForSnippets.equals(that.useForSnippets) && - id.equals(that.id); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - regularExpressions, - preferForRegularExpressionMatch, - useForSnippets, - id - ); - } - - @Override - public String toString() { - return "ParameterType{" + - "name=" + name + - ", regularExpressions=" + regularExpressions + - ", preferForRegularExpressionMatch=" + preferForRegularExpressionMatch + - ", useForSnippets=" + useForSnippets + - ", id=" + id + - '}'; - } - } - - public static final class ParseError { - private final SourceReference source; - private final String message; - - public ParseError( - SourceReference source, - String message - ) { - this.source = requireNonNull(source, "ParseError.source cannot be null"); - this.message = requireNonNull(message, "ParseError.message cannot be null"); - } - - public SourceReference getSource() { - return source; - } - - public String getMessage() { - return message; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ParseError that = (ParseError) o; - return - source.equals(that.source) && - message.equals(that.message); - } - - @Override - public int hashCode() { - return Objects.hash( - source, - message - ); - } - - @Override - public String toString() { - return "ParseError{" + - "source=" + source + - ", message=" + message + - '}'; - } - } - - public static final class Pickle { - private final String id; - private final String uri; - private final String name; - private final String language; - private final java.util.List steps; - private final java.util.List tags; - private final java.util.List astNodeIds; - - public Pickle( - String id, - String uri, - String name, - String language, - java.util.List steps, - java.util.List tags, - java.util.List astNodeIds - ) { - this.id = requireNonNull(id, "Pickle.id cannot be null"); - this.uri = requireNonNull(uri, "Pickle.uri cannot be null"); - this.name = requireNonNull(name, "Pickle.name cannot be null"); - this.language = requireNonNull(language, "Pickle.language cannot be null"); - this.steps = unmodifiableList(new ArrayList<>(requireNonNull(steps, "Pickle.steps cannot be null"))); - this.tags = unmodifiableList(new ArrayList<>(requireNonNull(tags, "Pickle.tags cannot be null"))); - this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "Pickle.astNodeIds cannot be null"))); - } - - public String getId() { - return id; - } - - public String getUri() { - return uri; - } - - public String getName() { - return name; - } - - public String getLanguage() { - return language; - } - - public java.util.List getSteps() { - return steps; - } - - public java.util.List getTags() { - return tags; - } - - public java.util.List getAstNodeIds() { - return astNodeIds; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Pickle that = (Pickle) o; - return - id.equals(that.id) && - uri.equals(that.uri) && - name.equals(that.name) && - language.equals(that.language) && - steps.equals(that.steps) && - tags.equals(that.tags) && - astNodeIds.equals(that.astNodeIds); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - uri, - name, - language, - steps, - tags, - astNodeIds - ); - } - - @Override - public String toString() { - return "Pickle{" + - "id=" + id + - ", uri=" + uri + - ", name=" + name + - ", language=" + language + - ", steps=" + steps + - ", tags=" + tags + - ", astNodeIds=" + astNodeIds + - '}'; - } - } - - public static final class PickleDocString { - private final String mediaType; - private final String content; - - public PickleDocString( - String mediaType, - String content - ) { - this.mediaType = mediaType; - this.content = requireNonNull(content, "PickleDocString.content cannot be null"); - } - - public Optional getMediaType() { - return Optional.ofNullable(mediaType); - } - - public String getContent() { - return content; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleDocString that = (PickleDocString) o; - return - Objects.equals(mediaType, that.mediaType) && - content.equals(that.content); - } - - @Override - public int hashCode() { - return Objects.hash( - mediaType, - content - ); - } - - @Override - public String toString() { - return "PickleDocString{" + - "mediaType=" + mediaType + - ", content=" + content + - '}'; - } - } - - public static final class PickleStep { - private final PickleStepArgument argument; - private final java.util.List astNodeIds; - private final String id; - private final String text; - - public PickleStep( - PickleStepArgument argument, - java.util.List astNodeIds, - String id, - String text - ) { - this.argument = argument; - this.astNodeIds = unmodifiableList(new ArrayList<>(requireNonNull(astNodeIds, "PickleStep.astNodeIds cannot be null"))); - this.id = requireNonNull(id, "PickleStep.id cannot be null"); - this.text = requireNonNull(text, "PickleStep.text cannot be null"); - } - - public Optional getArgument() { - return Optional.ofNullable(argument); - } - - public java.util.List getAstNodeIds() { - return astNodeIds; - } - - public String getId() { - return id; - } - - public String getText() { - return text; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleStep that = (PickleStep) o; - return - Objects.equals(argument, that.argument) && - astNodeIds.equals(that.astNodeIds) && - id.equals(that.id) && - text.equals(that.text); - } - - @Override - public int hashCode() { - return Objects.hash( - argument, - astNodeIds, - id, - text - ); - } - - @Override - public String toString() { - return "PickleStep{" + - "argument=" + argument + - ", astNodeIds=" + astNodeIds + - ", id=" + id + - ", text=" + text + - '}'; - } - } - - public static final class PickleStepArgument { - private final PickleDocString docString; - private final PickleTable dataTable; - - public static PickleStepArgument of(PickleDocString docString) { - return new PickleStepArgument( - requireNonNull(docString, "PickleStepArgument.docString cannot be null"), - null - ); - } - - public static PickleStepArgument of(PickleTable dataTable) { - return new PickleStepArgument( - null, - requireNonNull(dataTable, "PickleStepArgument.dataTable cannot be null") - ); - } - - public PickleStepArgument( - PickleDocString docString, - PickleTable dataTable - ) { - this.docString = docString; - this.dataTable = dataTable; - } - - public Optional getDocString() { - return Optional.ofNullable(docString); - } - - public Optional getDataTable() { - return Optional.ofNullable(dataTable); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleStepArgument that = (PickleStepArgument) o; - return - Objects.equals(docString, that.docString) && - Objects.equals(dataTable, that.dataTable); - } - - @Override - public int hashCode() { - return Objects.hash( - docString, - dataTable - ); - } - - @Override - public String toString() { - return "PickleStepArgument{" + - "docString=" + docString + - ", dataTable=" + dataTable + - '}'; - } - } - - public static final class PickleTable { - private final java.util.List rows; - - public PickleTable( - java.util.List rows - ) { - this.rows = unmodifiableList(new ArrayList<>(requireNonNull(rows, "PickleTable.rows cannot be null"))); - } - - public java.util.List getRows() { - return rows; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTable that = (PickleTable) o; - return - rows.equals(that.rows); - } - - @Override - public int hashCode() { - return Objects.hash( - rows - ); - } - - @Override - public String toString() { - return "PickleTable{" + - "rows=" + rows + - '}'; - } - } - - public static final class PickleTableCell { - private final String value; - - public PickleTableCell( - String value - ) { - this.value = requireNonNull(value, "PickleTableCell.value cannot be null"); - } - - public String getValue() { - return value; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTableCell that = (PickleTableCell) o; - return - value.equals(that.value); - } - - @Override - public int hashCode() { - return Objects.hash( - value - ); - } - - @Override - public String toString() { - return "PickleTableCell{" + - "value=" + value + - '}'; - } - } - - public static final class PickleTableRow { - private final java.util.List cells; - - public PickleTableRow( - java.util.List cells - ) { - this.cells = unmodifiableList(new ArrayList<>(requireNonNull(cells, "PickleTableRow.cells cannot be null"))); - } - - public java.util.List getCells() { - return cells; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTableRow that = (PickleTableRow) o; - return - cells.equals(that.cells); - } - - @Override - public int hashCode() { - return Objects.hash( - cells - ); - } - - @Override - public String toString() { - return "PickleTableRow{" + - "cells=" + cells + - '}'; - } - } - - public static final class PickleTag { - private final String name; - private final String astNodeId; - - public PickleTag( - String name, - String astNodeId - ) { - this.name = requireNonNull(name, "PickleTag.name cannot be null"); - this.astNodeId = requireNonNull(astNodeId, "PickleTag.astNodeId cannot be null"); - } - - public String getName() { - return name; - } - - public String getAstNodeId() { - return astNodeId; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - PickleTag that = (PickleTag) o; - return - name.equals(that.name) && - astNodeId.equals(that.astNodeId); - } - - @Override - public int hashCode() { - return Objects.hash( - name, - astNodeId - ); - } - - @Override - public String toString() { - return "PickleTag{" + - "name=" + name + - ", astNodeId=" + astNodeId + - '}'; - } - } - - public static final class Source { - private final String uri; - private final String data; - private final SourceMediaType mediaType; - - public Source( - String uri, - String data, - SourceMediaType mediaType - ) { - this.uri = requireNonNull(uri, "Source.uri cannot be null"); - this.data = requireNonNull(data, "Source.data cannot be null"); - this.mediaType = requireNonNull(mediaType, "Source.mediaType cannot be null"); - } - - public String getUri() { - return uri; - } - - public String getData() { - return data; - } - - public SourceMediaType getMediaType() { - return mediaType; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Source that = (Source) o; - return - uri.equals(that.uri) && - data.equals(that.data) && - mediaType.equals(that.mediaType); - } - - @Override - public int hashCode() { - return Objects.hash( - uri, - data, - mediaType - ); - } - - @Override - public String toString() { - return "Source{" + - "uri=" + uri + - ", data=" + data + - ", mediaType=" + mediaType + - '}'; - } - } - - public static final class SourceReference { - private final String uri; - private final JavaMethod javaMethod; - private final JavaStackTraceElement javaStackTraceElement; - private final Location location; - - public static SourceReference of(String uri) { - return new SourceReference( - requireNonNull(uri, "SourceReference.uri cannot be null"), - null, - null, - null - ); - } - - public static SourceReference of(JavaMethod javaMethod) { - return new SourceReference( - null, - requireNonNull(javaMethod, "SourceReference.javaMethod cannot be null"), - null, - null - ); - } - - public static SourceReference of(JavaStackTraceElement javaStackTraceElement) { - return new SourceReference( - null, - null, - requireNonNull(javaStackTraceElement, "SourceReference.javaStackTraceElement cannot be null"), - null - ); - } - - public static SourceReference of(Location location) { - return new SourceReference( - null, - null, - null, - requireNonNull(location, "SourceReference.location cannot be null") - ); - } - - public SourceReference( - String uri, - JavaMethod javaMethod, - JavaStackTraceElement javaStackTraceElement, - Location location - ) { - this.uri = uri; - this.javaMethod = javaMethod; - this.javaStackTraceElement = javaStackTraceElement; - this.location = location; - } - - public Optional getUri() { - return Optional.ofNullable(uri); - } - - public Optional getJavaMethod() { - return Optional.ofNullable(javaMethod); - } - - public Optional getJavaStackTraceElement() { - return Optional.ofNullable(javaStackTraceElement); - } - - public Optional getLocation() { - return Optional.ofNullable(location); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - SourceReference that = (SourceReference) o; - return - Objects.equals(uri, that.uri) && - Objects.equals(javaMethod, that.javaMethod) && - Objects.equals(javaStackTraceElement, that.javaStackTraceElement) && - Objects.equals(location, that.location); - } - - @Override - public int hashCode() { - return Objects.hash( - uri, - javaMethod, - javaStackTraceElement, - location - ); - } - - @Override - public String toString() { - return "SourceReference{" + - "uri=" + uri + - ", javaMethod=" + javaMethod + - ", javaStackTraceElement=" + javaStackTraceElement + - ", location=" + location + - '}'; - } - } - - public static final class JavaMethod { - private final String className; - private final String methodName; - private final java.util.List methodParameterTypes; - - public JavaMethod( - String className, - String methodName, - java.util.List methodParameterTypes - ) { - this.className = requireNonNull(className, "JavaMethod.className cannot be null"); - this.methodName = requireNonNull(methodName, "JavaMethod.methodName cannot be null"); - this.methodParameterTypes = unmodifiableList(new ArrayList<>(requireNonNull(methodParameterTypes, "JavaMethod.methodParameterTypes cannot be null"))); - } - - public String getClassName() { - return className; - } - - public String getMethodName() { - return methodName; - } - - public java.util.List getMethodParameterTypes() { - return methodParameterTypes; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - JavaMethod that = (JavaMethod) o; - return - className.equals(that.className) && - methodName.equals(that.methodName) && - methodParameterTypes.equals(that.methodParameterTypes); - } - - @Override - public int hashCode() { - return Objects.hash( - className, - methodName, - methodParameterTypes - ); - } - - @Override - public String toString() { - return "JavaMethod{" + - "className=" + className + - ", methodName=" + methodName + - ", methodParameterTypes=" + methodParameterTypes + - '}'; - } - } - - public static final class JavaStackTraceElement { - private final String className; - private final String fileName; - private final String methodName; - - public JavaStackTraceElement( - String className, - String fileName, - String methodName - ) { - this.className = requireNonNull(className, "JavaStackTraceElement.className cannot be null"); - this.fileName = requireNonNull(fileName, "JavaStackTraceElement.fileName cannot be null"); - this.methodName = requireNonNull(methodName, "JavaStackTraceElement.methodName cannot be null"); - } - - public String getClassName() { - return className; - } - - public String getFileName() { - return fileName; - } - - public String getMethodName() { - return methodName; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - JavaStackTraceElement that = (JavaStackTraceElement) o; - return - className.equals(that.className) && - fileName.equals(that.fileName) && - methodName.equals(that.methodName); - } - - @Override - public int hashCode() { - return Objects.hash( - className, - fileName, - methodName - ); - } - - @Override - public String toString() { - return "JavaStackTraceElement{" + - "className=" + className + - ", fileName=" + fileName + - ", methodName=" + methodName + - '}'; - } - } - - public static final class StepDefinition { - private final String id; - private final StepDefinitionPattern pattern; - private final SourceReference sourceReference; - - public StepDefinition( - String id, - StepDefinitionPattern pattern, - SourceReference sourceReference - ) { - this.id = requireNonNull(id, "StepDefinition.id cannot be null"); - this.pattern = requireNonNull(pattern, "StepDefinition.pattern cannot be null"); - this.sourceReference = requireNonNull(sourceReference, "StepDefinition.sourceReference cannot be null"); - } - - public String getId() { - return id; - } - - public StepDefinitionPattern getPattern() { - return pattern; - } - - public SourceReference getSourceReference() { - return sourceReference; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepDefinition that = (StepDefinition) o; - return - id.equals(that.id) && - pattern.equals(that.pattern) && - sourceReference.equals(that.sourceReference); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - pattern, - sourceReference - ); - } - - @Override - public String toString() { - return "StepDefinition{" + - "id=" + id + - ", pattern=" + pattern + - ", sourceReference=" + sourceReference + - '}'; - } - } - - public static final class StepDefinitionPattern { - private final String source; - private final StepDefinitionPatternType type; - - public StepDefinitionPattern( - String source, - StepDefinitionPatternType type - ) { - this.source = requireNonNull(source, "StepDefinitionPattern.source cannot be null"); - this.type = requireNonNull(type, "StepDefinitionPattern.type cannot be null"); - } - - public String getSource() { - return source; - } - - public StepDefinitionPatternType getType() { - return type; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepDefinitionPattern that = (StepDefinitionPattern) o; - return - source.equals(that.source) && - type.equals(that.type); - } - - @Override - public int hashCode() { - return Objects.hash( - source, - type - ); - } - - @Override - public String toString() { - return "StepDefinitionPattern{" + - "source=" + source + - ", type=" + type + - '}'; - } - } - - public static final class TestCase { - private final String id; - private final String pickleId; - private final java.util.List testSteps; - - public TestCase( - String id, - String pickleId, - java.util.List testSteps - ) { - this.id = requireNonNull(id, "TestCase.id cannot be null"); - this.pickleId = requireNonNull(pickleId, "TestCase.pickleId cannot be null"); - this.testSteps = unmodifiableList(new ArrayList<>(requireNonNull(testSteps, "TestCase.testSteps cannot be null"))); - } - - public String getId() { - return id; - } - - public String getPickleId() { - return pickleId; - } - - public java.util.List getTestSteps() { - return testSteps; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCase that = (TestCase) o; - return - id.equals(that.id) && - pickleId.equals(that.pickleId) && - testSteps.equals(that.testSteps); - } - - @Override - public int hashCode() { - return Objects.hash( - id, - pickleId, - testSteps - ); - } - - @Override - public String toString() { - return "TestCase{" + - "id=" + id + - ", pickleId=" + pickleId + - ", testSteps=" + testSteps + - '}'; - } - } - - public static final class Group { - private final java.util.List children; - private final Long start; - private final String value; - - public Group( - java.util.List children, - Long start, - String value - ) { - this.children = unmodifiableList(new ArrayList<>(requireNonNull(children, "Group.children cannot be null"))); - this.start = start; - this.value = value; - } - - public java.util.List getChildren() { - return children; - } - - public Optional getStart() { - return Optional.ofNullable(start); - } - - public Optional getValue() { - return Optional.ofNullable(value); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Group that = (Group) o; - return - children.equals(that.children) && - Objects.equals(start, that.start) && - Objects.equals(value, that.value); - } - - @Override - public int hashCode() { - return Objects.hash( - children, - start, - value - ); - } - - @Override - public String toString() { - return "Group{" + - "children=" + children + - ", start=" + start + - ", value=" + value + - '}'; - } - } - - public static final class StepMatchArgument { - private final Group group; - private final String parameterTypeName; - - public StepMatchArgument( - Group group, - String parameterTypeName - ) { - this.group = requireNonNull(group, "StepMatchArgument.group cannot be null"); - this.parameterTypeName = parameterTypeName; - } - - public Group getGroup() { - return group; - } - - public Optional getParameterTypeName() { - return Optional.ofNullable(parameterTypeName); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepMatchArgument that = (StepMatchArgument) o; - return - group.equals(that.group) && - Objects.equals(parameterTypeName, that.parameterTypeName); - } - - @Override - public int hashCode() { - return Objects.hash( - group, - parameterTypeName - ); - } - - @Override - public String toString() { - return "StepMatchArgument{" + - "group=" + group + - ", parameterTypeName=" + parameterTypeName + - '}'; - } - } - - public static final class StepMatchArgumentsList { - private final java.util.List stepMatchArguments; - - public StepMatchArgumentsList( - java.util.List stepMatchArguments - ) { - this.stepMatchArguments = unmodifiableList(new ArrayList<>(requireNonNull(stepMatchArguments, "StepMatchArgumentsList.stepMatchArguments cannot be null"))); - } - - public java.util.List getStepMatchArguments() { - return stepMatchArguments; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - StepMatchArgumentsList that = (StepMatchArgumentsList) o; - return - stepMatchArguments.equals(that.stepMatchArguments); - } - - @Override - public int hashCode() { - return Objects.hash( - stepMatchArguments - ); - } - - @Override - public String toString() { - return "StepMatchArgumentsList{" + - "stepMatchArguments=" + stepMatchArguments + - '}'; - } - } - - public static final class TestStep { - private final String hookId; - private final String id; - private final String pickleStepId; - private final java.util.List stepDefinitionIds; - private final java.util.List stepMatchArgumentsLists; - - public TestStep( - String hookId, - String id, - String pickleStepId, - java.util.List stepDefinitionIds, - java.util.List stepMatchArgumentsLists - ) { - this.hookId = hookId; - this.id = requireNonNull(id, "TestStep.id cannot be null"); - this.pickleStepId = pickleStepId; - this.stepDefinitionIds = stepDefinitionIds == null ? null : unmodifiableList(new ArrayList<>(stepDefinitionIds)); - this.stepMatchArgumentsLists = stepMatchArgumentsLists == null ? null : unmodifiableList(new ArrayList<>(stepMatchArgumentsLists)); - } - - public Optional getHookId() { - return Optional.ofNullable(hookId); - } - - public String getId() { - return id; - } - - public Optional getPickleStepId() { - return Optional.ofNullable(pickleStepId); - } - - public Optional> getStepDefinitionIds() { - return Optional.ofNullable(stepDefinitionIds); - } - - public Optional> getStepMatchArgumentsLists() { - return Optional.ofNullable(stepMatchArgumentsLists); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStep that = (TestStep) o; - return - Objects.equals(hookId, that.hookId) && - id.equals(that.id) && - Objects.equals(pickleStepId, that.pickleStepId) && - Objects.equals(stepDefinitionIds, that.stepDefinitionIds) && - Objects.equals(stepMatchArgumentsLists, that.stepMatchArgumentsLists); - } - - @Override - public int hashCode() { - return Objects.hash( - hookId, - id, - pickleStepId, - stepDefinitionIds, - stepMatchArgumentsLists - ); - } - - @Override - public String toString() { - return "TestStep{" + - "hookId=" + hookId + - ", id=" + id + - ", pickleStepId=" + pickleStepId + - ", stepDefinitionIds=" + stepDefinitionIds + - ", stepMatchArgumentsLists=" + stepMatchArgumentsLists + - '}'; - } - } - - public static final class TestCaseFinished { - private final String testCaseStartedId; - private final Timestamp timestamp; - private final Boolean willBeRetried; - - public TestCaseFinished( - String testCaseStartedId, - Timestamp timestamp, - Boolean willBeRetried - ) { - this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestCaseFinished.testCaseStartedId cannot be null"); - this.timestamp = requireNonNull(timestamp, "TestCaseFinished.timestamp cannot be null"); - this.willBeRetried = requireNonNull(willBeRetried, "TestCaseFinished.willBeRetried cannot be null"); - } - - public String getTestCaseStartedId() { - return testCaseStartedId; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - public Boolean getWillBeRetried() { - return willBeRetried; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCaseFinished that = (TestCaseFinished) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - timestamp.equals(that.timestamp) && - willBeRetried.equals(that.willBeRetried); - } - - @Override - public int hashCode() { - return Objects.hash( - testCaseStartedId, - timestamp, - willBeRetried - ); - } - - @Override - public String toString() { - return "TestCaseFinished{" + - "testCaseStartedId=" + testCaseStartedId + - ", timestamp=" + timestamp + - ", willBeRetried=" + willBeRetried + - '}'; - } - } - - public static final class TestCaseStarted { - private final Long attempt; - private final String id; - private final String testCaseId; - private final Timestamp timestamp; - - public TestCaseStarted( - Long attempt, - String id, - String testCaseId, - Timestamp timestamp - ) { - this.attempt = requireNonNull(attempt, "TestCaseStarted.attempt cannot be null"); - this.id = requireNonNull(id, "TestCaseStarted.id cannot be null"); - this.testCaseId = requireNonNull(testCaseId, "TestCaseStarted.testCaseId cannot be null"); - this.timestamp = requireNonNull(timestamp, "TestCaseStarted.timestamp cannot be null"); - } - - public Long getAttempt() { - return attempt; - } - - public String getId() { - return id; - } - - public String getTestCaseId() { - return testCaseId; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestCaseStarted that = (TestCaseStarted) o; - return - attempt.equals(that.attempt) && - id.equals(that.id) && - testCaseId.equals(that.testCaseId) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - attempt, - id, - testCaseId, - timestamp - ); - } - - @Override - public String toString() { - return "TestCaseStarted{" + - "attempt=" + attempt + - ", id=" + id + - ", testCaseId=" + testCaseId + - ", timestamp=" + timestamp + - '}'; - } - } - - public static final class TestRunFinished { - private final String message; - private final Boolean success; - private final Timestamp timestamp; - - public TestRunFinished( - String message, - Boolean success, - Timestamp timestamp - ) { - this.message = message; - this.success = requireNonNull(success, "TestRunFinished.success cannot be null"); - this.timestamp = requireNonNull(timestamp, "TestRunFinished.timestamp cannot be null"); - } - - public Optional getMessage() { - return Optional.ofNullable(message); - } - - public Boolean getSuccess() { - return success; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestRunFinished that = (TestRunFinished) o; - return - Objects.equals(message, that.message) && - success.equals(that.success) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - message, - success, - timestamp - ); - } - - @Override - public String toString() { - return "TestRunFinished{" + - "message=" + message + - ", success=" + success + - ", timestamp=" + timestamp + - '}'; - } - } - - public static final class TestRunStarted { - private final Timestamp timestamp; - - public TestRunStarted( - Timestamp timestamp - ) { - this.timestamp = requireNonNull(timestamp, "TestRunStarted.timestamp cannot be null"); - } - - public Timestamp getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestRunStarted that = (TestRunStarted) o; - return - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - timestamp - ); - } - - @Override - public String toString() { - return "TestRunStarted{" + - "timestamp=" + timestamp + - '}'; - } - } - - public static final class TestStepFinished { - private final String testCaseStartedId; - private final String testStepId; - private final TestStepResult testStepResult; - private final Timestamp timestamp; - - public TestStepFinished( - String testCaseStartedId, - String testStepId, - TestStepResult testStepResult, - Timestamp timestamp - ) { - this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestStepFinished.testCaseStartedId cannot be null"); - this.testStepId = requireNonNull(testStepId, "TestStepFinished.testStepId cannot be null"); - this.testStepResult = requireNonNull(testStepResult, "TestStepFinished.testStepResult cannot be null"); - this.timestamp = requireNonNull(timestamp, "TestStepFinished.timestamp cannot be null"); - } - - public String getTestCaseStartedId() { - return testCaseStartedId; - } - - public String getTestStepId() { - return testStepId; - } - - public TestStepResult getTestStepResult() { - return testStepResult; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepFinished that = (TestStepFinished) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - testStepId.equals(that.testStepId) && - testStepResult.equals(that.testStepResult) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - testCaseStartedId, - testStepId, - testStepResult, - timestamp - ); - } - - @Override - public String toString() { - return "TestStepFinished{" + - "testCaseStartedId=" + testCaseStartedId + - ", testStepId=" + testStepId + - ", testStepResult=" + testStepResult + - ", timestamp=" + timestamp + - '}'; - } - } - - public static final class TestStepResult { - private final Duration duration; - private final String message; - private final TestStepResultStatus status; - - public TestStepResult( - Duration duration, - String message, - TestStepResultStatus status - ) { - this.duration = requireNonNull(duration, "TestStepResult.duration cannot be null"); - this.message = message; - this.status = requireNonNull(status, "TestStepResult.status cannot be null"); - } - - public Duration getDuration() { - return duration; - } - - public Optional getMessage() { - return Optional.ofNullable(message); - } - - public TestStepResultStatus getStatus() { - return status; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepResult that = (TestStepResult) o; - return - duration.equals(that.duration) && - Objects.equals(message, that.message) && - status.equals(that.status); - } - - @Override - public int hashCode() { - return Objects.hash( - duration, - message, - status - ); - } - - @Override - public String toString() { - return "TestStepResult{" + - "duration=" + duration + - ", message=" + message + - ", status=" + status + - '}'; - } - } - - public static final class TestStepStarted { - private final String testCaseStartedId; - private final String testStepId; - private final Timestamp timestamp; - - public TestStepStarted( - String testCaseStartedId, - String testStepId, - Timestamp timestamp - ) { - this.testCaseStartedId = requireNonNull(testCaseStartedId, "TestStepStarted.testCaseStartedId cannot be null"); - this.testStepId = requireNonNull(testStepId, "TestStepStarted.testStepId cannot be null"); - this.timestamp = requireNonNull(timestamp, "TestStepStarted.timestamp cannot be null"); - } - - public String getTestCaseStartedId() { - return testCaseStartedId; - } - - public String getTestStepId() { - return testStepId; - } - - public Timestamp getTimestamp() { - return timestamp; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestStepStarted that = (TestStepStarted) o; - return - testCaseStartedId.equals(that.testCaseStartedId) && - testStepId.equals(that.testStepId) && - timestamp.equals(that.timestamp); - } - - @Override - public int hashCode() { - return Objects.hash( - testCaseStartedId, - testStepId, - timestamp - ); - } - - @Override - public String toString() { - return "TestStepStarted{" + - "testCaseStartedId=" + testCaseStartedId + - ", testStepId=" + testStepId + - ", timestamp=" + timestamp + - '}'; - } - } - - public static final class Timestamp { - private final Long seconds; - private final Long nanos; - - public Timestamp( - Long seconds, - Long nanos - ) { - this.seconds = requireNonNull(seconds, "Timestamp.seconds cannot be null"); - this.nanos = requireNonNull(nanos, "Timestamp.nanos cannot be null"); - } - - public Long getSeconds() { - return seconds; - } - - public Long getNanos() { - return nanos; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Timestamp that = (Timestamp) o; - return - seconds.equals(that.seconds) && - nanos.equals(that.nanos); - } - - @Override - public int hashCode() { - return Objects.hash( - seconds, - nanos - ); - } - - @Override - public String toString() { - return "Timestamp{" + - "seconds=" + seconds + - ", nanos=" + nanos + - '}'; - } - } - - public static final class UndefinedParameterType { - private final String expression; - private final String name; - - public UndefinedParameterType( - String expression, - String name - ) { - this.expression = requireNonNull(expression, "UndefinedParameterType.expression cannot be null"); - this.name = requireNonNull(name, "UndefinedParameterType.name cannot be null"); - } - - public String getExpression() { - return expression; - } - - public String getName() { - return name; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - UndefinedParameterType that = (UndefinedParameterType) o; - return - expression.equals(that.expression) && - name.equals(that.name); - } - - @Override - public int hashCode() { - return Objects.hash( - expression, - name - ); - } - - @Override - public String toString() { - return "UndefinedParameterType{" + - "expression=" + expression + - ", name=" + name + - '}'; - } - } - - public enum AttachmentContentEncoding { - IDENTITY("IDENTITY"), - BASE64("BASE64"); - - private final String value; - - AttachmentContentEncoding(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static AttachmentContentEncoding fromValue(String value) { - for (AttachmentContentEncoding v : values()) { - if (v.value.equals(value)) { - return v; - } - } - throw new IllegalArgumentException(value); - } - } - - public enum SourceMediaType { - TEXT_X_CUCUMBER_GHERKIN_PLAIN("text/x.cucumber.gherkin+plain"), - TEXT_X_CUCUMBER_GHERKIN_MARKDOWN("text/x.cucumber.gherkin+markdown"); - - private final String value; - - SourceMediaType(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static SourceMediaType fromValue(String value) { - for (SourceMediaType v : values()) { - if (v.value.equals(value)) { - return v; - } - } - throw new IllegalArgumentException(value); - } - } - - public enum StepDefinitionPatternType { - CUCUMBER_EXPRESSION("CUCUMBER_EXPRESSION"), - REGULAR_EXPRESSION("REGULAR_EXPRESSION"); - - private final String value; - - StepDefinitionPatternType(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static StepDefinitionPatternType fromValue(String value) { - for (StepDefinitionPatternType v : values()) { - if (v.value.equals(value)) { - return v; - } - } - throw new IllegalArgumentException(value); - } - } - - public enum TestStepResultStatus { - UNKNOWN("UNKNOWN"), - PASSED("PASSED"), - SKIPPED("SKIPPED"), - PENDING("PENDING"), - UNDEFINED("UNDEFINED"), - AMBIGUOUS("AMBIGUOUS"), - FAILED("FAILED"); - - private final String value; - - TestStepResultStatus(String value) { - this.value = value; - } - - @Override - public String toString() { - return this.value; - } - - public String value() { - return this.value; - } - - public static TestStepResultStatus fromValue(String value) { - for (TestStepResultStatus v : values()) { - if (v.value.equals(value)) { - return v; - } - } - throw new IllegalArgumentException(value); - } - } - -} diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 65c4688a5b..3f1c156cb5 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -1,7 +1,5 @@ package io.cucumber.messages; -import io.cucumber.messages.Messages.Envelope; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; diff --git a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java index a394a8ff15..aea8118e5b 100644 --- a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java +++ b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java @@ -1,7 +1,5 @@ package io.cucumber.messages; -import static io.cucumber.messages.Messages.*; - public final class TimeConversion { private TimeConversion(){ diff --git a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java index bd3d4b31b8..e716d7923a 100644 --- a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java @@ -1,21 +1,18 @@ package io.cucumber.messages; import com.fasterxml.jackson.core.JsonProcessingException; -import io.cucumber.messages.Messages.Envelope; -import io.cucumber.messages.Messages.TestRunStarted; -import io.cucumber.messages.Messages.Timestamp; import org.junit.jupiter.api.Test; import static io.cucumber.messages.Jackson.OBJECT_MAPPER; -import static io.cucumber.messages.Messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; +import static io.cucumber.messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.jupiter.api.Assertions.assertEquals; class JacksonTest { @Test void can_deserialize_enum() throws JsonProcessingException { - Messages.Source source = new Messages.Source("hello.feature", "Feature: Hello", TEXT_X_CUCUMBER_GHERKIN_PLAIN); + Source source = new Source("hello.feature", "Feature: Hello", TEXT_X_CUCUMBER_GHERKIN_PLAIN); String json = OBJECT_MAPPER.writeValueAsString(source); - assertEquals(source, OBJECT_MAPPER.readValue(json, Messages.Source.class)); + assertEquals(source, OBJECT_MAPPER.readValue(json, Source.class)); } @Test @@ -26,8 +23,8 @@ void serialize_enums_using_value() throws JsonProcessingException { @Test void can_deserialize_envelope() throws JsonProcessingException { - Messages.Envelope source = Envelope.of(new TestRunStarted(new Timestamp(3L,14L))); + Envelope source = Envelope.of(new TestRunStarted(new Timestamp(3L, 14L))); String json = OBJECT_MAPPER.writeValueAsString(source); - assertEquals(source, OBJECT_MAPPER.readValue(json, Messages.Envelope.class)); + assertEquals(source, OBJECT_MAPPER.readValue(json, Envelope.class)); } } diff --git a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java index 1efb4637f9..2507610f6a 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java @@ -8,13 +8,13 @@ public class MessagesTest { @Test void is_invalid_when_required_fields_are_missing() { assertThrows(NullPointerException.class, () -> { - new Messages.Attachment(null, null, null, null, null, null, null, null); + new Attachment(null, null, null, null, null, null, null, null); }, "Attachment.body cannot be null"); } @Test void is_valid_when_no_required_fields_are_missing() { - new Messages.Envelope( + new Envelope( null, null, null, diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index ca6ee322e2..7d433c676b 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -11,12 +11,6 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; -import static io.cucumber.messages.Messages.AttachmentContentEncoding; -import static io.cucumber.messages.Messages.Envelope; -import static io.cucumber.messages.Messages.Source; -import static io.cucumber.messages.Messages.SourceMediaType; -import static io.cucumber.messages.Messages.TestRunStarted; -import static io.cucumber.messages.Messages.Timestamp; import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -38,7 +32,9 @@ void writes_source_envelope() throws IOException { MessageToNdjsonWriter writer = createMessageWriter(output); writer.write(Envelope.of(new Source("uri", "data", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN))); String json = new String(output.toByteArray(), StandardCharsets.UTF_8); - assertEquals("{\"source\":{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}}\n", json); + assertEquals( + "{\"source\":{\"uri\":\"uri\",\"data\":\"data\",\"mediaType\":\"text/x.cucumber.gherkin+plain\"}}\n", + json); } @Test @@ -130,7 +126,9 @@ void ignores_empty_lines() { @Test void handles_enums() { - InputStream input = new ByteArrayInputStream("{\"attachment\":{\"contentEncoding\":\"BASE64\", \"body\":\"the-body\", \"mediaType\":\"text/plain\"}}\n".getBytes(UTF_8)); + InputStream input = new ByteArrayInputStream( + "{\"attachment\":{\"contentEncoding\":\"BASE64\", \"body\":\"the-body\", \"mediaType\":\"text/plain\"}}\n".getBytes( + UTF_8)); Iterable incomingMessages = createMessageIterable(input); Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); @@ -141,7 +139,8 @@ void handles_enums() { @Test void handles_single_argument_constructors() { - InputStream input = new ByteArrayInputStream("{\"testRunStarted\": {\"timestamp\":{\"nanos\":0,\"seconds\":0}}}\n".getBytes(UTF_8)); + InputStream input = new ByteArrayInputStream( + "{\"testRunStarted\": {\"timestamp\":{\"nanos\":0,\"seconds\":0}}}\n".getBytes(UTF_8)); Iterable incomingMessages = createMessageIterable(input); Iterator iterator = incomingMessages.iterator(); assertTrue(iterator.hasNext()); @@ -160,4 +159,5 @@ void includes_offending_line_in_error_message() { RuntimeException exception = assertThrows(RuntimeException.class, () -> assertTrue(iterator.hasNext())); assertEquals(exception.getMessage(), "Could not parse JSON: BLA BLA"); } + } diff --git a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java index b62c38af95..4abb9c19ea 100644 --- a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java @@ -2,7 +2,6 @@ import org.junit.jupiter.api.Test; -import static io.cucumber.messages.Messages.*; import static io.cucumber.messages.TimeConversion.durationToJavaDuration; import static io.cucumber.messages.TimeConversion.javaDurationToDuration; import static io.cucumber.messages.TimeConversion.javaInstantToTimestamp; diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb index ece2163d56..33569832dc 100644 --- a/messages/jsonschema/scripts/templates/java.enum.java.erb +++ b/messages/jsonschema/scripts/templates/java.enum.java.erb @@ -1,32 +1,37 @@ <% @enums.each do |enum| -%> - public enum <%= enum[:name] %> { - <% enum[:values].each_with_index do |value, index| -%> +<%= enum[:name] %>.java +package io.cucumber.messages; + +// Generated code +@SuppressWarnings("unused") +public enum <%= enum[:name] %> { +<% enum[:values].each_with_index do |value, index| -%> + <%= enum_constant(value) %>("<%= value %>")<%= index < enum[:values].length-1 ? ',' : ';' %> - <% end -%> +<% end -%> - private final String value; + private final String value; - <%= enum[:name] %>(String value) { - this.value = value; - } + <%= enum[:name] %>(String value) { + this.value = value; + } - @Override - public String toString() { - return this.value; - } + @Override + public String toString() { + return this.value; + } - public String value() { - return this.value; - } + public String value() { + return this.value; + } - public static <%= enum[:name] %> fromValue(String value) { - for (<%= enum[:name] %> v : values()) { - if (v.value.equals(value)) { - return v; - } + public static <%= enum[:name] %> fromValue(String value) { + for (<%= enum[:name] %> v : values()) { + if (v.value.equals(value)) { + return v; } - throw new IllegalArgumentException(value); } + throw new IllegalArgumentException(value); } - +} <% end -%> diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index dd3df0fba1..654b207dd2 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,98 +1,109 @@ <%- @schemas.each do |key, schema| -%> - public static final class <%= class_name(key) %> { - <%- schema['properties'].each do |property_name, property| -%> - private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; - <%- end -%> - <%- if (schema['required'] || []).empty? -%> - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> +<%= class_name(key) %>.java +package io.cucumber.messages; - public static <%= class_name(key) %> of(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { - return new <%= class_name(key) %>( - <%- schema['properties'].each_with_index do |(property_name_2, property_2), index_2| -%> - <%- if property_name_2 == property_name -%> - <%- if property['items'] -%> - unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")))<%= index_2 < schema['properties'].length-1 ? ',' : '' %> - <%- else -%> - requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")<%= index_2 < schema['properties'].length-1 ? ',' : '' %> - <%- end -%> - <%- else -%> - null<%= index_2 < schema['properties'].length-1 ? ',' : '' %> - <%- end -%> - <%- end -%> - ); - } - <%- end -%> - <%- end -%> +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; - public <%= class_name(key) %>( - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> - <%- end -%> - ) { - <%- schema['properties'].each_with_index do |(property_name, property), index| - required = (schema['required'] || []).index(property_name) - -%> - <%- if required -%> - <%- if property['items'] -%> - this.<%= property_name %> = unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))); - <%- else -%> - this.<%= property_name %> = requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); - <%- end -%> - <%- else -%> - <%- if property['items'] -%> - this.<%= property_name %> = <%= property_name %> == null ? null : unmodifiableList(new ArrayList<>(<%= property_name %>)); - <%- else -%> - this.<%= property_name %> = <%= property_name %>; - <%- end -%> - <%- end -%> - <%- end -%> - } - <%- schema['properties'].each do |property_name, property| -%> - <%- if (schema['required'] || []).index(property_name) -%> +import static java.util.Collections.unmodifiableList; +import static java.util.Objects.requireNonNull; - public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { - return <%= property_name %>; - } - <%- else -%> +// Generated code +@SuppressWarnings("unused") +public final class <%= class_name(key) %> { + <%- schema['properties'].each do |property_name, property| -%> + private final <%= type_for(class_name(key), property_name, property) -%> <%= property_name %>; + <%- end -%> + <%- if (schema['required'] || []).empty? -%> + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - public Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { - return Optional.ofNullable(<%= property_name %>); - } + public static <%= class_name(key) %> of(<%= type_for(class_name(key), property_name, property) -%> <%= property_name %>) { + return new <%= class_name(key) %>( + <%- schema['properties'].each_with_index do |(property_name_2, property_2), index_2| -%> + <%- if property_name_2 == property_name -%> + <%- if property['items'] -%> + unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")))<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + <%- else -%> + requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null")<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + <%- end -%> + <%- else -%> + null<%= index_2 < schema['properties'].length-1 ? ',' : '' %> + <%- end -%> <%- end -%> + ); + } + <%- end -%> + <%- end -%> + + public <%= class_name(key) %>( + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%= type_for(class_name(key), property_name, property) -%> <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> + <%- end -%> + ) { + <%- schema['properties'].each_with_index do |(property_name, property), index| + required = (schema['required'] || []).index(property_name) + -%> + <%- if required -%> + <%- if property['items'] -%> + this.<%= property_name %> = unmodifiableList(new ArrayList<>(requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"))); + <%- else -%> + this.<%= property_name %> = requireNonNull(<%= property_name %>, "<%= class_name(key) %>.<%= property_name %> cannot be null"); + <%- end -%> + <%- else -%> + <%- if property['items'] -%> + this.<%= property_name %> = <%= property_name %> == null ? null : unmodifiableList(new ArrayList<>(<%= property_name %>)); + <%- else -%> + this.<%= property_name %> = <%= property_name %>; + <%- end -%> + <%- end -%> <%- end -%> + } + <%- schema['properties'].each do |property_name, property| -%> + <%- if (schema['required'] || []).index(property_name) -%> - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - <%= class_name(key) %> that = (<%= class_name(key) %>) o; - return <%- schema['properties'].each_with_index do |(property_name, property), index| %> - <%- if (schema['required'] || []).index(property_name) -%> - <%= property_name -%>.equals(that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> - <%- else -%> - Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> - <%- end -%> - <% end -%> + public <%= type_for(class_name(key), property_name, property) -%> get<%= capitalize(property_name) %>() { + return <%= property_name %>; + } + <%- else -%> - } + public Optional<<%= type_for(class_name(key), property_name, property) -%>> get<%= capitalize(property_name) %>() { + return Optional.ofNullable(<%= property_name %>); + } + <%- end -%> + <%- end -%> - @Override - public int hashCode() { - return Objects.hash( - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + <%= class_name(key) %> that = (<%= class_name(key) %>) o; + return <%- schema['properties'].each_with_index do |(property_name, property), index| %> + <%- if (schema['required'] || []).index(property_name) -%> + <%= property_name -%>.equals(that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> + <%- else -%> + Objects.equals(<%= property_name -%>, that.<%= property_name -%>)<%= index < schema['properties'].length-1 ? ' && ' : ';' -%> <%- end -%> - ); - } + <% end -%> - @Override - public String toString() { - return "<%= class_name(key) %>{" + - <%- schema['properties'].each_with_index do |(property_name, property), index| -%> - "<%= index == 0 ? '' : ', '%><%= property_name %>=" + <%= property_name %> + - <%- end -%> - '}'; - } } + @Override + public int hashCode() { + return Objects.hash( + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + <%= property_name %><%= index < schema['properties'].length-1 ? ',' : ''%> + <%- end -%> + ); + } + + @Override + public String toString() { + return "<%= class_name(key) %>{" + + <%- schema['properties'].each_with_index do |(property_name, property), index| -%> + "<%= index == 0 ? '' : ', '%><%= property_name %>=" + <%= property_name %> + + <%- end -%> + '}'; + } +} <% end -%> From 9677e8b55196b43848dff6fb215229522cf8b03a Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sat, 29 Jan 2022 02:33:39 +0100 Subject: [PATCH 61/63] Update imports --- .../gherkin/GherkinDocumentBuilder.java | 40 +++++++++--------- .../io/cucumber/gherkin/GherkinParser.java | 12 +++--- .../io/cucumber/gherkin/PickleCompiler.java | 42 +++++++++---------- .../gherkin/GherkinDocumentBuilderTest.java | 10 ++--- .../cucumber/gherkin/GherkinParserTest.java | 21 ++++------ .../test/java/io/cucumber/gherkin/Main.java | 6 +-- .../cucumber/gherkin/MessageVersionTest.java | 4 +- .../java/io/cucumber/gherkin/ParserTest.java | 2 +- .../htmlformatter/MessagesToHtmlWriter.java | 3 +- .../java/io/cucumber/htmlformatter/Main.java | 2 +- .../MessagesToHtmlWriterTest.java | 8 ++-- .../messages/NdjsonToMessageIterable.java | 4 +- 12 files changed, 76 insertions(+), 78 deletions(-) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index 4d364ac41a..041285a3ff 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -1,6 +1,21 @@ package io.cucumber.gherkin; +import io.cucumber.messages.Background; +import io.cucumber.messages.Comment; +import io.cucumber.messages.DataTable; +import io.cucumber.messages.DocString; +import io.cucumber.messages.Examples; +import io.cucumber.messages.Feature; +import io.cucumber.messages.FeatureChild; +import io.cucumber.messages.GherkinDocument; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.Rule; +import io.cucumber.messages.RuleChild; +import io.cucumber.messages.Scenario; +import io.cucumber.messages.Step; +import io.cucumber.messages.TableCell; +import io.cucumber.messages.TableRow; +import io.cucumber.messages.Tag; import java.util.ArrayDeque; import java.util.ArrayList; @@ -12,21 +27,6 @@ import static io.cucumber.gherkin.Parser.Builder; import static io.cucumber.gherkin.Parser.RuleType; import static io.cucumber.gherkin.Parser.TokenType; -import static io.cucumber.messages.Messages.Background; -import static io.cucumber.messages.Messages.Comment; -import static io.cucumber.messages.Messages.DataTable; -import static io.cucumber.messages.Messages.DocString; -import static io.cucumber.messages.Messages.Examples; -import static io.cucumber.messages.Messages.Feature; -import static io.cucumber.messages.Messages.FeatureChild; -import static io.cucumber.messages.Messages.GherkinDocument; -import static io.cucumber.messages.Messages.Rule; -import static io.cucumber.messages.Messages.RuleChild; -import static io.cucumber.messages.Messages.Scenario; -import static io.cucumber.messages.Messages.Step; -import static io.cucumber.messages.Messages.TableCell; -import static io.cucumber.messages.Messages.TableRow; -import static io.cucumber.messages.Messages.Tag; class GherkinDocumentBuilder implements Builder { private final List comments = new ArrayList<>(); @@ -190,7 +190,8 @@ private Object getTransformedNode(AstNode node) { children.add(new FeatureChild(rule, null, null)); } String description = getDescription(header); - if (featureLine.matchedGherkinDialect == null) return null; + if (featureLine.matchedGherkinDialect == null) + return null; String language = featureLine.matchedGherkinDialect.getLanguage(); return new Feature( @@ -253,7 +254,8 @@ private List getTableRows(AstNode node) { } private void ensureCellCount(List rows) { - if (rows.isEmpty()) return; + if (rows.isEmpty()) + return; int cellCount = rows.get(0).getCells().size(); for (TableRow row : rows) { @@ -283,9 +285,9 @@ private List getSteps(AstNode node) { return node.getItems(RuleType.Step); } - private io.cucumber.messages.Messages.Location getLocation(Token token, int column) { + private io.cucumber.messages.Location getLocation(Token token, int column) { column = column == 0 ? token.location.getColumn() : column; - return new io.cucumber.messages.Messages.Location((long) token.location.getLine(), (long) column); + return new io.cucumber.messages.Location((long) token.location.getLine(), (long) column); } private String getDescription(AstNode node) { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index 45bd2ff167..52c8e48858 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -1,18 +1,18 @@ package io.cucumber.gherkin; import io.cucumber.gherkin.ParserException.CompositeParserException; +import io.cucumber.messages.Envelope; +import io.cucumber.messages.GherkinDocument; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.ParseError; +import io.cucumber.messages.Source; +import io.cucumber.messages.SourceReference; import java.util.ArrayList; import java.util.List; import java.util.UUID; import java.util.stream.Stream; -import static io.cucumber.messages.Messages.Envelope; -import static io.cucumber.messages.Messages.GherkinDocument; -import static io.cucumber.messages.Messages.ParseError; -import static io.cucumber.messages.Messages.Source; -import static io.cucumber.messages.Messages.SourceReference; import static java.util.Objects.requireNonNull; import static java.util.stream.Collectors.toCollection; @@ -132,7 +132,7 @@ private Envelope createParseError(ParserException e, String uri) { null, // We want 0 values not to be serialised, which is why we set them to null // This is a legacy requirement brought over from old protobuf behaviour - new io.cucumber.messages.Messages.Location( + new io.cucumber.messages.Location( line, column == 0 ? null : column ) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java b/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java index 8e87c7c7fb..8aca0e5765 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java @@ -1,6 +1,27 @@ package io.cucumber.gherkin; +import io.cucumber.messages.DataTable; +import io.cucumber.messages.DocString; +import io.cucumber.messages.Examples; +import io.cucumber.messages.Feature; +import io.cucumber.messages.FeatureChild; +import io.cucumber.messages.GherkinDocument; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.Pickle; +import io.cucumber.messages.PickleDocString; +import io.cucumber.messages.PickleStep; +import io.cucumber.messages.PickleStepArgument; +import io.cucumber.messages.PickleTable; +import io.cucumber.messages.PickleTableCell; +import io.cucumber.messages.PickleTableRow; +import io.cucumber.messages.PickleTag; +import io.cucumber.messages.Rule; +import io.cucumber.messages.RuleChild; +import io.cucumber.messages.Scenario; +import io.cucumber.messages.Step; +import io.cucumber.messages.TableCell; +import io.cucumber.messages.TableRow; +import io.cucumber.messages.Tag; import java.util.ArrayList; import java.util.Collection; @@ -9,27 +30,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static io.cucumber.messages.Messages.DataTable; -import static io.cucumber.messages.Messages.DocString; -import static io.cucumber.messages.Messages.Examples; -import static io.cucumber.messages.Messages.Feature; -import static io.cucumber.messages.Messages.FeatureChild; -import static io.cucumber.messages.Messages.GherkinDocument; -import static io.cucumber.messages.Messages.Pickle; -import static io.cucumber.messages.Messages.PickleDocString; -import static io.cucumber.messages.Messages.PickleStep; -import static io.cucumber.messages.Messages.PickleStepArgument; -import static io.cucumber.messages.Messages.PickleTable; -import static io.cucumber.messages.Messages.PickleTableCell; -import static io.cucumber.messages.Messages.PickleTableRow; -import static io.cucumber.messages.Messages.PickleTag; -import static io.cucumber.messages.Messages.Rule; -import static io.cucumber.messages.Messages.RuleChild; -import static io.cucumber.messages.Messages.Scenario; -import static io.cucumber.messages.Messages.Step; -import static io.cucumber.messages.Messages.TableCell; -import static io.cucumber.messages.Messages.TableRow; -import static io.cucumber.messages.Messages.Tag; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static java.util.Collections.unmodifiableList; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index 5a909d0134..fc9ebaf1e5 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -1,15 +1,15 @@ package io.cucumber.gherkin; +import io.cucumber.messages.Comment; +import io.cucumber.messages.FeatureChild; +import io.cucumber.messages.GherkinDocument; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.Pickle; +import io.cucumber.messages.TableRow; import org.junit.Test; import java.util.List; -import static io.cucumber.messages.Messages.Comment; -import static io.cucumber.messages.Messages.FeatureChild; -import static io.cucumber.messages.Messages.GherkinDocument; -import static io.cucumber.messages.Messages.Pickle; -import static io.cucumber.messages.Messages.TableRow; import static org.junit.Assert.assertEquals; public class GherkinDocumentBuilderTest { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java index 366b16a56d..0cf1a6965a 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java @@ -1,22 +1,19 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Messages; -import io.cucumber.messages.Messages.ParseError; -import io.cucumber.messages.Messages.Source; -import io.cucumber.messages.Messages.SourceReference; +import io.cucumber.messages.Envelope; +import io.cucumber.messages.Feature; +import io.cucumber.messages.GherkinDocument; +import io.cucumber.messages.ParseError; +import io.cucumber.messages.Pickle; +import io.cucumber.messages.PickleStep; +import io.cucumber.messages.Scenario; +import io.cucumber.messages.Source; import org.junit.Test; import java.util.Optional; -import static io.cucumber.messages.Messages.Envelope; -import static io.cucumber.messages.Messages.Feature; -import static io.cucumber.messages.Messages.GherkinDocument; -import static io.cucumber.messages.Messages.Pickle; -import static io.cucumber.messages.Messages.PickleStep; -import static io.cucumber.messages.Messages.Scenario; -import static io.cucumber.messages.Messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; +import static io.cucumber.messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; public class GherkinParserTest { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java index 1301cf7bd1..7f13938d5b 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java @@ -1,8 +1,9 @@ package io.cucumber.gherkin; +import io.cucumber.messages.Envelope; import io.cucumber.messages.MessageToNdjsonWriter; -import io.cucumber.messages.Messages.Source; -import io.cucumber.messages.Messages.SourceMediaType; +import io.cucumber.messages.Source; +import io.cucumber.messages.SourceMediaType; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -13,7 +14,6 @@ import java.util.List; import static io.cucumber.gherkin.Jackson.OBJECT_MAPPER; -import static io.cucumber.messages.Messages.Envelope; import static java.util.Arrays.asList; public class Main { diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java index efa0771ed1..5dcc41172f 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Messages; +import io.cucumber.messages.Envelope; import org.junit.Test; import static org.junit.Assert.assertNotNull; @@ -10,6 +10,6 @@ public class MessageVersionTest { @Test public void message_library_has_version() { - assertNotNull(Messages.Envelope.class.getPackage().getImplementationVersion()); + assertNotNull(Envelope.class.getPackage().getImplementationVersion()); } } diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index 6260bb53b5..b146af12ef 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -3,7 +3,7 @@ import io.cucumber.messages.IdGenerator; import org.junit.Test; -import static io.cucumber.messages.Messages.GherkinDocument; +import io.cucumber.messages.GherkinDocument; import static org.junit.Assert.assertEquals; public class ParserTest { diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index 421c920437..5f4b621ee7 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -1,5 +1,7 @@ package io.cucumber.htmlformatter; +import io.cucumber.messages.Envelope; + import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -11,7 +13,6 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; -import static io.cucumber.messages.Messages.Envelope; import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Objects.requireNonNull; diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java index fcb99d7850..78a69a4417 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java @@ -1,6 +1,7 @@ package io.cucumber.htmlformatter; import io.cucumber.htmlformatter.MessagesToHtmlWriter.Serializer; +import io.cucumber.messages.Envelope; import io.cucumber.messages.NdjsonToMessageIterable; import io.cucumber.messages.NdjsonToMessageIterable.Deserializer; @@ -9,7 +10,6 @@ import java.io.InputStream; import static io.cucumber.htmlformatter.Jackson.OBJECT_MAPPER; -import static io.cucumber.messages.Messages.Envelope; public final class Main { private static final Deserializer deserializer = (json) -> OBJECT_MAPPER.readValue(json, Envelope.class); diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 39643509d9..6c6f93f09c 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -1,18 +1,16 @@ package io.cucumber.htmlformatter; import io.cucumber.htmlformatter.MessagesToHtmlWriter.Serializer; +import io.cucumber.messages.Envelope; +import io.cucumber.messages.TestRunFinished; +import io.cucumber.messages.TestRunStarted; import io.cucumber.messages.TimeConversion; import org.junit.jupiter.api.Test; -import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.io.OutputStreamWriter; import java.time.Instant; -import static io.cucumber.messages.Messages.Envelope; -import static io.cucumber.messages.Messages.TestRunFinished; -import static io.cucumber.messages.Messages.TestRunStarted; import static java.nio.charset.StandardCharsets.UTF_8; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 3f1c156cb5..1e32b660d3 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -12,8 +12,8 @@ /** * Iterates over messages read from a stream. Client code should not depend on this class - * directly, but rather on a {@code Iterable} object. - * Tests can then use a {@code new ArrayList} which implements the same interface. + * directly, but rather on a {@code Iterable} object. + * Tests can then use a {@code new ArrayList} which implements the same interface. */ public final class NdjsonToMessageIterable implements Iterable, AutoCloseable { private final BufferedReader reader; From a56ed755b7a4392257a52763e5c657b12373a55d Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sat, 29 Jan 2022 02:48:01 +0100 Subject: [PATCH 62/63] Reduce diff size --- .../io/cucumber/gherkin/GherkinDialect.java | 1 - .../gherkin/GherkinDialectProvider.java | 1 - .../gherkin/GherkinDocumentBuilder.java | 34 +++++++-------- .../io/cucumber/gherkin/GherkinParser.java | 12 +++--- .../io/cucumber/gherkin/PickleCompiler.java | 42 +++++++++---------- .../gherkin/GherkinDocumentBuilderTest.java | 10 ++--- .../cucumber/gherkin/GherkinParserTest.java | 18 ++++---- .../test/java/io/cucumber/gherkin/Main.java | 6 +-- .../cucumber/gherkin/MessageVersionTest.java | 2 +- .../java/io/cucumber/gherkin/ParserTest.java | 2 +- .../htmlformatter/MessagesToHtmlWriter.java | 2 +- .../MessagesToHtmlWriterTest.java | 6 +-- messages/java/Makefile | 6 +-- .../messages/{ => types}/Attachment.java | 2 +- .../AttachmentContentEncoding.java | 2 +- .../messages/{ => types}/Background.java | 2 +- .../io/cucumber/messages/{ => types}/Ci.java | 2 +- .../messages/{ => types}/Comment.java | 2 +- .../messages/{ => types}/DataTable.java | 2 +- .../messages/{ => types}/DocString.java | 2 +- .../messages/{ => types}/Duration.java | 2 +- .../messages/{ => types}/Envelope.java | 2 +- .../messages/{ => types}/Examples.java | 2 +- .../messages/{ => types}/Feature.java | 2 +- .../messages/{ => types}/FeatureChild.java | 2 +- .../messages/{ => types}/GherkinDocument.java | 2 +- .../io/cucumber/messages/{ => types}/Git.java | 2 +- .../cucumber/messages/{ => types}/Group.java | 2 +- .../cucumber/messages/{ => types}/Hook.java | 2 +- .../messages/{ => types}/JavaMethod.java | 2 +- .../{ => types}/JavaStackTraceElement.java | 2 +- .../messages/{ => types}/Location.java | 2 +- .../cucumber/messages/{ => types}/Meta.java | 2 +- .../messages/{ => types}/ParameterType.java | 2 +- .../messages/{ => types}/ParseError.java | 2 +- .../cucumber/messages/{ => types}/Pickle.java | 2 +- .../messages/{ => types}/PickleDocString.java | 2 +- .../messages/{ => types}/PickleStep.java | 2 +- .../{ => types}/PickleStepArgument.java | 2 +- .../messages/{ => types}/PickleTable.java | 2 +- .../messages/{ => types}/PickleTableCell.java | 2 +- .../messages/{ => types}/PickleTableRow.java | 2 +- .../messages/{ => types}/PickleTag.java | 2 +- .../messages/{ => types}/Product.java | 2 +- .../cucumber/messages/{ => types}/Rule.java | 2 +- .../messages/{ => types}/RuleChild.java | 2 +- .../messages/{ => types}/Scenario.java | 2 +- .../cucumber/messages/{ => types}/Source.java | 2 +- .../messages/{ => types}/SourceMediaType.java | 2 +- .../messages/{ => types}/SourceReference.java | 2 +- .../cucumber/messages/{ => types}/Step.java | 2 +- .../messages/{ => types}/StepDefinition.java | 2 +- .../{ => types}/StepDefinitionPattern.java | 2 +- .../StepDefinitionPatternType.java | 2 +- .../{ => types}/StepMatchArgument.java | 2 +- .../{ => types}/StepMatchArgumentsList.java | 2 +- .../messages/{ => types}/TableCell.java | 2 +- .../messages/{ => types}/TableRow.java | 2 +- .../io/cucumber/messages/{ => types}/Tag.java | 2 +- .../messages/{ => types}/TestCase.java | 2 +- .../{ => types}/TestCaseFinished.java | 2 +- .../messages/{ => types}/TestCaseStarted.java | 2 +- .../messages/{ => types}/TestRunFinished.java | 2 +- .../messages/{ => types}/TestRunStarted.java | 2 +- .../messages/{ => types}/TestStep.java | 2 +- .../{ => types}/TestStepFinished.java | 2 +- .../messages/{ => types}/TestStepResult.java | 2 +- .../{ => types}/TestStepResultStatus.java | 2 +- .../messages/{ => types}/TestStepStarted.java | 2 +- .../messages/{ => types}/Timestamp.java | 2 +- .../{ => types}/UndefinedParameterType.java | 2 +- .../messages/MessageToNdjsonWriter.java | 2 + .../messages/NdjsonToMessageIterable.java | 2 + .../io/cucumber/messages/TimeConversion.java | 3 ++ .../io/cucumber/messages/JacksonTest.java | 6 ++- .../io/cucumber/messages/MessagesTest.java | 2 + .../messages/NdjsonSerializationTest.java | 6 +++ .../cucumber/messages/TimeConversionTest.java | 2 + .../scripts/templates/java.enum.java.erb | 2 +- .../scripts/templates/java.java.erb | 2 +- 80 files changed, 152 insertions(+), 133 deletions(-) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Attachment.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/AttachmentContentEncoding.java (94%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Background.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Ci.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Comment.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/DataTable.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/DocString.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Duration.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Envelope.java (99%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Examples.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Feature.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/FeatureChild.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/GherkinDocument.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Git.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Group.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Hook.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/JavaMethod.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/JavaStackTraceElement.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Location.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Meta.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/ParameterType.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/ParseError.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Pickle.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/PickleDocString.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/PickleStep.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/PickleStepArgument.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/PickleTable.java (96%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/PickleTableCell.java (96%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/PickleTableRow.java (96%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/PickleTag.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Product.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Rule.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/RuleChild.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Scenario.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Source.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/SourceMediaType.java (95%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/SourceReference.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Step.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/StepDefinition.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/StepDefinitionPattern.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/StepDefinitionPatternType.java (95%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/StepMatchArgument.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/StepMatchArgumentsList.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TableCell.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TableRow.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Tag.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestCase.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestCaseFinished.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestCaseStarted.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestRunFinished.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestRunStarted.java (96%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestStep.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestStepFinished.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestStepResult.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestStepResultStatus.java (95%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/TestStepStarted.java (98%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/Timestamp.java (97%) rename messages/java/src/generated/java/io/cucumber/messages/{ => types}/UndefinedParameterType.java (97%) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java index 31496abfd3..248d83225c 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialect.java @@ -91,6 +91,5 @@ public List getButKeywords() { public String getLanguage() { return language; } - } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java index eff14486f1..785a7f44aa 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDialectProvider.java @@ -58,5 +58,4 @@ public List getLanguages() { sort(languages); return unmodifiableList(languages); } - } diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java index 041285a3ff..3fd7272754 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java @@ -1,21 +1,21 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Background; -import io.cucumber.messages.Comment; -import io.cucumber.messages.DataTable; -import io.cucumber.messages.DocString; -import io.cucumber.messages.Examples; -import io.cucumber.messages.Feature; -import io.cucumber.messages.FeatureChild; -import io.cucumber.messages.GherkinDocument; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.Rule; -import io.cucumber.messages.RuleChild; -import io.cucumber.messages.Scenario; -import io.cucumber.messages.Step; -import io.cucumber.messages.TableCell; -import io.cucumber.messages.TableRow; -import io.cucumber.messages.Tag; +import io.cucumber.messages.types.Background; +import io.cucumber.messages.types.Comment; +import io.cucumber.messages.types.DataTable; +import io.cucumber.messages.types.DocString; +import io.cucumber.messages.types.Examples; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.FeatureChild; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Rule; +import io.cucumber.messages.types.RuleChild; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.Step; +import io.cucumber.messages.types.TableCell; +import io.cucumber.messages.types.TableRow; +import io.cucumber.messages.types.Tag; import java.util.ArrayDeque; import java.util.ArrayList; @@ -285,9 +285,9 @@ private List getSteps(AstNode node) { return node.getItems(RuleType.Step); } - private io.cucumber.messages.Location getLocation(Token token, int column) { + private io.cucumber.messages.types.Location getLocation(Token token, int column) { column = column == 0 ? token.location.getColumn() : column; - return new io.cucumber.messages.Location((long) token.location.getLine(), (long) column); + return new io.cucumber.messages.types.Location((long) token.location.getLine(), (long) column); } private String getDescription(AstNode node) { diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java index 52c8e48858..7af49aa398 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/GherkinParser.java @@ -1,12 +1,12 @@ package io.cucumber.gherkin; import io.cucumber.gherkin.ParserException.CompositeParserException; -import io.cucumber.messages.Envelope; -import io.cucumber.messages.GherkinDocument; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.GherkinDocument; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.ParseError; -import io.cucumber.messages.Source; -import io.cucumber.messages.SourceReference; +import io.cucumber.messages.types.ParseError; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.SourceReference; import java.util.ArrayList; import java.util.List; @@ -132,7 +132,7 @@ private Envelope createParseError(ParserException e, String uri) { null, // We want 0 values not to be serialised, which is why we set them to null // This is a legacy requirement brought over from old protobuf behaviour - new io.cucumber.messages.Location( + new io.cucumber.messages.types.Location( line, column == 0 ? null : column ) diff --git a/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java b/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java index 8aca0e5765..3085e850f6 100644 --- a/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java +++ b/gherkin/java/src/main/java/io/cucumber/gherkin/PickleCompiler.java @@ -1,27 +1,27 @@ package io.cucumber.gherkin; -import io.cucumber.messages.DataTable; -import io.cucumber.messages.DocString; -import io.cucumber.messages.Examples; -import io.cucumber.messages.Feature; -import io.cucumber.messages.FeatureChild; -import io.cucumber.messages.GherkinDocument; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.Pickle; -import io.cucumber.messages.PickleDocString; -import io.cucumber.messages.PickleStep; -import io.cucumber.messages.PickleStepArgument; -import io.cucumber.messages.PickleTable; -import io.cucumber.messages.PickleTableCell; -import io.cucumber.messages.PickleTableRow; -import io.cucumber.messages.PickleTag; -import io.cucumber.messages.Rule; -import io.cucumber.messages.RuleChild; -import io.cucumber.messages.Scenario; -import io.cucumber.messages.Step; -import io.cucumber.messages.TableCell; -import io.cucumber.messages.TableRow; -import io.cucumber.messages.Tag; +import io.cucumber.messages.types.DataTable; +import io.cucumber.messages.types.DocString; +import io.cucumber.messages.types.Examples; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.FeatureChild; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.PickleDocString; +import io.cucumber.messages.types.PickleStep; +import io.cucumber.messages.types.PickleStepArgument; +import io.cucumber.messages.types.PickleTable; +import io.cucumber.messages.types.PickleTableCell; +import io.cucumber.messages.types.PickleTableRow; +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.Step; +import io.cucumber.messages.types.TableCell; +import io.cucumber.messages.types.TableRow; +import io.cucumber.messages.types.Tag; import java.util.ArrayList; import java.util.Collection; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java index fc9ebaf1e5..8d80effa67 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinDocumentBuilderTest.java @@ -1,11 +1,11 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Comment; -import io.cucumber.messages.FeatureChild; -import io.cucumber.messages.GherkinDocument; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.Pickle; -import io.cucumber.messages.TableRow; +import io.cucumber.messages.types.Comment; +import io.cucumber.messages.types.FeatureChild; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.TableRow; import org.junit.Test; import java.util.List; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java index 0cf1a6965a..432a8a0e79 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/GherkinParserTest.java @@ -1,18 +1,18 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Envelope; -import io.cucumber.messages.Feature; -import io.cucumber.messages.GherkinDocument; -import io.cucumber.messages.ParseError; -import io.cucumber.messages.Pickle; -import io.cucumber.messages.PickleStep; -import io.cucumber.messages.Scenario; -import io.cucumber.messages.Source; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.ParseError; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.PickleStep; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.Source; import org.junit.Test; import java.util.Optional; -import static io.cucumber.messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; +import static io.cucumber.messages.types.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java index 7f13938d5b..e08f79959f 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/Main.java @@ -1,9 +1,9 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Envelope; +import io.cucumber.messages.types.Envelope; import io.cucumber.messages.MessageToNdjsonWriter; -import io.cucumber.messages.Source; -import io.cucumber.messages.SourceMediaType; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.SourceMediaType; import java.io.IOException; import java.nio.charset.StandardCharsets; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java index 5dcc41172f..63eecf708e 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/MessageVersionTest.java @@ -1,6 +1,6 @@ package io.cucumber.gherkin; -import io.cucumber.messages.Envelope; +import io.cucumber.messages.types.Envelope; import org.junit.Test; import static org.junit.Assert.assertNotNull; diff --git a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java index b146af12ef..a26962df30 100644 --- a/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java +++ b/gherkin/java/src/test/java/io/cucumber/gherkin/ParserTest.java @@ -1,9 +1,9 @@ package io.cucumber.gherkin; import io.cucumber.messages.IdGenerator; +import io.cucumber.messages.types.GherkinDocument; import org.junit.Test; -import io.cucumber.messages.GherkinDocument; import static org.junit.Assert.assertEquals; public class ParserTest { diff --git a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java index 5f4b621ee7..7997e07ac9 100644 --- a/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java +++ b/html-formatter/java/src/main/java/io/cucumber/htmlformatter/MessagesToHtmlWriter.java @@ -1,6 +1,6 @@ package io.cucumber.htmlformatter; -import io.cucumber.messages.Envelope; +import io.cucumber.messages.types.Envelope; import java.io.BufferedReader; import java.io.BufferedWriter; diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java index 6c6f93f09c..5e797f24ae 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/MessagesToHtmlWriterTest.java @@ -1,10 +1,10 @@ package io.cucumber.htmlformatter; import io.cucumber.htmlformatter.MessagesToHtmlWriter.Serializer; -import io.cucumber.messages.Envelope; -import io.cucumber.messages.TestRunFinished; -import io.cucumber.messages.TestRunStarted; import io.cucumber.messages.TimeConversion; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.TestRunFinished; +import io.cucumber.messages.types.TestRunStarted; import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; diff --git a/messages/java/Makefile b/messages/java/Makefile index c62ab7d500..9422243560 100644 --- a/messages/java/Makefile +++ b/messages/java/Makefile @@ -7,6 +7,6 @@ JSONSCHEMAS = $(shell find ../jsonschema -name "*.json") ruby ../jsonschema/scripts/codegen.rb Java ../jsonschema java.enum.java.erb >> Generated.java.tmp csplit --quiet --prefix=Generated --suffix-format=%02d.java.tmp --elide-empty-files Generated.java.tmp /^.*.java$$/ {*} rm Generated.java.tmp - rm -rf src/generated/java/io/cucumber/messages - mkdir --parents src/generated/java/io/cucumber/messages - for file in Generated**; do tail -n +2 $$file > src/generated/java/io/cucumber/messages/$$(head -n 1 $$file); rm $$file; done + rm -rf src/generated/java/io/cucumber/messages/types + mkdir --parents src/generated/java/io/cucumber/messages/types + for file in Generated**; do tail -n +2 $$file > src/generated/java/io/cucumber/messages/types/$$(head -n 1 $$file); rm $$file; done diff --git a/messages/java/src/generated/java/io/cucumber/messages/Attachment.java b/messages/java/src/generated/java/io/cucumber/messages/types/Attachment.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Attachment.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Attachment.java index 23c4d4cafe..f8c644c484 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Attachment.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Attachment.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/AttachmentContentEncoding.java b/messages/java/src/generated/java/io/cucumber/messages/types/AttachmentContentEncoding.java similarity index 94% rename from messages/java/src/generated/java/io/cucumber/messages/AttachmentContentEncoding.java rename to messages/java/src/generated/java/io/cucumber/messages/types/AttachmentContentEncoding.java index 65e155dfd2..0887e34c3c 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/AttachmentContentEncoding.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/AttachmentContentEncoding.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; // Generated code @SuppressWarnings("unused") diff --git a/messages/java/src/generated/java/io/cucumber/messages/Background.java b/messages/java/src/generated/java/io/cucumber/messages/types/Background.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Background.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Background.java index acf5c2778d..60634b3877 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Background.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Background.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Ci.java b/messages/java/src/generated/java/io/cucumber/messages/types/Ci.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Ci.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Ci.java index 5b2bc2ec81..d9ffbb6f71 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Ci.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Ci.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Comment.java b/messages/java/src/generated/java/io/cucumber/messages/types/Comment.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Comment.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Comment.java index b45c9fee44..4465473d68 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Comment.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Comment.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/DataTable.java b/messages/java/src/generated/java/io/cucumber/messages/types/DataTable.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/DataTable.java rename to messages/java/src/generated/java/io/cucumber/messages/types/DataTable.java index 6ec34ff0ea..1c487cd2f4 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/DataTable.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/DataTable.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/DocString.java b/messages/java/src/generated/java/io/cucumber/messages/types/DocString.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/DocString.java rename to messages/java/src/generated/java/io/cucumber/messages/types/DocString.java index 51c1e61200..c33889e598 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/DocString.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/DocString.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Duration.java b/messages/java/src/generated/java/io/cucumber/messages/types/Duration.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Duration.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Duration.java index bea941e063..dcf306dc07 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Duration.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Duration.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Envelope.java b/messages/java/src/generated/java/io/cucumber/messages/types/Envelope.java similarity index 99% rename from messages/java/src/generated/java/io/cucumber/messages/Envelope.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Envelope.java index 088dd47047..7f93a22706 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Envelope.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Envelope.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Examples.java b/messages/java/src/generated/java/io/cucumber/messages/types/Examples.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Examples.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Examples.java index 145cd57388..ba0d72d56f 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Examples.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Examples.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Feature.java b/messages/java/src/generated/java/io/cucumber/messages/types/Feature.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Feature.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Feature.java index 814a0c77d8..f2e3385748 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Feature.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Feature.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/FeatureChild.java b/messages/java/src/generated/java/io/cucumber/messages/types/FeatureChild.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/FeatureChild.java rename to messages/java/src/generated/java/io/cucumber/messages/types/FeatureChild.java index 8797688818..7972576a87 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/FeatureChild.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/FeatureChild.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/GherkinDocument.java b/messages/java/src/generated/java/io/cucumber/messages/types/GherkinDocument.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/GherkinDocument.java rename to messages/java/src/generated/java/io/cucumber/messages/types/GherkinDocument.java index a3e5921494..d8f7aca266 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/GherkinDocument.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/GherkinDocument.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Git.java b/messages/java/src/generated/java/io/cucumber/messages/types/Git.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Git.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Git.java index da71d1b7c9..b182bf27bd 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Git.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Git.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Group.java b/messages/java/src/generated/java/io/cucumber/messages/types/Group.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Group.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Group.java index 312edc5f2f..be90e45c47 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Group.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Group.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Hook.java b/messages/java/src/generated/java/io/cucumber/messages/types/Hook.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Hook.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Hook.java index eba338f1dd..bdfa6dfeff 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Hook.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Hook.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/JavaMethod.java b/messages/java/src/generated/java/io/cucumber/messages/types/JavaMethod.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/JavaMethod.java rename to messages/java/src/generated/java/io/cucumber/messages/types/JavaMethod.java index 249c2d2c7a..0e16618459 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/JavaMethod.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/JavaMethod.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/JavaStackTraceElement.java b/messages/java/src/generated/java/io/cucumber/messages/types/JavaStackTraceElement.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/JavaStackTraceElement.java rename to messages/java/src/generated/java/io/cucumber/messages/types/JavaStackTraceElement.java index 4b7b9d3e47..cbb9895aeb 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/JavaStackTraceElement.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/JavaStackTraceElement.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Location.java b/messages/java/src/generated/java/io/cucumber/messages/types/Location.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Location.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Location.java index 0eeaf5b892..1b0b81ed96 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Location.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Location.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Meta.java b/messages/java/src/generated/java/io/cucumber/messages/types/Meta.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Meta.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Meta.java index 4eafe66868..ecdf0598b0 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Meta.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Meta.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/ParameterType.java b/messages/java/src/generated/java/io/cucumber/messages/types/ParameterType.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/ParameterType.java rename to messages/java/src/generated/java/io/cucumber/messages/types/ParameterType.java index fbfe92ab72..8c1bc8258b 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/ParameterType.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/ParameterType.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/ParseError.java b/messages/java/src/generated/java/io/cucumber/messages/types/ParseError.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/ParseError.java rename to messages/java/src/generated/java/io/cucumber/messages/types/ParseError.java index 479c339e0b..7763d5cf8c 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/ParseError.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/ParseError.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Pickle.java b/messages/java/src/generated/java/io/cucumber/messages/types/Pickle.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Pickle.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Pickle.java index ad3027b3fa..2c8fdb1118 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Pickle.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Pickle.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleDocString.java b/messages/java/src/generated/java/io/cucumber/messages/types/PickleDocString.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/PickleDocString.java rename to messages/java/src/generated/java/io/cucumber/messages/types/PickleDocString.java index c682a347e8..993bb8a9ad 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/PickleDocString.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/PickleDocString.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleStep.java b/messages/java/src/generated/java/io/cucumber/messages/types/PickleStep.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/PickleStep.java rename to messages/java/src/generated/java/io/cucumber/messages/types/PickleStep.java index 79025850f1..29b7cf8d7c 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/PickleStep.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/PickleStep.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleStepArgument.java b/messages/java/src/generated/java/io/cucumber/messages/types/PickleStepArgument.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/PickleStepArgument.java rename to messages/java/src/generated/java/io/cucumber/messages/types/PickleStepArgument.java index 5405c2fc13..787a71cee6 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/PickleStepArgument.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/PickleStepArgument.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTable.java b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTable.java similarity index 96% rename from messages/java/src/generated/java/io/cucumber/messages/PickleTable.java rename to messages/java/src/generated/java/io/cucumber/messages/types/PickleTable.java index 93c5017cf1..6a83b946f7 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/PickleTable.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTable.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTableCell.java b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTableCell.java similarity index 96% rename from messages/java/src/generated/java/io/cucumber/messages/PickleTableCell.java rename to messages/java/src/generated/java/io/cucumber/messages/types/PickleTableCell.java index b3a76e4bfb..5891b4cc5a 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/PickleTableCell.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTableCell.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTableRow.java b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTableRow.java similarity index 96% rename from messages/java/src/generated/java/io/cucumber/messages/PickleTableRow.java rename to messages/java/src/generated/java/io/cucumber/messages/types/PickleTableRow.java index 753fb1ef8a..bac9723398 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/PickleTableRow.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTableRow.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/PickleTag.java b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTag.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/PickleTag.java rename to messages/java/src/generated/java/io/cucumber/messages/types/PickleTag.java index 2136822e4f..99777e630e 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/PickleTag.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/PickleTag.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Product.java b/messages/java/src/generated/java/io/cucumber/messages/types/Product.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Product.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Product.java index 4b110ad4f1..07baf71d79 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Product.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Product.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Rule.java b/messages/java/src/generated/java/io/cucumber/messages/types/Rule.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Rule.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Rule.java index 944588b329..3ea6847d87 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Rule.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Rule.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/RuleChild.java b/messages/java/src/generated/java/io/cucumber/messages/types/RuleChild.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/RuleChild.java rename to messages/java/src/generated/java/io/cucumber/messages/types/RuleChild.java index c12eaf7fac..86ea97ee69 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/RuleChild.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/RuleChild.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Scenario.java b/messages/java/src/generated/java/io/cucumber/messages/types/Scenario.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Scenario.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Scenario.java index 7fc00fa73c..be4d7eaf64 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Scenario.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Scenario.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Source.java b/messages/java/src/generated/java/io/cucumber/messages/types/Source.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Source.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Source.java index 42e3cbead3..5b3ac65d06 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Source.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Source.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/SourceMediaType.java b/messages/java/src/generated/java/io/cucumber/messages/types/SourceMediaType.java similarity index 95% rename from messages/java/src/generated/java/io/cucumber/messages/SourceMediaType.java rename to messages/java/src/generated/java/io/cucumber/messages/types/SourceMediaType.java index 933d46f23c..9ecc233390 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/SourceMediaType.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/SourceMediaType.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; // Generated code @SuppressWarnings("unused") diff --git a/messages/java/src/generated/java/io/cucumber/messages/SourceReference.java b/messages/java/src/generated/java/io/cucumber/messages/types/SourceReference.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/SourceReference.java rename to messages/java/src/generated/java/io/cucumber/messages/types/SourceReference.java index 37fcdedb4a..847a9fd099 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/SourceReference.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/SourceReference.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Step.java b/messages/java/src/generated/java/io/cucumber/messages/types/Step.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/Step.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Step.java index e48c2dfbea..ce9d1d6170 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Step.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Step.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepDefinition.java b/messages/java/src/generated/java/io/cucumber/messages/types/StepDefinition.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/StepDefinition.java rename to messages/java/src/generated/java/io/cucumber/messages/types/StepDefinition.java index 7d1ad9abb1..7ce7461333 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/StepDefinition.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/StepDefinition.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPattern.java b/messages/java/src/generated/java/io/cucumber/messages/types/StepDefinitionPattern.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPattern.java rename to messages/java/src/generated/java/io/cucumber/messages/types/StepDefinitionPattern.java index 93c730cf8c..09531ea51e 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPattern.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/StepDefinitionPattern.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPatternType.java b/messages/java/src/generated/java/io/cucumber/messages/types/StepDefinitionPatternType.java similarity index 95% rename from messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPatternType.java rename to messages/java/src/generated/java/io/cucumber/messages/types/StepDefinitionPatternType.java index e378f2c95d..c89886ddc7 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/StepDefinitionPatternType.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/StepDefinitionPatternType.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; // Generated code @SuppressWarnings("unused") diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgument.java b/messages/java/src/generated/java/io/cucumber/messages/types/StepMatchArgument.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/StepMatchArgument.java rename to messages/java/src/generated/java/io/cucumber/messages/types/StepMatchArgument.java index 19112826c4..df4384eac0 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgument.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/StepMatchArgument.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgumentsList.java b/messages/java/src/generated/java/io/cucumber/messages/types/StepMatchArgumentsList.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/StepMatchArgumentsList.java rename to messages/java/src/generated/java/io/cucumber/messages/types/StepMatchArgumentsList.java index 64d5f68e44..bd6b29080f 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/StepMatchArgumentsList.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/StepMatchArgumentsList.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TableCell.java b/messages/java/src/generated/java/io/cucumber/messages/types/TableCell.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/TableCell.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TableCell.java index 3ca369becd..afce5075a3 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TableCell.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TableCell.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TableRow.java b/messages/java/src/generated/java/io/cucumber/messages/types/TableRow.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/TableRow.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TableRow.java index a911e92c19..6fa83d3ce9 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TableRow.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TableRow.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Tag.java b/messages/java/src/generated/java/io/cucumber/messages/types/Tag.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Tag.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Tag.java index 52a675d980..cda1727a43 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Tag.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Tag.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestCase.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestCase.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/TestCase.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestCase.java index 39c4ef1b40..7161846f29 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestCase.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestCase.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestCaseFinished.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestCaseFinished.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/TestCaseFinished.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestCaseFinished.java index b816b7b3e0..6262f3b5a0 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestCaseFinished.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestCaseFinished.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestCaseStarted.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestCaseStarted.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/TestCaseStarted.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestCaseStarted.java index 4b9431de22..0de9df752a 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestCaseStarted.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestCaseStarted.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestRunFinished.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestRunFinished.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/TestRunFinished.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestRunFinished.java index 610b78d05a..3c8ac8cb4f 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestRunFinished.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestRunFinished.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestRunStarted.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestRunStarted.java similarity index 96% rename from messages/java/src/generated/java/io/cucumber/messages/TestRunStarted.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestRunStarted.java index 08077e1249..b478ece17b 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestRunStarted.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestRunStarted.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStep.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestStep.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/TestStep.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestStep.java index 139b698df5..f65a5ae0cf 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestStep.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestStep.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepFinished.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepFinished.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/TestStepFinished.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestStepFinished.java index aed5d943fc..d3ac318038 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestStepFinished.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepFinished.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepResult.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepResult.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/TestStepResult.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestStepResult.java index 738ee03747..b13366bb21 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestStepResult.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepResult.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepResultStatus.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepResultStatus.java similarity index 95% rename from messages/java/src/generated/java/io/cucumber/messages/TestStepResultStatus.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestStepResultStatus.java index d22584ca83..c67257554e 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestStepResultStatus.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepResultStatus.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; // Generated code @SuppressWarnings("unused") diff --git a/messages/java/src/generated/java/io/cucumber/messages/TestStepStarted.java b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepStarted.java similarity index 98% rename from messages/java/src/generated/java/io/cucumber/messages/TestStepStarted.java rename to messages/java/src/generated/java/io/cucumber/messages/types/TestStepStarted.java index e9ad21d5ac..9e57371416 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/TestStepStarted.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/TestStepStarted.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/Timestamp.java b/messages/java/src/generated/java/io/cucumber/messages/types/Timestamp.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/Timestamp.java rename to messages/java/src/generated/java/io/cucumber/messages/types/Timestamp.java index ee1ce7620d..0f8574e6da 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/Timestamp.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/Timestamp.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/generated/java/io/cucumber/messages/UndefinedParameterType.java b/messages/java/src/generated/java/io/cucumber/messages/types/UndefinedParameterType.java similarity index 97% rename from messages/java/src/generated/java/io/cucumber/messages/UndefinedParameterType.java rename to messages/java/src/generated/java/io/cucumber/messages/types/UndefinedParameterType.java index 39c3eca7a8..0d0f9039c5 100644 --- a/messages/java/src/generated/java/io/cucumber/messages/UndefinedParameterType.java +++ b/messages/java/src/generated/java/io/cucumber/messages/types/UndefinedParameterType.java @@ -1,4 +1,4 @@ -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; diff --git a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java index 2734ded1a7..80e0d85883 100644 --- a/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java +++ b/messages/java/src/main/java/io/cucumber/messages/MessageToNdjsonWriter.java @@ -1,5 +1,7 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Envelope; + import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; diff --git a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java index 1e32b660d3..eeb5e3c00c 100644 --- a/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java +++ b/messages/java/src/main/java/io/cucumber/messages/NdjsonToMessageIterable.java @@ -1,5 +1,7 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Envelope; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; diff --git a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java index aea8118e5b..89a522f25e 100644 --- a/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java +++ b/messages/java/src/main/java/io/cucumber/messages/TimeConversion.java @@ -1,5 +1,8 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Duration; +import io.cucumber.messages.types.Timestamp; + public final class TimeConversion { private TimeConversion(){ diff --git a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java index e716d7923a..d2b86d175d 100644 --- a/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/JacksonTest.java @@ -1,10 +1,14 @@ package io.cucumber.messages; import com.fasterxml.jackson.core.JsonProcessingException; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.TestRunStarted; +import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; import static io.cucumber.messages.Jackson.OBJECT_MAPPER; -import static io.cucumber.messages.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; +import static io.cucumber.messages.types.SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN; import static org.junit.jupiter.api.Assertions.assertEquals; class JacksonTest { diff --git a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java index 2507610f6a..840037b996 100644 --- a/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/MessagesTest.java @@ -1,5 +1,7 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Attachment; +import io.cucumber.messages.types.Envelope; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java index 7d433c676b..1c05a2cc48 100644 --- a/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/NdjsonSerializationTest.java @@ -1,5 +1,11 @@ package io.cucumber.messages; +import io.cucumber.messages.types.AttachmentContentEncoding; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.SourceMediaType; +import io.cucumber.messages.types.TestRunStarted; +import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; diff --git a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java index 4abb9c19ea..23e4a850d9 100644 --- a/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java +++ b/messages/java/src/test/java/io/cucumber/messages/TimeConversionTest.java @@ -1,5 +1,7 @@ package io.cucumber.messages; +import io.cucumber.messages.types.Duration; +import io.cucumber.messages.types.Timestamp; import org.junit.jupiter.api.Test; import static io.cucumber.messages.TimeConversion.durationToJavaDuration; diff --git a/messages/jsonschema/scripts/templates/java.enum.java.erb b/messages/jsonschema/scripts/templates/java.enum.java.erb index 33569832dc..d22c8943b1 100644 --- a/messages/jsonschema/scripts/templates/java.enum.java.erb +++ b/messages/jsonschema/scripts/templates/java.enum.java.erb @@ -1,6 +1,6 @@ <% @enums.each do |enum| -%> <%= enum[:name] %>.java -package io.cucumber.messages; +package io.cucumber.messages.types; // Generated code @SuppressWarnings("unused") diff --git a/messages/jsonschema/scripts/templates/java.java.erb b/messages/jsonschema/scripts/templates/java.java.erb index 654b207dd2..9902607d25 100644 --- a/messages/jsonschema/scripts/templates/java.java.erb +++ b/messages/jsonschema/scripts/templates/java.java.erb @@ -1,6 +1,6 @@ <%- @schemas.each do |key, schema| -%> <%= class_name(key) %>.java -package io.cucumber.messages; +package io.cucumber.messages.types; import java.util.ArrayList; import java.util.Objects; From 7e7683df39939ed689ad699e4400ef2a23d5fd73 Mon Sep 17 00:00:00 2001 From: "M.P. Korstanje" Date: Sat, 29 Jan 2022 02:58:26 +0100 Subject: [PATCH 63/63] Fix imports --- .../java/src/test/java/io/cucumber/htmlformatter/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java index 78a69a4417..62cd675b19 100644 --- a/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java +++ b/html-formatter/java/src/test/java/io/cucumber/htmlformatter/Main.java @@ -1,9 +1,9 @@ package io.cucumber.htmlformatter; import io.cucumber.htmlformatter.MessagesToHtmlWriter.Serializer; -import io.cucumber.messages.Envelope; 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;