1717
1818package org .apache .hugegraph .loader .test .functional ;
1919
20- import org .apache .hugegraph .loader .HugeGraphLoader ;
21- import org .apache .hugegraph .structure .graph .Edge ;
22- import org .apache .hugegraph .structure .graph .Vertex ;
23- import org .apache .hugegraph .testutil .Assert ;
24- import org .junit .*;
25-
2620import java .time .LocalDate ;
2721import java .time .LocalDateTime ;
2822import java .time .LocalTime ;
2923import java .time .Year ;
3024import java .time .format .DateTimeFormatter ;
3125import java .util .List ;
3226
27+ import org .apache .hugegraph .loader .HugeGraphLoader ;
28+ import org .apache .hugegraph .structure .graph .Edge ;
29+ import org .apache .hugegraph .structure .graph .Vertex ;
30+ import org .apache .hugegraph .testutil .Assert ;
31+ import org .junit .After ;
32+ import org .junit .AfterClass ;
33+ import org .junit .Before ;
34+ import org .junit .BeforeClass ;
35+ import org .junit .Test ;
36+
3337/**
3438 * TODO: add more test cases
3539 */
@@ -73,14 +77,14 @@ public static void setUp() {
7377 ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" );
7478 // vertex date
7579 dbUtil .execute ("CREATE TABLE IF NOT EXISTS `date_test` (" +
76- "`id` int(10) unsigned NOT NULL," +
77- "`calendar_date` DATE NOT NULL," +
78- "`calendar_datetime` DATETIME NOT NULL," +
79- "`calendar_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
80- "`calendar_time` TIME NOT NULL," +
81- "`calendar_year` YEAR NOT NULL," +
82- "PRIMARY KEY (`id`)" +
83- ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" );
80+ "`id` int(10) unsigned NOT NULL," +
81+ "`calendar_date` DATE NOT NULL," +
82+ "`calendar_datetime` DATETIME NOT NULL," +
83+ "`calendar_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
84+ "`calendar_time` TIME NOT NULL," +
85+ "`calendar_year` YEAR NOT NULL," +
86+ "PRIMARY KEY (`id`)" +
87+ ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" );
8488
8589 // edge knows
8690 dbUtil .execute ("CREATE TABLE IF NOT EXISTS `knows` (" +
@@ -101,7 +105,6 @@ public static void setUp() {
101105 "PRIMARY KEY (`id`)" +
102106 ") ENGINE=InnoDB DEFAULT CHARSET=utf8;" );
103107
104-
105108 }
106109
107110 @ AfterClass
@@ -229,16 +232,16 @@ public void testValueMappingInJDBCSource() {
229232 @ Test
230233 public void testNumberToStringInJDBCSource () {
231234 dbUtil .insert ("INSERT INTO `person` VALUES " +
232- "(1,'marko',29,'Beijing')," +
233- "(2,'vadas',27,'HongKong')," +
234- "(3,'josh',32,'Beijing')," +
235- "(4,'peter',35,'Shanghai')," +
236- "(5,'li,nary',26,'Wu,han')," +
237- "(6,'tom',NULL,NULL);" );
235+ "(1,'marko',29,'Beijing')," +
236+ "(2,'vadas',27,'HongKong')," +
237+ "(3,'josh',32,'Beijing')," +
238+ "(4,'peter',35,'Shanghai')," +
239+ "(5,'li,nary',26,'Wu,han')," +
240+ "(6,'tom',NULL,NULL);" );
238241
239242 dbUtil .insert ("INSERT INTO `software` VALUES " +
240- "(100,'lop','java',328.08)," +
241- "(200,'ripple','java',199.67);" );
243+ "(100,'lop','java',328.08)," +
244+ "(200,'ripple','java',199.67);" );
242245
243246 String [] args = new String []{
244247 "-f" , configPath ("jdbc_number_to_string/struct.json" ),
@@ -261,9 +264,12 @@ public void testNumberToStringInJDBCSource() {
261264 @ Test
262265 public void testJdbcSqlDateConvert () {
263266 dbUtil .execute ("INSERT INTO `date_test` VALUES " +
264- "(1, '2017-12-10', '2017-12-10 15:30:45', '2017-12-10 15:30:45', '15:30:45', '2017')," +
265- "(2, '2009-11-11', '2009-11-11 08:15:30', '2009-11-11 08:15:30', '08:15:30', '2009')," +
266- "(3, '2017-03-24', '2017-03-24 12:00:00', '2017-03-24 12:00:00', '12:00:00', '2017');" );
267+ "(1, '2017-12-10', '2017-12-10 15:30:45', '2017-12-10 15:30:45', " +
268+ "'15:30:45', '2017')," +
269+ "(2, '2009-11-11', '2009-11-11 08:15:30', '2009-11-11 08:15:30', " +
270+ "'08:15:30', '2009')," +
271+ "(3, '2017-03-24', '2017-03-24 12:00:00', '2017-03-24 12:00:00', " +
272+ "'12:00:00', '2017');" );
267273
268274 String [] args = new String []{
269275 "-f" , configPath ("jdbc_sql_date_convert/struct.json" ),
@@ -280,8 +286,8 @@ public void testJdbcSqlDateConvert() {
280286
281287 Assert .assertEquals (3 , vertices .size ());
282288 // Define formatters
283- DateTimeFormatter serverDateFormatter = DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss.SSS" );
284-
289+ DateTimeFormatter serverDateFormatter =
290+ DateTimeFormatter . ofPattern ( "yyyy-MM-dd HH:mm:ss.SSS" );
285291
286292 // DATE check
287293 DateTimeFormatter dateFormatter = DateTimeFormatter .ofPattern ("yyyy-MM-dd" );
@@ -302,10 +308,10 @@ public void testJdbcSqlDateConvert() {
302308 LocalDateTime yearStart = year .atDay (1 ).atStartOfDay (); // 补充日期为该年的第一天
303309
304310 assertContains (vertices , "date_test" ,
305- "calendar_date" , date .format (serverDateFormatter ),
306- "calendar_datetime" , datetime .format (serverDateFormatter ),
307- "calendar_timestamp" , timestamp .format (serverDateFormatter ),
308- "calendar_time" , timeWithDate .format (serverDateFormatter ),
309- "calendar_year" , yearStart .format (serverDateFormatter ));
311+ "calendar_date" , date .format (serverDateFormatter ),
312+ "calendar_datetime" , datetime .format (serverDateFormatter ),
313+ "calendar_timestamp" , timestamp .format (serverDateFormatter ),
314+ "calendar_time" , timeWithDate .format (serverDateFormatter ),
315+ "calendar_year" , yearStart .format (serverDateFormatter ));
310316 }
311317}
0 commit comments