Example #1
0
        public async Task CanRetrievePagedCommentsAsync()
        {
            var summaryValue = "Test Summary with comments " + _random.Next(int.MaxValue);
            var issue        = new Issue(_jira, "TST")
            {
                Type     = "1",
                Summary  = summaryValue,
                Assignee = "admin"
            };

            issue.SaveChanges();

            // Add a comments
            await issue.AddCommentAsync("new comment1");

            await issue.AddCommentAsync("new comment2");

            await issue.AddCommentAsync("new comment3");

            await issue.AddCommentAsync("new comment4");

            // Verify first page of comments
            var comments = await issue.GetPagedCommentsAsync(2);

            Assert.Equal(2, comments.Count());
            Assert.Equal("new comment1", comments.First().Body);
            Assert.Equal("new comment2", comments.Skip(1).First().Body);

            // Verify second page of comments
            comments = await issue.GetPagedCommentsAsync(2, 2);

            Assert.Equal(2, comments.Count());
            Assert.Equal("new comment3", comments.First().Body);
            Assert.Equal("new comment4", comments.Skip(1).First().Body);
        }
Example #2
0
        public void AddAndGetComments()
        {
            var summaryValue = "Test Summary " + _random.Next(int.MaxValue);
            var issue        = new Issue(_jira, "TST")
            {
                Type     = "1",
                Summary  = summaryValue,
                Assignee = "admin"
            };

            // create an issue, verify no comments
            issue.SaveChanges();
            Assert.Empty(issue.GetCommentsAsync().Result);

            // Add a comment
            issue.AddCommentAsync("new comment").Wait();

            var options = new CommentQueryOptions();

            options.Expand.Add("renderedBody");
            var comments = issue.GetCommentsAsync(options).Result;

            Assert.Single(comments);

            var comment = comments.First();

            Assert.Equal("new comment", comment.Body);
            Assert.Equal(DateTime.Now.Year, comment.CreatedDate.Value.Year);
            Assert.Null(comment.Visibility);
            Assert.Equal("new comment", comment.RenderedBody);
        }
Example #3
0
        public async Task AddAndUpdateComments()
        {
            var summaryValue = "Test Summary " + _random.Next(int.MaxValue);
            var issue        = new Issue(_jira, "TST")
            {
                Type     = "1",
                Summary  = summaryValue,
                Assignee = "admin"
            };

            issue.SaveChanges();

            // Add a comment
            var comment = new Comment()
            {
                Author     = _jira.Credentials.UserName,
                Body       = "New comment",
                Visibility = new CommentVisibility("Developers")
            };
            var newComment = await issue.AddCommentAsync(comment);

            // Verify visibility.
            Assert.Equal("role", newComment.Visibility.Type);
            Assert.Equal("Developers", newComment.Visibility.Value);

            // Update the comment
            newComment.Visibility.Value = "Users";
            newComment.Body             = "changed body";
            var updatedComment = await issue.UpdateCommentAsync(newComment);

            // verify changes.
            Assert.Equal("role", updatedComment.Visibility.Type);
            Assert.Equal("Users", updatedComment.Visibility.Value);
            Assert.Equal("changed body", updatedComment.Body);
        }
Example #4
0
        public async static Task <Issue> GetComentarioAsync(Jira jira)
        {
            // use LINQ syntax to retrieve issues
            int        rangeStart = 1634;
            int        rangeEnd   = 1646;
            List <int> range      = Enumerable.Range(rangeStart, rangeEnd).ToList();

            string[] issuesRange = range.Select(x => $"BDMS-{x}").ToArray();
            IDictionary <string, Issue> issuesDict = await jira.Issues.GetIssuesAsync(issueKeys : issuesRange);

            foreach (var iKey in issuesDict.Keys)
            {
                Console.WriteLine("------------------");
                Console.WriteLine($"Issue: {iKey}");
                Console.WriteLine(issuesDict[iKey]);
                Console.WriteLine("------------------");
            }


            // get comments
            Issue issue = await jira.Issues.GetIssueAsync("BDMS-1079");

            var comments = await issue.GetCommentsAsync();

            Console.WriteLine(comments.First().Body);
            Console.WriteLine(comments.First().CreatedDate);
            Console.WriteLine(comments);

            // add comment
            await issue.AddCommentAsync("new test comment");

            return(issue);
        }
Example #5
0
 internal void AddIssueComment(Issue issue, string comment)
 {
     StartAsyncTask(
         $"Add comment to issue [{issue.Key}]",
         issue.AddCommentAsync(comment)
         );
 }
