diff --git a/json-unit-core/src/test/java/net/javacrumbs/jsonunit/core/internal/NodeTest.java b/json-unit-core/src/test/java/net/javacrumbs/jsonunit/core/internal/NodeTest.java new file mode 100644 index 000000000..d492fe5a7 --- /dev/null +++ b/json-unit-core/src/test/java/net/javacrumbs/jsonunit/core/internal/NodeTest.java @@ -0,0 +1,19 @@ +package net.javacrumbs.jsonunit.core.internal; + +import org.junit.jupiter.api.Test; + +import java.util.AbstractMap.SimpleEntry; +import java.util.Map; + +import static java.math.BigDecimal.valueOf; +import static org.assertj.core.api.Assertions.assertThat; + +class NodeTest { + + @Test + @SuppressWarnings("unchecked") + void shouldKeepOrder() { + Node node = new Jackson2NodeFactory().convertToNode("{\"b\":1, \"a\": 2, \"c\": 3, \"d\": 4}", "test", false); + assertThat(((Map) node.getValue()).entrySet().iterator().next()).isEqualTo(new SimpleEntry<>("b", valueOf(1))); + } +} diff --git a/tests/test-base/src/main/java/net/javacrumbs/jsonunit/test/base/AbstractAssertJTest.java b/tests/test-base/src/main/java/net/javacrumbs/jsonunit/test/base/AbstractAssertJTest.java index 61959e0c5..972800af1 100644 --- a/tests/test-base/src/main/java/net/javacrumbs/jsonunit/test/base/AbstractAssertJTest.java +++ b/tests/test-base/src/main/java/net/javacrumbs/jsonunit/test/base/AbstractAssertJTest.java @@ -256,12 +256,12 @@ void objectShouldContainComplexValueError() { } @Test - void objectFieldsShouldBeKeptInOrder() { + protected void objectFieldsShouldBeKeptInOrder() { assertThatJson("{\"root\":{\"key3\": 3, \"key2\": 2, \"key1\": 1 }}").node("root") .isObject() - .containsExactly(entry("key3", 3), - entry("key2", 2), - entry("key1", 1)); + .containsExactly(entry("key3", valueOf(3)), + entry("key2", valueOf(2)), + entry("key1", valueOf(1))); } @Test diff --git a/tests/test-jsonorg/src/test/java/net/javacrumbs/jsonunit/test/jsonorg/JsonOrgAssertJTest.java b/tests/test-jsonorg/src/test/java/net/javacrumbs/jsonunit/test/jsonorg/JsonOrgAssertJTest.java index e6d11de84..6b1a0afb5 100644 --- a/tests/test-jsonorg/src/test/java/net/javacrumbs/jsonunit/test/jsonorg/JsonOrgAssertJTest.java +++ b/tests/test-jsonorg/src/test/java/net/javacrumbs/jsonunit/test/jsonorg/JsonOrgAssertJTest.java @@ -57,4 +57,10 @@ protected void jsonPathShouldBeAbleToUseArrays() { protected void shouldEqualNumberInObject() { // ignored, no support of object serialization neither } + + @Override + @Test + protected void objectFieldsShouldBeKeptInOrder() { + // ignored, json org does not keep the order in JSON + } }