Skip to content

Commit

Permalink
Fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mukta13 authored and wenshao committed Nov 5, 2024
1 parent 62a67f2 commit 2da286c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ public void test6() {
byte[] jsonbBytes = JSONB.toBytes(ex, writerFeatures);
UncheckedIOException ex1 = (UncheckedIOException) JSONB.parseObject(jsonbBytes, Object.class, readerFeatures);

assertEquals(ex.getMessage(), ex1.getMessage());
assertEquals(ex.getCause().getMessage(), ex1.getCause().getMessage());
assertNull(ex.getMessage(), "Expected original message to be null");
assertEquals(ex.getCause() != null ? ex.getCause().getMessage() : null, ex1.getCause() != null ? ex1.getCause().getMessage() : null);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue2959 {
@Test
public void test() {
assertEquals("{\"projectNO\":null,\"orderNO\":null,\"orderType\":null,\"pN\":null,\"qty\":null,\"description\":null,\"customerCode\":null,\"customerName\":null,\"currency\":null,\"netPrice\":null,\"uSD\":null,\"rate\":null,\"orderDate\":null,\"requestDate\":null,\"planedDate\":null,\"this$0\":null}",
JSON.toJSONString(new TobeDelivery(), JSONWriter.Feature.WriteNulls));
String expectedJson = "{\"projectNO\":null,\"orderNO\":null,\"orderType\":null,\"pN\":null,\"qty\":null,\"description\":null,\"customerCode\":null,\"customerName\":null,\"currency\":null,\"netPrice\":null,\"uSD\":null,\"rate\":null,\"orderDate\":null,\"requestDate\":null,\"planedDate\":null,\"this$0\":null}";
String actualJson = JSON.toJSONString(new TobeDelivery(), JSONWriter.Feature.WriteNulls);

// Parse the JSON strings into Maps for comparison
Map<String, Object> expectedMap = JSON.parseObject(expectedJson, Map.class);
Map<String, Object> actualMap = JSON.parseObject(actualJson, Map.class);

assertEquals(expectedMap, actualMap);
}

@Data
Expand Down

0 comments on commit 2da286c

Please sign in to comment.