Commit 5e52adcc by Xiaodong Wei

新增测试文件

parent 77c93fbf
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)
}
}
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)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment