Skip to content

Commit a00b911

Browse files
author
zhangrongfan
committed
2.1.0 PRE-RELEASE
1 parent 9fd20b8 commit a00b911

File tree

1 file changed

+63
-58
lines changed

1 file changed

+63
-58
lines changed

mybatis-boost-test/src/test/java/cn/mybatisboost/test/NosqlTest.java

Lines changed: 63 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@
33
import cn.mybatisboost.core.GenericMapper;
44
import org.junit.After;
55
import org.junit.Before;
6+
import org.junit.Test;
67
import org.junit.runner.RunWith;
78
import org.springframework.beans.factory.annotation.Autowired;
89
import org.springframework.boot.autoconfigure.SpringBootApplication;
910
import org.springframework.boot.test.context.SpringBootTest;
1011
import org.springframework.jdbc.core.JdbcTemplate;
1112
import org.springframework.test.context.junit4.SpringRunner;
1213

14+
import java.util.List;
15+
16+
import static org.junit.Assert.assertEquals;
17+
1318
@RunWith(SpringRunner.class)
1419
@SpringBootApplication
1520
@SpringBootTest(classes = GenericMapper.class)
1621
public class NosqlTest {
1722

18-
// @Autowired
19-
// private ProjectNosqlMapper mapper;
23+
@Autowired
24+
private ProjectNosqlMapper mapper;
2025
@Autowired
2126
private JdbcTemplate jdbcTemplate;
2227

@@ -31,60 +36,60 @@ public void setUp() {
3136
public void tearDown() {
3237
jdbcTemplate.execute("delete from project");
3338
}
34-
//
35-
// @Test
36-
// public void deleteAll() {
37-
// assertEquals(3, mapper.deleteAll());
38-
// jdbcTemplate.query("select * from project", resultSet -> {
39-
// assertEquals(0, resultSet.getRow());
40-
// });
41-
// }
42-
//
43-
// @Test
44-
// public void selectFirst() {
45-
// assertEquals(123, (int) mapper.selectFirst().getId());
46-
// }
47-
//
48-
// @Test
49-
// public void selectTop2() {
50-
// List<Project> list = mapper.selectTop2();
51-
// assertEquals(2, list.size());
52-
// assertEquals(123, (int) list.get(0).getId());
53-
// assertEquals(456, (int) list.get(1).getId());
54-
// }
55-
//
56-
// @Test
57-
// public void selectAllOffset1Limit1() {
58-
// assertEquals(456, (int) mapper.selectAllOffset1Limit1().getId());
59-
// }
60-
//
61-
// @Test
62-
// public void selectByGroupIdAndArtifactId() {
63-
// assertEquals(123, (int) mapper.selectByGroupIdAndArtifactId("cn.mybatisboost1", "mybatis-boost1").get(0).getId());
64-
// }
65-
//
66-
// @Test
67-
// public void selectByGroupIdOrArtifactId() {
68-
// List<Project> list = mapper.selectByGroupIdOrArtifactId("cn.mybatisboost1", "mybatis-boost2");
69-
// assertEquals(2, list.size());
70-
// assertEquals(123, (int) list.get(0).getId());
71-
// assertEquals(456, (int) list.get(1).getId());
72-
// }
73-
//
74-
// @Test
75-
// public void selectByNotArtifactId() {
76-
// List<Project> list = mapper.selectByArtifactIdNot("mybatis-boost1");
77-
// assertEquals(2, list.size());
78-
// assertEquals(456, (int) list.get(0).getId());
79-
// assertEquals(789, (int) list.get(1).getId());
80-
// }
81-
//
82-
// @Test
83-
// public void selectAllOrderByGroupIdDesc() {
84-
// List<Project> list = mapper.selectAllOrderByGroupIdDesc();
85-
// assertEquals(3, list.size());
86-
// assertEquals(789, (int) list.get(0).getId());
87-
// assertEquals(456, (int) list.get(1).getId());
88-
// assertEquals(123, (int) list.get(2).getId());
89-
// }
39+
40+
@Test
41+
public void deleteAll() {
42+
assertEquals(3, mapper.deleteAll());
43+
jdbcTemplate.query("select * from project", resultSet -> {
44+
assertEquals(0, resultSet.getRow());
45+
});
46+
}
47+
48+
@Test
49+
public void selectFirst() {
50+
assertEquals(123, (int) mapper.selectFirst().getId());
51+
}
52+
53+
@Test
54+
public void selectTop2() {
55+
List<Project> list = mapper.selectTop2();
56+
assertEquals(2, list.size());
57+
assertEquals(123, (int) list.get(0).getId());
58+
assertEquals(456, (int) list.get(1).getId());
59+
}
60+
61+
@Test
62+
public void selectAllOffset1Limit1() {
63+
assertEquals(456, (int) mapper.selectAllOffset1Limit1().getId());
64+
}
65+
66+
@Test
67+
public void selectByGroupIdAndArtifactId() {
68+
assertEquals(123, (int) mapper.selectByGroupIdAndArtifactId("cn.mybatisboost1", "mybatis-boost1").get(0).getId());
69+
}
70+
71+
@Test
72+
public void selectByGroupIdOrArtifactId() {
73+
List<Project> list = mapper.selectByGroupIdOrArtifactId("cn.mybatisboost1", "mybatis-boost2");
74+
assertEquals(2, list.size());
75+
assertEquals(123, (int) list.get(0).getId());
76+
assertEquals(456, (int) list.get(1).getId());
77+
}
78+
79+
@Test
80+
public void selectByNotArtifactId() {
81+
List<Project> list = mapper.selectByArtifactIdNot("mybatis-boost1");
82+
assertEquals(2, list.size());
83+
assertEquals(456, (int) list.get(0).getId());
84+
assertEquals(789, (int) list.get(1).getId());
85+
}
86+
87+
@Test
88+
public void selectAllOrderByGroupIdDesc() {
89+
List<Project> list = mapper.selectAllOrderByGroupIdDesc();
90+
assertEquals(3, list.size());
91+
assertEquals(789, (int) list.get(0).getId());
92+
assertEquals(456, (int) list.get(1).getId());
93+
assertEquals(123, (int) list.get(2).getId());
94+
}
9095
}

0 commit comments

Comments
 (0)