Example #1
0
        public ResponseInfo doRequestCreateSubTestExecution(SubTestExecution subTestExecution)
        {
            ResponseInfo responseInfo = new ResponseInfo();
            var          body         = buildRequestBodySubTestExecution(subTestExecution);
            var          request      = new RestRequest();
            var          client       = new RestClient(CREATE_TEST_EXECUTION_ENPOINT);

            request.AddHeader("Content-Type", ContentType.Json);
            request.AddHeader("Accept", ContentType.Json);
            request.AddHeader("Authorization", JIRA_AUTHORIZATION);
            request.Method = Method.POST;
            request.AddJsonBody(body);
            IRestResponse response = client.Post(request);

            if (!response.IsSuccessful)
            {
                responseInfo.isSuccess = false;
                responseInfo.message   = response.Content;
            }
            else
            {
                JObject jObject = JObject.Parse(response.Content);
                responseInfo.isSuccess = true;
                string id  = jObject.GetValue("id").ToString();
                string key = jObject.GetValue("key").ToString();
                responseInfo.id  = id;
                responseInfo.key = key;
                ResponseInfo responseInfoAddTestEnvironment = doRequestAddTestEnvironment(subTestExecution.fields.project.key, id, subTestExecution.fields.testEnvironment);
                if (!responseInfoAddTestEnvironment.isSuccess)
                {
                    responseInfo.message = responseInfoAddTestEnvironment.message;
                    return(responseInfo);
                }

                if (!string.IsNullOrEmpty(subTestExecution.fields.testPlanKey))
                {
                    ResponseInfo responseAddTestPlan = doRequestAddTestExecutionToTestPlan(subTestExecution.fields.testPlanKey, id);
                    if (!responseAddTestPlan.isSuccess)
                    {
                        responseInfo.message = responseAddTestPlan.message;
                    }
                }
                if (responseInfo.isSuccess)
                {
                    responseInfo.message = String.Format("Create sub test execution with key: {0} success", key);
                }
            }
            if (!responseInfo.isSuccess)
            {
                responseInfo.message = subTestExecution.fields.summary + "_" + responseInfo.message;
            }
            return(responseInfo);
        }
Example #2
0
 private void btnExecute_Click(object sender, EventArgs e)
 {
     btnExecute.Enabled = false;
     txtInfo.Text       = "";
     if (validate().Length > 0)
     {
         txtInfo.Text      = validate();
         txtInfo.ForeColor = Color.Red;
     }
     else
     {
         if (issueType == IssueType.TestExecution)
         {
             List <FieldsTestExecution> fieldsIssues  = ExcelUtils.getDataTestExecution(txtDataPath.Text, txtProjectKey.Text);
             List <ResponseInfo>        responseInfos = new List <ResponseInfo>();
             foreach (var p in fieldsIssues)
             {
                 TestExecution issue = new TestExecution {
                     fields = p
                 };
                 ResponseInfo responseInfo = RestShapUtils.getInstance().doRequestCreateTestExecution(issue);
                 responseInfos.Add(responseInfo);
                 txtInfo.Text += "\n" + responseInfo.message;
             }
             saveFile(responseInfos);
         }
         else
         {
             List <FieldsSubTestExecution> fieldsSubTests = ExcelUtils.getDataSubTestExecution(txtDataPath.Text, txtProjectKey.Text);
             List <ResponseInfo>           responseInfos  = new List <ResponseInfo>();
             foreach (var p in fieldsSubTests)
             {
                 SubTestExecution issue = new SubTestExecution {
                     fields = p
                 };
                 ResponseInfo responseInfo = RestShapUtils.getInstance().doRequestCreateSubTestExecution(issue);
                 responseInfos.Add(responseInfo);
                 txtInfo.Text += "\n" + responseInfo.message;
             }
             saveFile(responseInfos);
         }
     }
     btnExecute.Enabled = true;
 }
Example #3
0
        public string buildRequestBodySubTestExecution(SubTestExecution subTestExecution)
        {
            FieldsSubTestExecutionCreate fields = new FieldsSubTestExecutionCreate
            {
                components  = subTestExecution.fields.components,
                priority    = subTestExecution.fields.priority,
                parent      = subTestExecution.fields.parent,
                summary     = subTestExecution.fields.summary,
                description = subTestExecution.fields.description,
                labels      = subTestExecution.fields.labels,
                project     = subTestExecution.fields.project,
                issuetype   = new FieldByName {
                    name = "Sub Test Execution"
                }
            };
            SubTestExecutionCreate subTest = new SubTestExecutionCreate {
                fields = fields
            };
            var settings = new JsonSerializerSettings();

            settings.NullValueHandling    = NullValueHandling.Ignore;
            settings.DefaultValueHandling = DefaultValueHandling.Ignore;
            return(JsonConvert.SerializeObject(subTest, settings));
        }