Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !2919

Java jaxrs test lineending fix

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/drl-max/java-jaxrs-test-lineending-fix into master 6 years ago
  • Overview 0
  • Commits 6
  • Pipelines 0
  • Changes 1

Created by: drl-max

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. If contributing template-only or documentation-only changes which will change sample output, be sure to build the project first.
  • Filed the PR against the correct branch: master, 4.1.x, 5.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

(details of the change, additional tests that have been done, reference to the issue for tracking, etc)

Fix for #2815 (closed)

I believe the issue stems from the Generator creating a file the uses the OS's line separator (\r\n for Windows users), but then the test is attempting to compare each line of that file with a version that has \n hard-coded as it's end-of-line character. Using Java's System.lineSeparator() method seems to address the issue and should allow for flexibility across any environment.

@wing328 - Please review and let me know if there is anything else I can do.

Compare
  • master (base)

and
  • latest version
    a6c1c97f
    6 commits, 2 years ago

1 file
+ 9
- 7

    Preferences

    File browser
    Compare changes
modules/openapi-generator/src/test/java/org/openapitools/codegen/java/jaxrs/JavaJaxrsBaseTest.java
+ 9
- 7
  • View file @ a6c1c97f


@@ -45,10 +45,11 @@ public abstract class JavaJaxrsBaseTest {
generator.opts(input).generate();
String eol = System.lineSeparator();
String jsonTypeInfo = "@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = \"className\", visible = true)";
String jsonSubType = "@JsonSubTypes({\n" +
" @JsonSubTypes.Type(value = Dog.class, name = \"Dog\"),\n" +
" @JsonSubTypes.Type(value = Cat.class, name = \"Cat\"),\n" +
String jsonSubType = "@JsonSubTypes({" + eol +
" @JsonSubTypes.Type(value = Dog.class, name = \"Dog\")," + eol +
" @JsonSubTypes.Type(value = Cat.class, name = \"Cat\")," + eol +
"})";
checkFileContains(generator, outputPath + "/src/gen/java/org/openapitools/model/Animal.java", jsonTypeInfo, jsonSubType);
}
@@ -56,7 +57,7 @@ public abstract class JavaJaxrsBaseTest {
private void checkFileContains(MockDefaultGenerator generator, String path, String... lines) {
String file = generator.getFiles().get(path);
assertNotNull(file);
for (String line : lines)
for (String line : lines)
assertTrue(file.contains(line));
}
@@ -83,10 +84,11 @@ public abstract class JavaJaxrsBaseTest {
generator.opts(input).generate();
String eol = System.lineSeparator();
String jsonTypeInfo = "@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = \"className\", visible = true)";
String jsonSubType = "@JsonSubTypes({\n" +
" @JsonSubTypes.Type(value = Dog.class, name = \"Dog\"),\n" +
" @JsonSubTypes.Type(value = Cat.class, name = \"Cat\"),\n" +
String jsonSubType = "@JsonSubTypes({" + eol +
" @JsonSubTypes.Type(value = Dog.class, name = \"Dog\")," + eol +
" @JsonSubTypes.Type(value = Cat.class, name = \"Cat\")," + eol +
"})";
checkFileNotContains(generator, outputPath + "/src/gen/java/org/openapitools/model/Animal.java", jsonTypeInfo, jsonSubType);
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
1
Enhancement: CI/Test
1
Enhancement: CI/Test
    Assign labels
  • Manage project labels

Milestone
3.0.2
3.0.2 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference: OpenAPITools/openapi-generator!319
Source branch: github/fork/drl-max/java-jaxrs-test-lineending-fix

Menu

Explore Projects Groups Snippets