Skip to content

Commit

Permalink
make dto final
Browse files Browse the repository at this point in the history
  • Loading branch information
FilippoR committed Jun 9, 2022
1 parent 0808184 commit 8f7f196
Show file tree
Hide file tree
Showing 23 changed files with 218 additions and 201 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.cucumber.messages.types.RuleChild;
import io.cucumber.messages.types.Scenario;
import io.cucumber.messages.types.Source;
import io.cucumber.messages.types.SourceMediaType;
import io.cucumber.messages.types.SourceReference;
import io.cucumber.messages.types.Step;
import io.cucumber.messages.types.StepDefinition;
Expand Down Expand Up @@ -310,10 +311,15 @@ public static Attachment convert(io.cucumber.eclipse.java.plugins.dto.Attachment
return null;
return new Attachment(d.body,
AttachmentContentEncoding.fromValue(d.contentEncoding),
d.fileName, d.mediaType, convert(d.source),
d.fileName, d.mediaType, convert1(d.source),
d.testCaseStartedId, d.testStepId, d.url);
}

private static Source convert1(io.cucumber.eclipse.java.plugins.dto.SourceReference d) {
// TODO Auto-generated method stub
return new Source(d.uri, d.javaMethod.methodName, null);
}

public static Comment convert(io.cucumber.eclipse.java.plugins.dto.GherkinDocument.Comment d) {
if (d == null)
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ 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),
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),
Expand Down Expand Up @@ -212,7 +211,8 @@ public static Source convert(io.cucumber.messages.types.Source d) {
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),
return new Pickle(d.getId(), d.getUri(), d.getName(), d.getLanguage(),
convertList(d.getSteps(), MessageToDtoConverter::convert),
convertList(d.getTags(), MessageToDtoConverter::convert), d.getAstNodeIds());
}

Expand All @@ -225,7 +225,8 @@ public static PickleTag convert(io.cucumber.messages.types.PickleTag d) {
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.getType().map(PickleStepType::value).orElse(null)*/null, d.getText());
return new PickleStep(convert(d.getArgument().orElse(null)), d.getAstNodeIds(), d.getId(),
/* d.getType().map(PickleStepType::value).orElse(null) */null, d.getText());
}

public static PickleStepArgument convert(io.cucumber.messages.types.PickleStepArgument d) {
Expand Down Expand Up @@ -267,21 +268,22 @@ public static ParseError convert(io.cucumber.messages.types.ParseError d) {
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());
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)));
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)));
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) {
Expand All @@ -299,13 +301,15 @@ public static Product convert(io.cucumber.messages.types.Product d) {
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));
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)));
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) {
Expand All @@ -323,8 +327,15 @@ public static JavaStackTraceElement convert(io.cucumber.messages.types.JavaStack
public static Attachment convert(io.cucumber.messages.types.Attachment d) {
if (d == null)
return null;
return new Attachment(d.getBody(), d.getContentEncoding().value(), d.getFileName().orElse(null), d.getMediaType(), convert(d.getSource().orElse(null)),
d.getTestCaseStartedId().orElse(null), d.getTestStepId().orElse(null), d.getUrl().orElse(null));
return new Attachment(d.getBody(), d.getContentEncoding().value(), d.getFileName().orElse(null),
d.getMediaType(), convert1(d.getSource().orElse(null)), d.getTestCaseStartedId().orElse(null),
d.getTestStepId().orElse(null), d.getUrl().orElse(null));
}

private static SourceReference convert1(io.cucumber.messages.types.Source d) {
if (d == null)
return null;
return new SourceReference(d.getUri(), null, null, null);
}

public static Comment convert(io.cucumber.messages.types.Comment d) {
Expand All @@ -336,8 +347,8 @@ public static Comment convert(io.cucumber.messages.types.Comment d) {
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(),
return new Feature(convert(d.getLocation()), convertList(d.getTags(), MessageToDtoConverter::convert),
d.getLanguage(), d.getKeyword(), d.getName(), d.getDescription(),
convertList(d.getChildren(), MessageToDtoConverter::convert));
}

Expand All @@ -357,25 +368,25 @@ public static FeatureChild convert(io.cucumber.messages.types.FeatureChild d) {
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(),
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());
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(),
return new Rule(convert(d.getLocation()), convertList(d.getTags(), MessageToDtoConverter::convert),
d.getKeyword(), d.getName(), d.getDescription(),
convertList(d.getChildren(), MessageToDtoConverter::convert), d.getId());
}

Expand All @@ -396,8 +407,9 @@ public static Background convert(io.cucumber.messages.types.Background d) {
public static Step convert(io.cucumber.messages.types.Step d) {
if (d == null)
return null;
return new Step(convert(d.getLocation()), d.getKeyword(),/*d.getKeywordType().map(t->t.value()).orElse(null)*/null, d.getText(), convert(d.getDocString().orElse(null)),
convert(d.getDataTable().orElse(null)), d.getId());
return new Step(convert(d.getLocation()), d.getKeyword(),
/* d.getKeywordType().map(t->t.value()).orElse(null) */null, d.getText(),
convert(d.getDocString().orElse(null)), convert(d.getDataTable().orElse(null)), d.getId());
}

public static DocString convert(io.cucumber.messages.types.DocString d) {
Expand All @@ -409,15 +421,14 @@ public static DocString convert(io.cucumber.messages.types.DocString d) {
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));
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());
return new TableRow(convert(d.getLocation()), convertList(d.getCells(), MessageToDtoConverter::convert),
d.getId());
}

public static TableCell convert(io.cucumber.messages.types.TableCell d) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@


public class Attachment implements Serializable{
public String body;
public String contentEncoding;
public String fileName;
public String mediaType;
public Source source;
public String testCaseStartedId;
public String testStepId;
public String url;
public final String body;
public final String contentEncoding;
public final String fileName;
public final String mediaType;
public final SourceReference source;
public final String testCaseStartedId;
public final String testStepId;
public final String url;
public Attachment(String body, String contentEncoding, String fileName, String mediaType,
Source source, String testCaseStartedId, String testStepId, String url) {
SourceReference source, String testCaseStartedId, String testStepId, String url) {
this.body = body;
this.contentEncoding = contentEncoding;
this.fileName = fileName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import java.io.Serializable;

public class Duration implements Serializable{
public Long seconds;
public Long nanos;
public final Long seconds;
public final Long nanos;
public Duration(Long seconds, Long nanos) {
this.seconds = seconds;
this.nanos = nanos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
import java.io.Serializable;

public final class Envelope implements Serializable{
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;
public final Attachment attachment;
public final GherkinDocument gherkinDocument;
public final Hook hook;
public final Meta meta;
public final ParameterType parameterType;
public final ParseError parseError;
public final Pickle pickle;
public final Source source;
public final StepDefinition stepDefinition;
public final TestCase testCase;
public final TestCaseFinished testCaseFinished;
public final TestCaseStarted testCaseStarted;
public final TestRunFinished testRunFinished;
public final TestRunStarted testRunStarted;
public final TestStepFinished testStepFinished;
public final TestStepStarted testStepStarted;
public final UndefinedParameterType undefinedParameterType;

public Envelope(Attachment attachment, GherkinDocument gherkinDocument, Hook hook, Meta meta,
ParameterType parameterType, ParseError parseError, Pickle pickle, Source source,
Expand Down
Loading

0 comments on commit 8f7f196

Please sign in to comment.