Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breaking changes in Render contract #742

Merged
merged 3 commits into from
Feb 7, 2025
Merged

Fix breaking changes in Render contract #742

merged 3 commits into from
Feb 7, 2025

Conversation

DrSatyr
Copy link
Collaborator

@DrSatyr DrSatyr commented Feb 6, 2025

#741 fix

Copy link

@PawelWesolowski PawelWesolowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should return on the stream not the writer - sth like: return byteArrayOutputStream.toString();
not
return outputStreamWriter.toString();

I can fix and add a test.

@DrSatyr
Copy link
Collaborator Author

DrSatyr commented Feb 6, 2025

@PawelWesolowski you're absolutely right regarding the issue. I just left the testing to the evening, cause had no time.

Copy link

@PawelWesolowski PawelWesolowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome.
How about adding a test which is doing exactly what's in the docs? Sth like:

  @Test
  public void testDiffAndJsonWithoutProvidingStream() {
    ChangedOpenApi diff = OpenApiCompare.fromLocations(OPENAPI_DOC1, OPENAPI_DOC2);
    Render render = new JsonRender();
    String renderedAsString = render.render(diff);
    assertThat(renderedAsString).contains("\"newEndpoints\":");
  }

at OpenApiDiffTest.java

@DrSatyr
Copy link
Collaborator Author

DrSatyr commented Feb 7, 2025

Looks awesome. How about adding a test which is doing exactly what's in the docs? Sth like:

  @Test
  public void testDiffAndJsonWithoutProvidingStream() {
    ChangedOpenApi diff = OpenApiCompare.fromLocations(OPENAPI_DOC1, OPENAPI_DOC2);
    Render render = new JsonRender();
    String renderedAsString = render.render(diff);
    assertThat(renderedAsString).contains("\"newEndpoints\":");
  }

at OpenApiDiffTest.java

Each render has its own test class (eg JsonRenderTest), and they are doing pretty much the same as in doc (I've updated Readme to conform to the new approach, the old one is deprecated and can lead to issues)

@PawelWesolowski
Copy link

Looks awesome. How about adding a test which is doing exactly what's in the docs? Sth like:

  @Test
  public void testDiffAndJsonWithoutProvidingStream() {
    ChangedOpenApi diff = OpenApiCompare.fromLocations(OPENAPI_DOC1, OPENAPI_DOC2);
    Render render = new JsonRender();
    String renderedAsString = render.render(diff);
    assertThat(renderedAsString).contains("\"newEndpoints\":");
  }

at OpenApiDiffTest.java

Each render has its own test class (eg JsonRenderTest), and they are doing pretty much the same as in doc.

None of them failed after the first commit on this fix. The one I suggested did.

@DrSatyr
Copy link
Collaborator Author

DrSatyr commented Feb 7, 2025

Looks awesome. How about adding a test which is doing exactly what's in the docs? Sth like:

  @Test
  public void testDiffAndJsonWithoutProvidingStream() {
    ChangedOpenApi diff = OpenApiCompare.fromLocations(OPENAPI_DOC1, OPENAPI_DOC2);
    Render render = new JsonRender();
    String renderedAsString = render.render(diff);
    assertThat(renderedAsString).contains("\"newEndpoints\":");
  }

at OpenApiDiffTest.java

Each render has its own test class (eg JsonRenderTest), and they are doing pretty much the same as in doc.

None of them failed after the first commit on this fix. The one I suggested did.

Yep, because this tests cover new approach (with stream, it's also in documentation). To cover deprecated approach I've added RenderTest to test default method of the interface, instead of doing testing for each render implementation.

@DrSatyr DrSatyr self-assigned this Feb 7, 2025
@DrSatyr DrSatyr merged commit 1987575 into master Feb 7, 2025
6 checks passed
@DrSatyr DrSatyr deleted the issue_741 branch February 7, 2025 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants