Skip to content

Commit f53ab4f

Browse files
author
xinying7
committed
fixing flaky test testFormatOfBigDecimal
1 parent e8bb595 commit f53ab4f

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

modules/swagger-core/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@
5252
</plugins>
5353
</build>
5454
<dependencies>
55+
<dependency>
56+
<groupId>org.json</groupId>
57+
<artifactId>json</artifactId>
58+
<version>20230227</version>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.skyscreamer</groupId>
62+
<artifactId>jsonassert</artifactId>
63+
<version>1.5.0</version>
64+
</dependency>
5565
<dependency>
5666
<groupId>jakarta.xml.bind</groupId>
5767
<artifactId>jakarta.xml.bind-api</artifactId>

modules/swagger-core/src/test/java/io/swagger/v3/core/converting/NumericFormatTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import static io.swagger.v3.core.util.TestUtils.normalizeLineEnds;
1515
import static org.testng.Assert.assertEquals;
1616

17+
import org.json.JSONObject;
18+
import org.skyscreamer.jsonassert.JSONAssert;
19+
1720
public class NumericFormatTest {
1821
@Test
1922
public void testFormatOfInteger() {
@@ -41,8 +44,8 @@ public void testFormatOfDecimal() {
4144
final Map<String, Schema> models = ModelConverters.getInstance().readAll(ModelWithDecimalFields.class);
4245
assertEquals(models.size(), 1);
4346

44-
String json = Json.pretty(models);
45-
assertEquals(normalizeLineEnds(json),
47+
String json1 = Json.pretty(models);
48+
String json2 =
4649
"{\n" +
4750
" \"ModelWithDecimalFields\" : {\n" +
4851
" \"type\" : \"object\",\n" +
@@ -55,7 +58,11 @@ public void testFormatOfDecimal() {
5558
" }\n" +
5659
" }\n" +
5760
" }\n" +
58-
"}");
61+
"}";
62+
JSONObject jsonObj1 = new JSONObject(json1);
63+
JSONObject jsonObj2 = new JSONObject(json2);
64+
65+
JSONAssert.assertEquals(jsonObj1, jsonObj2, true);
5966
}
6067

6168
@Test

0 commit comments

Comments
 (0)