1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.primitive_result_type;
17
18 import static org.junit.jupiter.api.Assertions.assertEquals;
19 import static org.junit.jupiter.api.Assertions.assertTrue;
20
21 import java.math.BigDecimal;
22 import java.util.List;
23
24 import org.apache.ibatis.BaseDataTest;
25 import org.junit.jupiter.api.BeforeAll;
26 import org.junit.jupiter.api.Test;
27
28 class PrimitiveResultTypeTest {
29
30 @BeforeAll
31 static void setup() throws Exception {
32 BaseDataTest.runScript(IbatisConfig.getSqlSessionFactory().getConfiguration().getEnvironment().getDataSource(),
33 "org/apache/ibatis/submitted/primitive_result_type/create.sql");
34 }
35
36 @Test
37 void shouldReturnProperPrimitiveType() {
38 List<Integer> codes = ProductDAO.selectProductCodes();
39 for (Object code : codes) {
40 assertTrue(code instanceof Integer);
41 }
42 List<Long> lcodes = ProductDAO.selectProductCodesL();
43 for (Object lcode : lcodes) {
44 assertTrue(!(lcode instanceof Integer));
45 }
46 List<BigDecimal> bcodes = ProductDAO.selectProductCodesB();
47 for (Object bcode : bcodes) {
48 assertTrue(bcode instanceof BigDecimal);
49 }
50 }
51
52 @Test
53 void noErrorThrowOut() {
54 List<Product> products = ProductDAO.selectAllProducts();
55 assertEquals(4, products.size(), "should return 4 results");
56 }
57 }