Example #6
0
        public async Task AddAndGetCommentsAsync()
        {
            var summaryValue = "Test Summary with comments " + _random.Next(int.MaxValue);
            var issue        = new Issue(_jira, "TST")
            {
                Type     = "1",
                Summary  = summaryValue,
                Assignee = "admin"
            };

            // create an issue, verify no comments
            issue.SaveChanges();
            var comments = await issue.GetCommentsAsync();

            Assert.Equal(0, comments.Count());

            // Add a comment
            await issue.AddCommentAsync("new comment");

            // Verify comment retrieval
            comments = await issue.GetCommentsAsync();

            Assert.Equal(1, comments.Count());
            Assert.Equal("new comment", comments.First().Body);
        }
        private async void Respond(string response)
        {
            await Issue.AddCommentAsync(response);

            Setting.Value.Jira_Response = response;
            Setting.Save();
            Responded = true;
        }
Example #8
0
 /// <summary>Добавляет комментарии к задаче.</summary>
 /// <param name="form">Форма задачи.</param>
 /// <param name="watchers">Наблюдатели.</param>
 /// <param name="issue">Задача jira.</param>
 /// <param name="author">Автор задачи.</param>
 /// <param name="task_subject">Тема задачи.</param>
 /// <param name="workflow"></param>
 public void AddComment(CreateForm form, List <PersonInfo> watchers, Issue issue, string author, string task_subject, Workflow workflow)
 {
     if (watchers.Any())
     {
         var head    = string.Join(", ", watchers.Select(t => GetMention(form.UseMention, t)));
         var comment = workflow.CommentTemplate.Replace("greeting", head);
         comment = comment.Replace("username", author);
         comment = comment.Replace("task_subject", task_subject);
         issue.AddCommentAsync(comment);
     }
 }
Example #9
0
        public async Task GetIssueThatIncludesOnlyAllNonBasicFields(Jira jira)
        {
            // Arrange
            var issue = new Issue(jira, "TST")
            {
                Type     = "1",
                Summary  = "Test issue",
                Assignee = "admin"
            };

            issue.SaveChanges();

            await issue.AddCommentAsync("My comment");

            await issue.AddWorklogAsync("1d");

            // Act
            var options = new IssueSearchOptions($"key = {issue.Key.Value}")
            {
                FetchBasicFields = false,
                AdditionalFields = new List <string>()
                {
                    "comment", "watches", "worklog"
                }
            };

            var issues = await jira.Issues.GetIssuesFromJqlAsync(options);

            var serverIssue = issues.First();

            // Assert
            Assert.Null(serverIssue.Summary);
            Assert.True(serverIssue.AdditionalFields.ContainsKey("watches"));

            var worklogs = serverIssue.AdditionalFields.Worklogs;

            Assert.Equal(20, worklogs.ItemsPerPage);
            Assert.Equal(0, worklogs.StartAt);
            Assert.Equal(1, worklogs.TotalItems);
            Assert.Equal("1d", worklogs.First().TimeSpent);

            var comments = serverIssue.AdditionalFields.Comments;

            Assert.Equal(1, comments.ItemsPerPage);
            Assert.Equal(0, comments.StartAt);
            Assert.Equal(1, comments.TotalItems);
            Assert.Equal("My comment", comments.First().Body);
        }
Example #10
0
        public static async Task AddComment(Issue issue, Dictionary <string, CaptureResult> pages)
        {
            var comment = "";

            foreach (var page in pages)
            {
                var commentColor  = (page.Value.Difference <= 1.0) ? "#59afe1" : "#f79232";
                var singleComment = String.Format(@"*Page:* {0}
{{color:{2}}}% Difference: {3}{{color}}
||Prod||Stage||Diff||
|!{1}-original.png|thumbnail!|!{1}-updated.png|thumbnail!|!{1}-diff.png|thumbnail!|
", page.Value.URL, page.Key, commentColor, page.Value.Difference);
                comment += singleComment;
            }
            await issue.AddCommentAsync(comment);
        }
Example #11
0
        public async Task UpdateComment(Jira jira)
        {
            var summaryValue = "Test Summary with comments " + _random.Next(int.MaxValue);
            var issue        = new Issue(jira, "TST")
            {
                Type     = "1",
                Summary  = summaryValue,
                Assignee = "admin"
            };

            // create an issue, verify no comments
            issue.SaveChanges();
            var comments = await issue.GetPagedCommentsAsync();

            Assert.Empty(comments);

            // Add a comment
            var commentFromAdd = await issue.AddCommentAsync("new comment");

            Assert.Equal("new comment", commentFromAdd.Body);

            // Verify comment retrieval
            comments = await issue.GetPagedCommentsAsync();

            Assert.Single(comments);
            var commentFromGet = comments.First();

            Assert.Equal(commentFromAdd.Id, commentFromGet.Id);
            Assert.Equal("new comment", commentFromGet.Body);
            Assert.Empty(commentFromGet.Properties);

            //Update Comment
            commentFromGet.Body = "new body";
            var commentFromUpdate = await issue.UpdateCommentAsync(commentFromGet);

            //Verify comment updated
            comments = await issue.GetPagedCommentsAsync();

            commentFromGet = comments.First();

            Assert.Equal(commentFromGet.Id, commentFromUpdate.Id);
            Assert.Equal("new body", commentFromGet.Body);
        }