FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bugfix when handling array by wenhoujx · Pull Request #97 · java-json-tools/json-patch · GitHub

bugfix when handling array - #97

Open
wenhoujx wants to merge 1 commit into
java-json-tools:masterfrom
wenhoujx:master
Open

bugfix when handling array#97
wenhoujx wants to merge 1 commit into
java-json-tools:masterfrom
wenhoujx:master

Conversation

wenhoujx commented Apr 6, 2021
edited
Loading

Copy link
Copy Markdown

there is a bug that all the operations in diffs are stateful in the sense that their operation depends on the operations before them.

The remove and add case breaks the diffs order b/c it removes and add to the end of diffs.

repro:

    @Test
    void testJsonPatchBug() throws JsonProcessingException, JsonPatchException {
        JsonNode config1 = YAML_MAPPER.readTree(""
                + "foo:\n"
                + "  - bar:\n"
                + "      - baz: a\n"
                + "      - baz: b\n"
                + "      - baz: c\n"
                + "  - bar:\n"
                + "      - baz: d\n");
        JsonNode config2 = YAML_MAPPER.readTree(""
                + "foo:\n"
                + "- bar:\n"
                + "  - baz: d\n"
                + "- bar:\n"
                + "  - baz: c\n"
                + "  - baz: b\n"
                + "  - baz: a\n");
        Assertions.assertThat(JsonDiff.asJsonPatch(config1, config2).apply(config1))
                .isEqualTo(config2);

    }

# test fails the actual config is : 
foo:
- bar:
  - baz: d
- bar:
  - baz: c
  - baz: c
  - baz: a

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL