Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 创建>=3代深层测试文件夹_Java_Web Services_Rally - Fatal编程技术网

Java 创建>=3代深层测试文件夹

Java 创建>=3代深层测试文件夹,java,web-services,rally,Java,Web Services,Rally,我正在绘制我的代码,我的用户NickM的github位于 我需要创建一个测试文件夹层次结构>=3代,例如祖父母、父母、孩子等。下面是我目前添加的代码 Java代码与我对代码所做的添加一起工作。但是它仍然没有创建我想要的3代深度测试文件夹集,直到只创建2代深度。有人能帮我指出并给出一些我可以对代码进行修改的例子吗? 谢谢 我修改了代码,创建了一个孙子级测试文件夹,并向其中添加了一个测试用例。请参阅中的代码 import java.io.IOException; import java.net.U

我正在绘制我的代码,我的用户NickM的github位于

我需要创建一个测试文件夹层次结构>=3代,例如祖父母、父母、孩子等。下面是我目前添加的代码

Java代码与我对代码所做的添加一起工作。但是它仍然没有创建我想要的3代深度测试文件夹集,直到只创建2代深度。有人能帮我指出并给出一些我可以对代码进行修改的例子吗? 谢谢


我修改了代码,创建了一个孙子级测试文件夹,并向其中添加了一个测试用例。请参阅中的代码

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.request.GetRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.util.Ref;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.rallydev.rest.RallyRestApi;
import com.rallydev.rest.request.CreateRequest;
import com.rallydev.rest.request.GetRequest;
import com.rallydev.rest.request.QueryRequest;
import com.rallydev.rest.response.CreateResponse;
import com.rallydev.rest.response.GetResponse;
import com.rallydev.rest.response.QueryResponse;
import com.rallydev.rest.util.Fetch;
import com.rallydev.rest.util.QueryFilter;
import com.rallydev.rest.util.Ref;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class TestFolderTestCaseCreation {
        // TODO Auto-generated constructor stub
        public static void main(String[] args) throws URISyntaxException, IOException {


            String host = "https://rally1.rallydev.com";
            String username = "user@company.com";
            String password = "secret";
            String wsapiVersion = "v2.0";
            String projectRef = "/project/xxxxx";
            //String myWorkspace = "/workspace/xxxxx";
            String applicationName = "RestExample_createTFandTC";


                    RallyRestApi restApi = new RallyRestApi(
                     new URI(host),
                     username,
                     password);
                    restApi.setWsapiVersion(wsapiVersion);
                    restApi.setApplicationName(applicationName);



                    try {
                     for (int i=0; i<1; i++) {

            System.out.println("Creating a test folder...");
            JsonObject newTF = new JsonObject();
            newTF.addProperty("Name", "Grandparent");
            newTF.addProperty("Project", projectRef);
//Created Grandparent

            CreateRequest createRequest = new CreateRequest("testfolder", newTF);
            CreateResponse createResponse = restApi.create(createRequest);
            if (createResponse.wasSuccessful()) {

            System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));
            String folderRef = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
            System.out.println(String.format("\nReading TestFolder %s...",folderRef));
            System.out.println("Creating a child test folder...");
            JsonObject newChildTF = new JsonObject();
            newChildTF.addProperty("Name", "Parent");
            newChildTF.addProperty("Project", projectRef);
            //newChildTF.addProperty("Workspace", myWorkspace);
            newChildTF.addProperty("Parent", folderRef);
            String folderRef2 = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
            System.out.println(String.format("\nReading TestFolder %s...",folderRef2));
        JsonObject newChildTF2 = new JsonObject();
        newChildTF2.addProperty("Name", "Child");
        newChildTF2.addProperty("Project", projectRef);
        newChildTF2.addProperty("Parent", folderRef2);



                //Test Folder2
                CreateRequest createRequest2 = new CreateRequest("testfolder", newChildTF);
                CreateResponse createResponse2 = restApi.create(createRequest2);
                if (createResponse.wasSuccessful()) {

                System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));
                String childFolderRef = Ref.getRelativeRef(createResponse2.getObject().get("_ref").getAsString());
                System.out.println(String.format("\nReading Child TestFolder %s...",childFolderRef));
                //TestCase
                System.out.println("Creating a test case...");
                JsonObject newTC = new JsonObject();
                newTC.addProperty("Name", "tc via java");
                newTC.addProperty("Project", projectRef);
                //newChildTF.addProperty("Workspace", myWorkspace);
                newTC.addProperty("TestFolder", childFolderRef);
                newTC.addProperty("Method", "Manual");


                CreateRequest createRequest3 = new CreateRequest("testcase", newTC);
                CreateResponse createResponse3 = restApi.create(createRequest3);
                if (createResponse.wasSuccessful()) {

                System.out.println(String.format("Created %s", createResponse3.getObject().get("_ref").getAsString()));
                String testCaseRef = Ref.getRelativeRef(createResponse3.getObject().get("_ref").getAsString());
                System.out.println(String.format("\nReading TestCase %s...",testCaseRef));
                }

            }

            } else {
            String[] createErrors;
            createErrors = createResponse.getErrors();
            System.out.println("Error!");
            for (int j=0; i<createErrors.length;j++) {
            System.out.println(createErrors[j]);
            }
            }
                     }


                    } finally {
                        restApi.close();
                    } 


        }
}
    try {

            //-----creating a parent folder
            System.out.println("Creating a test folder...");
            JsonObject newTF = new JsonObject();
            newTF.addProperty("Name", "parent tf via java");
            newTF.addProperty("Project", projectRef); 


            CreateRequest createRequest = new CreateRequest("testfolder", newTF);
            CreateResponse createResponse = restApi.create(createRequest);  
            if (createResponse.wasSuccessful()) {

                System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));          

                //Read test folder
                String folderRef = Ref.getRelativeRef(createResponse.getObject().get("_ref").getAsString());
                System.out.println(String.format("\nReading TestFolder %s...",folderRef));
                System.out.println("Creating a child test folder...");
                JsonObject newChildTF = new JsonObject();
                newChildTF.addProperty("Name", "child tf via java");
                newChildTF.addProperty("Project", projectRef); 
                newChildTF.addProperty("Parent", folderRef); 


                CreateRequest createRequest2 = new CreateRequest("testfolder", newChildTF);
                CreateResponse createResponse2 = restApi.create(createRequest2); 
                if (createResponse2.wasSuccessful()) {
                    //----------------creating a grandchild folder  
                    System.out.println(String.format("Created %s", createResponse2.getObject().get("_ref").getAsString()));          

                    //Read test folder
                    String childFolderRef = Ref.getRelativeRef(createResponse2.getObject().get("_ref").getAsString());
                    System.out.println(String.format("\nReading TestFolder %s...",childFolderRef)); 
                    System.out.println("Creating a grandchild test folder...");
                    JsonObject newGrandChildTF = new JsonObject();
                    newGrandChildTF.addProperty("Name", "grandchild tf via java");
                    newGrandChildTF.addProperty("Project", projectRef); 
                    newGrandChildTF.addProperty("Parent", childFolderRef); 


                    CreateRequest createRequest3 = new CreateRequest("testfolder", newGrandChildTF);
                    CreateResponse createResponse3 = restApi.create(createRequest3); 
                    //----------------creating a test case
                    if (createResponse.wasSuccessful()) {

                        System.out.println(String.format("Created %s", createResponse.getObject().get("_ref").getAsString()));          

                        //Read test folder
                        String grandChildFolderRef = Ref.getRelativeRef(createResponse3.getObject().get("_ref").getAsString());
                        System.out.println(String.format("\nReading Child TestFolder %s...",grandChildFolderRef));

                        System.out.println("Creating a test case...");
                        JsonObject newTC = new JsonObject();
                        newTC.addProperty("Name", "tc via java");
                        newTC.addProperty("Project", projectRef); 
                        newTC.addProperty("TestFolder", grandChildFolderRef);
                        newTC.addProperty("Method", "Manual");


                        CreateRequest createRequest4 = new CreateRequest("testcase", newTC);
                        CreateResponse createResponse4 = restApi.create(createRequest4); 
                        if (createResponse.wasSuccessful()) {

                            System.out.println(String.format("Created %s", createResponse4.getObject().get("_ref").getAsString()));          

                            //Read test folder
                            String testCaseRef = Ref.getRelativeRef(createResponse4.getObject().get("_ref").getAsString());
                            System.out.println(String.format("\nReading TestCase %s...",testCaseRef));
                        }

                    }
                }



            } else {
                String[] createErrors;
                createErrors = createResponse.getErrors();
                System.out.println("Error!");
                for (int j=0; j<createErrors.length;j++) {
                    System.out.println(createErrors[j]);
                }
            }


    } finally {
        //Release all resources
        restApi.close();
    }