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

Provide a way back to JsonAssert from JsonMapAssert #560

Closed
chrylis opened this issue Sep 29, 2022 · 4 comments
Closed

Provide a way back to JsonAssert from JsonMapAssert #560

chrylis opened this issue Sep 29, 2022 · 4 comments

Comments

@chrylis
Copy link

chrylis commented Sep 29, 2022

In the AssertJ API, I can use this arrangement to assert individual elements of an object node:

assertThatJson(json)
  .inPath('$.data')
  .isObject()
  .containsEntry('id', '1234')

However, I'm then at a dead end. I would like to descend the path of the document and make some more checks:

assertThatJson(json)
  .inPath('$.data')
  .isObject()
  .containsEntry('id', '1234')
  .node('relationships')
  .isObject()
  ...

However, the isObject() call returns a JsonMapAssert, which is terminal. It would be convenient to have a method on it similar to the and() of most nesting Spring builders that would let me get back to the JsonAssert, and/or a node method on JsonMapAssert that would do the same thing with a parameter (supporting node('.'))?

Right now, I can build assertion trees similar to the second one above using and, but it ends up with multiple levels of nested calls when a single linear sequence would be adequate.

@lukas-krecan
Copy link
Owner

Hi, thanks for feedback, I will look into it.

@lukas-krecan
Copy link
Owner

Hi, would this be enough for your use case?

@chrylis
Copy link
Author

chrylis commented Oct 4, 2022

This looks like it would do it, yes!

@lukas-krecan
Copy link
Owner

Releasing as 2.36.0

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

No branches or pull requests

2 participants