In MediaTypeAssert, we have both isEqualTo(Object) and isEqualTo(String), but only isNotEqualTo(Object). The later is inherited from AbstractAssert.

As a String is never equal to a MediaType, the following test appears to pass but it does for the wrong reasons (false negative):

@Test
void isNotEqualWhenDifferentShouldPass() {
    assertThat(mediaType("application/json")).isNotEqualTo(MediaType.TEXT_HTML_VALUE);
}

To make the issue more evident, one can try the following test instead, which doesn't pass with the current implementation:

@Test
void isNotEqualWhenSameShouldFail() {
    assertThatExceptionOfType(AssertionError.class)
            .isThrownBy(() -> assertThat(mediaType("application/json")).isNotEqualTo(MediaType.APPLICATION_JSON_VALUE))
            .withMessageContaining("Media type");
}

(note that isNotEqual isn't currently tested in MediaTypeAssertTests, such tests should be added as part of fixing this issue)

Comment From: simonbasle

Note that this is also the case for ResponseBodyAssert#isEqualTo(String) but this is a bit different as the method is a shortcut for .asString().isEqualTo(String).

Comment From: simonbasle

edit: I went with introducing isNotEqualTo(String) after all, hiding this as resolved.

We should consider if the issue stems from the naming of isEqualTo(String). This method's intention is to parse the provided String and compare it to the actual MediaType. As such it could be named slightly differently in order to avoid confusion with common AbstractAssert assertions.

For instance: isEqualToValueOf(String).

In that case, we can probably defer the introduction of an opposite isNotEqualToValueOf method until we get feedback that this would actually be useful.