webcompere / model-assert

Assertions for data models
MIT License
29 stars 3 forks source link

Assertions with `InputStream` #40

Open ashleyfrieze opened 3 years ago

ashleyfrieze commented 3 years ago

Summary

Should be able to assert using InputStream of JSON as either actual or expected

deepakab03 commented 2 years ago

This would be very useful to read files from classpath.. otherwise how would we read such files?

ashleyfrieze commented 2 years ago

Generally, in tests, you have access to Paths.get("src", "test", "resources") so it's easy to read test resources.

isEqualTo supports various types of expected object https://github.com/webcompere/model-assert/blob/main/src/main/java/uk/org/webcompere/modelassert/json/dsl/nodespecific/tree/IsEqualToDsl.java

Your general escape hatch with assertJson is to first convert things into JsonNode use Jackson any way you like, and then use assertJson(jsonNode).isEqualTo(expectedJsonNode) or similar.

However, I can see that InputStream and maybe even a classpath option would enhance the library.

ashleyfrieze commented 2 months ago

Note: please upvote this if you would find it useful.