Skip to content

Use more specific AssertJ MapAssert for return of JsonContentAssert#extractingJsonPathMapValue #9650

@filiphr

Description

@filiphr

The method JsonContentAssert#extractingJsonPathMap returns AbstractMapAssert. However, the call to AssertJ returns MapAssert.

This causes compiler warnings like:

uses unchecked or unsafe operations

With Xlint it shows:

unchecked generic array creation for varargs parameter of type java.util.Map.Entry<? extends java.lang.Object,? extends java.lang.Object>[]

The more specific MapAssert has final methods annotated with @SafeVarargs which won't show the warning.

As an alternative there can be spring boot MapAssert that will extend from the AssertJ AbstractMapAssert that will make the methods as final and annotated them with @SafeVarargs.

The reason why AssertJ has those Abstract assert classes that are not annotated is for the support of soft assertions (that are done by using proxies).

See assertj/assertj#1017 for more information as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions