java - 使用 Rally wsapi v2.0 将标签添加到测试用例的正确方法

标签 java rally

           //this will query for the tag, if not found it will create the tag.
            ChkTag(r, wspace_ref, projref, tagx);

            QueryRequest tg = new QueryRequest("Tag");
            tg.setWorkspace(wspace_ref);
            tg.setProject(projref);
            tg.setQueryFilter(new QueryFilter("Name", "=", tagx));
            QueryResponse resp = r.query(tg);
            if(resp.wasSuccessful()&&resp.getTotalResultCount()==1){
                System.out.println("The tag: "+tagx+" is found.");
            } else {
                System.err.println("The tag wasn't found for this testcase.\n"
                        + "ChkTag() method was run earlier which should have created the tag. something weird is going on...");
            }

            //Now adding the tag to the test case
            JsonArray tiger = new JsonArray();
            tiger.add(resp.getResults().get(0));

            //System.out.println("Updating testcase tags...");
            JsonObject updatedtesttag = new JsonObject();
            updatedtesttag.add("Tags", tiger);

            UpdateRequest updatetag = new UpdateRequest(ref_testcase, updatedtesttag);
            UpdateResponse updatetagresp = r.update(updatetag);

            if(updatetagresp.wasSuccessful())
                System.out.println("Tag successfully added to the test case");
        }else{
            System.out.println("Tag for this testcase is Null...\nSkipping Tag...");
        }

我不确定这一行:

tiger.add(resp.getResults().get(0));

这一行是否会将测试用例重置为仅具有此一个标签,或者是否会将这一标签附加到测试用例的现有标签列表中?我不想丢失测试用例的现有标签。

最佳答案

执行此操作的能力是该项目中长期悬而未决的问题:https://github.com/RallyTools/RallyRestToolkitForJava/issues/14

我昨天有一些额外的时间,所以我实现了写入集合端点的功能,并发布了工具包的新版本 (2.2.1)。

这是一个执行您想要的操作的示例:

//Build the array of tags to add
JsonArray tagRefs = new JsonArray();
JsonObject tagRef = new JsonObject();
tagRef.addProperty("_ref", "/tag/12345");
tagRefs.add(tagRef);

//Update the collection
CollectionUpdateRequest testCaseTagCollectionAddRequest = new CollectionUpdateRequest("/testcase/23456", tagRefs, true);
testCaseTagCollectionAddRequest.setFetch(new Fetch("Name"));
CollectionUpdateResponse testCaseTagCollectionAddResponse = restApi.updateCollection(testCaseTagCollectionAddRequest);

请注意,您也可以使用 updateCollection 方法从集合中删除项目。

这个新功能只是将可写集合端点包装在 WSAPI v2.0 中,如下所述:https://rally1.rallydev.com/slm/doc/webservice/rest_collections.jsp

关于java - 使用 Rally wsapi v2.0 将标签添加到测试用例的正确方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35975518/

相关文章:

java - 重复的日志条目 log4j

java - 当文件包含错误时是否可以拒绝 egit 提交

rally - 在 Rally 应用程序中使用图像

java - 如何使用 rally rest api 查找给定迭代和给定项目下的用户故事列表

java - 主页启动器强制停止后未收到 Android AppWidget 的按钮单击事件

java - 使用 picasso 将图像大小调整为全宽和固定高度

java - Hadoop-PCap-Lib 字段类型

java - 如果文件夹属于特定根文件夹,如何使用 java 通过 Api to Rally 获取信息

javascript - Rally 列出所有功能查询

c# - 如何使用 rally rest API 和 C# 在功能中添加/更新里程碑?