From 3cae263804e0b9ca44f5db2ad1327550c5a44213 Mon Sep 17 00:00:00 2001 From: FilippoR Date: Fri, 27 May 2022 18:00:21 +0200 Subject: [PATCH 1/9] initial Migration to cucumber 7 --- .../CucumberRunCodeMiningProvider.java | 8 +- .../GherkinContentAssistProcessor.java | 12 +- .../editor/debug/GherkingGroupValue.java | 4 +- .../editor/debug/GherkingStackFrame.java | 2 + .../debug/GherkingStepDefinitionValue.java | 2 +- .../editor/debug/GherkingStepStackFrame.java | 17 +-- .../GherkingToggleBreakpointsTarget.java | 6 +- .../document/GherkinEditorDocument.java | 75 ++++++----- .../document/GherkinMessageHandler.java | 62 ++++----- .../editor/document/GherkinStream.java | 59 +++++---- .../editor/document/TestStepEvent.java | 14 +-- .../hyperlinks/IStepDefinitionOpener.java | 2 +- .../editor/hyperlinks/StepHyperlink.java | 2 +- .../hyperlinks/StepHyperlinkDetector.java | 6 +- .../CucumberFeatureLaunchShortcut.java | 2 +- .../editor/launching/EnvelopeListener.java | 2 +- .../eclipse/editor/launching/ILauncher.java | 4 +- .../eclipse/editor/marker/MarkerFactory.java | 18 +-- .../testresults/CucumberTestRunnerClient.java | 78 ++++++------ .../validation/GherkinSyntaxValidator.java | 2 +- io.cucumber.eclipse.feature/feature.xml | 74 +++++------ .../java/plugins/CucumberEclipsePlugin.java | 4 +- .../eclipse/java/plugins/MessageEndpoint.java | 17 ++- .../launching/CucumberRuntimeLauncher.java | 37 +++--- .../launching/MessageEndpointProcess.java | 2 +- .../eclipse/java/runtime/CucumberRuntime.java | 4 +- .../java/steps/JavaStepDefinitionOpener.java | 2 +- .../cucumber.eclipse.targetdefinition.target | 118 ++++++++++++------ 28 files changed, 355 insertions(+), 280 deletions(-) diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/codemining/CucumberRunCodeMiningProvider.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/codemining/CucumberRunCodeMiningProvider.java index d2ae449c..b7fd0cba 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/codemining/CucumberRunCodeMiningProvider.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/codemining/CucumberRunCodeMiningProvider.java @@ -28,10 +28,10 @@ import io.cucumber.eclipse.editor.document.GherkinEditorDocument; import io.cucumber.eclipse.editor.launching.ILauncher; import io.cucumber.eclipse.editor.launching.ILauncher.Mode; -import io.cucumber.messages.Messages.GherkinDocument.Feature; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Tag; -import io.cucumber.messages.Messages.Location; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.Location; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.Tag; import io.cucumber.tagexpressions.TagExpressionParser; /** diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/contentassist/GherkinContentAssistProcessor.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/contentassist/GherkinContentAssistProcessor.java index 65883fed..90a06ed8 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/contentassist/GherkinContentAssistProcessor.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/contentassist/GherkinContentAssistProcessor.java @@ -22,8 +22,8 @@ import io.cucumber.eclipse.editor.document.GherkinEditorDocument; import io.cucumber.eclipse.editor.document.GherkinKeyword; import io.cucumber.gherkin.GherkinDialect; -import io.cucumber.messages.Messages.GherkinDocument.Feature; -import io.cucumber.messages.Messages.GherkinDocument.Feature.FeatureChild; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.FeatureChild; /** * Provides content assist for gherkin keywords @@ -53,9 +53,9 @@ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int .map(featureKeyWord -> createFeatureKeyWordProposal(featureKeyWord.getKey(), offset, typed)) .toArray(ICompletionProposal[]::new); } - Predicate hasTopLevelElement = FeatureChild::hasBackground; - hasTopLevelElement = hasTopLevelElement.or(FeatureChild::hasRule); - hasTopLevelElement = hasTopLevelElement.or(FeatureChild::hasScenario); + Predicate hasTopLevelElement = f->f.getBackground().isPresent(); + hasTopLevelElement = hasTopLevelElement.or(f->f.getRule().isPresent()); + hasTopLevelElement = hasTopLevelElement.or(f->f.getScenario().isPresent()); if (editorDocument.getFeatureChilds().filter(hasTopLevelElement).count() == 0) { // in this case Rule, Scenario or background are required return editorDocument.getTopLevelKeywords()// @@ -102,7 +102,7 @@ public IContextInformation[] computeContextInformation(ITextViewer viewer, int o try { IRegion line = viewer.getDocument().getLineInformationOfOffset(offset); - String typed = viewer.getDocument().get(line.getOffset(), offset - line.getOffset()).stripLeading(); + /* String typed = */ viewer.getDocument().get(line.getOffset(), offset - line.getOffset()).stripLeading(); editorDocument.keyWords(GherkinDialect::getFeatureKeywords); diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingGroupValue.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingGroupValue.java index 0cdb9893..20ef4f18 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingGroupValue.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingGroupValue.java @@ -3,7 +3,7 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IDebugElement; -import io.cucumber.messages.Messages.TestCase.TestStep.StepMatchArgumentsList.StepMatchArgument.Group; +import io.cucumber.messages.types.Group; /** * A group value @@ -22,7 +22,7 @@ public GherkingGroupValue(IDebugElement parent, String type, Group group) { @Override public String getValueString() throws DebugException { - return group.getValue(); + return group.getValue().orElse(null); } } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStackFrame.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStackFrame.java index 997366b4..5789a009 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStackFrame.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStackFrame.java @@ -29,6 +29,8 @@ public GherkingStackFrame(IThread thread, int lineNumber, String name) { this.name = name; } + + @Override public boolean canStepInto() { return false; diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepDefinitionValue.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepDefinitionValue.java index 75ce018d..6b92c294 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepDefinitionValue.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepDefinitionValue.java @@ -3,7 +3,7 @@ import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.model.IDebugElement; -import io.cucumber.messages.Messages.StepDefinition; +import io.cucumber.messages.types.StepDefinition; /** * A value representing a step definition diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepStackFrame.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepStackFrame.java index 8d7462d0..82423ba5 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepStackFrame.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingStepStackFrame.java @@ -7,9 +7,9 @@ import org.eclipse.debug.core.model.IThread; import org.eclipse.debug.core.model.IVariable; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; -import io.cucumber.messages.Messages.StepDefinition; -import io.cucumber.messages.Messages.TestCase.TestStep; +import io.cucumber.messages.types.Step; +import io.cucumber.messages.types.StepDefinition; +import io.cucumber.messages.types.TestStep; /** * Special stackframe that represents a test-step @@ -25,7 +25,7 @@ public class GherkingStepStackFrame extends GherkingStackFrame { private DebugRunnable stepOverHandler; public GherkingStepStackFrame(IThread thread, TestStep testStep, Step step, StepDefinition stepDefinition) { - super(thread, step.getLocation().getLine(), "[" + step.getKeyword().strip() + "] " + step.getText()); + super(thread, step.getLocation().getLine().intValue(), "[" + step.getKeyword().strip() + "] " + step.getText()); this.testStep = testStep; this.step = step; this.stepDefinition = stepDefinition; @@ -41,11 +41,12 @@ public GherkingStepStackFrame(IThread thread, TestStep testStep, Step step, Step private void addGroups(GherkingStackFrame stepFrame, Consumer variableConsumer) { AtomicInteger counter = new AtomicInteger(); - testStep.getStepMatchArgumentsListsList().stream().flatMap(list -> list.getStepMatchArgumentsList().stream()) + testStep.getStepMatchArgumentsLists().stream().flatMap(list -> list.stream().flatMap(p->p.getStepMatchArguments().stream())) .forEach(argument -> { - String type = argument.getParameterTypeName(); - variableConsumer.accept(new GherkingStepVariable(stepFrame, "arg" + counter.get(), - new GherkingGroupValue(stepFrame.getDebugTarget(), type, argument.getGroup()))); + argument.getParameterTypeName().ifPresent(type-> + variableConsumer.accept(new GherkingStepVariable(stepFrame, "arg" + counter.get(), + new GherkingGroupValue(stepFrame.getDebugTarget(), type, argument.getGroup()))) + ); }); } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingToggleBreakpointsTarget.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingToggleBreakpointsTarget.java index be31a232..f355c307 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingToggleBreakpointsTarget.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/debug/GherkingToggleBreakpointsTarget.java @@ -19,8 +19,8 @@ import org.osgi.service.component.annotations.Component; import io.cucumber.eclipse.editor.document.GherkinEditorDocument; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; -import io.cucumber.messages.Messages.Location; +import io.cucumber.messages.types.Step; +import io.cucumber.messages.types.Location; /** * Service for providing breakpoints to the generic editor @@ -102,7 +102,7 @@ public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) { ITextSelection textSelection = (ITextSelection) selection; int lineNumber = textSelection.getStartLine() + 1; Stream stream = editorDocument.getSteps().map(Step::getLocation); - return stream.mapToInt(Location::getLine).filter(line -> line == lineNumber).findAny().isPresent(); + return stream.mapToLong(Location::getLine).filter(line -> line == lineNumber).findAny().isPresent(); } } } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java index 3aa377a1..20f1d771 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java @@ -32,13 +32,15 @@ import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Position; -import io.cucumber.gherkin.Gherkin; +//import io.cucumber.gherkin.Gherkin; import io.cucumber.gherkin.GherkinDialect; import io.cucumber.gherkin.GherkinDialectProvider; -import io.cucumber.gherkin.Location; -import io.cucumber.gherkin.ParserException.NoSuchLanguageException; +import io.cucumber.gherkin.GherkinParser; import io.cucumber.messages.IdGenerator; -import io.cucumber.messages.Messages.Envelope; +import io.cucumber.messages.types.Attachment; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.SourceMediaType; /** * @@ -70,8 +72,8 @@ public final class GherkinEditorDocument extends GherkinStream { private Supplier resourceSupplier; private GherkinEditorDocument(IDocument document, Supplier resourceSupplier) { - super(Gherkin.fromSources(Collections.singletonList(Gherkin.makeSourceEnvelope(document.get(), "")), true, true, - false, new IdGenerator.Incrementing()).toArray(Envelope[]::new)); + + super(getEnvelopes(document, resourceSupplier)); this.resourceSupplier = resourceSupplier; document.addDocumentListener(new IDocumentListener() { @@ -87,28 +89,45 @@ public void documentAboutToBeChanged(DocumentEvent event) { } }); this.document = document; - dialect = getFeature().map(f -> f.getLanguage()).filter(Objects::nonNull).filter(Predicate.not(String::isBlank)) - .map(lang -> provider.getDialect(lang, new Location(-1, -1))).orElseGet(() -> { - try { - IRegion firstLine = document.getLineInformation(0); - String line = document.get(firstLine.getOffset(), firstLine.getLength()).trim(); - if (line.startsWith("#")) { - String[] split = line.split("language:", 2); - if (split.length == 2) { - try { - return provider.getDialect(split[1].trim(), new Location(-1, -1)); - } catch (NoSuchLanguageException e) { - } - } + + Optional langOpt = getFeature().map(f -> f.getLanguage()).filter(Objects::nonNull) + .filter(Predicate.not(String::isBlank)); + + dialect = langOpt.map(lang -> provider.getDialect(lang, null)).orElseGet(() -> { + try { + IRegion firstLine = document.getLineInformation(0); + String line = document.get(firstLine.getOffset(), firstLine.getLength()).trim(); + if (line.startsWith("#")) { + String[] split = line.split("language:", 2); + if (split.length == 2) { + try { + return provider.getDialect(split[1].trim(), null); + } catch (Exception e) { } - } catch (BadLocationException e) { } - return provider.getDefaultDialect(); - }); + + } + } catch (BadLocationException e) { + } + return provider.getDefaultDialect(); + }); + locale = Locale.forLanguageTag(dialect.getLanguage()); } + private static Envelope[] getEnvelopes(IDocument document, Supplier resourceSupplier) { +// Gherkin.fromSources(Collections.singletonList(Gherkin.makeSourceEnvelope(document.get(), "")), true, true, +// false, new IdGenerator.Incrementing()).toArray(Envelope[]::new) + GherkinParser parser = GherkinParser.builder() + .includeSource(true) + .includePickles(true) + .build(); + Source source = new Source(document.get(), "", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN); + Envelope envelope = Envelope.of(source); + return parser.parse(envelope).toArray(Envelope[]::new); + } + /** * @return the dialect of the document */ @@ -127,19 +146,19 @@ public IDocument getDocument() { return document; } - public Position getPosition(io.cucumber.messages.Messages.Location location) throws BadLocationException { + public Position getPosition(io.cucumber.messages.types.Location location) throws BadLocationException { return getPosition(location, 0); } - public Position getPosition(io.cucumber.messages.Messages.Location location, int lineOffset) + public Position getPosition(io.cucumber.messages.types.Location location, int lineOffset) throws BadLocationException { - int line = location.getLine(); + int line = location.getLine().intValue(); int offset = document.getLineOffset(line - 1 - lineOffset); - return new Position(offset + location.getColumn() - 1, 1); + return new Position(offset + location.getColumn().orElse(0l).intValue() - 1, 1); } - public Position getEolPosition(io.cucumber.messages.Messages.Location location) throws BadLocationException { - int line = location.getLine(); + public Position getEolPosition(io.cucumber.messages.types.Location location) throws BadLocationException { + int line = location.getLine().intValue(); int offset = document.getLineOffset(line - 1); int lineLength = document.getLineLength(line - 1); // Workaround for Bug 570740 diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinMessageHandler.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinMessageHandler.java index ab6bc80b..02e441ab 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinMessageHandler.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinMessageHandler.java @@ -7,17 +7,17 @@ import java.util.stream.Stream; import io.cucumber.eclipse.editor.launching.EnvelopeListener; -import io.cucumber.messages.Messages.Envelope; -import io.cucumber.messages.Messages.GherkinDocument.Feature; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; -import io.cucumber.messages.Messages.Pickle; -import io.cucumber.messages.Messages.Pickle.PickleStep; -import io.cucumber.messages.Messages.StepDefinition; -import io.cucumber.messages.Messages.TestCase; -import io.cucumber.messages.Messages.TestCase.TestStep; -import io.cucumber.messages.Messages.TestStepFinished; -import io.cucumber.messages.Messages.TestStepStarted; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.Step; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.PickleStep; +import io.cucumber.messages.types.StepDefinition; +import io.cucumber.messages.types.TestCase; +import io.cucumber.messages.types.TestStep; +import io.cucumber.messages.types.TestStepFinished; +import io.cucumber.messages.types.TestStepStarted; /** * Handler that links the individual message parts together @@ -35,38 +35,38 @@ public abstract class GherkinMessageHandler implements EnvelopeListener { @Override public void handleEnvelope(Envelope env) { - if (env.hasTestCase()) { - TestCase testCase = env.getTestCase(); - for (TestStep step : testCase.getTestStepsList()) { + if (env.getTestCase().isPresent()) { + TestCase testCase = env.getTestCase().get(); + for (TestStep step : testCase.getTestSteps()) { testStepMap.put(step.getId(), new TestStepLink(testCase, step)); } return; } - if (env.hasPickle()) { - Pickle pickle = env.getPickle(); - for (PickleStep step : pickle.getStepsList()) { + if (env.getPickle().isPresent()) { + Pickle pickle = env.getPickle().get(); + for (PickleStep step : pickle.getSteps()) { pickleStepMap.put(step.getId(), new PickleStepLink(pickle, step)); } return; } - if (env.hasGherkinDocument()) { + if (env.getGherkinDocument().isPresent()) { stream = new GherkinStream(env); return; } - if (env.hasStepDefinition()) { - StepDefinition stepDefinition = env.getStepDefinition(); + if (env.getStepDefinition().isPresent()) { + StepDefinition stepDefinition = env.getStepDefinition().get(); stepDefinitionMap.put(stepDefinition.getId(), stepDefinition); return; } - boolean testStepStarted = env.hasTestStepStarted(); - boolean testStepFinished = env.hasTestStepFinished(); + boolean testStepStarted = env.getTestStepStarted().isPresent(); + boolean testStepFinished = env.getTestStepFinished().isPresent(); if (testStepStarted || testStepFinished) { TestStepLink stepLink; if (testStepStarted) { - TestStepStarted stepStarted = env.getTestStepStarted(); + TestStepStarted stepStarted = env.getTestStepStarted().get(); stepLink = testStepMap.get(stepStarted.getTestStepId()); } else if (testStepFinished) { - TestStepFinished stepFinished = env.getTestStepFinished(); + TestStepFinished stepFinished = env.getTestStepFinished().get(); stepLink = testStepMap.get(stepFinished.getTestStepId()); } else { stepLink = null; @@ -97,37 +97,37 @@ public void handleEnvelope(Envelope env) { private final class TestStepLink { - private TestCase testCase; +// private TestCase testCase; private TestStep testStep; public TestStepLink(TestCase testCase, TestStep step) { - this.testCase = testCase; +// this.testCase = testCase; this.testStep = step; } Optional link() { - return Optional.ofNullable(pickleStepMap.get(testStep.getPickleStepId())); + return testStep.getPickleStepId().flatMap(id-> Optional.ofNullable(pickleStepMap.get(id))); } Stream stepDefinitions() { - return testStep.getStepDefinitionIdsList().stream().map(stepDefinitionMap::get).filter(Objects::nonNull); + return testStep.getStepDefinitionIds().map(l->l.stream().map(stepDefinitionMap::get).filter(Objects::nonNull)).orElse(Stream.of()); } } private final class PickleStepLink { - private Pickle pickle; +// private Pickle pickle; private PickleStep step; public PickleStepLink(Pickle pickle, PickleStep step) { - this.pickle = pickle; +// this.pickle = pickle; this.step = step; } Optional backtrace() { if (stream != null) { - return step.getAstNodeIdsList().stream().flatMap(astId -> { + return step.getAstNodeIds().stream().flatMap(astId -> { return findByAst(astId); }).findAny(); } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java index a41f8ae0..0d94e592 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java @@ -5,18 +5,18 @@ import java.util.Optional; import java.util.stream.Stream; -import io.cucumber.messages.Messages.Envelope; -import io.cucumber.messages.Messages.GherkinDocument; -import io.cucumber.messages.Messages.GherkinDocument.Feature; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Background; -import io.cucumber.messages.Messages.GherkinDocument.Feature.FeatureChild; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario.Examples; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step.DataTable; -import io.cucumber.messages.Messages.GherkinDocument.Feature.TableRow; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Tag; -import io.cucumber.messages.Messages.ParseError; +import io.cucumber.messages.types.Background; +import io.cucumber.messages.types.DataTable; +import io.cucumber.messages.types.Envelope; +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.ParseError; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.Step; +import io.cucumber.messages.types.TableRow; +import io.cucumber.messages.types.Tag; /** * Helper handling the different items of a message stream @@ -38,11 +38,11 @@ public GherkinStream(Envelope... envelopes) { * feature is present (either none is defined or there are parse errors) */ public Optional getFeature() { - return getGherkinDocument().filter(GherkinDocument::hasFeature).map(GherkinDocument::getFeature); + return getGherkinDocument().flatMap(GherkinDocument::getFeature); } public Optional getGherkinDocument() { - return Arrays.stream(envelopes).filter(Envelope::hasGherkinDocument).map(s -> s.getGherkinDocument()) + return Arrays.stream(envelopes).map(s -> s.getGherkinDocument()).filter(o -> o.isPresent()).map(o -> o.get()) .findFirst(); } @@ -51,61 +51,60 @@ public Stream getFeatureChilds() { } public static Stream featureChilds(Feature feature) { - return feature.getChildrenList().stream(); + return feature.getChildren().stream(); } public Stream getScenarios() { - return getFeatureChilds().filter(FeatureChild::hasScenario).map(FeatureChild::getScenario); + return getFeatureChilds().map(FeatureChild::getScenario).filter(o -> o.isPresent()).map(o -> o.get()); } public static Stream scenarios(Feature feature) { - return featureChilds(feature).filter(FeatureChild::hasScenario).map(FeatureChild::getScenario); + return featureChilds(feature).map(FeatureChild::getScenario).filter(o -> o.isPresent()).map(o -> o.get()); } public Stream getSteps() { - Stream backgroundSteps = getBackgrounds().flatMap(bg -> bg.getStepsList().stream()); + Stream backgroundSteps = getBackgrounds().flatMap(bg -> bg.getSteps().stream()); Stream scenarioSteps = getScenarios().flatMap(GherkinStream::scenarioSteps); return Stream.concat(scenarioSteps, backgroundSteps).distinct(); } public static Stream scenarioSteps(Scenario scenario) { - return scenario.getStepsList().stream(); + return scenario.getSteps().stream(); } public Stream getBackgrounds() { - return getFeatureChilds().filter(FeatureChild::hasBackground).map(FeatureChild::getBackground); + return getFeatureChilds().map(FeatureChild::getBackground).filter(o -> o.isPresent()).map(o -> o.get()); } public Stream getTags() { - - return Stream.concat(getExamples().flatMap(example -> example.getTagsList().stream()), - Stream.concat(getScenarios().flatMap(scenario -> scenario.getTagsList().stream()), - getFeature().stream().flatMap(feature -> feature.getTagsList().stream()))) + return Stream.concat(getExamples().flatMap(example -> example.getTags().stream()), + Stream.concat(getScenarios().flatMap(scenario -> scenario.getTags().stream()), + getFeature().stream().flatMap(feature -> feature.getTags().stream()))) .distinct(); } public Stream getExamples() { - return getScenarios().flatMap(s -> s.getExamplesList().stream()); + return getScenarios().flatMap(s -> s.getExamples().stream()); } public Stream getTableHeaders() { - return getExamples().filter(Examples::hasTableHeader).map(Examples::getTableHeader).distinct(); + return getExamples().map(Examples::getTableHeader).filter(o -> o.isPresent()).map(o -> o.get()).distinct(); } public Stream> getTableBodys() { - return getExamples().filter(Examples::hasTableHeader).map(Examples::getTableBodyList).distinct(); + return getExamples().map(Examples::getTableBody).distinct(); } public Stream getDataTables() { - return getScenarios().flatMap(scenario -> scenario.getStepsList().stream()).filter(Step::hasDataTable) - .map(Step::getDataTable).distinct(); + return getScenarios().flatMap(scenario -> scenario.getSteps().stream()) + .map(Step::getDataTable).filter(o -> o.isPresent()).map(o -> o.get()).distinct(); } /** * @return a stream of parse errors for the given document */ public Stream getParseError() { - return Arrays.stream(envelopes).filter(Envelope::hasParseError).map(Envelope::getParseError); + return Arrays.stream(envelopes).map(Envelope::getParseError).filter(o -> o.isPresent()).map(o -> o.get()); } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/TestStepEvent.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/TestStepEvent.java index 220b26dc..c0f4c8a2 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/TestStepEvent.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/TestStepEvent.java @@ -5,11 +5,11 @@ import io.cucumber.eclipse.editor.debug.GherkingStackFrame; import io.cucumber.eclipse.editor.debug.GherkingStepStackFrame; -import io.cucumber.messages.Messages.GherkinDocument.Feature; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; -import io.cucumber.messages.Messages.StepDefinition; -import io.cucumber.messages.Messages.TestCase.TestStep; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.Step; +import io.cucumber.messages.types.StepDefinition; +import io.cucumber.messages.types.TestStep; /** * Event collecting the whole context of a given test step @@ -48,9 +48,9 @@ public Step getStep() { public IStackFrame[] getStackTrace(IThread thread) { GherkingStackFrame stepFrame = new GherkingStepStackFrame(thread, testStep, step, stepDefinition); - GherkingStackFrame scenarioFrame = new GherkingStackFrame(thread, scenario.getLocation().getLine(), + GherkingStackFrame scenarioFrame = new GherkingStackFrame(thread, scenario.getLocation().getLine().intValue(), "[" + scenario.getKeyword().strip() + "] " + scenario.getName()); - GherkingStackFrame featureFrame = new GherkingStackFrame(thread, feature.getLocation().getLine(), + GherkingStackFrame featureFrame = new GherkingStackFrame(thread, feature.getLocation().getLine().intValue(), "[" + feature.getKeyword().strip() + "] " + feature.getName()); return new IStackFrame[] { stepFrame, scenarioFrame, featureFrame }; } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/IStepDefinitionOpener.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/IStepDefinitionOpener.java index a4f755bb..1cf42bed 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/IStepDefinitionOpener.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/IStepDefinitionOpener.java @@ -4,7 +4,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.ITextViewer; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; +import io.cucumber.messages.types.Step; /** * The cucumber editor try to jump to step definition resource by itself when it diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlink.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlink.java index 53999ea9..ffcb0327 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlink.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlink.java @@ -9,7 +9,7 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.hyperlink.IHyperlink; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; +import io.cucumber.messages.types.Step; public class StepHyperlink implements IHyperlink { diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlinkDetector.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlinkDetector.java index c7f773e7..743a3ea6 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlinkDetector.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/hyperlinks/StepHyperlinkDetector.java @@ -47,10 +47,10 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boo IHyperlink[] hyperlinks = editorDocument.getSteps() .filter(step -> step.getLocation().getLine() == lineNumber).map(step -> { - int column = step.getLocation().getColumn() - 1; + long column = step.getLocation().getColumn().orElse(0l) - 1; String keyword = step.getKeyword(); - int statementStartOffset = lineStartOffset + column + keyword.length(); - IRegion stepRegion = new Region(statementStartOffset, step.getText().length()); + Long statementStartOffset = lineStartOffset + column + keyword.length(); + IRegion stepRegion = new Region(statementStartOffset.intValue(), step.getText().length()); return new StepHyperlink(stepRegion, step, textViewer, resource, openers); }).filter(Objects::nonNull).toArray(IHyperlink[]::new); diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/CucumberFeatureLaunchShortcut.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/CucumberFeatureLaunchShortcut.java index 639263f0..0db463b4 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/CucumberFeatureLaunchShortcut.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/CucumberFeatureLaunchShortcut.java @@ -32,7 +32,7 @@ import io.cucumber.eclipse.editor.CucumberServiceRegistry; import io.cucumber.eclipse.editor.document.GherkinEditorDocument; import io.cucumber.eclipse.editor.launching.ILauncher.Mode; -import io.cucumber.messages.Messages.GherkinDocument.Feature; +import io.cucumber.messages.types.Feature; import io.cucumber.tagexpressions.TagExpressionParser; public class CucumberFeatureLaunchShortcut implements ILaunchShortcut { diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/EnvelopeListener.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/EnvelopeListener.java index 13a24d77..81507c70 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/EnvelopeListener.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/EnvelopeListener.java @@ -1,6 +1,6 @@ package io.cucumber.eclipse.editor.launching; -import io.cucumber.messages.Messages.Envelope; +import io.cucumber.messages.types.Envelope; /** * A listener that is notified about new envelopes diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/ILauncher.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/ILauncher.java index 1456e34d..c7c959ee 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/ILauncher.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/launching/ILauncher.java @@ -15,8 +15,8 @@ import io.cucumber.eclipse.editor.Activator; import io.cucumber.eclipse.editor.document.GherkinEditorDocument; import io.cucumber.eclipse.editor.preferences.ICucumberPreferenceConstants; -import io.cucumber.messages.Messages.GherkinDocument.Feature; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.Scenario; /** * a launcher is capable of launching a cucumber run for a given resource and a diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/marker/MarkerFactory.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/marker/MarkerFactory.java index 6d28467f..4f2a5cb8 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/marker/MarkerFactory.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/marker/MarkerFactory.java @@ -20,9 +20,9 @@ import org.eclipse.jface.text.Region; import io.cucumber.eclipse.editor.Activator; -import io.cucumber.messages.Messages.Location; -import io.cucumber.messages.Messages.ParseError; -import io.cucumber.messages.Messages.SourceReference; +import io.cucumber.messages.types.Location; +import io.cucumber.messages.types.ParseError; +import io.cucumber.messages.types.SourceReference; /** * The marker factory exposes methods to put makers: - unmatched step - gherkin @@ -136,15 +136,15 @@ public void build() throws CoreException { Map existingMarker = getExistingMarker(resource, GHERKIN_SYNTAX_ERROR); for (ParseError error : errors) { String sourceId; - int line; - int column; - if (error.hasSource()) { + Long line; + long column; + if (error.getSource().getLocation().isPresent()) { SourceReference source = error.getSource(); - Location location = source.getLocation(); + Location location = source.getLocation().get(); line = location.getLine(); - column = location.getColumn(); + column = location.getColumn().orElse(-1l); } else { - line = -1; + line = -1l; column = -1; } if (line > 0) { diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java index 0b13418b..10f6cc8c 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java @@ -20,18 +20,18 @@ import io.cucumber.eclipse.editor.launching.EnvelopeListener; import io.cucumber.eclipse.editor.launching.EnvelopeProvider; -import io.cucumber.messages.Messages.Envelope; -import io.cucumber.messages.Messages.GherkinDocument; -import io.cucumber.messages.Messages.GherkinDocument.Feature; -import io.cucumber.messages.Messages.Pickle; -import io.cucumber.messages.Messages.Pickle.PickleStep; -import io.cucumber.messages.Messages.TestCase; -import io.cucumber.messages.Messages.TestCase.TestStep; -import io.cucumber.messages.Messages.TestCaseStarted; -import io.cucumber.messages.Messages.TestStepFinished; -import io.cucumber.messages.Messages.TestStepFinished.TestStepResult; -import io.cucumber.messages.Messages.TestStepFinished.TestStepResult.Status; -import io.cucumber.messages.Messages.TestStepStarted; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Feature; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.PickleStep; +import io.cucumber.messages.types.TestCase; +import io.cucumber.messages.types.TestStep; +import io.cucumber.messages.types.TestCaseStarted; +import io.cucumber.messages.types.TestStepFinished; +import io.cucumber.messages.types.TestStepResult; +import io.cucumber.messages.types.TestStepResultStatus; +import io.cucumber.messages.types.TestStepStarted; /** * {@link ITestRunnerClient} that converts cucumber events into appropriate @@ -87,38 +87,38 @@ public void startMonitoring() { @Override public void handleEnvelope(Envelope env) { - if (env.hasTestRunStarted()) { + if (env.getTestRunStarted().isPresent()) { session.notifyTestSessionStarted(null); return; } - if (env.hasGherkinDocument()) { - GherkinDocument document = env.getGherkinDocument(); - Feature feature = document.getFeature(); + if (env.getGherkinDocument().isPresent()) { + GherkinDocument document = env.getGherkinDocument().get(); + Feature feature = document.getFeature().get(); // TODO get number of tests? - session.newTestSuite(document.getUri(), feature.getName(), null, null, feature.getName(), ""); + session.newTestSuite(document.getUri().get(), feature.getName(), null, null, feature.getName(), ""); return; } - if (env.hasPickle()) { - Pickle pickle = env.getPickle(); + if (env.getPickle().isPresent()) { + Pickle pickle = env.getPickle().get(); pickles.put(pickle.getId(), pickle); return; } - if (env.hasTestCase()) { + if (env.getTestCase().isPresent()) { // TODO support "parameterized" test for scenario outlines see Eclipse Bug // 573263 - TestCase testCase = env.getTestCase(); + TestCase testCase = env.getTestCase().get(); testcases.put(testCase.getId(), testCase); Pickle pickle = pickles.get(testCase.getPickleId()); // TODO match the pickle to the scenario/... item... and use this as the "method // name" - Map pickleSteps = pickle.getStepsList().stream() + Map pickleSteps = pickle.getSteps().stream() .collect(Collectors.toMap(PickleStep::getId, Function.identity())); - ITestSuiteElement testSuite = session.newTestSuite(testCase.getId(), pickle.getAstNodeIdsList().toString(), - testCase.getTestStepsCount(), (ITestSuiteElement) session.getTestElement(pickle.getUri()), + ITestSuiteElement testSuite = session.newTestSuite(testCase.getId(), pickle.getAstNodeIds().toString(), + testCase.getTestSteps().size(), (ITestSuiteElement) session.getTestElement(pickle.getUri()), pickle.getName(), env.toString()); - for (TestStep step : testCase.getTestStepsList()) { - String pickleStepId = step.getPickleStepId(); + for (TestStep step : testCase.getTestSteps()) { + String pickleStepId = step.getPickleStepId().get(); if (pickleStepId.isBlank()) { continue; } @@ -127,29 +127,29 @@ public void handleEnvelope(Envelope env) { } return; } - if (env.hasTestCaseStarted()) { - TestCaseStarted testCaseStarted = env.getTestCaseStarted(); + if (env.getTestCaseStarted().isPresent()) { + TestCaseStarted testCaseStarted = env.getTestCaseStarted().get(); started.put(testCaseStarted.getId(), testCaseStarted); return; } - if (env.hasTestStepStarted()) { - TestStepStarted testStepStarted = env.getTestStepStarted(); + if (env.getTestStepStarted().isPresent()) { + TestStepStarted testStepStarted = env.getTestStepStarted().get(); // TODO pass time-stamps see see Eclipse Bug 573264 session.notifyTestStarted(session.getTestElement(testStepStarted.getTestStepId())); return; } - if (env.hasTestStepFinished()) { + if (env.getTestStepFinished().isPresent()) { // TODO pass time-stamps see see Eclipse Bug 573264 - TestStepFinished testStepFinished = env.getTestStepFinished(); + TestStepFinished testStepFinished = env.getTestStepFinished().get(); TestStepResult testStepResult = testStepFinished.getTestStepResult(); - Status status = testStepResult.getStatus(); - if (status == Status.PASSED || status == Status.PENDING || status == Status.SKIPPED) { + TestStepResultStatus status = testStepResult.getStatus(); + if (status == TestStepResultStatus.PASSED || status == TestStepResultStatus.PENDING || status == TestStepResultStatus.SKIPPED) { session.notifyTestEnded(session.getTestElement(testStepFinished.getTestStepId()), - status != Status.PASSED); + status != TestStepResultStatus.PASSED); } else { String expected = null; String actual = null; - String message = testStepResult.getMessage(); + String message = testStepResult.getMessage().get(); message = message.replace("\\r", "\r").replace("\\n", "\n").replace("\\t", "\t"); Matcher matcher = OPENTEST4J.matcher(message); if (matcher.find()) { @@ -158,16 +158,16 @@ public void handleEnvelope(Envelope env) { } FailureTrace trace = new FailureTrace(message, expected, actual); session.notifyTestFailed(session.getTestElement(testStepFinished.getTestStepId()), - status == Status.FAILED ? Result.FAILURE : Result.ERROR, status == Status.UNDEFINED, trace); + status == TestStepResultStatus.FAILED ? Result.FAILURE : Result.ERROR, status == TestStepResultStatus.UNDEFINED, trace); } return; } - if (env.hasTestCaseFinished()) { + if (env.getTestCaseFinished().isPresent()) { // TestCaseFinished testCaseFinished = env.getTestCaseFinished(); // TestCaseStarted testCaseStarted = started.get(testCaseFinished.getTestCaseStartedId()); } - if (env.hasTestRunFinished()) { + if (env.getTestRunFinished().isPresent()) { // TODO pass duration? session.notifyTestSessionCompleted(null); return; diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/GherkinSyntaxValidator.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/GherkinSyntaxValidator.java index 03f366d9..2b7132c4 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/GherkinSyntaxValidator.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/validation/GherkinSyntaxValidator.java @@ -17,7 +17,7 @@ import io.cucumber.eclipse.editor.document.GherkinEditorDocument; import io.cucumber.eclipse.editor.marker.MarkerFactory; -import io.cucumber.messages.Messages.ParseError; +import io.cucumber.messages.types.ParseError; /** * Performs syntax-validation of the document on each change updating the diff --git a/io.cucumber.eclipse.feature/feature.xml b/io.cucumber.eclipse.feature/feature.xml index 11871f9c..3e4e768b 100644 --- a/io.cucumber.eclipse.feature/feature.xml +++ b/io.cucumber.eclipse.feature/feature.xml @@ -13,25 +13,25 @@ - The MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + The MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -59,13 +59,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. id="io.cucumber.gherkin" download-size="0" install-size="0" - version="16.0.0"/> + version="23.0.1"/> + version="18.0.0"/> + version="7.3.4"/> + version="7.3.4"/> + version="7.3.4"/> - - + version="7.3.4"/> + version="15.2.0"/> + version="7.3.4"/> + version="7.3.4"/> + version="4.1.0"/> + + diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java index c9a36cc4..1675bae5 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java @@ -9,7 +9,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import io.cucumber.messages.Messages.Envelope; +import io.cucumber.messages.types.Envelope; import io.cucumber.plugin.ConcurrentEventListener; import io.cucumber.plugin.event.EventPublisher; @@ -89,7 +89,7 @@ public void accept(Envelope env) { output.flush(); int read = input.read() & 0xFF; written.incrementAndGet(); - if (env.hasTestRunFinished() || read == GOOD_BY_MESSAGE) { + if (env.getTestRunFinished().isPresent() || read == GOOD_BY_MESSAGE) { finish(); } } catch (IOException e) { diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java index 67317bb0..2d2fe0ae 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java @@ -7,8 +7,10 @@ import java.net.Socket; import java.util.Collection; -import io.cucumber.messages.Messages.Envelope; -import io.cucumber.messages.internal.com.google.protobuf.Parser; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.SourceMediaType; /** * open an server endpoint to communicate with a remote cucumber instance @@ -44,13 +46,16 @@ public void run() { OutputStream outputStream = socket.getOutputStream()) { int framelength; byte[] buffer = new byte[1024 * 1024 * 10]; - Parser parser = Envelope.parser(); + //Parser parser = Envelope.parser(); +// GherkinParser parser = GherkinParser.builder().build(); while ((framelength = inputStream.readInt()) > 0) { if (buffer.length < framelength) { buffer = new byte[framelength]; } - inputStream.readFully(buffer, 0, framelength); - Envelope envelope = parser.parseFrom(buffer, 0, framelength); +// inputStream.readFully(buffer, 0, framelength); + +// Envelope envelope = parser.parseFrom(buffer, 0, framelength); + Envelope envelope = Envelope.of(new Source("inputStream", new String(buffer), SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); try { handleMessage(envelope); } catch (InterruptedException e) { @@ -58,7 +63,7 @@ public void run() { } outputStream.write(CucumberEclipsePlugin.HANDLED_MESSAGE); outputStream.flush(); - if (envelope.hasTestRunFinished()) { + if (envelope.getTestRunFinished().isPresent()) { break; } } diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java index 1db175b8..737d0c52 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java @@ -40,13 +40,13 @@ import io.cucumber.eclipse.java.JDTUtil; import io.cucumber.eclipse.java.plugins.CucumberEclipsePlugin; import io.cucumber.eclipse.java.runtime.CucumberRuntime; -import io.cucumber.messages.Messages.Envelope; -import io.cucumber.messages.Messages.GherkinDocument; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Scenario; -import io.cucumber.messages.Messages.TestCaseStarted; -import io.cucumber.messages.Messages.TestStepFinished; -import io.cucumber.messages.Messages.TestStepStarted; -import io.cucumber.messages.Messages.Timestamp; +import io.cucumber.messages.types.Envelope; +import io.cucumber.messages.types.GherkinDocument; +import io.cucumber.messages.types.Scenario; +import io.cucumber.messages.types.TestCaseStarted; +import io.cucumber.messages.types.TestStepFinished; +import io.cucumber.messages.types.TestStepStarted; +import io.cucumber.messages.types.Timestamp; import io.cucumber.tagexpressions.Expression; import mnita.ansiconsole.preferences.AnsiConsolePreferenceUtils; @@ -84,7 +84,7 @@ public void launch(Map launchMap, M Scenario scenario = (Scenario) object; URI locationURI = resource.getLocationURI(); featuresWithLines.add(FeatureWithLines.create(locationURI, - Collections.singleton(scenario.getLocation().getLine()))); + Collections.singleton(scenario.getLocation().getLine().intValue()))); } else if (object instanceof Expression) { filters.add((Expression) object); } @@ -146,22 +146,22 @@ public static void runFeaturesEmbedded(IJavaProject javaProject, List f @Override public void accept(Envelope envelope) { // System.out.println(envelope); - if (envelope.hasTestCaseStarted()) { - TestCaseStarted testCaseStarted = envelope.getTestCaseStarted(); + if (envelope.getTestCaseStarted().isPresent()) { + TestCaseStarted testCaseStarted = envelope.getTestCaseStarted().get(); String testCaseId = testCaseStarted.getTestCaseId(); // System.out.println("Testcase started: " + testCaseId); } // TODO publish it - if (envelope.hasTestStepFinished()) { - TestStepFinished stepFinished = envelope.getTestStepFinished(); + if (envelope.getTestStepFinished().isPresent()) { + TestStepFinished stepFinished = envelope.getTestStepFinished().get(); map.get(stepFinished.getTestStepId()).end = stepFinished.getTimestamp(); - } else if (envelope.hasTestStepStarted()) { - TestStepStarted stepStarted = envelope.getTestStepStarted(); + } else if (envelope.getTestStepStarted().isPresent()) { + TestStepStarted stepStarted = envelope.getTestStepStarted().get(); // stepStarted.getTestCaseStartedId() map.put(stepStarted.getTestStepId(), new TestStepPerfInfo(stepStarted.getTimestamp())); - } else if (envelope.hasGherkinDocument()) { - gherkinDocument = envelope.getGherkinDocument(); - } else if (envelope.hasTestRunFinished()) { + } else if (envelope.getGherkinDocument().isPresent()) { + gherkinDocument = envelope.getGherkinDocument().get(); + } else if (envelope.getTestRunFinished().isPresent()) { // Feature id maps to the pickle -> ast_node_ids // gherkinDocument.getFeature().getChildrenList().stream().filter(FeatureChild::hasScenario) // .map(FeatureChild::getScenario).forEach(s -> System.out.println(s.getId())); @@ -185,7 +185,8 @@ public void accept(Envelope envelope) { } options.setPublishQuiet(true); // TODO other options - options.addDefaultSummaryPrinterIfAbsent(); +// options.addDefaultSummaryPrinterIfAbsent(); + options.addDefaultSummaryPrinterIfNotDisabled(); options.setThreads(java.lang.Runtime.getRuntime().availableProcessors()); options.setMonochrome(!AnsiConsolePreferenceUtils.isAnsiConsoleEnabled()); cucumberRuntime.addPlugin(plugin); diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/MessageEndpointProcess.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/MessageEndpointProcess.java index 2f1e34f0..227819f0 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/MessageEndpointProcess.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/MessageEndpointProcess.java @@ -18,7 +18,7 @@ import io.cucumber.eclipse.editor.launching.EnvelopeProvider; import io.cucumber.eclipse.java.Activator; import io.cucumber.eclipse.java.plugins.MessageEndpoint; -import io.cucumber.messages.Messages.Envelope; +import io.cucumber.messages.types.Envelope; /** * Integrates a {@link MessageEndpoint} with the eclipse launcher framework diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/runtime/CucumberRuntime.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/runtime/CucumberRuntime.java index 56497eae..241aa6a4 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/runtime/CucumberRuntime.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/runtime/CucumberRuntime.java @@ -15,6 +15,7 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; +import java.util.function.Supplier; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -120,9 +121,10 @@ public void run(IProgressMonitor monitor, PrintStream stream) { @Override public Collection get() { + Supplier classLoaderSupplier = ()->this.getClass().getClassLoader(); // TODO https://github.com/cucumber/cucumber-jvm/issues/2217 ThreadLocalObjectFactorySupplier supplier = new ThreadLocalObjectFactorySupplier( - new ObjectFactoryServiceLoader(options)); + new ObjectFactoryServiceLoader(classLoaderSupplier, options)); ObjectFactory objectFactory = supplier.get(); Set backends = Collections.singleton( BACKEND_PROVIDER_SERVICE.create(objectFactory, objectFactory, () -> classLoader)); diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/steps/JavaStepDefinitionOpener.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/steps/JavaStepDefinitionOpener.java index e18632d1..0a273075 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/steps/JavaStepDefinitionOpener.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/steps/JavaStepDefinitionOpener.java @@ -32,7 +32,7 @@ import io.cucumber.eclipse.java.plugins.MatchedPickleStep; import io.cucumber.eclipse.java.plugins.MatchedStep; import io.cucumber.eclipse.java.validation.CucumberGlueValidator; -import io.cucumber.messages.Messages.GherkinDocument.Feature.Step; +import io.cucumber.messages.types.Step; @Component(service = IStepDefinitionOpener.class) public class JavaStepDefinitionOpener implements IStepDefinitionOpener { diff --git a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target index f07fb172..a3da85d6 100644 --- a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target +++ b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target @@ -28,63 +28,109 @@ - - io.cucumber - gherkin - 16.0.0 - jar - + + + + + + + io.cucumber + gherkin + 23.0.1 + jar + + + +Export-Package: *;version="${version}";-noimport:=true +]]> - - io.cucumber - cucumber-java - 6.9.1 - jar - + + + io.cucumber + cucumber-java + 7.3.4 + jar + + + +Export-Package: *;version="${version}";-noimport:=true +]]> - - io.cucumber - cucumber-core - 6.9.1 - jar - + + + io.cucumber + cucumber-core + 7.3.4 + jar + + + +Export-Package: *;version="${version}";-noimport:=true +]]> - - io.cucumber - cucumber-expressions - 11.0.0 - jar - + + + io.cucumber + cucumber-expressions + 15.2.0 + jar + + + +Export-Package: *;version="${version}";-noimport:=true +]]> - - org.apache.commons - commons-text - 1.9 - jar + + + + org.apache.commons + commons-text + 1.9 + jar + + - - - + + + + io.cucumber + create-meta + 6.0.4 + jar + + + \ No newline at end of file From bbab98fc5fd34ba1b652e51d01a1bb580a5780f6 Mon Sep 17 00:00:00 2001 From: FilippoR Date: Fri, 27 May 2022 19:41:13 +0200 Subject: [PATCH 2/9] serialize envelope with gson --- .../META-INF/MANIFEST.MF | 3 ++- .../java/plugins/CucumberEclipsePlugin.java | 5 ++++- .../eclipse/java/plugins/MessageEndpoint.java | 15 +++++++++------ .../cucumber.eclipse.targetdefinition.target | 10 ++++++++++ 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF b/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF index da4b7203..49cd8690 100644 --- a/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF +++ b/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF @@ -6,5 +6,6 @@ Bundle-Version: 2.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: io.cucumber.eclipse.java.plugins Require-Bundle: io.cucumber.cucumber-plugin, - io.cucumber.messages + io.cucumber.messages, + com.google.gson Export-Package: io.cucumber.eclipse.java.plugins diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java index 1675bae5..52c09e7a 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java @@ -4,11 +4,14 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStreamWriter; import java.net.Socket; import java.net.UnknownHostException; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; +import com.google.gson.Gson; + import io.cucumber.messages.types.Envelope; import io.cucumber.plugin.ConcurrentEventListener; import io.cucumber.plugin.event.EventPublisher; @@ -83,7 +86,7 @@ public void accept(Envelope env) { } try { buffer.reset(); - env.writeTo(buffer); + new Gson().toJson(env,new OutputStreamWriter(buffer)); output.writeInt(buffer.size()); buffer.writeTo(output); output.flush(); diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java index 2d2fe0ae..afec5f0e 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java @@ -1,16 +1,18 @@ package io.cucumber.eclipse.java.plugins; +import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; +import java.io.InputStreamReader; import java.io.OutputStream; +import java.io.Reader; import java.net.ServerSocket; import java.net.Socket; import java.util.Collection; +import com.google.gson.Gson; + import io.cucumber.messages.types.Envelope; -import io.cucumber.messages.types.GherkinDocument; -import io.cucumber.messages.types.Source; -import io.cucumber.messages.types.SourceMediaType; /** * open an server endpoint to communicate with a remote cucumber instance @@ -47,15 +49,16 @@ public void run() { int framelength; byte[] buffer = new byte[1024 * 1024 * 10]; //Parser parser = Envelope.parser(); -// GherkinParser parser = GherkinParser.builder().build(); + Gson gson =new Gson(); while ((framelength = inputStream.readInt()) > 0) { if (buffer.length < framelength) { buffer = new byte[framelength]; } -// inputStream.readFully(buffer, 0, framelength); + inputStream.readFully(buffer, 0, framelength); // Envelope envelope = parser.parseFrom(buffer, 0, framelength); - Envelope envelope = Envelope.of(new Source("inputStream", new String(buffer), SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN)); + ByteArrayInputStream bais = new ByteArrayInputStream(buffer, 0, framelength); + Envelope envelope = gson.fromJson((Reader) new InputStreamReader(bais), Envelope.class); try { handleMessage(envelope); } catch (InterruptedException e) { diff --git a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target index a3da85d6..47eb0503 100644 --- a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target +++ b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target @@ -132,5 +132,15 @@ Import-Package: !sun.*,io.cucumber.messages.internal.com.google.gson*,!io Export-Package: *;version="${version}";-noimport:=true ]]> + + + + com.google.code.gson + gson + 2.9.0 + jar + + + \ No newline at end of file From 34b000ca685622d46287bc9abba907771bbcd129 Mon Sep 17 00:00:00 2001 From: FilippoR Date: Sat, 28 May 2022 03:18:42 +0200 Subject: [PATCH 3/9] make it works --- .gitignore | 3 +- io.cucumber.eclipse.feature/feature.xml | 50 ++-- .../META-INF/MANIFEST.MF | 5 +- .../src/io/cucumber/cienvironment/.gitkeep | 0 .../java/plugins/CucumberEclipsePlugin.java | 7 +- .../eclipse/java/plugins/MessageEndpoint.java | 13 +- .../CreateStepDefinitionsFilterDialog.java | 82 +++---- .../CucumberJavaPreferencesPage.java | 222 +++++++++--------- .../cucumber.eclipse.targetdefinition.target | 92 ++------ 9 files changed, 219 insertions(+), 255 deletions(-) create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/cienvironment/.gitkeep diff --git a/.gitignore b/.gitignore index 7519bded..03f3b2e5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ DS_Store bin/ io.cucumber.eclipse.lsp/ cucumber.*/ -.polyglot* \ No newline at end of file +.polyglot* +/.project diff --git a/io.cucumber.eclipse.feature/feature.xml b/io.cucumber.eclipse.feature/feature.xml index 3e4e768b..4326d459 100644 --- a/io.cucumber.eclipse.feature/feature.xml +++ b/io.cucumber.eclipse.feature/feature.xml @@ -13,25 +13,25 @@ - The MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + The MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -97,6 +97,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. install-size="0" version="7.3.4"/> + + - - diff --git a/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF b/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF index 49cd8690..2a856670 100644 --- a/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF +++ b/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF @@ -6,6 +6,5 @@ Bundle-Version: 2.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: io.cucumber.eclipse.java.plugins Require-Bundle: io.cucumber.cucumber-plugin, - io.cucumber.messages, - com.google.gson -Export-Package: io.cucumber.eclipse.java.plugins + io.cucumber.messages +Export-Package: io.cucumber.eclipse.java.plugins,io.cucumber.cienvironment diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/cienvironment/.gitkeep b/io.cucumber.eclipse.java.plugins/src/io/cucumber/cienvironment/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java index 52c09e7a..e9d7d7f5 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java @@ -4,13 +4,13 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStreamWriter; +import java.io.ObjectOutputStream; import java.net.Socket; import java.net.UnknownHostException; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -import com.google.gson.Gson; +//import com.google.gson.Gson; import io.cucumber.messages.types.Envelope; import io.cucumber.plugin.ConcurrentEventListener; @@ -86,7 +86,8 @@ public void accept(Envelope env) { } try { buffer.reset(); - new Gson().toJson(env,new OutputStreamWriter(buffer)); + ObjectOutputStream oos = new ObjectOutputStream(buffer); + oos.writeObject(env); output.writeInt(buffer.size()); buffer.writeTo(output); output.flush(); diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java index afec5f0e..ca61bd6f 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java @@ -4,13 +4,14 @@ import java.io.DataInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.io.ObjectInputStream; import java.io.OutputStream; import java.io.Reader; import java.net.ServerSocket; import java.net.Socket; import java.util.Collection; -import com.google.gson.Gson; +//import com.google.gson.Gson; import io.cucumber.messages.types.Envelope; @@ -49,7 +50,7 @@ public void run() { int framelength; byte[] buffer = new byte[1024 * 1024 * 10]; //Parser parser = Envelope.parser(); - Gson gson =new Gson(); + while ((framelength = inputStream.readInt()) > 0) { if (buffer.length < framelength) { buffer = new byte[framelength]; @@ -58,7 +59,13 @@ public void run() { // Envelope envelope = parser.parseFrom(buffer, 0, framelength); ByteArrayInputStream bais = new ByteArrayInputStream(buffer, 0, framelength); - Envelope envelope = gson.fromJson((Reader) new InputStreamReader(bais), Envelope.class); + ObjectInputStream ois = new ObjectInputStream(bais); + Envelope envelope; + try { + envelope = (Envelope) ois.readObject(); + } catch (ClassNotFoundException e1) { + throw new RuntimeException(e1); + } try { handleMessage(envelope); } catch (InterruptedException e) { diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CreateStepDefinitionsFilterDialog.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CreateStepDefinitionsFilterDialog.java index 05a93765..304a2edf 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CreateStepDefinitionsFilterDialog.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CreateStepDefinitionsFilterDialog.java @@ -3,7 +3,7 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.debug.internal.ui.actions.StatusInfo; import org.eclipse.jdt.debug.ui.IJavaDebugUIConstants; -import org.eclipse.jdt.internal.debug.ui.Filter; +//import org.eclipse.jdt.internal.debug.ui.Filter; import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; @@ -27,32 +27,32 @@ public class CreateStepDefinitionsFilterDialog extends StatusDialog { private static final String DEFAULT_NEW_FILTER_TEXT = ""; //$NON-NLS-1$ private Text text; - private Filter filter; +// private Filter filter; private Button okButton; private boolean filterValid; private boolean okClicked; - private Filter[] existingFilters; +// private Filter[] existingFilters; - private CreateStepDefinitionsFilterDialog(Shell parent, Filter filter, Filter[] existingFilters) { + private CreateStepDefinitionsFilterDialog(Shell parent/* , Filter filter, Filter[] existingFilters */) { super(parent); setShellStyle(getShellStyle() | SWT.RESIZE); - this.filter = filter; - this.existingFilters = existingFilters; +// this.filter = filter; +// this.existingFilters = existingFilters; setTitle(CucumberJavaUIMessages.CreateStepDefinitionsFilterDialog); setStatusLineAboveButtons(false); } - static Filter showCreateStepFilterDialog(Shell parent, Filter[] existingFilters) { - CreateStepDefinitionsFilterDialog createStepFilterDialog = new CreateStepDefinitionsFilterDialog(parent, - new Filter(DEFAULT_NEW_FILTER_TEXT, true), existingFilters); - createStepFilterDialog.create(); - createStepFilterDialog.open(); - - return createStepFilterDialog.filter; - } +// static Filter showCreateStepFilterDialog(Shell parent, Filter[] existingFilters) { +// CreateStepDefinitionsFilterDialog createStepFilterDialog = new CreateStepDefinitionsFilterDialog(parent, +// new Filter(DEFAULT_NEW_FILTER_TEXT, true), existingFilters); +// createStepFilterDialog.create(); +// createStepFilterDialog.open(); +// +// return createStepFilterDialog.filter; +// } @Override protected void createButtonsForButtonBar(Composite parent) { @@ -96,12 +96,12 @@ protected Control createDialogArea(Composite parent) { text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { - validateChange(); +// validateChange(); if (!filterValid) { updateStatus(new StatusInfo(IStatus.ERROR, CucumberJavaUIMessages.CreateStepDefinitionsFilterDialog_4)); - } else if (isDuplicateFilter(text.getText().trim())) { - updateStatus(new StatusInfo(IStatus.WARNING, CucumberJavaUIMessages.CreateStepDefinitionsFilterDialog_5)); - return; +// } else if (isDuplicateFilter(text.getText().trim())) { +// updateStatus(new StatusInfo(IStatus.WARNING, CucumberJavaUIMessages.CreateStepDefinitionsFilterDialog_5)); +// return; } else { updateStatus(new StatusInfo()); } @@ -111,28 +111,28 @@ public void modifyText(ModifyEvent e) { return container; } - private void validateChange() { - String trimmedValue = text.getText().trim(); - - if (trimmedValue.length() > 0 && validateInput(trimmedValue)) { - okButton.setEnabled(true); - filter.setName(text.getText()); - filterValid = true; - } else { - okButton.setEnabled(false); - filter.setName(DEFAULT_NEW_FILTER_TEXT); - filterValid = false; - } - } - - private boolean isDuplicateFilter(String trimmedValue) { - for (int i = 0; i < existingFilters.length; i++) { - if (existingFilters[i].getName().equals(trimmedValue)) { - return true; - } - } - return false; - } +// private void validateChange() { +// String trimmedValue = text.getText().trim(); +// +// if (trimmedValue.length() > 0 && validateInput(trimmedValue)) { +// okButton.setEnabled(true); +// filter.setName(text.getText()); +// filterValid = true; +// } else { +// okButton.setEnabled(false); +// filter.setName(DEFAULT_NEW_FILTER_TEXT); +// filterValid = false; +// } +// } + +// private boolean isDuplicateFilter(String trimmedValue) { +// for (int i = 0; i < existingFilters.length; i++) { +// if (existingFilters[i].getName().equals(trimmedValue)) { +// return true; +// } +// } +// return false; +// } /** * A valid step filter is simply one that is a valid Java identifier. and, as @@ -182,7 +182,7 @@ protected String getDialogSettingsSectionName() { public boolean close() { if (!okClicked) { filterValid = false; - filter = null; +// filter = null; } return super.close(); } diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CucumberJavaPreferencesPage.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CucumberJavaPreferencesPage.java index 2ce3d93b..a1554255 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CucumberJavaPreferencesPage.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/preferences/CucumberJavaPreferencesPage.java @@ -7,9 +7,9 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.internal.debug.ui.Filter; -import org.eclipse.jdt.internal.debug.ui.FilterLabelProvider; -import org.eclipse.jdt.internal.debug.ui.FilterViewerComparator; +//import org.eclipse.jdt.internal.debug.ui.Filter; +//import org.eclipse.jdt.internal.debug.ui.FilterLabelProvider; +//import org.eclipse.jdt.internal.debug.ui.FilterViewerComparator; import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.ui.IJavaElementSearchConstants; @@ -58,28 +58,28 @@ public class CucumberJavaPreferencesPage extends PreferencePage implements IWork public static final String PAGE_ID = "cucumber.eclipse.editor.steps.jdt.CucumberJavaPreferencesPage"; //$NON-NLS-1$ - /** - * Content provider for the table. Content consists of instances of StepFilter. - * - */ - class StepDefinitionsFilterContentProvider implements IStructuredContentProvider { - public StepDefinitionsFilterContentProvider() { - initTableState(false); - } - - @Override - public Object[] getElements(Object inputElement) { - return getAllFiltersFromTable(); - } - - @Override - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - @Override - public void dispose() { - } - } +// /** +// * Content provider for the table. Content consists of instances of StepFilter. +// * +// */ +// class StepDefinitionsFilterContentProvider implements IStructuredContentProvider { +// public StepDefinitionsFilterContentProvider() { +// initTableState(false); +// } +// +// @Override +// public Object[] getElements(Object inputElement) { +// return getAllFiltersFromTable(); +// } +// +// @Override +// public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { +// } +// +// @Override +// public void dispose() { +// } +// } // widgets private CheckboxTableViewer fTableViewer; @@ -166,17 +166,17 @@ private void createStepFilterPreferences(Composite parent) { fTableViewer = CheckboxTableViewer.newCheckList(group, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); fTableViewer.getTable().setFont(container.getFont()); - fTableViewer.setLabelProvider(new FilterLabelProvider()); - fTableViewer.setComparator(new FilterViewerComparator()); - fTableViewer.setContentProvider(new StepDefinitionsFilterContentProvider()); - fTableViewer.setInput(getAllStoredFilters(false)); +// fTableViewer.setLabelProvider(new FilterLabelProvider()); +// fTableViewer.setComparator(new FilterViewerComparator()); +// fTableViewer.setContentProvider(new StepDefinitionsFilterContentProvider()); +// fTableViewer.setInput(getAllStoredFilters(false)); fTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); - fTableViewer.addCheckStateListener(new ICheckStateListener() { - @Override - public void checkStateChanged(CheckStateChangedEvent event) { - ((Filter) event.getElement()).setChecked(event.getChecked()); - } - }); +// fTableViewer.addCheckStateListener(new ICheckStateListener() { +// @Override +// public void checkStateChanged(CheckStateChangedEvent event) { +// ((Filter) event.getElement()).setChecked(event.getChecked()); +// } +// }); fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { @@ -209,11 +209,11 @@ public void keyPressed(KeyEvent event) { * @since 3.2 */ private void initTableState(boolean defaults) { - Filter[] filters = getAllStoredFilters(defaults); - for (int i = 0; i < filters.length; i++) { - fTableViewer.add(filters[i]); - fTableViewer.setChecked(filters[i], filters[i].isChecked()); - } +// Filter[] filters = getAllStoredFilters(defaults); +// for (int i = 0; i < filters.length; i++) { +// fTableViewer.add(filters[i]); +// fTableViewer.setChecked(filters[i], filters[i].isChecked()); +// } } // /** @@ -323,18 +323,18 @@ public void handleEvent(Event e) { } - /** - * Allows a new filter to be added to the listing - */ - private void addFilter() { - Filter newfilter = CreateStepDefinitionsFilterDialog.showCreateStepFilterDialog(getShell(), - getAllFiltersFromTable()); - if (newfilter != null) { - fTableViewer.add(newfilter); - fTableViewer.setChecked(newfilter, true); - fTableViewer.refresh(newfilter); - } - } +// /** +// * Allows a new filter to be added to the listing +// */ +// private void addFilter() { +// Filter newfilter = CreateStepDefinitionsFilterDialog.showCreateStepFilterDialog(getShell(), +// getAllFiltersFromTable()); +// if (newfilter != null) { +// fTableViewer.add(newfilter); +// fTableViewer.setChecked(newfilter, true); +// fTableViewer.refresh(newfilter); +// } +// } /** * add a new type to the listing of available filters @@ -409,15 +409,15 @@ public boolean performOk() { ArrayList active = new ArrayList(); ArrayList inactive = new ArrayList(); String name = ""; //$NON-NLS-1$ - Filter[] filters = getAllFiltersFromTable(); - for (int i = 0; i < filters.length; i++) { - name = filters[i].getName(); - if (filters[i].isChecked()) { - active.add(name); - } else { - inactive.add(name); - } - } +// Filter[] filters = getAllFiltersFromTable(); +// for (int i = 0; i < filters.length; i++) { +// name = filters[i].getName(); +// if (filters[i].isChecked()) { +// active.add(name); +// } else { +// inactive.add(name); +// } +// } String pref = CucumberJavaPreferences.serializeList(active.toArray(new String[active.size()])); store.setValue(CucumberJavaPreferences.PREF_ACTIVE_FILTERS_LIST, pref); pref = CucumberJavaPreferences.serializeList(inactive.toArray(new String[inactive.size()])); @@ -457,58 +457,58 @@ protected void performDefaults() { */ protected void addFilter(String filter, boolean checked) { if (filter != null) { - Filter f = new Filter(filter, checked); - fTableViewer.add(f); - fTableViewer.setChecked(f, checked); +// Filter f = new Filter(filter, checked); +// fTableViewer.add(f); +// fTableViewer.setChecked(f, checked); } } - /** - * returns all of the filters from the table, this includes ones that have not - * yet been saved - * - * @return a possibly empty lits of filters fron the table - * @since 3.2 - */ - protected Filter[] getAllFiltersFromTable() { - TableItem[] items = fTableViewer.getTable().getItems(); - Filter[] filters = new Filter[items.length]; - for (int i = 0; i < items.length; i++) { - filters[i] = (Filter) items[i].getData(); - filters[i].setChecked(items[i].getChecked()); - } - return filters; - } +// /** +// * returns all of the filters from the table, this includes ones that have not +// * yet been saved +// * +// * @return a possibly empty lits of filters fron the table +// * @since 3.2 +// */ +// protected Filter[] getAllFiltersFromTable() { +// TableItem[] items = fTableViewer.getTable().getItems(); +// Filter[] filters = new Filter[items.length]; +// for (int i = 0; i < items.length; i++) { +// filters[i] = (Filter) items[i].getData(); +// filters[i].setChecked(items[i].getChecked()); +// } +// return filters; +// } - /** - * Returns all of the committed filters - * - * @param defaults when true defaults values are used - * @return an array of committed filters - * @since 3.2 - */ - protected Filter[] getAllStoredFilters(boolean defaults) { - Filter[] filters = null; - String[] activefilters, inactivefilters; - IPreferenceStore store = getPreferenceStore(); - if (defaults) { - activefilters = CucumberJavaPreferences - .parseList(store.getDefaultString(CucumberJavaPreferences.PREF_ACTIVE_FILTERS_LIST)); - inactivefilters = CucumberJavaPreferences - .parseList(store.getDefaultString(CucumberJavaPreferences.PREF_INACTIVE_FILTERS_LIST)); - } else { - activefilters = CucumberJavaPreferences - .parseList(store.getString(CucumberJavaPreferences.PREF_ACTIVE_FILTERS_LIST)); - inactivefilters = CucumberJavaPreferences - .parseList(store.getString(CucumberJavaPreferences.PREF_INACTIVE_FILTERS_LIST)); - } - filters = new Filter[activefilters.length + inactivefilters.length]; - for (int i = 0; i < activefilters.length; i++) { - filters[i] = new Filter(activefilters[i], true); - } - for (int i = 0; i < inactivefilters.length; i++) { - filters[i + activefilters.length] = new Filter(inactivefilters[i], false); - } - return filters; - } +// /** +// * Returns all of the committed filters +// * +// * @param defaults when true defaults values are used +// * @return an array of committed filters +// * @since 3.2 +// */ +// protected Filter[] getAllStoredFilters(boolean defaults) { +// Filter[] filters = null; +// String[] activefilters, inactivefilters; +// IPreferenceStore store = getPreferenceStore(); +// if (defaults) { +// activefilters = CucumberJavaPreferences +// .parseList(store.getDefaultString(CucumberJavaPreferences.PREF_ACTIVE_FILTERS_LIST)); +// inactivefilters = CucumberJavaPreferences +// .parseList(store.getDefaultString(CucumberJavaPreferences.PREF_INACTIVE_FILTERS_LIST)); +// } else { +// activefilters = CucumberJavaPreferences +// .parseList(store.getString(CucumberJavaPreferences.PREF_ACTIVE_FILTERS_LIST)); +// inactivefilters = CucumberJavaPreferences +// .parseList(store.getString(CucumberJavaPreferences.PREF_INACTIVE_FILTERS_LIST)); +// } +// filters = new Filter[activefilters.length + inactivefilters.length]; +// for (int i = 0; i < activefilters.length; i++) { +// filters[i] = new Filter(activefilters[i], true); +// } +// for (int i = 0; i < inactivefilters.length; i++) { +// filters[i + activefilters.length] = new Filter(inactivefilters[i], false); +// } +// return filters; +// } } diff --git a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target index 47eb0503..067ff75c 100644 --- a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target +++ b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target @@ -28,119 +28,75 @@ - - - - - - - + io.cucumber gherkin 23.0.1 jar - - - +Export-Package: *;version="${version}";-noimport:=true]]> - - - + io.cucumber cucumber-java 7.3.4 jar - - - +Export-Package: *;version="${version}";-noimport:=true]]> - - - + io.cucumber cucumber-core 7.3.4 jar - - - +Export-Package: *;version="${version}";-noimport:=true]]> - - - + io.cucumber cucumber-expressions 15.2.0 jar - - - +Export-Package: *;version="${version}";-noimport:=true]]> - - - + org.apache.commons commons-text 1.9 jar - - - - - - io.cucumber - create-meta - 6.0.4 - jar - - - + + + + + io.cucumber + create-meta + 6.0.4 + jar + - - - - - com.google.code.gson - gson - 2.9.0 - jar - - +Export-Package: *;version="${version}";-noimport:=true]]> \ No newline at end of file From 0c53f08524e4e97a051ca68c7924d6f34ee3209d Mon Sep 17 00:00:00 2001 From: FilippoR Date: Sat, 28 May 2022 04:38:58 +0200 Subject: [PATCH 4/9] update to 2022-03 4.23 --- .gitignore | 1 + io.cucumber.eclipse.editor/META-INF/MANIFEST.MF | 2 +- .../cucumber.eclipse.targetdefinition.target | 8 ++++---- pom.xml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 03f3b2e5..6d8275ff 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ io.cucumber.eclipse.lsp/ cucumber.*/ .polyglot* /.project +.settings/ diff --git a/io.cucumber.eclipse.editor/META-INF/MANIFEST.MF b/io.cucumber.eclipse.editor/META-INF/MANIFEST.MF index d983a2ed..f4a67528 100644 --- a/io.cucumber.eclipse.editor/META-INF/MANIFEST.MF +++ b/io.cucumber.eclipse.editor/META-INF/MANIFEST.MF @@ -35,7 +35,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.5.0", org.apache.commons.commons-text;bundle-version="1.9.0", org.apache.commons.io;bundle-version="2.6.0", io.cucumber.tag-expressions, - org.eclipse.unittest.ui;bundle-version="1.0.0" + org.eclipse.unittest.ui Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: io.cucumber.eclipse.editor Bundle-ActivationPolicy: lazy diff --git a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target index 067ff75c..25e029a2 100644 --- a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target +++ b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target @@ -16,10 +16,10 @@ - + - + @@ -83,8 +83,8 @@ Export-Package: *;version="${version}";-noimport:=true]]> jar - - + + io.cucumber diff --git a/pom.xml b/pom.xml index 6c5fc4b9..d40cd7ad 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ io.cucumber.eclipse.java.plugins io.cucumber.eclipse.feature io.cucumber.eclipse.thirdparty.feature - io.cucumber.eclipse.product + io.cucumber.eclipse.updatesite From e5618d2dfa69a9519cb30ac1ead18153181f8254 Mon Sep 17 00:00:00 2001 From: FilippoR Date: Mon, 30 May 2022 10:25:53 +0200 Subject: [PATCH 5/9] Fix parser --- .../eclipse/editor/document/GherkinEditorDocument.java | 5 +++-- .../io/cucumber/eclipse/editor/document/GherkinStream.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java index 20f1d771..5e60e852 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinEditorDocument.java @@ -121,9 +121,10 @@ private static Envelope[] getEnvelopes(IDocument document, Supplier r // false, new IdGenerator.Incrementing()).toArray(Envelope[]::new) GherkinParser parser = GherkinParser.builder() .includeSource(true) - .includePickles(true) + .includeGherkinDocument(true) + .includePickles(false) .build(); - Source source = new Source(document.get(), "", SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN); + Source source = new Source("", document.get(), SourceMediaType.TEXT_X_CUCUMBER_GHERKIN_PLAIN); Envelope envelope = Envelope.of(source); return parser.parse(envelope).toArray(Envelope[]::new); } diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java index 0d94e592..f5e3b30a 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/document/GherkinStream.java @@ -92,7 +92,7 @@ public Stream getTableHeaders() { } public Stream> getTableBodys() { - return getExamples().map(Examples::getTableBody).distinct(); + return getExamples().filter(e->e.getTableHeader().isPresent()).map(Examples::getTableBody).distinct(); } public Stream getDataTables() { From 13f427b7160cc8ad74106e64ba3b3eb76cab3c6c Mon Sep 17 00:00:00 2001 From: FilippoR Date: Tue, 31 May 2022 16:21:13 +0200 Subject: [PATCH 6/9] fix serialization --- .../testresults/CucumberTestRunnerClient.java | 7 +- io.cucumber.eclipse.feature/feature.xml | 42 +- .../META-INF/MANIFEST.MF | 5 +- .../src/io/cucumber/cienvironment/.gitkeep | 0 .../java/plugins/CucumberEclipsePlugin.java | 5 +- .../java/plugins/DtoToMessageConverter.java | 421 +++++++++++++++++ .../eclipse/java/plugins/Jackson.java | 27 ++ .../eclipse/java/plugins/MessageEndpoint.java | 19 +- .../java/plugins/MessageToDtoConverter.java | 433 ++++++++++++++++++ .../eclipse/java/plugins/dto/Attachment.java | 17 + .../eclipse/java/plugins/dto/Duration.java | 5 + .../eclipse/java/plugins/dto/Envelope.java | 21 + .../java/plugins/dto/GherkinDocument.java | 116 +++++ .../eclipse/java/plugins/dto/Hook.java | 8 + .../eclipse/java/plugins/dto/Location.java | 6 + .../eclipse/java/plugins/dto/Meta.java | 29 ++ .../java/plugins/dto/ParameterType.java | 11 + .../eclipse/java/plugins/dto/ParseError.java | 6 + .../eclipse/java/plugins/dto/Pickle.java | 47 ++ .../eclipse/java/plugins/dto/Source.java | 9 + .../java/plugins/dto/SourceReference.java | 21 + .../java/plugins/dto/StepDefinition.java | 14 + .../eclipse/java/plugins/dto/TestCase.java | 31 ++ .../java/plugins/dto/TestCaseFinished.java | 10 + .../java/plugins/dto/TestCaseStarted.java | 8 + .../java/plugins/dto/TestRunFinished.java | 9 + .../java/plugins/dto/TestRunStarted.java | 7 + .../java/plugins/dto/TestStepFinished.java | 17 + .../java/plugins/dto/TestStepStarted.java | 10 + .../eclipse/java/plugins/dto/Timestamp.java | 5 + .../plugins/dto/UndefinedParameterType.java | 9 + .../cucumber.eclipse.targetdefinition.target | 15 +- 32 files changed, 1338 insertions(+), 52 deletions(-) delete mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/cienvironment/.gitkeep create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/DtoToMessageConverter.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Jackson.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java diff --git a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java index 10f6cc8c..7e4d52c7 100644 --- a/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java +++ b/io.cucumber.eclipse.editor/src/io/cucumber/eclipse/editor/testresults/CucumberTestRunnerClient.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.function.Function; import java.util.regex.Matcher; @@ -118,11 +119,11 @@ public void handleEnvelope(Envelope env) { testCase.getTestSteps().size(), (ITestSuiteElement) session.getTestElement(pickle.getUri()), pickle.getName(), env.toString()); for (TestStep step : testCase.getTestSteps()) { - String pickleStepId = step.getPickleStepId().get(); - if (pickleStepId.isBlank()) { + Optional pickleStepId = step.getPickleStepId(); + if (pickleStepId.isEmpty()|| pickleStepId.get().isBlank()) { continue; } - PickleStep pickleStep = pickleSteps.get(pickleStepId); + PickleStep pickleStep = pickleSteps.get(pickleStepId.get()); session.newTestCase(step.getId(), pickleStep.getId(), testSuite, pickleStep.getText(), step.toString()); } return; diff --git a/io.cucumber.eclipse.feature/feature.xml b/io.cucumber.eclipse.feature/feature.xml index 4326d459..4252229f 100644 --- a/io.cucumber.eclipse.feature/feature.xml +++ b/io.cucumber.eclipse.feature/feature.xml @@ -13,31 +13,31 @@ - The MIT License - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + The MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - + + diff --git a/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF b/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF index 2a856670..9e82e6a4 100644 --- a/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF +++ b/io.cucumber.eclipse.java.plugins/META-INF/MANIFEST.MF @@ -6,5 +6,6 @@ Bundle-Version: 2.0.0.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-11 Automatic-Module-Name: io.cucumber.eclipse.java.plugins Require-Bundle: io.cucumber.cucumber-plugin, - io.cucumber.messages -Export-Package: io.cucumber.eclipse.java.plugins,io.cucumber.cienvironment + io.cucumber.messages, + io.cucumber.cucumber-core +Export-Package: io.cucumber.eclipse.java.plugins diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/cienvironment/.gitkeep b/io.cucumber.eclipse.java.plugins/src/io/cucumber/cienvironment/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java index e9d7d7f5..b418dfa4 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java @@ -4,7 +4,6 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.ObjectOutputStream; import java.net.Socket; import java.net.UnknownHostException; import java.util.concurrent.atomic.AtomicInteger; @@ -86,8 +85,7 @@ public void accept(Envelope env) { } try { buffer.reset(); - ObjectOutputStream oos = new ObjectOutputStream(buffer); - oos.writeObject(env); + Jackson.OBJECT_MAPPER.writeValue(buffer, env); output.writeInt(buffer.size()); buffer.writeTo(output); output.flush(); @@ -97,6 +95,7 @@ public void accept(Envelope env) { finish(); } } catch (IOException e) { + e.printStackTrace(); } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/DtoToMessageConverter.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/DtoToMessageConverter.java new file mode 100644 index 00000000..53fd6515 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/DtoToMessageConverter.java @@ -0,0 +1,421 @@ +package io.cucumber.eclipse.java.plugins; + +import static java.util.stream.Collectors.toList; + +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import io.cucumber.eclipse.java.plugins.dto.Envelope; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Background; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Comment; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DataTable; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DocString; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Examples; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Feature; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.FeatureChild; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Rule; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.RuleChild; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Scenario; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Step; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableCell; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableRow; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Tag; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStep; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableCell; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableRow; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTag; +import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgument; +import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgumentsList; +import io.cucumber.eclipse.java.plugins.dto.TestCase.TestStep; +import io.cucumber.messages.types.Attachment; +import io.cucumber.messages.types.Ci; +import io.cucumber.messages.types.Duration; +import io.cucumber.messages.types.Git; +import io.cucumber.messages.types.Group; +import io.cucumber.messages.types.Hook; +import io.cucumber.messages.types.JavaMethod; +import io.cucumber.messages.types.JavaStackTraceElement; +import io.cucumber.messages.types.Meta; +import io.cucumber.messages.types.ParameterType; +import io.cucumber.messages.types.ParseError; +import io.cucumber.messages.types.Pickle; +import io.cucumber.messages.types.PickleDocString; +import io.cucumber.messages.types.PickleStepArgument; +import io.cucumber.messages.types.PickleTable; +import io.cucumber.messages.types.Product; +import io.cucumber.messages.types.Source; +import io.cucumber.messages.types.SourceReference; +import io.cucumber.messages.types.StepDefinition; +import io.cucumber.messages.types.StepDefinitionPattern; +import io.cucumber.messages.types.TestCase; +import io.cucumber.messages.types.TestCaseFinished; +import io.cucumber.messages.types.TestCaseStarted; +import io.cucumber.messages.types.TestRunFinished; +import io.cucumber.messages.types.TestRunStarted; +import io.cucumber.messages.types.TestStepFinished; +import io.cucumber.messages.types.TestStepResult; +import io.cucumber.messages.types.TestStepStarted; +import io.cucumber.messages.types.Timestamp; +import io.cucumber.messages.types.UndefinedParameterType; + +public class DtoToMessageConverter { + + public static io.cucumber.messages.types.Envelope convert(Envelope d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Envelope(convert(d.attachment), convert(d.gherkinDocument), + convert(d.hook), convert(d.meta), convert(d.parameterType), convert(d.parseError), convert(d.pickle), + convert(d.source), convert(d.stepDefinition), convert(d.testCase), convert(d.testCaseFinished), + convert(d.testCaseStarted), convert(d.testRunFinished), convert(d.testRunStarted), + convert(d.testStepFinished), convert(d.testStepStarted), convert(d.undefinedParameterType)); + } + + public static List convertList(List list, Function converter) { + Optional> map = Optional.ofNullable(list) + .map(l -> l.stream().map(v -> converter.apply(v)).collect(toList())); + return map.orElse(null); + } + + public static UndefinedParameterType convert(io.cucumber.eclipse.java.plugins.dto.UndefinedParameterType d) { + if (d == null) + return null; + return new UndefinedParameterType(d.expression, d.name); + } + + public static TestStepStarted convert(io.cucumber.eclipse.java.plugins.dto.TestStepStarted d) { + if (d == null) + return null; + return new TestStepStarted(d.testCaseStartedId, d.testStepId, convert(d.timestamp)); + } + + public static Timestamp convert(io.cucumber.eclipse.java.plugins.dto.Timestamp d) { + if (d == null) + return null; + return new Timestamp(d.seconds, d.nanos); + } + + public static TestStepFinished convert(io.cucumber.eclipse.java.plugins.dto.TestStepFinished d) { + if (d == null) + return null; + return new TestStepFinished(d.testCaseStartedId, d.testStepId, convert(d.testStepResult), convert(d.timestamp)); + } + + public static TestStepResult convert(io.cucumber.eclipse.java.plugins.dto.TestStepFinished.TestStepResult d) { + if (d == null) + return null; + return new TestStepResult(convert(d.duration), d.message, d.status); + } + + public static Duration convert(io.cucumber.eclipse.java.plugins.dto.Duration d) { + if (d == null) + return null; + return new Duration(d.seconds, d.nanos); + } + + public static TestRunStarted convert(io.cucumber.eclipse.java.plugins.dto.TestRunStarted d) { + if (d == null) + return null; + return new TestRunStarted(convert(d.timestamp)); + } + + public static TestRunFinished convert(io.cucumber.eclipse.java.plugins.dto.TestRunFinished d) { + if (d == null) + return null; + return new TestRunFinished(d.message, d.success, convert(d.timestamp)); + } + + public static TestCaseStarted convert(io.cucumber.eclipse.java.plugins.dto.TestCaseStarted d) { + if (d == null) + return null; + return new TestCaseStarted(d.attempt, d.id, d.testCaseId, convert(d.timestamp)); + } + + public static TestCaseFinished convert(io.cucumber.eclipse.java.plugins.dto.TestCaseFinished d) { + if (d == null) + return null; + return new TestCaseFinished(d.testCaseStartedId, convert(d.timestamp), d.willBeRetried); + } + + public static TestCase convert(io.cucumber.eclipse.java.plugins.dto.TestCase d) { + if (d == null) + return null; + return new TestCase(d.id, d.pickleId, convertList(d.testSteps,DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.TestStep convert(TestStep d) { + if (d == null) + return null; + return new io.cucumber.messages.types.TestStep(d.hookId, d.id, d.pickleStepId, d.stepDefinitionIds, + convertList(d.stepMatchArgumentsLists, DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.StepMatchArgumentsList convert(StepMatchArgumentsList d) { + if (d == null) + return null; + return new io.cucumber.messages.types.StepMatchArgumentsList( + convertList(d.stepMatchArguments, DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.StepMatchArgument convert(StepMatchArgument d) { + if (d == null) + return null; + return new io.cucumber.messages.types.StepMatchArgument(convert(d.group), d.parameterTypeName); + } + + public static Group convert(io.cucumber.eclipse.java.plugins.dto.TestCase.Group d) { + if (d == null) + return null; + return new Group(convertList(d.children,DtoToMessageConverter::convert), d.start, d.value); + } + + public static StepDefinition convert(io.cucumber.eclipse.java.plugins.dto.StepDefinition d) { + if (d == null) + return null; + return new StepDefinition(d.id, convert(d.pattern), convert(d.sourceReference)); + } + + public static StepDefinitionPattern convert( + io.cucumber.eclipse.java.plugins.dto.StepDefinition.StepDefinitionPattern d) { + if (d == null) + return null; + return new StepDefinitionPattern(d.source, d.type); + } + + public static Source convert(io.cucumber.eclipse.java.plugins.dto.Source d) { + if (d == null) + return null; + return new Source(d.uri, d.data, d.mediaType); + } + + public static Pickle convert(io.cucumber.eclipse.java.plugins.dto.Pickle d) { + if (d == null) + return null; + return new Pickle(d.id, d.uri, d.name, d.language, convertList(d.steps,DtoToMessageConverter::convert), + convertList(d.tags,DtoToMessageConverter::convert), d.astNodeIds); + } + + public static io.cucumber.messages.types.PickleTag convert(PickleTag d) { + if (d == null) + return null; + return new io.cucumber.messages.types.PickleTag(d.name, d.astNodeId); + } + + public static io.cucumber.messages.types.PickleStep convert(PickleStep d) { + if (d == null) + return null; + return new io.cucumber.messages.types.PickleStep(convert(d.argument), d.astNodeIds, d.id, d.text); + } + + public static PickleStepArgument convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStepArgument d) { + if (d == null) + return null; + return new PickleStepArgument(convert(d.docString), convert(d.dataTable)); + } + + public static PickleTable convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTable d) { + if (d == null) + return null; + return new PickleTable(convertList(d.rows,DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.PickleTableRow convert(PickleTableRow d) { + if (d == null) + return null; + return new io.cucumber.messages.types.PickleTableRow(convertList(d.cells,DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.PickleTableCell convert(PickleTableCell d) { + if (d == null) + return null; + return new io.cucumber.messages.types.PickleTableCell(d.value); + } + + public static PickleDocString convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleDocString d) { + if (d == null) + return null; + return new PickleDocString(d.mediaType, d.content); + } + + public static ParseError convert(io.cucumber.eclipse.java.plugins.dto.ParseError d) { + if (d == null) + return null; + return new ParseError(convert(d.source), d.message); + } + + public static ParameterType convert(io.cucumber.eclipse.java.plugins.dto.ParameterType d) { + if (d == null) + return null; + return new ParameterType(d.name, d.regularExpressions, d.preferForRegularExpressionMatch, d.useForSnippets, + d.id); + } + + public static Meta convert(io.cucumber.eclipse.java.plugins.dto.Meta d) { + if (d == null) + return null; + return new Meta(d.protocolVersion, convert(d.implementation), convert(d.runtime), convert(d.os), convert(d.cpu), + convert(d.ci)); + } + + public static Ci convert(io.cucumber.eclipse.java.plugins.dto.Meta.Ci d) { + if (d == null) + return null; + return new Ci(d.name, d.url, d.buildNumber, convert(d.git)); + } + + public static Git convert(io.cucumber.eclipse.java.plugins.dto.Meta.Git d) { + if (d == null) + return null; + return new Git(d.remote, d.revision, d.branch, d.tag); + } + + public static Product convert(io.cucumber.eclipse.java.plugins.dto.Meta.Product d) { + if (d == null) + return null; + return new Product(d.name, d.version); + } + + public static Hook convert(io.cucumber.eclipse.java.plugins.dto.Hook d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Hook(d.id, d.name, convert(d.sourceReference), d.tagExpression); + } + + public static SourceReference convert(io.cucumber.eclipse.java.plugins.dto.SourceReference d) { + if (d == null) + return null; + return new SourceReference(d.uri, convert(d.javaMethod), convert(d.javaStackTraceElement), convert(d.location)); + } + + public static JavaMethod convert(io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaMethod d) { + if (d == null) + return null; + return new JavaMethod(d.className, d.methodName, d.methodParameterTypes); + } + + public static JavaStackTraceElement convert( + io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaStackTraceElement d) { + if (d == null) + return null; + return new JavaStackTraceElement(d.className, d.fileName, d.methodName); + } + + public static Attachment convert(io.cucumber.eclipse.java.plugins.dto.Attachment d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Attachment(d.body, d.contentEncoding, d.fileName, d.mediaType, d.source, + d.testCaseStartedId, d.testStepId, d.url); + } + + public static io.cucumber.messages.types.Comment convert(Comment d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Comment(convert(d.location), d.text); + } + + public static io.cucumber.messages.types.Feature convert(Feature d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Feature(convert(d.location), + convertList(d.tags,DtoToMessageConverter::convert), d.language, d.keyword, d.name, d.description, + convertList(d.children,DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.Tag convert(Tag d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Tag(convert(d.location), d.name, d.id); + } + + public static io.cucumber.messages.types.FeatureChild convert(FeatureChild d) { + if (d == null) + return null; + return new io.cucumber.messages.types.FeatureChild(convert(d.rule), convert(d.background), convert(d.scenario)); + } + + public static io.cucumber.messages.types.Scenario convert(Scenario d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Scenario(convert(d.location), + convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, + convertList(d.steps,DtoToMessageConverter::convert), + convertList(d.examples,DtoToMessageConverter::convert), d.id); + } + + public static io.cucumber.messages.types.Examples convert(Examples d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Examples(convert(d.location), + convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, + convert(d.tableHeader), convertList(d.tableBody,DtoToMessageConverter::convert), d.id); + } + + public static io.cucumber.messages.types.Rule convert(Rule d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Rule(convert(d.location), + convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, + convertList(d.children,DtoToMessageConverter::convert), d.id); + } + + public static io.cucumber.messages.types.RuleChild convert(RuleChild d) { + if (d == null) + return null; + return new io.cucumber.messages.types.RuleChild(DtoToMessageConverter.convert(d.background), convert(d.scenario)); + } + + public static io.cucumber.messages.types.Background convert(Background d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Background(convert(d.location), d.keyword, d.name, d.description, + convertList(d.steps,DtoToMessageConverter::convert), d.id); + } + + public static io.cucumber.messages.types.Step convert(Step d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Step(convert(d.location), d.keyword, d.text, convert(d.docString), + convert(d.dataTable), d.id); + } + + public static io.cucumber.messages.types.DocString convert(DocString d) { + if (d == null) + return null; + return new io.cucumber.messages.types.DocString(convert(d.location), d.mediaType, d.content, d.delimiter); + } + + public static io.cucumber.messages.types.DataTable convert(DataTable d) { + if (d == null) + return null; + return new io.cucumber.messages.types.DataTable(convert(d.location), + convertList(d.rows,DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.TableRow convert(TableRow d) { + if (d == null) + return null; + return new io.cucumber.messages.types.TableRow(convert(d.location), + convertList(d.cells,DtoToMessageConverter::convert), d.id); + } + + public static io.cucumber.messages.types.TableCell convert(TableCell d) { + if (d == null) + return null; + return new io.cucumber.messages.types.TableCell(convert(d.location), d.value); + } + + public static io.cucumber.messages.types.GherkinDocument convert(GherkinDocument d) { + if (d == null) + return null; + return new io.cucumber.messages.types.GherkinDocument(d.uri, convert(d.feature), + convertList(d.comments,DtoToMessageConverter::convert)); + } + + public static io.cucumber.messages.types.Location convert(io.cucumber.eclipse.java.plugins.dto.Location d) { + if (d == null) + return null; + return new io.cucumber.messages.types.Location(d.line, d.column); + } + +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Jackson.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Jackson.java new file mode 100644 index 00000000..dc4136ba --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Jackson.java @@ -0,0 +1,27 @@ +package io.cucumber.eclipse.java.plugins; + +import io.cucumber.core.internal.com.fasterxml.jackson.annotation.JsonInclude.Include; +import io.cucumber.core.internal.com.fasterxml.jackson.core.JsonGenerator; +import io.cucumber.core.internal.com.fasterxml.jackson.databind.DeserializationFeature; +import io.cucumber.core.internal.com.fasterxml.jackson.databind.ObjectMapper; +import io.cucumber.core.internal.com.fasterxml.jackson.databind.SerializationFeature; +import io.cucumber.core.internal.com.fasterxml.jackson.databind.cfg.ConstructorDetector; +import io.cucumber.core.internal.com.fasterxml.jackson.databind.json.JsonMapper; +import io.cucumber.core.internal.com.fasterxml.jackson.datatype.jdk8.Jdk8Module; + +final class Jackson { + public static final ObjectMapper OBJECT_MAPPER = JsonMapper.builder() + .addModule(new Jdk8Module()) + .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/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java index ca61bd6f..6e343f30 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java @@ -1,20 +1,15 @@ package io.cucumber.eclipse.java.plugins; -import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; -import java.io.InputStreamReader; -import java.io.ObjectInputStream; import java.io.OutputStream; -import java.io.Reader; import java.net.ServerSocket; import java.net.Socket; import java.util.Collection; -//import com.google.gson.Gson; - import io.cucumber.messages.types.Envelope; + /** * open an server endpoint to communicate with a remote cucumber instance * @@ -56,16 +51,7 @@ public void run() { buffer = new byte[framelength]; } inputStream.readFully(buffer, 0, framelength); - -// Envelope envelope = parser.parseFrom(buffer, 0, framelength); - ByteArrayInputStream bais = new ByteArrayInputStream(buffer, 0, framelength); - ObjectInputStream ois = new ObjectInputStream(bais); - Envelope envelope; - try { - envelope = (Envelope) ois.readObject(); - } catch (ClassNotFoundException e1) { - throw new RuntimeException(e1); - } + Envelope envelope = DtoToMessageConverter.convert(Jackson.OBJECT_MAPPER.readValue(buffer, 0, framelength, io.cucumber.eclipse.java.plugins.dto.Envelope.class)); try { handleMessage(envelope); } catch (InterruptedException e) { @@ -82,6 +68,7 @@ public void run() { } socket.close(); } catch (IOException e) { + e.printStackTrace(); } finally { try { serverSocket.close(); diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java new file mode 100644 index 00000000..edf0dab6 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java @@ -0,0 +1,433 @@ +//package io.cucumber.eclipse.java.plugins; +// +//import static java.util.stream.Collectors.toList; +// +//import java.util.List; +//import java.util.Optional; +//import java.util.function.Function; +// +//import io.cucumber.eclipse.java.plugins.dto.Envelope; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Background; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Comment; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DataTable; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DocString; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Examples; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Feature; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.FeatureChild; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Rule; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.RuleChild; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Scenario; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Step; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableCell; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableRow; +//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Tag; +//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStep; +//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableCell; +//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableRow; +//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTag; +//import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgument; +//import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgumentsList; +//import io.cucumber.eclipse.java.plugins.dto.TestCase.TestStep; +//import io.cucumber.messages.types.Attachment; +//import io.cucumber.messages.types.Ci; +//import io.cucumber.messages.types.Duration; +//import io.cucumber.messages.types.Git; +//import io.cucumber.messages.types.Group; +//import io.cucumber.messages.types.Hook; +//import io.cucumber.messages.types.JavaMethod; +//import io.cucumber.messages.types.JavaStackTraceElement; +//import io.cucumber.messages.types.Meta; +//import io.cucumber.messages.types.ParameterType; +//import io.cucumber.messages.types.ParseError; +//import io.cucumber.messages.types.Pickle; +//import io.cucumber.messages.types.PickleDocString; +//import io.cucumber.messages.types.PickleStepArgument; +//import io.cucumber.messages.types.PickleTable; +//import io.cucumber.messages.types.Product; +//import io.cucumber.messages.types.Source; +//import io.cucumber.messages.types.SourceReference; +//import io.cucumber.messages.types.StepDefinition; +//import io.cucumber.messages.types.StepDefinitionPattern; +//import io.cucumber.messages.types.TestCase; +//import io.cucumber.messages.types.TestCaseFinished; +//import io.cucumber.messages.types.TestCaseStarted; +//import io.cucumber.messages.types.TestRunFinished; +//import io.cucumber.messages.types.TestRunStarted; +//import io.cucumber.messages.types.TestStepFinished; +//import io.cucumber.messages.types.TestStepResult; +//import io.cucumber.messages.types.TestStepStarted; +//import io.cucumber.messages.types.Timestamp; +//import io.cucumber.messages.types.UndefinedParameterType; +// +//public class MessageToDtoConverter { +// +// public static Envelope convert(io.cucumber.messages.types.Envelope d) { +// if (d == null) +// return null; +// return new Envelope( +// convert(d.getAttachment()), +// convert(d.getGherkinDocument()), +// convert(d.getHook()), +// convert(d.getMeta()), +// convert(d.getParameterType()), +// convert(d.getParseError()), +// convert(d.getPickle()), +// convert(d.getSource()), +// convert(d.getStepDefinition()), +// convert(d.getTestCase()), +// convert(d.getTestCaseFinished()), +// convert(d.getTestCaseStarted()), +// convert(d.getTestRunFinished()), +// convert(d.getTestRunStarted()), +// convert(d.getTestStepFinished()), +// convert(d.getTestStepStarted()), +// convert(d.getUndefinedParameterType())); +// } +// +// public static List convertList(List list, Function converter) { +// Optional> map = Optional.ofNullable(list) +// .map(l -> l.stream().map(v -> converter.apply(v)).collect(toList())); +// return map.orElse(null); +// } +// +// public static UndefinedParameterType convert(io.cucumber.eclipse.java.plugins.dto.UndefinedParameterType d) { +// if (d == null) +// return null; +// return new UndefinedParameterType(d.expression, d.name); +// } +// +// public static TestStepStarted convert(io.cucumber.eclipse.java.plugins.dto.TestStepStarted d) { +// if (d == null) +// return null; +// return new TestStepStarted(d.testCaseStartedId, d.testStepId, convert(d.timestamp)); +// } +// +// public static Timestamp convert(io.cucumber.eclipse.java.plugins.dto.Timestamp d) { +// if (d == null) +// return null; +// return new Timestamp(d.seconds, d.nanos); +// } +// +// public static TestStepFinished convert(io.cucumber.eclipse.java.plugins.dto.TestStepFinished d) { +// if (d == null) +// return null; +// return new TestStepFinished(d.testCaseStartedId, d.testStepId, convert(d.testStepResult), convert(d.timestamp)); +// } +// +// public static TestStepResult convert(io.cucumber.eclipse.java.plugins.dto.TestStepFinished.TestStepResult d) { +// if (d == null) +// return null; +// return new TestStepResult(convert(d.duration), d.message, d.status); +// } +// +// public static Duration convert(io.cucumber.eclipse.java.plugins.dto.Duration d) { +// if (d == null) +// return null; +// return new Duration(d.seconds, d.nanos); +// } +// +// public static TestRunStarted convert(io.cucumber.eclipse.java.plugins.dto.TestRunStarted d) { +// if (d == null) +// return null; +// return new TestRunStarted(convert(d.timestamp)); +// } +// +// public static TestRunFinished convert(io.cucumber.eclipse.java.plugins.dto.TestRunFinished d) { +// if (d == null) +// return null; +// return new TestRunFinished(d.message, d.success, convert(d.timestamp)); +// } +// +// public static TestCaseStarted convert(io.cucumber.eclipse.java.plugins.dto.TestCaseStarted d) { +// if (d == null) +// return null; +// return new TestCaseStarted(d.attempt, d.id, d.testCaseId, convert(d.timestamp)); +// } +// +// public static TestCaseFinished convert(io.cucumber.eclipse.java.plugins.dto.TestCaseFinished d) { +// if (d == null) +// return null; +// return new TestCaseFinished(d.testCaseStartedId, convert(d.timestamp), d.willBeRetried); +// } +// +// public static TestCase convert(io.cucumber.eclipse.java.plugins.dto.TestCase d) { +// if (d == null) +// return null; +// return new TestCase(d.id, d.pickleId, convertList(d.testSteps,DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.TestStep convert(TestStep d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.TestStep(d.hookId, d.id, d.pickleStepId, d.stepDefinitionIds, +// convertList(d.stepMatchArgumentsLists, DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.StepMatchArgumentsList convert(StepMatchArgumentsList d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.StepMatchArgumentsList( +// convertList(d.stepMatchArguments, DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.StepMatchArgument convert(StepMatchArgument d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.StepMatchArgument(convert(d.group), d.parameterTypeName); +// } +// +// public static Group convert(io.cucumber.eclipse.java.plugins.dto.TestCase.Group d) { +// if (d == null) +// return null; +// return new Group(convertList(d.children,DtoToMessageConverter::convert), d.start, d.value); +// } +// +// public static StepDefinition convert(io.cucumber.eclipse.java.plugins.dto.StepDefinition d) { +// if (d == null) +// return null; +// return new StepDefinition(d.id, convert(d.pattern), convert(d.sourceReference)); +// } +// +// public static StepDefinitionPattern convert( +// io.cucumber.eclipse.java.plugins.dto.StepDefinition.StepDefinitionPattern d) { +// if (d == null) +// return null; +// return new StepDefinitionPattern(d.source, d.type); +// } +// +// public static Source convert(io.cucumber.eclipse.java.plugins.dto.Source d) { +// if (d == null) +// return null; +// return new Source(d.uri, d.data, d.mediaType); +// } +// +// public static Pickle convert(io.cucumber.eclipse.java.plugins.dto.Pickle d) { +// if (d == null) +// return null; +// return new Pickle(d.id, d.uri, d.name, d.language, convertList(d.steps,DtoToMessageConverter::convert), +// convertList(d.tags,DtoToMessageConverter::convert), d.astNodeIds); +// } +// +// public static io.cucumber.messages.types.PickleTag convert(PickleTag d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.PickleTag(d.name, d.astNodeId); +// } +// +// public static io.cucumber.messages.types.PickleStep convert(PickleStep d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.PickleStep(convert(d.argument), d.astNodeIds, d.id, d.text); +// } +// +// public static PickleStepArgument convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStepArgument d) { +// if (d == null) +// return null; +// return new PickleStepArgument(convert(d.docString), convert(d.dataTable)); +// } +// +// public static PickleTable convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTable d) { +// if (d == null) +// return null; +// return new PickleTable(convertList(d.rows,DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.PickleTableRow convert(PickleTableRow d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.PickleTableRow(convertList(d.cells,DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.PickleTableCell convert(PickleTableCell d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.PickleTableCell(d.value); +// } +// +// public static PickleDocString convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleDocString d) { +// if (d == null) +// return null; +// return new PickleDocString(d.mediaType, d.content); +// } +// +// public static ParseError convert(io.cucumber.eclipse.java.plugins.dto.ParseError d) { +// if (d == null) +// return null; +// return new ParseError(convert(d.source), d.message); +// } +// +// public static ParameterType convert(io.cucumber.eclipse.java.plugins.dto.ParameterType d) { +// if (d == null) +// return null; +// return new ParameterType(d.name, d.regularExpressions, d.preferForRegularExpressionMatch, d.useForSnippets, +// d.id); +// } +// +// public static Meta convert(io.cucumber.eclipse.java.plugins.dto.Meta d) { +// if (d == null) +// return null; +// return new Meta(d.protocolVersion, convert(d.implementation), convert(d.runtime), convert(d.os), convert(d.cpu), +// convert(d.ci)); +// } +// +// public static Ci convert(io.cucumber.eclipse.java.plugins.dto.Meta.Ci d) { +// if (d == null) +// return null; +// return new Ci(d.name, d.url, d.buildNumber, convert(d.git)); +// } +// +// public static Git convert(io.cucumber.eclipse.java.plugins.dto.Meta.Git d) { +// if (d == null) +// return null; +// return new Git(d.remote, d.revision, d.branch, d.tag); +// } +// +// public static Product convert(io.cucumber.eclipse.java.plugins.dto.Meta.Product d) { +// if (d == null) +// return null; +// return new Product(d.name, d.version); +// } +// +// public static Hook convert(io.cucumber.eclipse.java.plugins.dto.Hook d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Hook(d.id, d.name, convert(d.sourceReference), d.tagExpression); +// } +// +// public static SourceReference convert(io.cucumber.eclipse.java.plugins.dto.SourceReference d) { +// if (d == null) +// return null; +// return new SourceReference(d.uri, convert(d.javaMethod), convert(d.javaStackTraceElement), convert(d.location)); +// } +// +// public static JavaMethod convert(io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaMethod d) { +// if (d == null) +// return null; +// return new JavaMethod(d.className, d.methodName, d.methodParameterTypes); +// } +// +// public static JavaStackTraceElement convert( +// io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaStackTraceElement d) { +// if (d == null) +// return null; +// return new JavaStackTraceElement(d.className, d.fileName, d.methodName); +// } +// +// public static Attachment convert(io.cucumber.eclipse.java.plugins.dto.Attachment d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Attachment(d.body, d.contentEncoding, d.fileName, d.mediaType, d.source, +// d.testCaseStartedId, d.testStepId, d.url); +// } +// +// public static io.cucumber.messages.types.Comment convert(Comment d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Comment(convert(d.location), d.text); +// } +// +// public static io.cucumber.messages.types.Feature convert(Feature d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Feature(convert(d.location), +// convertList(d.tags,DtoToMessageConverter::convert), d.language, d.keyword, d.name, d.description, +// convertList(d.children,DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.Tag convert(Tag d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Tag(convert(d.location), d.name, d.id); +// } +// +// public static io.cucumber.messages.types.FeatureChild convert(FeatureChild d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.FeatureChild(convert(d.rule), convert(d.background), convert(d.scenario)); +// } +// +// public static io.cucumber.messages.types.Scenario convert(Scenario d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Scenario(convert(d.location), +// convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, +// convertList(d.steps,DtoToMessageConverter::convert), +// convertList(d.examples,DtoToMessageConverter::convert), d.id); +// } +// +// public static io.cucumber.messages.types.Examples convert(Examples d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Examples(convert(d.location), +// convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, +// convert(d.tableHeader), convertList(d.tableBody,DtoToMessageConverter::convert), d.id); +// } +// +// public static io.cucumber.messages.types.Rule convert(Rule d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Rule(convert(d.location), +// convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, +// convertList(d.children,DtoToMessageConverter::convert), d.id); +// } +// +// public static io.cucumber.messages.types.RuleChild convert(RuleChild d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.RuleChild(DtoToMessageConverter.convert(d.background), convert(d.scenario)); +// } +// +// public static io.cucumber.messages.types.Background convert(Background d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Background(convert(d.location), d.keyword, d.name, d.description, +// convertList(d.steps,DtoToMessageConverter::convert), d.id); +// } +// +// public static io.cucumber.messages.types.Step convert(Step d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Step(convert(d.location), d.keyword, d.text, convert(d.docString), +// convert(d.dataTable), d.id); +// } +// +// public static io.cucumber.messages.types.DocString convert(DocString d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.DocString(convert(d.location), d.mediaType, d.content, d.delimiter); +// } +// +// public static io.cucumber.messages.types.DataTable convert(DataTable d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.DataTable(convert(d.location), +// convertList(d.rows,DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.TableRow convert(TableRow d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.TableRow(convert(d.location), +// convertList(d.cells,DtoToMessageConverter::convert), d.id); +// } +// +// public static io.cucumber.messages.types.TableCell convert(TableCell d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.TableCell(convert(d.location), d.value); +// } +// +// public static io.cucumber.messages.types.GherkinDocument convert(GherkinDocument d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.GherkinDocument(d.uri, convert(d.feature), +// convertList(d.comments,DtoToMessageConverter::convert)); +// } +// +// public static io.cucumber.messages.types.Location convert(io.cucumber.eclipse.java.plugins.dto.Location d) { +// if (d == null) +// return null; +// return new io.cucumber.messages.types.Location(d.line, d.column); +// } +//} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java new file mode 100644 index 00000000..d47e4726 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java @@ -0,0 +1,17 @@ +package io.cucumber.eclipse.java.plugins.dto; + +import io.cucumber.messages.types.AttachmentContentEncoding; +import io.cucumber.messages.types.Source; + +public class Attachment { + public String body; + public AttachmentContentEncoding contentEncoding; + public String fileName; + public String mediaType; + public Source source; + public String testCaseStartedId; + public String testStepId; + public String url; + + +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java new file mode 100644 index 00000000..8fe86028 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java @@ -0,0 +1,5 @@ +package io.cucumber.eclipse.java.plugins.dto; +public class Duration { + public Long seconds; + public Long nanos; +} \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java new file mode 100644 index 00000000..c76f4786 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java @@ -0,0 +1,21 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public final class Envelope { + public Attachment attachment; + public GherkinDocument gherkinDocument; + public Hook hook; + public Meta meta; + public ParameterType parameterType; + public ParseError parseError; + public Pickle pickle; + public Source source; + public StepDefinition stepDefinition; + public TestCase testCase; + public TestCaseFinished testCaseFinished; + public TestCaseStarted testCaseStarted; + public TestRunFinished testRunFinished; + public TestRunStarted testRunStarted; + public TestStepFinished testStepFinished; + public TestStepStarted testStepStarted; + public UndefinedParameterType undefinedParameterType; +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java new file mode 100644 index 00000000..2f67a48b --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java @@ -0,0 +1,116 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class GherkinDocument { + public String uri; + public Feature feature; + public java.util.List comments; + + public static class Feature { + public Location location; + public java.util.List tags; + public String language; + public String keyword; + public String name; + public String description; + public java.util.List children; + } + + public static class Tag { + public Location location; + public String name; + public String id; + } + + public static class FeatureChild { + public Rule rule; + public Background background; + public Scenario scenario; + } + + public static class Rule { + public Location location; + public java.util.List tags; + public String keyword; + public String name; + public String description; + public java.util.List children; + public String id; + + + } + + public static class RuleChild { + public Background background; + public Scenario scenario; + + } + + public static class Background { + public Location location; + public String keyword; + public String name; + public String description; + public java.util.List steps; + public String id; + } + + public static class Step { + public Location location; + public String keyword; + public String text; + public DocString docString; + public DataTable dataTable; + public String id; + + } + + public static class Comment { + public Location location; + public String text; + } + + public static class DataTable { + public Location location; + public java.util.List rows; + } + + public static class TableRow { + public Location location; + public java.util.List cells; + public String id; + } + + public static class TableCell { + public Location location; + public String value; + } + + public static class DocString { + public Location location; + public String mediaType; + public String content; + public String delimiter; + } + + public static class Scenario { + public Location location; + public java.util.List tags; + public String keyword; + public String name; + public String description; + public java.util.List steps; + public java.util.List examples; + public String id; + } + + public static class Examples { + public Location location; + public java.util.List tags; + public String keyword; + public String name; + public String description; + public TableRow tableHeader; + public java.util.List tableBody; + public String id; + } +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java new file mode 100644 index 00000000..3ab43734 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java @@ -0,0 +1,8 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class Hook { + public String id; + public String name; + public SourceReference sourceReference; + public String tagExpression; +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java new file mode 100644 index 00000000..dbbdef82 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java @@ -0,0 +1,6 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class Location { + public Long line; + public Long column; +} \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java new file mode 100644 index 00000000..3750e161 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java @@ -0,0 +1,29 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class Meta { + public String protocolVersion; + public Product implementation; + public Product runtime; + public Product os; + public Product cpu; + public Ci ci; + + public static class Ci { + public String name; + public String url; + public String buildNumber; + public Git git; + } + + public static class Git { + public String remote; + public String revision; + public String branch; + public String tag; + } + + public final class Product { + public String name; + public String version; + } +} \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java new file mode 100644 index 00000000..ac5bda7a --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java @@ -0,0 +1,11 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class ParameterType { + + public String name; + public java.util.List regularExpressions; + public Boolean preferForRegularExpressionMatch; + public Boolean useForSnippets; + public String id; + +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java new file mode 100644 index 00000000..43a6ffc0 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java @@ -0,0 +1,6 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class ParseError { + public SourceReference source; + public String message; +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java new file mode 100644 index 00000000..10b95134 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java @@ -0,0 +1,47 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class Pickle { + + public String id; + public String uri; + public String name; + public String language; + public java.util.List steps; + public java.util.List tags; + public java.util.List astNodeIds; + + + public static class PickleStep { + public PickleStepArgument argument; + public java.util.List astNodeIds; + public String id; + public String text; + } + + public static class PickleStepArgument { + public PickleDocString docString; + public PickleTable dataTable; + } + + public static class PickleDocString { + public String mediaType; + public String content; + } + + public static class PickleTable { + public java.util.List rows; + } + + public static class PickleTableRow { + public java.util.List cells; + } + + public static class PickleTableCell { + public String value; + } + + public static class PickleTag { + public String name; + public String astNodeId; + } +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java new file mode 100644 index 00000000..5d112cb0 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java @@ -0,0 +1,9 @@ +package io.cucumber.eclipse.java.plugins.dto; + +import io.cucumber.messages.types.SourceMediaType; + +public class Source { + public String uri; + public String data; + public SourceMediaType mediaType; +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java new file mode 100644 index 00000000..95861086 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java @@ -0,0 +1,21 @@ +package io.cucumber.eclipse.java.plugins.dto; + + public class SourceReference { + public String uri; + public JavaMethod javaMethod; + public JavaStackTraceElement javaStackTraceElement; + public Location location; + + public static class JavaMethod { + public String className; + public String methodName; + public java.util.List methodParameterTypes; + } + + public final class JavaStackTraceElement { + public String className; + public String fileName; + public String methodName; + } + +} \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java new file mode 100644 index 00000000..3bc88957 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java @@ -0,0 +1,14 @@ +package io.cucumber.eclipse.java.plugins.dto; + +import io.cucumber.messages.types.StepDefinitionPatternType; + +public class StepDefinition { + public String id; + public StepDefinitionPattern pattern; + public SourceReference sourceReference; + + public static class StepDefinitionPattern { + public String source; + public StepDefinitionPatternType type; + } +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java new file mode 100644 index 00000000..4cdb5066 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java @@ -0,0 +1,31 @@ +package io.cucumber.eclipse.java.plugins.dto; + + +public class TestCase { + + public String id; + public String pickleId; + public java.util.List testSteps; + + public static class TestStep { + public String hookId; + public String id; + public String pickleStepId; + public java.util.List stepDefinitionIds; + public java.util.List stepMatchArgumentsLists; + } + public static class StepMatchArgumentsList { + public java.util.List stepMatchArguments; + } + + public static class StepMatchArgument { + public Group group; + public String parameterTypeName; + } + + public static class Group { + public java.util.List children; + public Long start; + public String value; + } +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java new file mode 100644 index 00000000..4c74fcff --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java @@ -0,0 +1,10 @@ +package io.cucumber.eclipse.java.plugins.dto; + + +public class TestCaseFinished { + + public String testCaseStartedId; + public Timestamp timestamp; + public Boolean willBeRetried; + +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java new file mode 100644 index 00000000..567e1dee --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java @@ -0,0 +1,8 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class TestCaseStarted { + public Long attempt; + public String id; + public String testCaseId; + public Timestamp timestamp; +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java new file mode 100644 index 00000000..1f73d4b5 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java @@ -0,0 +1,9 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class TestRunFinished { + + public String message; + public Boolean success; + public Timestamp timestamp; + +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java new file mode 100644 index 00000000..b437791b --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java @@ -0,0 +1,7 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class TestRunStarted { + + public Timestamp timestamp; + +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java new file mode 100644 index 00000000..236f7511 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java @@ -0,0 +1,17 @@ +package io.cucumber.eclipse.java.plugins.dto; + +import io.cucumber.messages.types.TestStepResultStatus; + +public class TestStepFinished { + + public String testCaseStartedId; + public String testStepId; + public TestStepResult testStepResult; + public Timestamp timestamp; + + public static class TestStepResult { + public Duration duration; + public String message; + public TestStepResultStatus status; + } +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java new file mode 100644 index 00000000..8e8a025a --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java @@ -0,0 +1,10 @@ +package io.cucumber.eclipse.java.plugins.dto; + + +public class TestStepStarted { + + public String testCaseStartedId; + public String testStepId; + public Timestamp timestamp; + +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java new file mode 100644 index 00000000..c9c3efc3 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java @@ -0,0 +1,5 @@ +package io.cucumber.eclipse.java.plugins.dto; +public class Timestamp { + public Long seconds; + public Long nanos; +} \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java new file mode 100644 index 00000000..93dbfef5 --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java @@ -0,0 +1,9 @@ +package io.cucumber.eclipse.java.plugins.dto; + +public class UndefinedParameterType { + + public String expression; + public String name; + + +} diff --git a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target index 25e029a2..a4b8a9ea 100644 --- a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target +++ b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target @@ -1,6 +1,6 @@ - + @@ -22,12 +22,13 @@ + + - + - io.cucumber gherkin @@ -87,10 +88,10 @@ Export-Package: *;version="${version}";-noimport:=true]]> - io.cucumber - create-meta - 6.0.4 - jar + io.cucumber + create-meta + 6.0.4 + jar Date: Tue, 31 May 2022 16:44:11 +0200 Subject: [PATCH 7/9] fix target platform --- .../cucumber.eclipse.targetdefinition.target | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target index a4b8a9ea..22d338f9 100644 --- a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target +++ b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target @@ -38,7 +38,7 @@ version: ${version_cleanup;${mvnVersion}} Bundle-SymbolicName: ${mvnGroupId}.${mvnArtifactId} Bundle-Version: ${version} -Import-Package: !sun.*,io.cucumber.messages.internal.com.google.gson*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Import-Package: !sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* Export-Package: *;version="${version}";-noimport:=true]]> @@ -50,7 +50,7 @@ Export-Package: *;version="${version}";-noimport:=true]]> version: ${version_cleanup;${mvnVersion}} Bundle-SymbolicName: ${mvnGroupId}.${mvnArtifactId} Bundle-Version: ${version} -Import-Package: !sun.*,io.cucumber.messages.internal.com.google.gson*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Import-Package: !sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* Export-Package: *;version="${version}";-noimport:=true]]> @@ -62,9 +62,10 @@ Export-Package: *;version="${version}";-noimport:=true]]> version: ${version_cleanup;${mvnVersion}} Bundle-SymbolicName: ${mvnGroupId}.${mvnArtifactId} Bundle-Version: ${version} -Import-Package: !sun.*,io.cucumber.messages.internal.com.google.gson*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Import-Package: !sun.*,!io.cucumber.cienvironment,!io.cucumber.messages.internal.*,!org.checkerframework.*,* Export-Package: *;version="${version}";-noimport:=true]]> + io.cucumber cucumber-expressions @@ -74,7 +75,7 @@ Export-Package: *;version="${version}";-noimport:=true]]> version: ${version_cleanup;${mvnVersion}} Bundle-SymbolicName: ${mvnGroupId}.${mvnArtifactId} Bundle-Version: ${version} -Import-Package: !sun.*,io.cucumber.messages.internal.com.google.gson*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Import-Package: !sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* Export-Package: *;version="${version}";-noimport:=true]]> @@ -96,7 +97,7 @@ Export-Package: *;version="${version}";-noimport:=true]]> version: ${version_cleanup;${mvnVersion}} Bundle-SymbolicName: ${mvnGroupId}.${mvnArtifactId} Bundle-Version: ${version} -Import-Package: !sun.*,io.cucumber.messages.internal.com.google.gson*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Import-Package: !sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* Export-Package: *;version="${version}";-noimport:=true]]> From 9ad214d6d268e2182a095fb4d962a2cda3233a04 Mon Sep 17 00:00:00 2001 From: FilippoR Date: Tue, 31 May 2022 19:16:04 +0200 Subject: [PATCH 8/9] Use java serialization and prepare for 6 compatibility --- ...in.java => BaseCucumberEclipsePlugin.java} | 60 +- .../java/plugins/Cucumber7EclipsePlugin.java | 37 + .../eclipse/java/plugins/MessageEndpoint.java | 34 +- .../java/plugins/MessageToDtoConverter.java | 874 +++++++++--------- .../eclipse/java/plugins/dto/Attachment.java | 15 +- .../eclipse/java/plugins/dto/Duration.java | 9 +- .../eclipse/java/plugins/dto/Envelope.java | 30 +- .../java/plugins/dto/GherkinDocument.java | 136 ++- .../eclipse/java/plugins/dto/Hook.java | 10 +- .../eclipse/java/plugins/dto/Location.java | 8 +- .../eclipse/java/plugins/dto/Meta.java | 36 +- .../java/plugins/dto/ParameterType.java | 13 +- .../eclipse/java/plugins/dto/ParseError.java | 8 +- .../eclipse/java/plugins/dto/Pickle.java | 60 +- .../eclipse/java/plugins/dto/Source.java | 9 +- .../java/plugins/dto/SourceReference.java | 27 +- .../java/plugins/dto/StepDefinition.java | 16 +- .../eclipse/java/plugins/dto/TestCase.java | 39 +- .../java/plugins/dto/TestCaseFinished.java | 8 +- .../java/plugins/dto/TestCaseStarted.java | 10 +- .../java/plugins/dto/TestRunFinished.java | 9 +- .../java/plugins/dto/TestRunStarted.java | 8 +- .../java/plugins/dto/TestStepFinished.java | 19 +- .../java/plugins/dto/TestStepStarted.java | 8 +- .../eclipse/java/plugins/dto/Timestamp.java | 9 +- .../plugins/dto/UndefinedParameterType.java | 9 +- ...pplicationLaunchConfigurationDelegate.java | 4 +- .../launching/CucumberRuntimeLauncher.java | 4 +- 28 files changed, 977 insertions(+), 532 deletions(-) rename io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/{CucumberEclipsePlugin.java => BaseCucumberEclipsePlugin.java} (71%) create mode 100644 io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Cucumber7EclipsePlugin.java diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/BaseCucumberEclipsePlugin.java similarity index 71% rename from io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java rename to io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/BaseCucumberEclipsePlugin.java index b418dfa4..0b5a4699 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/CucumberEclipsePlugin.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/BaseCucumberEclipsePlugin.java @@ -4,56 +4,40 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; +import java.io.ObjectOutputStream; import java.net.Socket; import java.net.UnknownHostException; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; -//import com.google.gson.Gson; - import io.cucumber.messages.types.Envelope; import io.cucumber.plugin.ConcurrentEventListener; import io.cucumber.plugin.event.EventPublisher; -/** - * Specialized plugin that allows to transfer the {@link Envelope}s emitted to a - * remote process or consume them locally - * - * @author christoph - * - */ -public class CucumberEclipsePlugin implements ConcurrentEventListener { +public abstract class BaseCucumberEclipsePlugin implements ConcurrentEventListener { - private Consumer consumer; + protected Consumer consumer; public static final int HANDLED_MESSAGE = 0x1; public static final int GOOD_BY_MESSAGE = 0x0; - public CucumberEclipsePlugin(String port) throws IOException { - this(new SocketConsumer(port)); - } - - public CucumberEclipsePlugin(Consumer consumer) { + public BaseCucumberEclipsePlugin(Consumer consumer) { this.consumer = consumer; } - - @Override - public void setEventPublisher(EventPublisher publisher) { - publisher.registerHandlerFor(Envelope.class, this::writeMessage); - } - - private void writeMessage(Envelope envelope) { - consumer.accept(envelope); + public BaseCucumberEclipsePlugin(String port) throws IOException { + this.consumer = new SocketConsumer(port, this) ; } - - private static final class SocketConsumer implements Consumer { + + protected static final class SocketConsumer implements Consumer { private final Socket socket; private final DataOutputStream output; private final ByteArrayOutputStream buffer = new ByteArrayOutputStream(1024 * 1024 * 10); private AtomicInteger written = new AtomicInteger(); private InputStream input; + private BaseCucumberEclipsePlugin plugin; - public SocketConsumer(String port) throws NumberFormatException, UnknownHostException, IOException { + public SocketConsumer(String port,BaseCucumberEclipsePlugin plugin) throws IOException { + this.plugin = plugin; try { socket = new Socket((String) null, Integer.parseInt(port)); output = new DataOutputStream(socket.getOutputStream()); @@ -85,13 +69,14 @@ public void accept(Envelope env) { } try { buffer.reset(); - Jackson.OBJECT_MAPPER.writeValue(buffer, env); + ObjectOutputStream oos = new ObjectOutputStream(buffer); + oos.writeObject(plugin.convert(env)); output.writeInt(buffer.size()); buffer.writeTo(output); output.flush(); int read = input.read() & 0xFF; written.incrementAndGet(); - if (env.getTestRunFinished().isPresent() || read == GOOD_BY_MESSAGE) { + if (env.getTestRunFinished().isPresent()|| read == GOOD_BY_MESSAGE) { finish(); } } catch (IOException e) { @@ -109,4 +94,19 @@ private void finish() throws IOException { } } -} + + @Override + public void setEventPublisher(EventPublisher publisher) { + publisher.registerHandlerFor(Envelope.class, this::writeMessage); + } + + private void writeMessage(Envelope envelope) { + consumer.accept(envelope); + } + + protected abstract io.cucumber.eclipse.java.plugins.dto.Envelope convert( + io.cucumber.messages.types.Envelope envelope); + + + +} \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Cucumber7EclipsePlugin.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Cucumber7EclipsePlugin.java new file mode 100644 index 00000000..247dec3e --- /dev/null +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/Cucumber7EclipsePlugin.java @@ -0,0 +1,37 @@ +package io.cucumber.eclipse.java.plugins; + +import java.io.IOException; +import java.util.function.Consumer; + +//import com.google.gson.Gson; + +import io.cucumber.messages.types.Envelope; + +/** + * Specialized plugin that allows to transfer the {@link Envelope}s emitted to a + * remote process or consume them locally + * + * @author christoph + * + */ +public class Cucumber7EclipsePlugin extends BaseCucumberEclipsePlugin { + + public Cucumber7EclipsePlugin(String port) throws IOException { + super(port); + } + + + + public Cucumber7EclipsePlugin(Consumer consumer) { + super(consumer); + } + + + + @Override + protected io.cucumber.eclipse.java.plugins.dto.Envelope convert( + Envelope envelope) { + + return MessageToDtoConverter.convert(envelope); + } +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java index 6e343f30..582b0812 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageEndpoint.java @@ -1,7 +1,9 @@ package io.cucumber.eclipse.java.plugins; +import java.io.ByteArrayInputStream; import java.io.DataInputStream; import java.io.IOException; +import java.io.ObjectInputStream; import java.io.OutputStream; import java.net.ServerSocket; import java.net.Socket; @@ -51,19 +53,29 @@ public void run() { buffer = new byte[framelength]; } inputStream.readFully(buffer, 0, framelength); - Envelope envelope = DtoToMessageConverter.convert(Jackson.OBJECT_MAPPER.readValue(buffer, 0, framelength, io.cucumber.eclipse.java.plugins.dto.Envelope.class)); +// Envelope envelope = DtoToMessageConverter.convert(Jackson.OBJECT_MAPPER.readValue(buffer, 0, framelength, io.cucumber.eclipse.java.plugins.dto.Envelope.class)); + ByteArrayInputStream bais = new ByteArrayInputStream(buffer, 0, framelength); + ObjectInputStream ois = new ObjectInputStream(bais); + Envelope envelope; try { - handleMessage(envelope); - } catch (InterruptedException e) { - break; - } - outputStream.write(CucumberEclipsePlugin.HANDLED_MESSAGE); - outputStream.flush(); - if (envelope.getTestRunFinished().isPresent()) { - break; + envelope = DtoToMessageConverter.convert( + (io.cucumber.eclipse.java.plugins.dto.Envelope) ois.readObject()); + + try { + handleMessage(envelope); + } catch (InterruptedException e) { + break; + } + outputStream.write(Cucumber7EclipsePlugin.HANDLED_MESSAGE); + outputStream.flush(); + if (envelope.getTestRunFinished().isPresent()) { + break; + } + } catch (ClassNotFoundException e1) { + e1.printStackTrace(); } } - outputStream.write(CucumberEclipsePlugin.GOOD_BY_MESSAGE); + outputStream.write(Cucumber7EclipsePlugin.GOOD_BY_MESSAGE); outputStream.flush(); } socket.close(); @@ -83,7 +95,7 @@ public void run() { public void addArguments(Collection args) { args.add("-p"); - args.add(CucumberEclipsePlugin.class.getName() + ":" + String.valueOf(serverSocket.getLocalPort())); + args.add(Cucumber7EclipsePlugin.class.getName() + ":" + String.valueOf(serverSocket.getLocalPort())); } public boolean isTerminated() { diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java index edf0dab6..0e562a1d 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/MessageToDtoConverter.java @@ -1,433 +1,441 @@ -//package io.cucumber.eclipse.java.plugins; -// -//import static java.util.stream.Collectors.toList; -// -//import java.util.List; -//import java.util.Optional; -//import java.util.function.Function; -// -//import io.cucumber.eclipse.java.plugins.dto.Envelope; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Background; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Comment; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DataTable; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DocString; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Examples; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Feature; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.FeatureChild; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Rule; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.RuleChild; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Scenario; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Step; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableCell; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableRow; -//import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Tag; -//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStep; -//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableCell; -//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableRow; -//import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTag; -//import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgument; -//import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgumentsList; -//import io.cucumber.eclipse.java.plugins.dto.TestCase.TestStep; -//import io.cucumber.messages.types.Attachment; -//import io.cucumber.messages.types.Ci; -//import io.cucumber.messages.types.Duration; -//import io.cucumber.messages.types.Git; -//import io.cucumber.messages.types.Group; -//import io.cucumber.messages.types.Hook; -//import io.cucumber.messages.types.JavaMethod; -//import io.cucumber.messages.types.JavaStackTraceElement; -//import io.cucumber.messages.types.Meta; -//import io.cucumber.messages.types.ParameterType; -//import io.cucumber.messages.types.ParseError; -//import io.cucumber.messages.types.Pickle; -//import io.cucumber.messages.types.PickleDocString; -//import io.cucumber.messages.types.PickleStepArgument; -//import io.cucumber.messages.types.PickleTable; -//import io.cucumber.messages.types.Product; -//import io.cucumber.messages.types.Source; -//import io.cucumber.messages.types.SourceReference; -//import io.cucumber.messages.types.StepDefinition; -//import io.cucumber.messages.types.StepDefinitionPattern; -//import io.cucumber.messages.types.TestCase; -//import io.cucumber.messages.types.TestCaseFinished; -//import io.cucumber.messages.types.TestCaseStarted; -//import io.cucumber.messages.types.TestRunFinished; -//import io.cucumber.messages.types.TestRunStarted; -//import io.cucumber.messages.types.TestStepFinished; -//import io.cucumber.messages.types.TestStepResult; -//import io.cucumber.messages.types.TestStepStarted; -//import io.cucumber.messages.types.Timestamp; -//import io.cucumber.messages.types.UndefinedParameterType; -// -//public class MessageToDtoConverter { -// -// public static Envelope convert(io.cucumber.messages.types.Envelope d) { -// if (d == null) -// return null; -// return new Envelope( -// convert(d.getAttachment()), -// convert(d.getGherkinDocument()), -// convert(d.getHook()), -// convert(d.getMeta()), -// convert(d.getParameterType()), -// convert(d.getParseError()), -// convert(d.getPickle()), -// convert(d.getSource()), -// convert(d.getStepDefinition()), -// convert(d.getTestCase()), -// convert(d.getTestCaseFinished()), -// convert(d.getTestCaseStarted()), -// convert(d.getTestRunFinished()), -// convert(d.getTestRunStarted()), -// convert(d.getTestStepFinished()), -// convert(d.getTestStepStarted()), -// convert(d.getUndefinedParameterType())); -// } -// -// public static List convertList(List list, Function converter) { -// Optional> map = Optional.ofNullable(list) -// .map(l -> l.stream().map(v -> converter.apply(v)).collect(toList())); -// return map.orElse(null); -// } -// -// public static UndefinedParameterType convert(io.cucumber.eclipse.java.plugins.dto.UndefinedParameterType d) { -// if (d == null) -// return null; -// return new UndefinedParameterType(d.expression, d.name); -// } -// -// public static TestStepStarted convert(io.cucumber.eclipse.java.plugins.dto.TestStepStarted d) { -// if (d == null) -// return null; -// return new TestStepStarted(d.testCaseStartedId, d.testStepId, convert(d.timestamp)); -// } -// -// public static Timestamp convert(io.cucumber.eclipse.java.plugins.dto.Timestamp d) { -// if (d == null) -// return null; -// return new Timestamp(d.seconds, d.nanos); -// } -// -// public static TestStepFinished convert(io.cucumber.eclipse.java.plugins.dto.TestStepFinished d) { -// if (d == null) -// return null; -// return new TestStepFinished(d.testCaseStartedId, d.testStepId, convert(d.testStepResult), convert(d.timestamp)); -// } -// -// public static TestStepResult convert(io.cucumber.eclipse.java.plugins.dto.TestStepFinished.TestStepResult d) { -// if (d == null) -// return null; -// return new TestStepResult(convert(d.duration), d.message, d.status); -// } -// -// public static Duration convert(io.cucumber.eclipse.java.plugins.dto.Duration d) { -// if (d == null) -// return null; -// return new Duration(d.seconds, d.nanos); -// } -// -// public static TestRunStarted convert(io.cucumber.eclipse.java.plugins.dto.TestRunStarted d) { -// if (d == null) -// return null; -// return new TestRunStarted(convert(d.timestamp)); -// } -// -// public static TestRunFinished convert(io.cucumber.eclipse.java.plugins.dto.TestRunFinished d) { -// if (d == null) -// return null; -// return new TestRunFinished(d.message, d.success, convert(d.timestamp)); -// } -// -// public static TestCaseStarted convert(io.cucumber.eclipse.java.plugins.dto.TestCaseStarted d) { -// if (d == null) -// return null; -// return new TestCaseStarted(d.attempt, d.id, d.testCaseId, convert(d.timestamp)); -// } -// -// public static TestCaseFinished convert(io.cucumber.eclipse.java.plugins.dto.TestCaseFinished d) { -// if (d == null) -// return null; -// return new TestCaseFinished(d.testCaseStartedId, convert(d.timestamp), d.willBeRetried); -// } -// -// public static TestCase convert(io.cucumber.eclipse.java.plugins.dto.TestCase d) { -// if (d == null) -// return null; -// return new TestCase(d.id, d.pickleId, convertList(d.testSteps,DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.TestStep convert(TestStep d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.TestStep(d.hookId, d.id, d.pickleStepId, d.stepDefinitionIds, -// convertList(d.stepMatchArgumentsLists, DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.StepMatchArgumentsList convert(StepMatchArgumentsList d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.StepMatchArgumentsList( -// convertList(d.stepMatchArguments, DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.StepMatchArgument convert(StepMatchArgument d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.StepMatchArgument(convert(d.group), d.parameterTypeName); -// } -// -// public static Group convert(io.cucumber.eclipse.java.plugins.dto.TestCase.Group d) { -// if (d == null) -// return null; -// return new Group(convertList(d.children,DtoToMessageConverter::convert), d.start, d.value); -// } -// -// public static StepDefinition convert(io.cucumber.eclipse.java.plugins.dto.StepDefinition d) { -// if (d == null) -// return null; -// return new StepDefinition(d.id, convert(d.pattern), convert(d.sourceReference)); -// } -// -// public static StepDefinitionPattern convert( -// io.cucumber.eclipse.java.plugins.dto.StepDefinition.StepDefinitionPattern d) { -// if (d == null) -// return null; -// return new StepDefinitionPattern(d.source, d.type); -// } -// -// public static Source convert(io.cucumber.eclipse.java.plugins.dto.Source d) { -// if (d == null) -// return null; -// return new Source(d.uri, d.data, d.mediaType); -// } -// -// public static Pickle convert(io.cucumber.eclipse.java.plugins.dto.Pickle d) { -// if (d == null) -// return null; -// return new Pickle(d.id, d.uri, d.name, d.language, convertList(d.steps,DtoToMessageConverter::convert), -// convertList(d.tags,DtoToMessageConverter::convert), d.astNodeIds); -// } -// -// public static io.cucumber.messages.types.PickleTag convert(PickleTag d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.PickleTag(d.name, d.astNodeId); -// } -// -// public static io.cucumber.messages.types.PickleStep convert(PickleStep d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.PickleStep(convert(d.argument), d.astNodeIds, d.id, d.text); -// } -// -// public static PickleStepArgument convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStepArgument d) { -// if (d == null) -// return null; -// return new PickleStepArgument(convert(d.docString), convert(d.dataTable)); -// } -// -// public static PickleTable convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTable d) { -// if (d == null) -// return null; -// return new PickleTable(convertList(d.rows,DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.PickleTableRow convert(PickleTableRow d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.PickleTableRow(convertList(d.cells,DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.PickleTableCell convert(PickleTableCell d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.PickleTableCell(d.value); -// } -// -// public static PickleDocString convert(io.cucumber.eclipse.java.plugins.dto.Pickle.PickleDocString d) { -// if (d == null) -// return null; -// return new PickleDocString(d.mediaType, d.content); -// } -// -// public static ParseError convert(io.cucumber.eclipse.java.plugins.dto.ParseError d) { -// if (d == null) -// return null; -// return new ParseError(convert(d.source), d.message); -// } -// -// public static ParameterType convert(io.cucumber.eclipse.java.plugins.dto.ParameterType d) { -// if (d == null) -// return null; -// return new ParameterType(d.name, d.regularExpressions, d.preferForRegularExpressionMatch, d.useForSnippets, -// d.id); -// } -// -// public static Meta convert(io.cucumber.eclipse.java.plugins.dto.Meta d) { -// if (d == null) -// return null; -// return new Meta(d.protocolVersion, convert(d.implementation), convert(d.runtime), convert(d.os), convert(d.cpu), -// convert(d.ci)); -// } -// -// public static Ci convert(io.cucumber.eclipse.java.plugins.dto.Meta.Ci d) { -// if (d == null) -// return null; -// return new Ci(d.name, d.url, d.buildNumber, convert(d.git)); -// } -// -// public static Git convert(io.cucumber.eclipse.java.plugins.dto.Meta.Git d) { -// if (d == null) -// return null; -// return new Git(d.remote, d.revision, d.branch, d.tag); -// } -// -// public static Product convert(io.cucumber.eclipse.java.plugins.dto.Meta.Product d) { -// if (d == null) -// return null; -// return new Product(d.name, d.version); -// } -// -// public static Hook convert(io.cucumber.eclipse.java.plugins.dto.Hook d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Hook(d.id, d.name, convert(d.sourceReference), d.tagExpression); -// } -// -// public static SourceReference convert(io.cucumber.eclipse.java.plugins.dto.SourceReference d) { -// if (d == null) -// return null; -// return new SourceReference(d.uri, convert(d.javaMethod), convert(d.javaStackTraceElement), convert(d.location)); -// } -// -// public static JavaMethod convert(io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaMethod d) { -// if (d == null) -// return null; -// return new JavaMethod(d.className, d.methodName, d.methodParameterTypes); -// } -// -// public static JavaStackTraceElement convert( -// io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaStackTraceElement d) { -// if (d == null) -// return null; -// return new JavaStackTraceElement(d.className, d.fileName, d.methodName); -// } -// -// public static Attachment convert(io.cucumber.eclipse.java.plugins.dto.Attachment d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Attachment(d.body, d.contentEncoding, d.fileName, d.mediaType, d.source, -// d.testCaseStartedId, d.testStepId, d.url); -// } -// -// public static io.cucumber.messages.types.Comment convert(Comment d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Comment(convert(d.location), d.text); -// } -// -// public static io.cucumber.messages.types.Feature convert(Feature d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Feature(convert(d.location), -// convertList(d.tags,DtoToMessageConverter::convert), d.language, d.keyword, d.name, d.description, -// convertList(d.children,DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.Tag convert(Tag d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Tag(convert(d.location), d.name, d.id); -// } -// -// public static io.cucumber.messages.types.FeatureChild convert(FeatureChild d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.FeatureChild(convert(d.rule), convert(d.background), convert(d.scenario)); -// } -// -// public static io.cucumber.messages.types.Scenario convert(Scenario d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Scenario(convert(d.location), -// convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, -// convertList(d.steps,DtoToMessageConverter::convert), -// convertList(d.examples,DtoToMessageConverter::convert), d.id); -// } -// -// public static io.cucumber.messages.types.Examples convert(Examples d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Examples(convert(d.location), -// convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, -// convert(d.tableHeader), convertList(d.tableBody,DtoToMessageConverter::convert), d.id); -// } -// -// public static io.cucumber.messages.types.Rule convert(Rule d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Rule(convert(d.location), -// convertList(d.tags,DtoToMessageConverter::convert), d.keyword, d.name, d.description, -// convertList(d.children,DtoToMessageConverter::convert), d.id); -// } -// -// public static io.cucumber.messages.types.RuleChild convert(RuleChild d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.RuleChild(DtoToMessageConverter.convert(d.background), convert(d.scenario)); -// } -// -// public static io.cucumber.messages.types.Background convert(Background d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Background(convert(d.location), d.keyword, d.name, d.description, -// convertList(d.steps,DtoToMessageConverter::convert), d.id); -// } -// -// public static io.cucumber.messages.types.Step convert(Step d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Step(convert(d.location), d.keyword, d.text, convert(d.docString), -// convert(d.dataTable), d.id); -// } -// -// public static io.cucumber.messages.types.DocString convert(DocString d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.DocString(convert(d.location), d.mediaType, d.content, d.delimiter); -// } -// -// public static io.cucumber.messages.types.DataTable convert(DataTable d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.DataTable(convert(d.location), -// convertList(d.rows,DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.TableRow convert(TableRow d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.TableRow(convert(d.location), -// convertList(d.cells,DtoToMessageConverter::convert), d.id); -// } -// -// public static io.cucumber.messages.types.TableCell convert(TableCell d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.TableCell(convert(d.location), d.value); -// } -// -// public static io.cucumber.messages.types.GherkinDocument convert(GherkinDocument d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.GherkinDocument(d.uri, convert(d.feature), -// convertList(d.comments,DtoToMessageConverter::convert)); -// } -// -// public static io.cucumber.messages.types.Location convert(io.cucumber.eclipse.java.plugins.dto.Location d) { -// if (d == null) -// return null; -// return new io.cucumber.messages.types.Location(d.line, d.column); -// } -//} +package io.cucumber.eclipse.java.plugins; + +import static java.util.stream.Collectors.toList; + +import java.util.List; +import java.util.Optional; +import java.util.function.Function; + +import io.cucumber.eclipse.java.plugins.dto.Attachment; +import io.cucumber.eclipse.java.plugins.dto.Duration; +import io.cucumber.eclipse.java.plugins.dto.Envelope; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Background; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Comment; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DataTable; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.DocString; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Examples; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Feature; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.FeatureChild; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Rule; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.RuleChild; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Scenario; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Step; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableCell; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.TableRow; +import io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Tag; +import io.cucumber.eclipse.java.plugins.dto.Hook; +import io.cucumber.eclipse.java.plugins.dto.Location; +import io.cucumber.eclipse.java.plugins.dto.Meta; +import io.cucumber.eclipse.java.plugins.dto.Meta.Ci; +import io.cucumber.eclipse.java.plugins.dto.Meta.Git; +import io.cucumber.eclipse.java.plugins.dto.Meta.Product; +import io.cucumber.eclipse.java.plugins.dto.ParameterType; +import io.cucumber.eclipse.java.plugins.dto.ParseError; +import io.cucumber.eclipse.java.plugins.dto.Pickle; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleDocString; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStep; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleStepArgument; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTable; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableCell; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTableRow; +import io.cucumber.eclipse.java.plugins.dto.Pickle.PickleTag; +import io.cucumber.eclipse.java.plugins.dto.Source; +import io.cucumber.eclipse.java.plugins.dto.SourceReference; +import io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaMethod; +import io.cucumber.eclipse.java.plugins.dto.SourceReference.JavaStackTraceElement; +import io.cucumber.eclipse.java.plugins.dto.StepDefinition; +import io.cucumber.eclipse.java.plugins.dto.StepDefinition.StepDefinitionPattern; +import io.cucumber.eclipse.java.plugins.dto.TestCase; +import io.cucumber.eclipse.java.plugins.dto.TestCase.Group; +import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgument; +import io.cucumber.eclipse.java.plugins.dto.TestCase.StepMatchArgumentsList; +import io.cucumber.eclipse.java.plugins.dto.TestCase.TestStep; +import io.cucumber.eclipse.java.plugins.dto.TestCaseFinished; +import io.cucumber.eclipse.java.plugins.dto.TestCaseStarted; +import io.cucumber.eclipse.java.plugins.dto.TestRunFinished; +import io.cucumber.eclipse.java.plugins.dto.TestRunStarted; +import io.cucumber.eclipse.java.plugins.dto.TestStepFinished; +import io.cucumber.eclipse.java.plugins.dto.TestStepFinished.TestStepResult; +import io.cucumber.eclipse.java.plugins.dto.TestStepStarted; +import io.cucumber.eclipse.java.plugins.dto.Timestamp; +import io.cucumber.eclipse.java.plugins.dto.UndefinedParameterType; + +public class MessageToDtoConverter { + + public static Envelope convert(io.cucumber.messages.types.Envelope d) { + if (d == null) + return null; + return new Envelope( + d.getAttachment().map(MessageToDtoConverter::convert).orElse(null), + d.getGherkinDocument().map(MessageToDtoConverter::convert).orElse(null), + d.getHook().map(MessageToDtoConverter::convert).orElse(null), + d.getMeta().map(MessageToDtoConverter::convert).orElse(null), + d.getParameterType().map(MessageToDtoConverter::convert).orElse(null), + d.getParseError().map(MessageToDtoConverter::convert).orElse(null), + d.getPickle().map(MessageToDtoConverter::convert).orElse(null), + d.getSource().map(MessageToDtoConverter::convert).orElse(null), + d.getStepDefinition().map(MessageToDtoConverter::convert).orElse(null), + d.getTestCase().map(MessageToDtoConverter::convert).orElse(null), + d.getTestCaseFinished().map(MessageToDtoConverter::convert).orElse(null), + d.getTestCaseStarted().map(MessageToDtoConverter::convert).orElse(null), + d.getTestRunFinished().map(MessageToDtoConverter::convert).orElse(null), + d.getTestRunStarted().map(MessageToDtoConverter::convert).orElse(null), + d.getTestStepFinished().map(MessageToDtoConverter::convert).orElse(null), + d.getTestStepStarted().map(MessageToDtoConverter::convert).orElse(null), + d.getUndefinedParameterType().map(MessageToDtoConverter::convert).orElse(null)); + } + + public static List convertList(List list, Function converter) { + Optional> map = Optional.ofNullable(list) + .map(l -> l.stream().map(v -> converter.apply(v)).collect(toList())); + return map.orElse(null); + } + + public static List convertList(Optional> list, Function converter) { + Optional> map = list.map(l -> l.stream().map(v -> converter.apply(v)).collect(toList())); + return map.orElse(null); + } + + private static UndefinedParameterType convert(io.cucumber.messages.types.UndefinedParameterType d) { + if (d == null) + return null; + return new UndefinedParameterType(d.getExpression(), d.getName()); + } + + public static TestStepStarted convert(io.cucumber.messages.types.TestStepStarted d) { + if (d == null) + return null; + return new TestStepStarted(d.getTestCaseStartedId(), d.getTestStepId(), convert(d.getTimestamp())); + } + + public static Timestamp convert(io.cucumber.messages.types.Timestamp d) { + if (d == null) + return null; + return new Timestamp(d.getSeconds(), d.getNanos()); + } + + public static TestStepFinished convert(io.cucumber.messages.types.TestStepFinished d) { + if (d == null) + return null; + return new TestStepFinished(d.getTestCaseStartedId(), d.getTestStepId(), convert(d.getTestStepResult()), + convert(d.getTimestamp())); + } + + public static TestStepResult convert(io.cucumber.messages.types.TestStepResult d) { + if (d == null) + return null; + return new TestStepResult(convert(d.getDuration()), d.getMessage().orElse(null), d.getStatus()); + } + + public static Duration convert(io.cucumber.messages.types.Duration d) { + if (d == null) + return null; + return new Duration(d.getSeconds(), d.getNanos()); + } + + public static TestRunStarted convert(io.cucumber.messages.types.TestRunStarted d) { + if (d == null) + return null; + return new TestRunStarted(convert(d.getTimestamp())); + } + + public static TestRunFinished convert(io.cucumber.messages.types.TestRunFinished d) { + if (d == null) + return null; + return new TestRunFinished(d.getMessage().orElse(null), d.getSuccess(), convert(d.getTimestamp())); + } + + public static TestCaseStarted convert(io.cucumber.messages.types.TestCaseStarted d) { + if (d == null) + return null; + return new TestCaseStarted(d.getAttempt(), d.getId(), d.getTestCaseId(), convert(d.getTimestamp())); + } + + public static TestCaseFinished convert(io.cucumber.messages.types.TestCaseFinished d) { + if (d == null) + return null; + return new TestCaseFinished(d.getTestCaseStartedId(), convert(d.getTimestamp()), d.getWillBeRetried()); + } + + public static TestCase convert(io.cucumber.messages.types.TestCase d) { + if (d == null) + return null; + return new TestCase(d.getId(), d.getPickleId(), convertList(d.getTestSteps(), MessageToDtoConverter::convert)); + } + + public static TestStep convert(io.cucumber.messages.types.TestStep d) { + if (d == null) + return null; + return new TestStep(d.getHookId().orElse(null), d.getId(), d.getPickleStepId().orElse(null), + d.getStepDefinitionIds().orElse(null), + convertList(d.getStepMatchArgumentsLists(), MessageToDtoConverter::convert)); + } + + public static StepMatchArgumentsList convert(io.cucumber.messages.types.StepMatchArgumentsList d) { + if (d == null) + return null; + return new StepMatchArgumentsList(convertList(d.getStepMatchArguments(), MessageToDtoConverter::convert)); + } + + public static StepMatchArgument convert(io.cucumber.messages.types.StepMatchArgument d) { + if (d == null) + return null; + return new StepMatchArgument(convert(d.getGroup()), d.getParameterTypeName().orElse(null)); + } + + public static Group convert(io.cucumber.messages.types.Group d) { + if (d == null) + return null; + return new Group(convertList(d.getChildren(), MessageToDtoConverter::convert), d.getStart().orElse(null), + d.getValue().orElse(null)); + } + + public static StepDefinition convert(io.cucumber.messages.types.StepDefinition d) { + if (d == null) + return null; + return new StepDefinition(d.getId(), convert(d.getPattern()), convert(d.getSourceReference())); + } + + public static StepDefinitionPattern convert(io.cucumber.messages.types.StepDefinitionPattern d) { + if (d == null) + return null; + return new StepDefinitionPattern(d.getSource(), d.getType()); + } + + public static Source convert(io.cucumber.messages.types.Source d) { + if (d == null) + return null; + return new Source(d.getUri(), d.getData(), d.getMediaType()); + } + + public static Pickle convert(io.cucumber.messages.types.Pickle d) { + if (d == null) + return null; + return new Pickle(d.getId(), d.getUri(), d.getName(), d.getLanguage(), convertList(d.getSteps(), MessageToDtoConverter::convert), + convertList(d.getTags(), MessageToDtoConverter::convert), d.getAstNodeIds()); + } + + public static PickleTag convert(io.cucumber.messages.types.PickleTag d) { + if (d == null) + return null; + return new PickleTag(d.getName(), d.getAstNodeId()); + } + + public static PickleStep convert(io.cucumber.messages.types.PickleStep d) { + if (d == null) + return null; + return new PickleStep(convert(d.getArgument().orElse(null)), d.getAstNodeIds(), d.getId(), d.getText()); + } + + public static PickleStepArgument convert(io.cucumber.messages.types.PickleStepArgument d) { + if (d == null) + return null; + return new PickleStepArgument(convert(d.getDocString().orElse(null)), convert(d.getDataTable().orElse(null))); + } + + public static PickleTable convert(io.cucumber.messages.types.PickleTable d) { + if (d == null) + return null; + return new PickleTable(convertList(d.getRows(), MessageToDtoConverter::convert)); + } + + public static PickleTableRow convert(io.cucumber.messages.types.PickleTableRow d) { + if (d == null) + return null; + return new PickleTableRow(convertList(d.getCells(), MessageToDtoConverter::convert)); + } + + public static PickleTableCell convert(io.cucumber.messages.types.PickleTableCell d) { + if (d == null) + return null; + return new PickleTableCell(d.getValue()); + } + + public static PickleDocString convert(io.cucumber.messages.types.PickleDocString d) { + if (d == null) + return null; + return new PickleDocString(d.getMediaType().orElse(null), d.getContent()); + } + + public static ParseError convert(io.cucumber.messages.types.ParseError d) { + if (d == null) + return null; + return new ParseError(convert(d.getSource()), d.getMessage()); + } + + public static ParameterType convert(io.cucumber.messages.types.ParameterType d) { + if (d == null) + return null; + return new ParameterType(d.getName(), d.getRegularExpressions(), d.getPreferForRegularExpressionMatch(), d.getUseForSnippets(), + d.getId()); + } + + public static Meta convert(io.cucumber.messages.types.Meta d) { + if (d == null) + return null; + return new Meta(d.getProtocolVersion(), convert(d.getImplementation()), convert(d.getRuntime()), convert(d.getOs()), convert(d.getCpu()), + convert(d.getCi().orElse(null))); + } + + public static Ci convert(io.cucumber.messages.types.Ci d) { + if (d == null) + return null; + return new Ci(d.getName(), d.getUrl().orElse(null), d.getBuildNumber().orElse(null), convert(d.getGit().orElse(null))); + } + + public static Git convert(io.cucumber.messages.types.Git d) { + if (d == null) + return null; + return new Git(d.getRemote(), d.getRevision(), d.getBranch().orElse(null), d.getTag().orElse(null)); + } + + public static Product convert(io.cucumber.messages.types.Product d) { + if (d == null) + return null; + return new Product(d.getName(), d.getVersion().orElse(null)); + } + + public static Hook convert(io.cucumber.messages.types.Hook d) { + if (d == null) + return null; + return new Hook(d.getId(), d.getName().orElse(null), convert(d.getSourceReference()), d.getTagExpression().orElse(null)); + } + + public static SourceReference convert(io.cucumber.messages.types.SourceReference d) { + if (d == null) + return null; + return new SourceReference(d.getUri().orElse(null), convert(d.getJavaMethod().orElse(null)), convert(d.getJavaStackTraceElement().orElse(null)), convert(d.getLocation().orElse(null))); + } + + public static JavaMethod convert(io.cucumber.messages.types.JavaMethod d) { + if (d == null) + return null; + return new JavaMethod(d.getClassName(), d.getMethodName(), d.getMethodParameterTypes()); + } + + public static JavaStackTraceElement convert(io.cucumber.messages.types.JavaStackTraceElement d) { + if (d == null) + return null; + return new JavaStackTraceElement(d.getClassName(), d.getFileName(), d.getMethodName()); + } + + public static Attachment convert(io.cucumber.messages.types.Attachment d) { + if (d == null) + return null; + return new Attachment(d.getBody(), d.getContentEncoding(), d.getFileName().orElse(null), d.getMediaType(), d.getSource().orElse(null), + d.getTestCaseStartedId().orElse(null), d.getTestStepId().orElse(null), d.getUrl().orElse(null)); + } + + public static Comment convert(io.cucumber.messages.types.Comment d) { + if (d == null) + return null; + return new Comment(convert(d.getLocation()), d.getText()); + } + + public static Feature convert(io.cucumber.messages.types.Feature d) { + if (d == null) + return null; + return new Feature(convert(d.getLocation()), + convertList(d.getTags(), MessageToDtoConverter::convert), d.getLanguage(), d.getKeyword(), d.getName(), d.getDescription(), + convertList(d.getChildren(), MessageToDtoConverter::convert)); + } + + public static Tag convert(io.cucumber.messages.types.Tag d) { + if (d == null) + return null; + return new Tag(convert(d.getLocation()), d.getName(), d.getId()); + } + + public static FeatureChild convert(io.cucumber.messages.types.FeatureChild d) { + if (d == null) + return null; + return new FeatureChild(convert(d.getRule().orElse(null)), convert(d.getBackground().orElse(null)), + convert(d.getScenario().orElse(null))); + } + + public static Scenario convert(io.cucumber.messages.types.Scenario d) { + if (d == null) + return null; + return new Scenario(convert(d.getLocation()), + convertList(d.getTags(), MessageToDtoConverter::convert), d.getKeyword(), d.getName(), d.getDescription(), + convertList(d.getSteps(), MessageToDtoConverter::convert), + convertList(d.getExamples(), MessageToDtoConverter::convert), d.getId()); + } + + public static Examples convert(io.cucumber.messages.types.Examples d) { + if (d == null) + return null; + return new Examples(convert(d.getLocation()), + convertList(d.getTags(), MessageToDtoConverter::convert), d.getKeyword(), d.getName(), d.getDescription(), + convert(d.getTableHeader().orElse(null)), convertList(d.getTableBody(), MessageToDtoConverter::convert), d.getId()); + } + + public static Rule convert(io.cucumber.messages.types.Rule d) { + if (d == null) + return null; + return new Rule(convert(d.getLocation()), + convertList(d.getTags(), MessageToDtoConverter::convert), d.getKeyword(), d.getName(), d.getDescription(), + convertList(d.getChildren(), MessageToDtoConverter::convert), d.getId()); + } + + public static RuleChild convert(io.cucumber.messages.types.RuleChild d) { + if (d == null) + return null; + return new RuleChild(MessageToDtoConverter.convert(d.getBackground().orElse(null)), + convert(d.getScenario().orElse(null))); + } + + public static Background convert(io.cucumber.messages.types.Background d) { + if (d == null) + return null; + return new Background(convert(d.getLocation()), d.getKeyword(), d.getName(), d.getDescription(), + convertList(d.getSteps(), MessageToDtoConverter::convert), d.getId()); + } + + public static Step convert(io.cucumber.messages.types.Step d) { + if (d == null) + return null; + return new Step(convert(d.getLocation()), d.getKeyword(), d.getText(), convert(d.getDocString().orElse(null)), + convert(d.getDataTable().orElse(null)), d.getId()); + } + + public static DocString convert(io.cucumber.messages.types.DocString d) { + if (d == null) + return null; + return new DocString(convert(d.getLocation()), d.getMediaType().orElse(null), d.getContent(), d.getDelimiter()); + } + + public static DataTable convert(io.cucumber.messages.types.DataTable d) { + if (d == null) + return null; + return new DataTable(convert(d.getLocation()), + convertList(d.getRows(), MessageToDtoConverter::convert)); + } + + public static TableRow convert(io.cucumber.messages.types.TableRow d) { + if (d == null) + return null; + return new TableRow(convert(d.getLocation()), + convertList(d.getCells(), MessageToDtoConverter::convert), d.getId()); + } + + public static TableCell convert(io.cucumber.messages.types.TableCell d) { + if (d == null) + return null; + return new TableCell(convert(d.getLocation()), d.getValue()); + } + + public static GherkinDocument convert(io.cucumber.messages.types.GherkinDocument d) { + if (d == null) + return null; + return new GherkinDocument(d.getUri().orElse(null), convert(d.getFeature().orElse(null)), + convertList(d.getComments(), MessageToDtoConverter::convert)); + } + + public static Location convert(io.cucumber.messages.types.Location d) { + if (d == null) + return null; + return new Location(d.getLine(), d.getColumn().orElse(null)); + } +} diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java index d47e4726..9aa29b08 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Attachment.java @@ -1,9 +1,11 @@ package io.cucumber.eclipse.java.plugins.dto; +import java.io.Serializable; + import io.cucumber.messages.types.AttachmentContentEncoding; import io.cucumber.messages.types.Source; -public class Attachment { +public class Attachment implements Serializable{ public String body; public AttachmentContentEncoding contentEncoding; public String fileName; @@ -12,6 +14,17 @@ public class Attachment { public String testCaseStartedId; public String testStepId; public String url; + public Attachment(String body, AttachmentContentEncoding contentEncoding, String fileName, String mediaType, + Source source, String testCaseStartedId, String testStepId, String url) { + this.body = body; + this.contentEncoding = contentEncoding; + this.fileName = fileName; + this.mediaType = mediaType; + this.source = source; + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.url = url; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java index 8fe86028..40f5a96c 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Duration.java @@ -1,5 +1,12 @@ package io.cucumber.eclipse.java.plugins.dto; -public class Duration { + +import java.io.Serializable; + +public class Duration implements Serializable{ public Long seconds; public Long nanos; + public Duration(Long seconds, Long nanos) { + this.seconds = seconds; + this.nanos = nanos; + } } \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java index c76f4786..b88d954c 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Envelope.java @@ -1,6 +1,8 @@ package io.cucumber.eclipse.java.plugins.dto; -public final class Envelope { +import java.io.Serializable; + +public final class Envelope implements Serializable{ public Attachment attachment; public GherkinDocument gherkinDocument; public Hook hook; @@ -18,4 +20,30 @@ public final class Envelope { public TestStepFinished testStepFinished; public TestStepStarted testStepStarted; public UndefinedParameterType 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) { + super(); + 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; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java index 2f67a48b..37cf4a7e 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/GherkinDocument.java @@ -1,11 +1,14 @@ package io.cucumber.eclipse.java.plugins.dto; -public class GherkinDocument { +import java.io.Serializable; +import java.util.List; + +public class GherkinDocument implements Serializable { public String uri; public Feature feature; public java.util.List comments; - public static class Feature { + public static class Feature implements Serializable { public Location location; public java.util.List tags; public String language; @@ -13,21 +16,41 @@ public static class Feature { public String name; public String description; public java.util.List children; + public Feature(Location location, List tags, String language, String keyword, String name, + String description, List children) { + this.location = location; + this.tags = tags; + this.language = language; + this.keyword = keyword; + this.name = name; + this.description = description; + this.children = children; + } } - public static class Tag { + public static class Tag implements Serializable { public Location location; public String name; public String id; + public Tag(Location location, String name, String id) { + this.location = location; + this.name = name; + this.id = id; + } } - public static class FeatureChild { + public static class FeatureChild implements Serializable { public Rule rule; public Background background; public Scenario scenario; + public FeatureChild(Rule rule, Background background, Scenario scenario) { + this.rule = rule; + this.background = background; + this.scenario = scenario; + } } - public static class Rule { + public static class Rule implements Serializable { public Location location; public java.util.List tags; public String keyword; @@ -35,64 +58,119 @@ public static class Rule { public String description; public java.util.List children; public String id; + public Rule(Location location, List tags, String keyword, String name, String description, + List children, String id) { + this.location = location; + this.tags = tags; + this.keyword = keyword; + this.name = name; + this.description = description; + this.children = children; + this.id = id; + } } - public static class RuleChild { + public static class RuleChild implements Serializable { public Background background; public Scenario scenario; + public RuleChild(Background background, Scenario scenario) { + this.background = background; + this.scenario = scenario; + } } - public static class Background { + public static class Background implements Serializable { public Location location; public String keyword; public String name; public String description; public java.util.List steps; public String id; + public Background(Location location, String keyword, String name, String description, List steps, + String id) { + this.location = location; + this.keyword = keyword; + this.name = name; + this.description = description; + this.steps = steps; + this.id = id; + } } - public static class Step { + public static class Step implements Serializable { public Location location; public String keyword; public String text; public DocString docString; public DataTable dataTable; public String id; + public Step(Location location, String keyword, String text, DocString docString, DataTable dataTable, + String id) { + this.location = location; + this.keyword = keyword; + this.text = text; + this.docString = docString; + this.dataTable = dataTable; + this.id = id; + } } - public static class Comment { + public static class Comment implements Serializable { public Location location; public String text; + public Comment(Location location, String text) { + this.location = location; + this.text = text; + } } - public static class DataTable { + public static class DataTable implements Serializable { public Location location; public java.util.List rows; + public DataTable(Location location, List rows) { + this.location = location; + this.rows = rows; + } } - public static class TableRow { + public static class TableRow implements Serializable { public Location location; public java.util.List cells; public String id; + public TableRow(Location location, List cells, String id) { + this.location = location; + this.cells = cells; + this.id = id; + } } - public static class TableCell { + public static class TableCell implements Serializable { public Location location; public String value; + public TableCell(Location location, String value) { + this.location = location; + this.value = value; + } } - public static class DocString { + public static class DocString implements Serializable { public Location location; public String mediaType; public String content; public String delimiter; + public DocString(Location location, String mediaType, String content, String delimiter) { + this.location = location; + this.mediaType = mediaType; + this.content = content; + this.delimiter = delimiter; + } } - public static class Scenario { + public static class Scenario implements Serializable { public Location location; public java.util.List tags; public String keyword; @@ -101,9 +179,20 @@ public static class Scenario { public java.util.List steps; public java.util.List examples; public String id; + public Scenario(Location location, List tags, String keyword, String name, String description, + List steps, List examples, String id) { + this.location = location; + this.tags = tags; + this.keyword = keyword; + this.name = name; + this.description = description; + this.steps = steps; + this.examples = examples; + this.id = id; + } } - public static class Examples { + public static class Examples implements Serializable { public Location location; public java.util.List tags; public String keyword; @@ -112,5 +201,22 @@ public static class Examples { public TableRow tableHeader; public java.util.List tableBody; public String id; + public Examples(Location location, List tags, String keyword, String name, String description, + TableRow tableHeader, List tableBody, String id) { + this.location = location; + this.tags = tags; + this.keyword = keyword; + this.name = name; + this.description = description; + this.tableHeader = tableHeader; + this.tableBody = tableBody; + this.id = id; + } + } + + public GherkinDocument(String uri, Feature feature, List comments) { + this.uri = uri; + this.feature = feature; + this.comments = comments; } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java index 3ab43734..eabff0ba 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Hook.java @@ -1,8 +1,16 @@ package io.cucumber.eclipse.java.plugins.dto; -public class Hook { +import java.io.Serializable; + +public class Hook implements Serializable{ public String id; public String name; public SourceReference sourceReference; public String tagExpression; + public Hook(String id, String name, SourceReference sourceReference, String tagExpression) { + this.id = id; + this.name = name; + this.sourceReference = sourceReference; + this.tagExpression = tagExpression; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java index dbbdef82..dc2f19b1 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Location.java @@ -1,6 +1,12 @@ package io.cucumber.eclipse.java.plugins.dto; -public class Location { +import java.io.Serializable; + +public class Location implements Serializable { public Long line; public Long column; + public Location(Long line, Long column) { + this.line = line; + this.column = column; + } } \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java index 3750e161..9626195e 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Meta.java @@ -1,6 +1,8 @@ package io.cucumber.eclipse.java.plugins.dto; -public class Meta { +import java.io.Serializable; + +public class Meta implements Serializable{ public String protocolVersion; public Product implementation; public Product runtime; @@ -8,22 +10,48 @@ public class Meta { public Product cpu; public Ci ci; - public static class Ci { + public static class Ci implements Serializable{ public String name; public String url; public String buildNumber; public Git git; + public Ci(String name, String url, String buildNumber, Git git) { + this.name = name; + this.url = url; + this.buildNumber = buildNumber; + this.git = git; + } } - public static class Git { + public static class Git implements Serializable{ public String remote; public String revision; public String branch; public String tag; + public Git(String remote, String revision, String branch, String tag) { + this.remote = remote; + this.revision = revision; + this.branch = branch; + this.tag = tag; + } } - public final class Product { + public static class Product implements Serializable{ public String name; public String version; + + public Product(String name, String version) { + this.name = name; + this.version = version; + } + } + + public Meta(String protocolVersion, Product implementation, Product runtime, Product os, Product cpu, Ci ci) { + this.protocolVersion = protocolVersion; + this.implementation = implementation; + this.runtime = runtime; + this.os = os; + this.cpu = cpu; + this.ci = ci; } } \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java index ac5bda7a..c0bb2a69 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParameterType.java @@ -1,11 +1,22 @@ package io.cucumber.eclipse.java.plugins.dto; -public class ParameterType { +import java.io.Serializable; +import java.util.List; + +public class ParameterType implements Serializable{ public String name; public java.util.List regularExpressions; public Boolean preferForRegularExpressionMatch; public Boolean useForSnippets; public String id; + public ParameterType(String name, List regularExpressions, Boolean preferForRegularExpressionMatch, + Boolean useForSnippets, String id) { + this.name = name; + this.regularExpressions = regularExpressions; + this.preferForRegularExpressionMatch = preferForRegularExpressionMatch; + this.useForSnippets = useForSnippets; + this.id = id; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java index 43a6ffc0..6c71f74c 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/ParseError.java @@ -1,6 +1,12 @@ package io.cucumber.eclipse.java.plugins.dto; -public class ParseError { +import java.io.Serializable; + +public class ParseError implements Serializable { public SourceReference source; public String message; + public ParseError(SourceReference source, String message) { + this.source = source; + this.message = message; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java index 10b95134..231ca72d 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Pickle.java @@ -1,6 +1,9 @@ package io.cucumber.eclipse.java.plugins.dto; -public class Pickle { +import java.io.Serializable; +import java.util.List; + +public class Pickle implements Serializable{ public String id; public String uri; @@ -11,37 +14,78 @@ public class Pickle { public java.util.List astNodeIds; - public static class PickleStep { + public static class PickleStep implements Serializable{ public PickleStepArgument argument; public java.util.List astNodeIds; public String id; public String text; + public PickleStep(PickleStepArgument argument, List astNodeIds, String id, String text) { + this.argument = argument; + this.astNodeIds = astNodeIds; + this.id = id; + this.text = text; + } } - public static class PickleStepArgument { + public static class PickleStepArgument implements Serializable { public PickleDocString docString; public PickleTable dataTable; + public PickleStepArgument(PickleDocString docString, PickleTable dataTable) { + this.docString = docString; + this.dataTable = dataTable; + } } - public static class PickleDocString { + public static class PickleDocString implements Serializable{ public String mediaType; public String content; + public PickleDocString(String mediaType, String content) { + this.mediaType = mediaType; + this.content = content; + } } - public static class PickleTable { + public static class PickleTable implements Serializable{ public java.util.List rows; + + public PickleTable(List rows) { + this.rows = rows; + } } - public static class PickleTableRow { + public static class PickleTableRow implements Serializable { public java.util.List cells; + + public PickleTableRow(List cells) { + this.cells = cells; + } } - public static class PickleTableCell { + public static class PickleTableCell implements Serializable{ public String value; + + public PickleTableCell(String value) { + this.value = value; + } } - public static class PickleTag { + public static class PickleTag implements Serializable{ public String name; public String astNodeId; + public PickleTag(String name, String astNodeId) { + this.name = name; + this.astNodeId = astNodeId; + } } + + public Pickle(String id, String uri, String name, String language, List steps, List tags, + List astNodeIds) { + this.id = id; + this.uri = uri; + this.name = name; + this.language = language; + this.steps = steps; + this.tags = tags; + this.astNodeIds = astNodeIds; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java index 5d112cb0..dabeeed9 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Source.java @@ -1,9 +1,16 @@ package io.cucumber.eclipse.java.plugins.dto; +import java.io.Serializable; + import io.cucumber.messages.types.SourceMediaType; -public class Source { +public class Source implements Serializable { public String uri; public String data; public SourceMediaType mediaType; + public Source(String uri, String data, SourceMediaType mediaType) { + this.uri = uri; + this.data = data; + this.mediaType = mediaType; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java index 95861086..05d1c250 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/SourceReference.java @@ -1,21 +1,42 @@ package io.cucumber.eclipse.java.plugins.dto; - public class SourceReference { +import java.io.Serializable; +import java.util.List; + +public class SourceReference implements Serializable{ public String uri; public JavaMethod javaMethod; public JavaStackTraceElement javaStackTraceElement; public Location location; - public static class JavaMethod { + public static class JavaMethod implements Serializable{ public String className; public String methodName; public java.util.List methodParameterTypes; + public JavaMethod(String className, String methodName, List methodParameterTypes) { + this.className = className; + this.methodName = methodName; + this.methodParameterTypes = methodParameterTypes; + } } - public final class JavaStackTraceElement { + public static class JavaStackTraceElement implements Serializable{ public String className; public String fileName; public String methodName; + public JavaStackTraceElement(String className, String fileName, String methodName) { + this.className = className; + this.fileName = fileName; + this.methodName = methodName; + } } + + public SourceReference(String uri, JavaMethod javaMethod, JavaStackTraceElement javaStackTraceElement, + Location location) { + this.uri = uri; + this.javaMethod = javaMethod; + this.javaStackTraceElement = javaStackTraceElement; + this.location = location; + } } \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java index 3bc88957..93351986 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/StepDefinition.java @@ -1,14 +1,26 @@ package io.cucumber.eclipse.java.plugins.dto; +import java.io.Serializable; + import io.cucumber.messages.types.StepDefinitionPatternType; -public class StepDefinition { +public class StepDefinition implements Serializable{ public String id; public StepDefinitionPattern pattern; public SourceReference sourceReference; - public static class StepDefinitionPattern { + public static class StepDefinitionPattern implements Serializable{ public String source; public StepDefinitionPatternType type; + public StepDefinitionPattern(String source, StepDefinitionPatternType type) { + this.source = source; + this.type = type; + } } + + public StepDefinition(String id, StepDefinitionPattern pattern, SourceReference sourceReference) { + this.id = id; + this.pattern = pattern; + this.sourceReference = sourceReference; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java index 4cdb5066..25cdf20f 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCase.java @@ -1,31 +1,60 @@ package io.cucumber.eclipse.java.plugins.dto; +import java.io.Serializable; +import java.util.List; -public class TestCase { +public class TestCase implements Serializable{ public String id; public String pickleId; public java.util.List testSteps; - public static class TestStep { + public static class TestStep implements Serializable { public String hookId; public String id; public String pickleStepId; public java.util.List stepDefinitionIds; public java.util.List stepMatchArgumentsLists; + public TestStep(String hookId, String id, String pickleStepId, List stepDefinitionIds, + List stepMatchArgumentsLists) { + this.hookId = hookId; + this.id = id; + this.pickleStepId = pickleStepId; + this.stepDefinitionIds = stepDefinitionIds; + this.stepMatchArgumentsLists = stepMatchArgumentsLists; + } } - public static class StepMatchArgumentsList { + public static class StepMatchArgumentsList implements Serializable { public java.util.List stepMatchArguments; + + public StepMatchArgumentsList(List stepMatchArguments) { + this.stepMatchArguments = stepMatchArguments; + } } - public static class StepMatchArgument { + public static class StepMatchArgument implements Serializable{ public Group group; public String parameterTypeName; + public StepMatchArgument(Group group, String parameterTypeName) { + this.group = group; + this.parameterTypeName = parameterTypeName; + } } - public static class Group { + public static class Group implements Serializable{ public java.util.List children; public Long start; public String value; + public Group(List children, Long start, String value) { + this.children = children; + this.start = start; + this.value = value; + } } + + public TestCase(String id, String pickleId, List testSteps) { + this.id = id; + this.pickleId = pickleId; + this.testSteps = testSteps; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java index 4c74fcff..bf648cca 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseFinished.java @@ -1,10 +1,16 @@ package io.cucumber.eclipse.java.plugins.dto; +import java.io.Serializable; -public class TestCaseFinished { +public class TestCaseFinished implements Serializable { public String testCaseStartedId; public Timestamp timestamp; public Boolean willBeRetried; + public TestCaseFinished(String testCaseStartedId, Timestamp timestamp, Boolean willBeRetried) { + this.testCaseStartedId = testCaseStartedId; + this.timestamp = timestamp; + this.willBeRetried = willBeRetried; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java index 567e1dee..382c01a1 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestCaseStarted.java @@ -1,8 +1,16 @@ package io.cucumber.eclipse.java.plugins.dto; -public class TestCaseStarted { +import java.io.Serializable; + +public class TestCaseStarted implements Serializable{ public Long attempt; public String id; public String testCaseId; public Timestamp timestamp; + public TestCaseStarted(Long attempt, String id, String testCaseId, Timestamp timestamp) { + this.attempt = attempt; + this.id = id; + this.testCaseId = testCaseId; + this.timestamp = timestamp; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java index 1f73d4b5..87ef8bdd 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunFinished.java @@ -1,9 +1,16 @@ package io.cucumber.eclipse.java.plugins.dto; -public class TestRunFinished { +import java.io.Serializable; + +public class TestRunFinished implements Serializable { public String message; public Boolean success; public Timestamp timestamp; + public TestRunFinished(String message, Boolean success, Timestamp timestamp) { + this.message = message; + this.success = success; + this.timestamp = timestamp; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java index b437791b..e4609b82 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestRunStarted.java @@ -1,7 +1,13 @@ package io.cucumber.eclipse.java.plugins.dto; -public class TestRunStarted { +import java.io.Serializable; + +public class TestRunStarted implements Serializable { public Timestamp timestamp; + public TestRunStarted(Timestamp timestamp) { + this.timestamp = timestamp; + } + } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java index 236f7511..ac7c9c01 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepFinished.java @@ -1,17 +1,32 @@ package io.cucumber.eclipse.java.plugins.dto; +import java.io.Serializable; + import io.cucumber.messages.types.TestStepResultStatus; -public class TestStepFinished { +public class TestStepFinished implements Serializable { public String testCaseStartedId; public String testStepId; public TestStepResult testStepResult; public Timestamp timestamp; - public static class TestStepResult { + public static class TestStepResult implements Serializable { public Duration duration; public String message; public TestStepResultStatus status; + public TestStepResult(Duration duration, String message, TestStepResultStatus status) { + this.duration = duration; + this.message = message; + this.status = status; + } } + + public TestStepFinished(String testCaseStartedId, String testStepId, TestStepResult testStepResult, + Timestamp timestamp) { + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.testStepResult = testStepResult; + this.timestamp = timestamp; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java index 8e8a025a..166a642f 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/TestStepStarted.java @@ -1,10 +1,16 @@ package io.cucumber.eclipse.java.plugins.dto; +import java.io.Serializable; -public class TestStepStarted { +public class TestStepStarted implements Serializable{ public String testCaseStartedId; public String testStepId; public Timestamp timestamp; + public TestStepStarted(String testCaseStartedId, String testStepId, Timestamp timestamp) { + this.testCaseStartedId = testCaseStartedId; + this.testStepId = testStepId; + this.timestamp = timestamp; + } } diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java index c9c3efc3..9c7a6a14 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/Timestamp.java @@ -1,5 +1,12 @@ package io.cucumber.eclipse.java.plugins.dto; -public class Timestamp { + +import java.io.Serializable; + +public class Timestamp implements Serializable { public Long seconds; public Long nanos; + public Timestamp(Long seconds, Long nanos) { + this.seconds = seconds; + this.nanos = nanos; + } } \ No newline at end of file diff --git a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java index 93dbfef5..97fa720d 100644 --- a/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java +++ b/io.cucumber.eclipse.java.plugins/src/io/cucumber/eclipse/java/plugins/dto/UndefinedParameterType.java @@ -1,9 +1,16 @@ package io.cucumber.eclipse.java.plugins.dto; -public class UndefinedParameterType { +import java.io.Serializable; + +public class UndefinedParameterType implements Serializable{ public String expression; public String name; + + public UndefinedParameterType(String expression, String name) { + this.expression = expression; + this.name = name; + } } diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberFeatureLocalApplicationLaunchConfigurationDelegate.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberFeatureLocalApplicationLaunchConfigurationDelegate.java index 0bf79bc2..6a635723 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberFeatureLocalApplicationLaunchConfigurationDelegate.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberFeatureLocalApplicationLaunchConfigurationDelegate.java @@ -44,7 +44,7 @@ import io.cucumber.eclipse.editor.document.TestStepEvent; import io.cucumber.eclipse.editor.launching.ILauncher.Mode; import io.cucumber.eclipse.java.JDTUtil; -import io.cucumber.eclipse.java.plugins.CucumberEclipsePlugin; +import io.cucumber.eclipse.java.plugins.Cucumber7EclipsePlugin; import io.cucumber.eclipse.java.runtime.CucumberRuntime; import io.cucumber.tagexpressions.Expression; import mnita.ansiconsole.preferences.AnsiConsolePreferenceUtils; @@ -268,7 +268,7 @@ private void runEmbedded(ILaunchConfiguration config, String mode, ILaunch launc private VMRunnerConfiguration createRunConfig(String[][] classpathAndModules) { List classPath = new ArrayList<>(Arrays.asList(classpathAndModules[0])); try { - File file = FileLocator.getBundleFile(FrameworkUtil.getBundle(CucumberEclipsePlugin.class)); + File file = FileLocator.getBundleFile(FrameworkUtil.getBundle(Cucumber7EclipsePlugin.class)); if (file != null) { if (file.isDirectory() && !new File(file, "io").exists()) { // try to get the path for the IDE... diff --git a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java index 737d0c52..ed1a051f 100644 --- a/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java +++ b/io.cucumber.eclipse.java/src/io/cucumber/eclipse/java/launching/CucumberRuntimeLauncher.java @@ -38,7 +38,7 @@ import io.cucumber.eclipse.editor.document.GherkinEditorDocument; import io.cucumber.eclipse.editor.launching.ILauncher; import io.cucumber.eclipse.java.JDTUtil; -import io.cucumber.eclipse.java.plugins.CucumberEclipsePlugin; +import io.cucumber.eclipse.java.plugins.Cucumber7EclipsePlugin; import io.cucumber.eclipse.java.runtime.CucumberRuntime; import io.cucumber.messages.types.Envelope; import io.cucumber.messages.types.GherkinDocument; @@ -138,7 +138,7 @@ public static void runFeaturesEmbedded(IJavaProject javaProject, List f Collection featureFilter, Mode mode, CucumberConsole console, IProgressMonitor monitor, Collection tagFilters) throws CoreException { try (CucumberRuntime cucumberRuntime = CucumberRuntime.create(javaProject)) { - CucumberEclipsePlugin plugin = new CucumberEclipsePlugin(new Consumer() { + Cucumber7EclipsePlugin plugin = new Cucumber7EclipsePlugin(new Consumer() { private Map map = new HashMap<>(); private GherkinDocument gherkinDocument; From 0dc681f630b67ab93b079d05f77cca584a60f52b Mon Sep 17 00:00:00 2001 From: FilippoR Date: Tue, 31 May 2022 21:19:02 +0200 Subject: [PATCH 9/9] fix target --- .../cucumber.eclipse.targetdefinition.target | 84 +++++++++++++------ 1 file changed, 58 insertions(+), 26 deletions(-) diff --git a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target index 22d338f9..3fd5280a 100644 --- a/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target +++ b/io.cucumber.eclipse.targetdefinition/cucumber.eclipse.targetdefinition.target @@ -29,76 +29,108 @@ - + + + + + + io.cucumber gherkin 23.0.1 jar - + + +Import-Package: !io.cucumber.cienvironment*,!sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Export-Package: *;version="${version}";-noimport:=true +]]> - + + + io.cucumber cucumber-java 7.3.4 jar - + + +Import-Package: !io.cucumber.cienvironment*,!sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Export-Package: *;version="${version}";-noimport:=true +]]> - + + + io.cucumber cucumber-core 7.3.4 jar - + + +Import-Package: !io.cucumber.cienvironment*,!sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Export-Package: *;version="${version}";-noimport:=true +]]> - - + + + io.cucumber cucumber-expressions 15.2.0 jar - + + +Import-Package: !io.cucumber.cienvironment*,!sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Export-Package: *;version="${version}";-noimport:=true +]]> - + + + org.apache.commons commons-text 1.9 jar + + - - - - - + + + io.cucumber create-meta 6.0.4 jar - + + +Import-Package: !io.cucumber.cienvironment*,!sun.*,!io.cucumber.messages.internal.*,!org.checkerframework.*,* +Export-Package: *;version="${version}";-noimport:=true +]]> \ No newline at end of file