public async Task UpdateIssue(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var reference = await jira.CreateIssueAsync(new JiraIssue { Project = TestMetadata.Project, IssueType = TestMetadata.IssueType, Summary = "Test issue" }, CancellationToken.None); await jira.UpdateIssueAsync(reference, new JiraIssue { Assignee = new JiraUser { Key = "testUser" } }, CancellationToken.None); var response = await jira.SelectIssuesAsync(new JiraIssuesRequest { Jql = "summary ~ Test", Fields = new[] { "summary", "assignee" } }); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.Issues[0].Key, Is.EqualTo(reference.Key)); Assert.That(response.Issues[0].Id, Is.EqualTo(reference.Id)); Assert.That(response.Issues[0].Self, Is.EqualTo(reference.Self)); Assert.That(response.Issues[0].Summary, Is.EqualTo("Test issue")); Assert.That(response.Issues[0].Assignee, Is.Not.Null); Assert.That(response.Issues[0].Assignee.Key, Is.EqualTo("testUser")); }
public async Task UpdateIssueIgnoresUnchangingFields(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var reference = await jira.CreateIssueAsync(new JiraCustomIssue { Summary = "Test issue", IntValue = 256 }, CancellationToken.None); await jira.UpdateIssueAsync(reference, new JiraCustomIssue { Project = new JiraProject(), IssueType = new JiraIssueType(), Summary = "Test issue 1", IntValue = 257 }, CancellationToken.None); var response = await jira.SelectIssuesAsync <JiraCustomIssue>(new JiraIssuesRequest { Jql = $"KEY = {reference.Key}", Fields = new[] { "project", "issueType", "summary", "customfield_43567" } }); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.Issues[0].Key, Is.EqualTo(reference.Key)); Assert.That(response.Issues[0].Project, Is.Not.Null); Assert.That(response.Issues[0].Project.Id, Is.EqualTo(TestMetadata.Project.Id)); Assert.That(response.Issues[0].IssueType, Is.Not.Null); Assert.That(response.Issues[0].IssueType.Id, Is.EqualTo(TestMetadata.IssueType.Id)); Assert.That(response.Issues[0].Summary, Is.EqualTo("Test issue 1")); Assert.That(response.Issues[0].IntValue, Is.EqualTo(257)); }
public async Task SelectUsingMaxResult(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var reference1 = await jira.CreateIssueAsync(new JiraCustomIssue { Summary = "Test issue 1", IntValue = 1234 }, CancellationToken.None); var reference2 = await jira.CreateIssueAsync(new JiraCustomIssue { Summary = "Test issue 2", IntValue = 1235 }, CancellationToken.None); var response = await jira.SelectIssuesAsync <JiraCustomIssue>(new JiraIssuesRequest { Jql = "order by cf[43567]", MaxResults = 1, Fields = new[] { "customfield_43567" } }); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.StartAt, Is.EqualTo(0)); Assert.That(response.Total, Is.EqualTo(2)); Assert.That(response.MaxResults, Is.EqualTo(1)); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.Issues[0].Key, Is.EqualTo(reference1.Key)); Assert.That(response.Issues[0].IntValue, Is.EqualTo(1234)); }
public async Task AddComment(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var reference = await jira.CreateIssueAsync(new JiraIssue { Project = TestMetadata.Project, IssueType = TestMetadata.IssueType, Summary = "Test issue" }, CancellationToken.None); await jira.AddCommentAsync(reference, new JiraComment { Body = "Some comment" }, CancellationToken.None); var response = await jira.GetCommentsAsync(reference, new JiraCommentsRequest { StartAt = 0, MaxResults = 200 }, CancellationToken.None); Assert.That(response.Total, Is.EqualTo(1)); Assert.That(response.StartAt, Is.EqualTo(0)); Assert.That(response.Comments.Length, Is.EqualTo(1)); Assert.That(response.Comments[0].Body, Is.EqualTo("Some comment")); }
public void UploadAttachment(JiraType jiraType) { var jira = jiraType == JiraType.File ? fileJira : inMemoryJira; var threads = new Thread[10]; Exception lastException = null; var lockObject = new object(); int value = 0; var reference = jira.CreateIssue(new JiraCustomIssue { Project = TestMetadata.Project, IssueType = TestMetadata.IssueType, IntValue = value }); for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(o => { try { for (int j = 0; j < 100; ++j) { jira.UploadAttachment(reference, $"{Interlocked.Increment(ref value)}.txt", Encoding.UTF8.GetBytes("Hello, world!")); } } catch (Exception e) { lock (lockObject) lastException = e; } }); } foreach (var t in threads) { t.Start(); } foreach (var t in threads) { t.Join(); } Assert.That(lastException, Is.Null); var response = jira.SelectIssues <JiraCustomIssue>(new JiraIssuesRequest { StartAt = 0, MaxResults = 200, Jql = "project = TESTPROJECT", Fields = new[] { "attachment" } }); Assert.That(response.Total, Is.EqualTo(1)); Assert.That(response.Issues[0].Key, Is.EqualTo(reference.Key)); Assert.That(response.Issues[0].Attachment.Length, Is.EqualTo(1000)); }
public void DownloadAttachment(JiraType jiraType) { var jira = jiraType == JiraType.File ? fileJira : inMemoryJira; var threads = new Thread[10]; Exception lastException = null; var lockObject = new object(); int value = 0; var reference = jira.CreateIssue(new JiraCustomIssue { Project = TestMetadata.Project, IssueType = TestMetadata.IssueType, IntValue = value }); var attachment = jira.UploadAttachment(reference, $"{Interlocked.Increment(ref value)}.txt", Encoding.UTF8.GetBytes("Hello, world!")); for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(o => { try { for (int j = 0; j < 100; ++j) { var bytes = jira.DownloadAttachment(attachment); Assert.That(Encoding.UTF8.GetString(bytes), Is.EqualTo("Hello, world!")); } } catch (Exception e) { lock (lockObject) lastException = e; } }); } foreach (var t in threads) { t.Start(); } foreach (var t in threads) { t.Join(); } Assert.That(lastException, Is.Null); }
public async Task UploadAttachment(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var reference = await jira.CreateIssueAsync(new JiraIssue { Project = TestMetadata.Project, IssueType = TestMetadata.IssueType, Summary = "Test issue" }, CancellationToken.None); var attachment = await jira.UploadAttachmentAsync(reference, "some.txt", Encoding.UTF8.GetBytes("some text"), CancellationToken.None); var downloadedAttachment = await jira.DownloadAttachmentAsync(attachment, CancellationToken.None); Assert.That(downloadedAttachment, Is.Not.Null); Assert.That(Encoding.UTF8.GetString(downloadedAttachment), Is.EqualTo("some text")); }
public async Task SelectReturnsOnlyRequiredFields(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var reference = await jira.CreateIssueAsync(new JiraCustomIssue { Summary = "Test issue", IntValue = 1234 }, CancellationToken.None); var response = await jira.SelectIssuesAsync <JiraCustomIssue>(new JiraIssuesRequest { Jql = $"KEY = {reference.Key}", Fields = new[] { "customfield_43567" } }); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.Issues[0].Key, Is.EqualTo(reference.Key)); Assert.That(response.Issues[0].IntValue, Is.EqualTo(1234)); Assert.That(response.Issues[0].Summary, Is.Null); }
public async Task CreatesMethodFillsOtherFields(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var now = DateTime.Now; var reference = await jira.CreateIssueAsync(new JiraCustomIssue { Summary = "Test issue", }, CancellationToken.None); var response = await jira.SelectIssuesAsync <JiraCustomIssue>(new JiraIssuesRequest { Jql = $"KEY = {reference.Key}", Fields = new[] { "created", "updated", "creator" } }); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.Issues[0].Key, Is.EqualTo(reference.Key)); Assert.That(response.Issues[0].Created, Is.GreaterThan(now)); Assert.That(response.Issues[0].Updated, Is.GreaterThan(now)); Assert.That(response.Issues[0].Creator, Is.Not.Null); Assert.That(response.Issues[0].Creator.Key, Is.EqualTo(TestMetadata.User.Key)); }
public async Task UpdateFillsUpdated(JiraType type) { var jira = type == JiraType.File ? fileJira : memoryJira; var reference = await jira.CreateIssueAsync(new JiraCustomIssue { Updated = new DateTime(1900, 1, 1), Summary = "Test issue", }, CancellationToken.None); var now = DateTime.Now; await jira.UpdateIssueAsync(reference, new JiraCustomIssue(), CancellationToken.None); var response = await jira.SelectIssuesAsync <JiraCustomIssue>(new JiraIssuesRequest { Jql = $"KEY = {reference.Key}", Fields = new[] { "updated" } }); Assert.That(response.Issues.Length, Is.EqualTo(1)); Assert.That(response.Issues[0].Key, Is.EqualTo(reference.Key)); Assert.That(response.Issues[0].Updated, Is.GreaterThan(now)); }
public void Create(JiraType jiraType) { var threads = new Thread[10]; Exception lastException = null; var lockObject = new object(); int value = 0; var jira = jiraType == JiraType.File ? fileJira : inMemoryJira; for (int i = 0; i < threads.Length; i++) { threads[i] = new Thread(o => { try { for (int j = 0; j < 100; ++j) { jira.CreateIssue(new JiraCustomIssue { Project = TestMetadata.Project, IssueType = TestMetadata.IssueType, IntValue = Interlocked.Increment(ref value) }); } } catch (Exception e) { lock (lockObject) lastException = e; } }); } foreach (var t in threads) { t.Start(); } foreach (var t in threads) { t.Join(); } Assert.That(lastException, Is.Null); var response = jira.SelectIssues <JiraCustomIssue>(new JiraIssuesRequest { StartAt = 0, MaxResults = 200, Jql = "project = TESTPROJECT", }); Assert.That(response.Total, Is.EqualTo(1000)); var issues = response.Issues.ToList(); for (int i = 0; i < 4; ++i) { issues.AddRange(jira.SelectIssues <JiraCustomIssue>(new JiraIssuesRequest { StartAt = (i + 1) * 200, MaxResults = 200, Jql = "project = TESTPROJECT" }).Issues); } Assert.That(issues.Count, Is.EqualTo(1000)); Assert.That(issues.Select(x => x.IntValue), Is.EquivalentTo(Enumerable.Range(1, 1000))); }