Minor fixes
This commit is contained in:
parent
0eeb8a37f5
commit
706035468b
@ -18,8 +18,8 @@ public class JsonCompareUnitTest {
|
|||||||
public void givenTwoSameJsonDataObjects_whenCompared_thenAreEqual() throws IOException {
|
public void givenTwoSameJsonDataObjects_whenCompared_thenAreEqual() throws IOException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34 }}";
|
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\", \"age\": 34 }}";
|
||||||
String s2 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34 }}";
|
String s2 = "{\"employee\": {\"id\": \"1212\",\"age\": 34, \"fullName\": \"John Miles\" }}";
|
||||||
|
|
||||||
JsonNode actualObj1 = mapper.readTree(s1);
|
JsonNode actualObj1 = mapper.readTree(s1);
|
||||||
JsonNode actualObj2 = mapper.readTree(s2);
|
JsonNode actualObj2 = mapper.readTree(s2);
|
||||||
@ -29,11 +29,11 @@ public class JsonCompareUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTwoSameNestedJsonDataObjects_whenCompared_thenAreEqual() throws IOException {
|
public void givenTwoSameNestedJsonDataObjects_whenCompared_thenEqual() throws IOException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34,\n" + "\"contact\":{\"email\": \"john@xyz.com\",\"phone\": \"9999999999\"} }}";
|
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"contact\":{\"email\": \"john@xyz.com\",\"phone\": \"9999999999\"} }}";
|
||||||
String s2 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34,\n" + "\"contact\":{\"email\": \"john@xyz.com\",\"phone\": \"9999999999\"} }}";
|
String s2 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"contact\":{\"email\": \"john@xyz.com\",\"phone\": \"9999999999\"} }}";
|
||||||
|
|
||||||
JsonNode actualObj1 = mapper.readTree(s1);
|
JsonNode actualObj1 = mapper.readTree(s1);
|
||||||
JsonNode actualObj2 = mapper.readTree(s2);
|
JsonNode actualObj2 = mapper.readTree(s2);
|
||||||
@ -43,7 +43,7 @@ public class JsonCompareUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTwoSameListJsonDataObjects_whenCompared_thenAreEqual() throws IOException {
|
public void givenTwoSameListJsonDataObjects_whenCompared_thenEqual() throws IOException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"skills\":[\"Java\", \"C++\", \"Python\"] }}";
|
String s1 = "{\"employee\": {\"id\": \"1212\",\"fullName\": \"John Miles\",\"age\": 34, \"skills\":[\"Java\", \"C++\", \"Python\"] }}";
|
||||||
@ -57,7 +57,7 @@ public class JsonCompareUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTwoJsonDataObjects_whenComparedUsingCustomComparator_thenEqual() throws Exception {
|
public void givenTwoJsonDataObjects_whenComparedUsingCustomComparator_thenEqual() throws IOException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
String s1 = "{\"name\": \"John\",\"score\":5.0}";
|
String s1 = "{\"name\": \"John\",\"score\":5.0}";
|
||||||
@ -65,7 +65,6 @@ public class JsonCompareUnitTest {
|
|||||||
JsonNode actualObj1 = mapper.readTree(s1);
|
JsonNode actualObj1 = mapper.readTree(s1);
|
||||||
JsonNode actualObj2 = mapper.readTree(s2);
|
JsonNode actualObj2 = mapper.readTree(s2);
|
||||||
|
|
||||||
|
|
||||||
Comparator<JsonNode> cmp = new Comparator<JsonNode>() {
|
Comparator<JsonNode> cmp = new Comparator<JsonNode>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(JsonNode o1, JsonNode o2) {
|
public int compare(JsonNode o1, JsonNode o2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user