| | 89 | * excludes用来指定,哪些字段不参与构建sql插入语句,这里可以设置null[[BR]] |
| | 90 | 测试准备工作,做好了,下面就可以编写测试了[[BR]] |
| | 91 | |
| | 92 | {{{ #!java |
| | 93 | @Test |
| | 94 | public void testBuildInsert() { |
| | 95 | List<FieldDesc> list = newFieldDescs(); |
| | 96 | String insert = SqlHelper.buildInsert(list, "game", null); |
| | 97 | Assert.assertEquals("INSERT INTO game (gameId,createAt) VALUES (?,?)", |
| | 98 | insert); |
| | 99 | |
| | 100 | } |
| | 101 | |
| | 102 | private List<FieldDesc> newFieldDescs() { |
| | 103 | List<FieldDesc> list = new ArrayList<FieldDesc>(); |
| | 104 | FieldDesc id = new FieldDesc(); |
| | 105 | id.setField("gameId"); |
| | 106 | id.setType("int(11)"); |
| | 107 | FieldDesc createAt = new FieldDesc(); |
| | 108 | createAt.setField("createAt"); |
| | 109 | createAt.setType("timestamp"); |
| | 110 | list.add(id); |
| | 111 | list.add(createAt); |
| | 112 | return list; |
| | 113 | } |
| | 114 | }}} |
| | 115 | |