fsk119 commented on code in PR #21523:
URL: https://github.com/apache/flink/pull/21523#discussion_r1057089320
##########
flink-table/flink-sql-gateway/src/test/java/org/apache/flink/table/gateway/rest/serde/ResultInfoJsonSerDeTest.java:
##########
@@ -75,80 +79,73 @@
/** Tests for {@link ResultInfoJsonSerializer} and {@link
ResultInfoJsonDeserializer}. */
public class ResultInfoJsonSerDeTest {
-
- private final byte tinyint = 'c';
- private final short smallint = 128;
- private final int intValue = 45536;
- private final float floatValue = 33.333F;
- private final long bigint = 1238123899121L;
- private final String name = "asdlkjasjkdla998y1122";
- private static final byte[] BYTES = new byte[1024];
- private final Double[] doubles = new Double[] {1.1, 2.2, 3.3};
- private final BigDecimal decimal = new BigDecimal("123.456789");
- private final LocalDate date = LocalDate.parse("1990-10-14");
- private final LocalTime time = LocalTime.parse("12:12:43");
- private final Timestamp timestamp3 = Timestamp.valueOf("1990-10-14
12:12:43.123");
- private final Timestamp timestamp9 = Timestamp.valueOf("1990-10-14
12:12:43.123456789");
- private final Instant timestampWithLocalZone =
- LocalDateTime.of(1990, 10, 14, 12, 12, 43, 123456789)
- .atOffset(ZoneOffset.of("Z"))
- .toInstant();
-
- private static final Map<String, Long> MAP = new HashMap<>();
- private static final Map<String, Integer> MULTI_SET = new HashMap<>();
- private static final Map<String, Map<String, Integer>> NESTED_MAP = new
HashMap<>();
-
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+ private static final Row testRow = initRow();
+
private final int rowNumber = 10;
@BeforeAll
public static void setUp() {
- MAP.put("element", 123L);
- MULTI_SET.put("element", 2);
- Map<String, Integer> innerMap = new HashMap<>();
- innerMap.put("key", 234);
- NESTED_MAP.put("inner_map", innerMap);
- ThreadLocalRandom.current().nextBytes(BYTES);
-
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(ResultInfo.class, new
ResultInfoJsonSerializer());
simpleModule.addDeserializer(ResultInfo.class, new
ResultInfoJsonDeserializer());
OBJECT_MAPPER.registerModule(simpleModule);
}
@Test
- void testResultInfoSerDeWithSingleRowData() throws Exception {
- Row row = getTestRowData();
- serDeTest(Collections.singletonList(row), getFields());
+ public void testResultInfoSerDeWithSingleRow() throws Exception {
+ serDeTest(Collections.singletonList(testRow));
}
@Test
- void testResultInfoSerDeWithMultiRowData() throws Exception {
+ public void testResultInfoSerDeWithMultiRowData() throws Exception {
List<Row> rowList = new ArrayList<>();
for (int i = 0; i < rowNumber; i++) {
- rowList.add(getTestRowData());
+ rowList.add(testRow);
}
- serDeTest(rowList, getFields());
+ serDeTest(rowList);
}
@Test
- void testResultInfoSerDeWithNullValues() throws Exception {
+ public void testResultInfoSerDeWithNullValues() throws Exception {
List<Row> rowList = new ArrayList<>();
List<Integer> positions = new ArrayList<>();
for (int i = 0; i < 18; i++) {
positions.add(new Random().nextInt(18));
}
for (int i = 0; i < rowNumber; i++) {
- rowList.add(getTestRowDataWithNullValues(positions));
+ rowList.add(getTestRowDataWithNullValues(testRow, positions));
Review Comment:
It always sets the same row.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]