Skip to content

Commit 3a9cc73

Browse files
committed
完善测试
1 parent b46057e commit 3a9cc73

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

src/test/java/tk/mybatis/mapper/model/Entity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
* @since 2015-12-06 10:31
3535
*/
3636
public class Entity<ID extends Serializable, NAME extends Serializable> {
37+
//这里的a,b,c,d仅用来测试FieldHelper中的静态字段
38+
private static Integer a, b, c, d;
3739

3840
private ID id;
3941

src/test/java/tk/mybatis/mapper/test/country/TestSelect.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,26 @@ public void testDynamicSelectPage() {
8686
}
8787
}
8888

89+
/**
90+
* 查询全部
91+
*/
92+
@Test
93+
public void testAllColumns() {
94+
SqlSession sqlSession = MybatisHelper.getSqlSession();
95+
try {
96+
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
97+
Country country = new Country();
98+
//35,'China','CN'
99+
country.setCountrycode("CN");
100+
country.setId(35);
101+
country.setCountryname("China");
102+
List<Country> countryList = mapper.select(country);
103+
Assert.assertEquals(1, countryList.size());
104+
} finally {
105+
sqlSession.close();
106+
}
107+
}
108+
89109
/**
90110
* 入参为null时查询全部
91111
*/

src/test/java/tk/mybatis/mapper/test/country/TestUpdateByPrimaryKey.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void testDynamicUpdateByPrimaryKey() {
7676
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
7777
Country country = new Country();
7878
country.setId(174);
79+
country.setCountryname(null);
7980
country.setCountryname("美国");
8081
Assert.assertEquals(1, mapper.updateByPrimaryKey(country));
8182

src/test/java/tk/mybatis/mapper/test/example/TestSelectByExample.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,19 @@ public void testSelectColumnsByExample() {
163163
}
164164
}
165165

166+
@Test
167+
public void testOrderBy() {
168+
SqlSession sqlSession = MybatisHelper.getSqlSession();
169+
try {
170+
CountryMapper mapper = sqlSession.getMapper(CountryMapper.class);
171+
Example example = new Example(Country.class);
172+
example.setOrderByClause("id desc");
173+
List<Country> countries = mapper.selectByExample(example);
174+
//查询总数
175+
Assert.assertEquals(183, (int) countries.get(0).getId());
176+
} finally {
177+
sqlSession.close();
178+
}
179+
}
180+
166181
}

0 commit comments

Comments
 (0)