Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
uniplat-example
/
intent-example
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
10dc850f
authored
Apr 19, 2022
by
Xiaodong Wei
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
更新测试用例
parent
1dc37b90
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
175 additions
and
0 deletions
test/models/province_default_test.groovy
test/models/province_default_test.groovy
0 → 100644
View file @
10dc850f
import
com.qinqinxiaobao.report.Application
import
com.qinqinxiaobao.report.exception.MyException
import
com.qinqinxiaobao.report.uniplat.engine.DO.DataObject
import
com.qinqinxiaobao.report.uniplat.engine.DataList
import
com.qinqinxiaobao.report.uniplat.host.Host
import
com.qinqinxiaobao.report.uniplat.test.ActionTestExecuteResult
import
com.qinqinxiaobao.report.uniplat.test.ActionTestContext
import
com.qinqinxiaobao.report.uniplat.test.DetailQueryTestContext
import
com.qinqinxiaobao.report.uniplat.test.ListQueryTestContext
import
com.qinqinxiaobao.report.uniplat.test.TestContextLoader
import
com.qinqinxiaobao.report.uniplat.test.TestLevel
import
com.qinqinxiaobao.report.uniplat.test.UniplatTestContext
import
org.junit.jupiter.api.Test
import
org.junit.jupiter.api.function.Executable
import
org.springframework.boot.test.context.SpringBootTest
import
org.springframework.test.context.ContextConfiguration
@SpringBootTest
(
classes
=
[
Application
])
@ContextConfiguration
(
loader
=
TestContextLoader
)
class
province_default_test
extends
UniplatTestContext
{
@Test
@TestLevel
(
1
)
void
testList_default
()
{
ListQueryTestContext
.
testList
(
"province"
,
""
)
}
@Test
@TestLevel
(
1
)
void
testList_abc
()
{
ListQueryTestContext
.
testList
(
"province"
,
"abc"
)
}
@Test
@TestLevel
(
1
)
void
testDetail_default
()
{
DataObject
object
=
Host
.
instance
.
getDataModel
(
"province"
).
queryDataList
([:],[:],
0
,
1
).
fetchOne
()
if
(
object
==
null
)
{
throw
new
MyException
(
"详情页测试未找到有效数据"
)
}
DetailQueryTestContext
.
testDetail
(
"province"
,
""
,
object
.
getKeyFieldValue
())
}
@Test
@TestLevel
(
2
)
void
testSimpleAction_up
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"province"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"province"
,
"up"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
2
)
void
testSimpleAction_down
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"province"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"province"
,
"down"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_insert
()
{
new
ActionTestContext
(
"province"
,
"insert"
,
[])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_update
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"province"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"province"
,
"update"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
2
)
void
testSimpleAction_update_name
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"province"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"province"
,
"update_name"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_delete
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"province"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"province"
,
"delete"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
private
void
action_execute_up
(
List
<
Object
>
ids
)
{
ActionTestContext
context
=
new
ActionTestContext
(
"province"
,
"up"
,
ids
)
ActionTestExecuteResult
result
=
context
.
executeActually
()
assertResult
([])
}
private
void
action_execute_down
(
List
<
Object
>
ids
)
{
ActionTestContext
context
=
new
ActionTestContext
(
"province"
,
"down"
,
ids
)
ActionTestExecuteResult
result
=
context
.
executeActually
()
assertResult
([])
}
private
ActionTestExecuteResult
action_execute_insert
()
{
ActionTestContext
context
=
new
ActionTestContext
(
"province"
,
"insert"
,
[])
ActionTestExecuteResult
result
=
context
.
executeActually
()
if
(
result
==
null
)
{
throw
new
MyException
(
"新增数据失败"
)
}
assertResult
([])
return
result
}
private
void
action_execute_update
(
List
<
Object
>
ids
)
{
ActionTestContext
context
=
new
ActionTestContext
(
"province"
,
"update"
,
ids
)
ActionTestExecuteResult
result
=
context
.
executeActually
()
assertResult
([])
}
private
void
action_execute_delete
(
List
<
Object
>
ids
)
{
ActionTestContext
context
=
new
ActionTestContext
(
"province"
,
"delete"
,
ids
)
assertResult
([{
context
.
assertDeleteResult
()}
as
Executable
])
}
@Test
@TestLevel
(
4
)
void
testAction_up_test
()
{
ActionTestExecuteResult
result
=
action_execute_insert
()
action_execute_up
(
result
.
behaviorResult
.
ids
)
action_execute_delete
(
result
.
behaviorResult
.
ids
)
}
@Test
@TestLevel
(
4
)
void
testAction_down_test
()
{
ActionTestExecuteResult
result
=
action_execute_insert
()
action_execute_down
(
result
.
behaviorResult
.
ids
)
action_execute_delete
(
result
.
behaviorResult
.
ids
)
}
@Test
@TestLevel
(
4
)
void
testAction_update_test
()
{
ActionTestExecuteResult
result
=
action_execute_insert
()
action_execute_update
(
result
.
behaviorResult
.
ids
)
action_execute_delete
(
result
.
behaviorResult
.
ids
)
}
@Test
@TestLevel
(
4
)
void
testAction_all_test
()
{
ActionTestExecuteResult
result
result
=
action_execute_insert
()
action_execute_up
(
result
.
behaviorResult
.
ids
)
action_execute_down
(
result
.
behaviorResult
.
ids
)
action_execute_update
(
result
.
behaviorResult
.
ids
)
action_execute_delete
(
result
.
behaviorResult
.
ids
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment