Search in sources :

Example 1 with TestSuiteVo

use of com.ngtesting.platform.vo.TestSuiteVo in project ngtesting-platform by aaronchen2k.

the class SuiteServiceImpl method save.

@Override
public TestSuite save(JSONObject json, UserVo optUser) {
    Long id = json.getLong("id");
    TestSuite po;
    TestSuiteVo vo = JSON.parseObject(JSON.toJSONString(json), TestSuiteVo.class);
    Constant.MsgType action;
    if (id != null) {
        po = (TestSuite) get(TestSuite.class, id);
        action = Constant.MsgType.update;
    } else {
        po = new TestSuite();
        action = Constant.MsgType.create;
    }
    po.setName(vo.getName());
    po.setEstimate(vo.getEstimate());
    po.setDescr(vo.getDescr());
    po.setProjectId(vo.getProjectId());
    po.setUserId(optUser.getId());
    saveOrUpdate(po);
    historyService.create(po.getProjectId(), optUser, action.msg, TestHistory.TargetType.suite, po.getId(), po.getName());
    return po;
}
Also used : Constant(com.ngtesting.platform.config.Constant) TestSuiteVo(com.ngtesting.platform.vo.TestSuiteVo)

Example 2 with TestSuiteVo

use of com.ngtesting.platform.vo.TestSuiteVo in project ngtesting-platform by aaronchen2k.

the class SuiteServiceImpl method genVo.

@Override
public TestSuiteVo genVo(TestSuite po, Boolean withCases) {
    TestSuiteVo vo = new TestSuiteVo();
    vo.setId(po.getId());
    vo.setName(po.getName());
    vo.setEstimate(po.getEstimate());
    vo.setDescr(po.getDescr());
    vo.setProjectId(po.getProjectId());
    vo.setUserId(po.getUserId());
    TestUser user = (TestUser) get(TestUser.class, po.getUserId());
    vo.setUserName(user.getName());
    vo.setCreateTime(po.getCreateTime());
    vo.setUpdateTime(po.getUpdateTime());
    int count = 0;
    if (withCases) {
        for (TestCaseInSuite p : po.getTestcases()) {
            TestCaseInSuiteVo v = genCaseVo(p);
            vo.getTestcases().add(v);
            if (p.getLeaf()) {
                count++;
            }
        }
    } else {
        vo.setCount(countCase(vo.getId()).intValue());
    }
    return vo;
}
Also used : TestCaseInSuiteVo(com.ngtesting.platform.vo.TestCaseInSuiteVo) TestSuiteVo(com.ngtesting.platform.vo.TestSuiteVo)

Example 3 with TestSuiteVo

use of com.ngtesting.platform.vo.TestSuiteVo in project ngtesting-platform by aaronchen2k.

the class SuiteServiceImpl method getById.

@Override
public TestSuiteVo getById(Long caseId) {
    TestSuite po = (TestSuite) get(TestSuite.class, caseId);
    TestSuiteVo vo = genVo(po);
    return vo;
}
Also used : TestSuiteVo(com.ngtesting.platform.vo.TestSuiteVo)

Example 4 with TestSuiteVo

use of com.ngtesting.platform.vo.TestSuiteVo in project ngtesting-platform by aaronchen2k.

the class PlanAction method get.

@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Long projectId = json.getLong("projectId");
    Long id = json.getLong("id");
    TestPlanVo vo = planService.getById(id);
    List<TestSuite> ls = suiteService.query(projectId, null, null);
    List<TestSuiteVo> suites = suiteService.genVos(ls);
    ret.put("data", vo);
    ret.put("suites", suites);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : TestPlanVo(com.ngtesting.platform.vo.TestPlanVo) UserVo(com.ngtesting.platform.vo.UserVo) TestSuite(com.ngtesting.platform.entity.TestSuite) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestSuiteVo(com.ngtesting.platform.vo.TestSuiteVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with TestSuiteVo

use of com.ngtesting.platform.vo.TestSuiteVo in project ngtesting-platform by aaronchen2k.

the class SuiteAction method get.

@AuthPassport(validate = true)
@RequestMapping(value = "get", method = RequestMethod.POST)
@ResponseBody
public Map<String, Object> get(HttpServletRequest request, @RequestBody JSONObject json) {
    Map<String, Object> ret = new HashMap<String, Object>();
    UserVo userVo = (UserVo) request.getSession().getAttribute(Constant.HTTP_SESSION_USER_KEY);
    Long id = json.getLong("id");
    TestSuiteVo vo = suiteService.getById(id, false);
    ret.put("data", vo);
    ret.put("code", Constant.RespCode.SUCCESS.getCode());
    return ret;
}
Also used : UserVo(com.ngtesting.platform.vo.UserVo) HashMap(java.util.HashMap) JSONObject(com.alibaba.fastjson.JSONObject) TestSuiteVo(com.ngtesting.platform.vo.TestSuiteVo) AuthPassport(com.ngtesting.platform.util.AuthPassport) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

TestSuiteVo (com.ngtesting.platform.vo.TestSuiteVo)9 JSONObject (com.alibaba.fastjson.JSONObject)4 AuthPassport (com.ngtesting.platform.util.AuthPassport)4 UserVo (com.ngtesting.platform.vo.UserVo)4 HashMap (java.util.HashMap)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 TestSuite (com.ngtesting.platform.entity.TestSuite)3 Constant (com.ngtesting.platform.config.Constant)1 TestCaseInSuiteVo (com.ngtesting.platform.vo.TestCaseInSuiteVo)1 TestPlanVo (com.ngtesting.platform.vo.TestPlanVo)1 LinkedList (java.util.LinkedList)1