Giter Site home page Giter Site logo

More fluent Map assertions about assertj HOT 4 CLOSED

assertj avatar assertj commented on July 20, 2024
More fluent Map assertions

from assertj.

Comments (4)

pbetkier avatar pbetkier commented on July 20, 2024

I'm currently working on this one, but I'm not sure what are the semantics of the API proposed:

.valueForKey("key2").doesNotExist()

What does it mean that a value doesn't exist for a given key? That it's set to null? Or that the key does not exist in the map?

Perhaps .valueForKey("key2").isNull() would be more explicit?

from assertj.

joel-costigliola avatar joel-costigliola commented on July 20, 2024

My thoughts:

  • some Map can have a null value for a given key, thus we should have both doesNotExist and isNull.
  • if given key does not exist we should throw an AssertionError since we expect it to exist.

from assertj.

pbetkier avatar pbetkier commented on July 20, 2024

It would be best if valueForKey method could return a subclass of AbstractAssert in context of the actual value for key. The tough part though is making assertion methods of this subclass return earlier MapAssert instead of itself.

From what I see in the code this is currently not possible without same major changes in AbstractAssert. Do you recall having such problem solved somewhere in the code base already?

An alternative is not to subclass AbstractAssert for value assertions, but provide a couple of basic assertions on their own, like isEqualTo, isNotEqualTo, isNull, and make them return MapAssert. This would not be as powerful, but would be least invasive.

from assertj.

joel-costigliola avatar joel-costigliola commented on July 20, 2024

Closing this because of #690 and #691.

from assertj.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.