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
5e52adcc
authored
Apr 13, 2022
by
Xiaodong Wei
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增测试文件
parent
77c93fbf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
277 additions
and
0 deletions
test/models/Example1_default_test.groovy
test/models/example_url_default_test.groovy
test/models/Example1_default_test.groovy
0 → 100644
View file @
5e52adcc
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
Example1_default_test
extends
UniplatTestContext
{
@Test
@TestLevel
(
1
)
void
testList_default_pageCount
()
{
ListQueryTestContext
.
testListPageCounter
(
"Example1"
,
""
)
}
@Test
@TestLevel
(
1
)
void
testList_default_page1
()
{
ListQueryTestContext
.
testPageOfList
(
"Example1"
,
""
,
"page1"
)
}
@Test
@TestLevel
(
1
)
void
testList_default_page2
()
{
ListQueryTestContext
.
testPageOfList
(
"Example1"
,
""
,
"page2"
)
}
@Test
@TestLevel
(
1
)
void
testList_normal
()
{
ListQueryTestContext
.
testList
(
"Example1"
,
"normal"
)
}
@Test
@TestLevel
(
1
)
void
testDetail_default
()
{
DataObject
object
=
Host
.
instance
.
getDataModel
(
"Example1"
).
queryDataList
([:],[:],
0
,
1
).
fetchOne
()
if
(
object
==
null
)
{
throw
new
MyException
(
"详情页测试未找到有效数据"
)
}
DetailQueryTestContext
.
testDetail
(
"Example1"
,
""
,
object
.
getKeyFieldValue
())
}
@Test
@TestLevel
(
1
)
void
testDetail_detail1
()
{
DataObject
object
=
Host
.
instance
.
getDataModel
(
"Example1"
).
queryDataList
([:],[:],
0
,
1
).
fetchOne
()
if
(
object
==
null
)
{
throw
new
MyException
(
"详情页测试未找到有效数据"
)
}
DetailQueryTestContext
.
testDetail
(
"Example1"
,
"detail1"
,
object
.
getKeyFieldValue
())
}
@Test
@TestLevel
(
2
)
void
testSimpleAction_startPlanTask
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"Example1"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"Example1"
,
"startPlanTask"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_insert
()
{
new
ActionTestContext
(
"Example1"
,
"insert"
,
[])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_update
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"Example1"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"Example1"
,
"update"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_delete
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"Example1"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"Example1"
,
"delete"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
2
)
void
testSimpleAction_startProcess
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"Example1"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"Example1"
,
"startProcess"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
private
void
action_execute_startPlanTask
(
List
<
Object
>
ids
)
{
ActionTestContext
context
=
new
ActionTestContext
(
"Example1"
,
"startPlanTask"
,
ids
)
ActionTestExecuteResult
result
=
context
.
executeActually
()
assertResult
([])
}
private
ActionTestExecuteResult
action_execute_insert
()
{
ActionTestContext
context
=
new
ActionTestContext
(
"Example1"
,
"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
(
"Example1"
,
"update"
,
ids
)
ActionTestExecuteResult
result
=
context
.
executeActually
()
assertResult
([])
}
private
void
action_execute_delete
(
List
<
Object
>
ids
)
{
ActionTestContext
context
=
new
ActionTestContext
(
"Example1"
,
"delete"
,
ids
)
assertResult
([{
context
.
assertDeleteResult
()}
as
Executable
])
}
@Test
@TestLevel
(
4
)
void
testAction_startPlanTask_test
()
{
ActionTestExecuteResult
result
=
action_execute_insert
()
action_execute_startPlanTask
(
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_startPlanTask
(
result
.
behaviorResult
.
ids
)
action_execute_update
(
result
.
behaviorResult
.
ids
)
action_execute_delete
(
result
.
behaviorResult
.
ids
)
}
}
test/models/example_url_default_test.groovy
0 → 100644
View file @
5e52adcc
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
example_url_default_test
extends
UniplatTestContext
{
@Test
@TestLevel
(
1
)
void
testList_default
()
{
ListQueryTestContext
.
testList
(
"example_url"
,
""
)
}
@Test
@TestLevel
(
1
)
void
testDetail_default
()
{
DataObject
object
=
Host
.
instance
.
getDataModel
(
"example_url"
).
queryDataList
([:],[:],
0
,
1
).
fetchOne
()
if
(
object
==
null
)
{
throw
new
MyException
(
"详情页测试未找到有效数据"
)
}
DetailQueryTestContext
.
testDetail
(
"example_url"
,
""
,
object
.
getKeyFieldValue
())
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_insert
()
{
new
ActionTestContext
(
"example_url"
,
"insert"
,
[])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_update
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"example_url"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"example_url"
,
"update"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
@Test
@TestLevel
(
3
)
void
testSimpleAction_delete
()
{
DataList
list
=
Host
.
instance
.
getDataModel
(
"example_url"
).
queryDataList
([:],[:],
0
,
1
)
if
(
list
.
isEmpty
())
{
throw
new
MyException
(
"未找到可用数据"
)
}
new
ActionTestContext
(
"example_url"
,
"delete"
,
[
list
.
one
().
getKeyFieldValue
()])
.
execute
()
}
private
ActionTestExecuteResult
action_execute_insert
()
{
ActionTestContext
context
=
new
ActionTestContext
(
"example_url"
,
"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
(
"example_url"
,
"update"
,
ids
)
ActionTestExecuteResult
result
=
context
.
executeActually
()
assertResult
([])
}
private
void
action_execute_delete
(
List
<
Object
>
ids
)
{
ActionTestContext
context
=
new
ActionTestContext
(
"example_url"
,
"delete"
,
ids
)
assertResult
([{
context
.
assertDeleteResult
()}
as
Executable
])
}
@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_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