Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
deb6cd23
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
deb6cd23
编写于
11月 14, 2020
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
0b6e8c0a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
77 addition
and
5 deletion
+77
-5
tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Weather.java
.../com/taosdata/example/mybatisplusdemo/domain/Weather.java
+1
-0
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-dev.yml
...C/mybatisplus-demo/src/main/resources/application-dev.yml
+2
-2
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml
.../mybatisplus-demo/src/main/resources/application-prod.yml
+9
-0
tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
...ata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
+65
-3
未找到文件。
tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/domain/Weather.java
浏览文件 @
deb6cd23
...
...
@@ -10,5 +10,6 @@ public class Weather {
private
Timestamp
ts
;
private
float
temperature
;
private
int
humidity
;
private
String
location
;
}
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-dev.yml
浏览文件 @
deb6cd23
spring
:
datasource
:
driver-class-name
:
org.h2.Driver
schema
:
classpath:db/schema-
h2
.sql
data
:
classpath:db/data-
h2
.sql
schema
:
classpath:db/schema-
taos
.sql
data
:
classpath:db/data-
taos
.sql
url
:
jdbc:h2:mem:test
user
:
root
password
:
test
\ No newline at end of file
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml
浏览文件 @
deb6cd23
...
...
@@ -9,3 +9,12 @@ spring:
# url: jdbc:mysql://master:3306/test?useSSL=false
# username: root
# password: 123456
logging
:
level
:
com
:
taosdata
:
example
:
mybatisplusdemo
:
mapper
:
debug
tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
浏览文件 @
deb6cd23
package
com.taosdata.example.mybatisplusdemo.mapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.taosdata.example.mybatisplusdemo.domain.Weather
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -8,22 +9,83 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
java.sql.Timestamp
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringBootTest
public
class
WeatherMapperTest
{
private
static
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
@Autowired
private
WeatherMapper
mapper
;
@Test
public
void
testSelect
()
{
System
.
out
.
println
((
"----- selectAll method test ------"
));
public
void
testSelectList
()
{
List
<
Weather
>
weatherList
=
mapper
.
selectList
(
null
);
Assert
.
assertEquals
(
5
,
weatherList
.
size
());
//
Assert.assertEquals(5, weatherList.size());
weatherList
.
forEach
(
System
.
out
::
println
);
}
@Test
public
void
testInsert
()
{
Weather
weather
=
new
Weather
();
weather
.
setTs
(
new
Timestamp
(
System
.
currentTimeMillis
()));
weather
.
setTemperature
(
random
.
nextFloat
()
*
50
);
weather
.
setHumidity
(
random
.
nextInt
(
100
));
weather
.
setLocation
(
"望京"
);
int
affectRows
=
mapper
.
insert
(
weather
);
Assert
.
assertEquals
(
1
,
affectRows
);
}
@Test
public
void
testDelete
()
{
mapper
.
delete
(
new
QueryWrapper
<
Weather
>().
eq
(
"location"
,
"望京"
));
}
@Test
public
void
testDeleteByMap
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"location"
,
"望京"
);
int
affectRows
=
mapper
.
deleteByMap
(
map
);
// Assert.assertEquals(0, affectRows);
}
@Test
public
void
testSelectOne
()
{
QueryWrapper
<
Weather
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"location"
,
"beijing"
);
Weather
weather
=
mapper
.
selectOne
(
wrapper
);
System
.
out
.
println
(
weather
);
Assert
.
assertEquals
(
12.22f
,
weather
.
getTemperature
(),
0.00f
);
Assert
.
assertEquals
(
45
,
weather
.
getHumidity
());
Assert
.
assertEquals
(
"beijing"
,
weather
.
getLocation
());
}
@Test
public
void
testSelectByMap
()
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"location"
,
"beijing"
);
List
<
Weather
>
weathers
=
mapper
.
selectByMap
(
map
);
Assert
.
assertEquals
(
1
,
weathers
.
size
());
}
@Test
public
void
testSelectObjs
()
{
List
<
Object
>
ts
=
mapper
.
selectObjs
(
null
);
System
.
out
.
println
(
ts
);
// Assert.assertEquals(5, ts.size());
}
@Test
public
void
testSelectCount
()
{
int
count
=
mapper
.
selectCount
(
null
);
Assert
.
assertEquals
(
5
,
count
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录