Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
lukas-krecan committed Jul 16, 2024
1 parent 673fd45 commit 81105bd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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<String, Object>) node.getValue()).entrySet().iterator().next()).isEqualTo(new SimpleEntry<>("b", valueOf(1)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

0 comments on commit 81105bd

Please sign in to comment.