Skip to content

Document using AssertJ's satisfies together with extractingJsonPathNumberValue #16229

@wimdeblauwe

Description

@wimdeblauwe

I am using extractingJsonPathNumberValue to test a double value in my JSON:

 assertThat(json.write(message))
   .extractingJsonPathNumberValue("@.stopTime.percentage").isEqualTo(0.16666666666666666)

However, this does not work because of different types:

org.opentest4j.AssertionFailedError:
Expecting:
<"0.16666666666666666 (BigDecimal@1c52552f)">
to be equal to:
<"0.16666666666666666 (Double@5dc769f9)">
but was not.
Expected :0.16666666666666666
Actual :0.16666666666666666

What is the recommended way to do this? Should there be other methods like extractingJsonPathDoubleValue or extractingJsonPathFloatValue that could return DoubleAssert or FloatAssert so that methods like isCloseTo can be used?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions