Invalid transformation of assertThat(map.get(key)).usingRecursiveComparison().isEqualTo(value) #3

Closed
opened 2021-02-05 16:39:26 +01:00 by hankem · 2 comments
hankem commented 2021-02-05 16:39:26 +01:00 (Migrated from github.com)

Hi @chrisly42,

first of all, thank you so much for this plugin, which I find extremely nice and useful! 💙

This is to let you know that I today noticed (for the first time, by the way! 👍) an invalid transformation in the following case:

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

class AssertMapEntryUsingRecursiveComparisonTest {
    @org.junit.jupiter.api.Test
    void usingRecursiveComparison() {
        Map<String, DTO> map = Map.of("1", new DTO(1, "one"));

        assertThat(map).containsOnlyKeys("1");
        assertThat(map.get("1")).usingRecursiveComparison().isEqualTo(new DTO(1, "one"));
    }

    static class DTO {  // doesn't implement equals based on fields
        final int i;
        final String s;

        DTO(int i, String s) {
            this.i = i;
            this.s = s;
        }
    }
}

Cajon v1.11 replaces

assertThat(map.get(key)).usingRecursiveComparison().isEqualTo(value)

with

assertThat(map).usingRecursiveComparison().containsEntry(key, value)

– which doesn't work with the current version org.assertj:assertj-core:3.19.0.

Vielen Dank und schöne Grüße, 😉

Manfred

Hi @chrisly42, first of all, thank you so much for this plugin, which I find extremely nice and useful! 💙 This is to let you know that I today noticed (for the first time, by the way! 👍) an invalid transformation in the following case: ```java import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; class AssertMapEntryUsingRecursiveComparisonTest { @org.junit.jupiter.api.Test void usingRecursiveComparison() { Map<String, DTO> map = Map.of("1", new DTO(1, "one")); assertThat(map).containsOnlyKeys("1"); assertThat(map.get("1")).usingRecursiveComparison().isEqualTo(new DTO(1, "one")); } static class DTO { // doesn't implement equals based on fields final int i; final String s; DTO(int i, String s) { this.i = i; this.s = s; } } } ``` Cajon v1.11 replaces ```java assertThat(map.get(key)).usingRecursiveComparison().isEqualTo(value) ``` with ```java assertThat(map).usingRecursiveComparison().containsEntry(key, value) ``` – which doesn't work with the current version `org.assertj`:`assertj-core`:`3.19.0`. Vielen Dank und schöne Grüße, 😉 Manfred
chrisly42 commented 2021-02-05 18:09:58 +01:00 (Migrated from github.com)

Dear Manfred,

long time no see :) I hope you are well. You are perfectly right about this issue, and I will fix it as soon as possible.

Cheers,

Chris

Dear Manfred, long time no see :) I hope you are well. You are perfectly right about this issue, and I will fix it as soon as possible. Cheers, Chris
chrisly42 commented 2021-05-06 12:54:10 +02:00 (Migrated from github.com)

Fixed with V1.12

Fixed with V1.12
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: chrisly42/cajon-plugin#3