private string FormatIssue(RemoteIssue issue, bool showComments) { string issueDetails = Run(() => issue.Format()); if (showComments) { issueDetails = issueDetails + "\r\n" + Run(() => _jira.GetComments(issue.key)); } return issueDetails + "\r\n" + UrlFor(issue); }
public void AddIssue(string key, string assignee, string status, string summary) { var issue = new RemoteIssue() { key = key, assignee = assignee, status = status, summary = summary }; this.issues.Add(issue); }
public void TestRequiredArguments() { var issue = new RemoteIssue {key = "BTST-123", status="1", created = new DateTime(2009, 01, 05), summary = "summary"}; using (var issueCommandMock = NewCommand<IssueCommand, RemoteIssue>(proxy => proxy.GetIssue("BTST-123"), issue)) { Mock<IContext> contextMock = ContextMockFor("issue-user", issue.key); var result = issueCommandMock.Process(contextMock.Object); Assert.AreEqual(ExpectedResultFor(issue), result.HumanReadable); Assert.AreEqual(issue.key, result.PipeValue); } }
public override string CreateDefect( Dictionary<string, string> defectInfos ) { Connect(); RemoteIssue issue = new RemoteIssue(); RemotePriority[] priorities = jira.getPriorities(jiraToken); RemoteIssueType[] issueTypes = jira.getIssueTypes(jiraToken); jira.getProjectRoles(jiraToken); issue.created = DateTime.Now; issue.summary = "TOSCA[" + defectInfos["Workspace-User"] + "]: Error in Testcase \"" + defectInfos["TestCase-Name"] + "\""; string description = defectInfos["Log-Description"]; if (!String.IsNullOrEmpty(description)) { issue.description = description; } else { String compressedLog = defectInfos["CompressedLogDetails"]; issue.description = String.IsNullOrEmpty(compressedLog) ? String.Empty : GetLogInfoFromCompressedLogDetails(compressedLog); } issue.assignee = GetDefectIntegrationSetting("DefectAssignee", defectInfos); if (issue.assignee == string.Empty) { issue.assignee = "-1"; } issue.project = GetDefectIntegrationSetting("DefectProject", defectInfos); issue.priority = GetDefectIntegrationSetting("DefectPriority", defectInfos); foreach (RemotePriority priority in priorities) { if (priority.name == issue.priority) { issue.priority = priority.id; break; } } issue.status = GetDefectIntegrationSetting("DefectStatus", defectInfos); issue.type = GetDefectIntegrationSetting("DefectType", defectInfos); foreach (RemoteIssueType issueType in issueTypes) { if (issueType.name == issue.type) { issue.type = issueType.id; break; } } issue.components = GetComponents(GetDefectIntegrationSetting("DefectComponents", defectInfos)); issue.customFieldValues = GetCustomDefectProperties(defectInfos).Select(property => new RemoteCustomFieldValue { customfieldId = "customfield_" + property.id, values = property.value.Split(',') }).ToArray(); issue = jira.createIssue(jiraToken, issue); Disconnect(); return issue != null ? issue.key : string.Empty; }
public void TestNonExistingIssue() { RemoteIssue issue = new RemoteIssue { key = "BTST-123", status = "2", created = new DateTime(2009, 01, 05), summary = "summary" }; using (var commandMock = NewCommand<IssueCommand>(mock => mock.Setup(proxy => proxy.GetIssue("BTST-123")).Throws(new JiraProxyException("Failed to get issue: " + issue.key, new Exception(""))))) { Mock<IContext> contextMock = ContextMockFor("issue-user", issue.key); var result = commandMock.Process(contextMock.Object); Assert.AreEqual("Failed to get issue: " + issue.key + "\r\n\r\n", result.HumanReadable); Assert.AreEqual(issue.key, result.PipeValue); } }
public async Task IfComponentsAdded_ReturnsFields() { var issue = new RemoteIssue() { key = "foo" }.ToLocal(TestableJira.Create()); var component = new RemoteComponent() { id = "1", name = "1.0" }; issue.Components.Add(component.ToLocal()); var fields = await GetUpdatedFieldsForIssueAsync(issue); Assert.Single(fields); Assert.Equal("components", fields[0].id); Assert.Equal("1", fields[0].values[0]); }
public async Task IfAddAffectsVersion_ReturnAllFieldsThatChanged() { var issue = new RemoteIssue() { key = "foo" }.ToLocal(TestableJira.Create()); var version = new RemoteVersion() { id = "1", name = "1.0" }; issue.AffectsVersions.Add(version.ToLocal(TestableJira.Create())); var fields = await GetUpdatedFieldsForIssueAsync(issue); Assert.Single(fields); Assert.Equal("versions", fields[0].id); Assert.Equal("1", fields[0].values[0]); }
internal void ProcessAction(JiraIssue issue, IIssueAction action, IIssueUser assignTo) { var actionParams = new List <RemoteFieldValue>(); RemoteField[] fields = _service.getFieldsForAction(_token, issue.DisplayId, action.Id); foreach (RemoteField field in fields) { var param = new RemoteFieldValue(); string paramName = param.id = field.id; if (StringComparer.OrdinalIgnoreCase.Equals("Resolution", field.name)) { param.values = new[] { FindFixResolution() } } ; else if (StringComparer.OrdinalIgnoreCase.Equals("Assignee", field.name)) { param.values = new[] { assignTo.Id } } ; else if (StringComparer.OrdinalIgnoreCase.Equals("Worklog", paramName)) // JIRA 4.1 - worklogs are required! { continue; } else { param.values = issue.GetFieldValue(paramName); if (param.values == null || param.values.Length == 0 || (param.values.Length == 1 && param.values[0] == null)) { string setting = _settings(String.Format("{0}:{1}", action.Name, field.name)); if (setting != null) { param.values = new[] { setting } } ; } } actionParams.Add(param); } RemoteIssue newIssue = _service.progressWorkflowAction(_token, issue.DisplayId, action.Id, actionParams.ToArray()); }
public async Task IfComparableEqual_ReturnNoFieldsThatChanged() { var jira = TestableJira.Create(); var remoteIssue = new RemoteIssue() { priority = new RemotePriority() { id = "5" }, }; var issue = remoteIssue.ToLocal(jira); issue.Priority = "5"; jira.IssuePriorityService.Setup(s => s.GetPrioritiesAsync(CancellationToken.None)) .Returns(Task.FromResult(Enumerable.Repeat(new IssuePriority("5"), 1))); Assert.Empty(await GetUpdatedFieldsForIssueAsync(issue)); }
public void IfAddAffectsVersion_ReturnAllFieldsThatChanged() { var issue = new RemoteIssue() { key = "foo" }.ToLocal(); var version = new RemoteVersion() { id = "1", name = "1.0" }; issue.AffectsVersions.Add(version.ToLocal()); var fields = GetUpdatedFieldsForIssue(issue); Assert.Equal(1, fields.Length); Assert.Equal("versions", fields[0].id); Assert.Equal("1", fields[0].values[0]); }
public void IfComponentsAdded_ReturnsFields() { var issue = new RemoteIssue() { key = "foo" }.ToLocal(); var component = new RemoteComponent() { id = "1", name = "1.0" }; issue.Components.Add(component.ToLocal()); var fields = GetUpdatedFieldsForIssue(issue); Assert.Equal(1, fields.Length); Assert.Equal("components", fields[0].id); Assert.Equal("1", fields[0].values[0]); }
public void ReturnsCustomFieldThatWasModified() { var jira = TestableJira.Create(); var remoteField = new RemoteField() { id = "CustomField1", name = "My Custom Field" }; var remoteCustomFieldValue = new RemoteCustomFieldValue() { customfieldId = "CustomField1", values = new string[1] { "My Value" } }; var remoteIssue = new RemoteIssue() { key = "TST-1", project = "TST", type = "1", customFieldValues = new RemoteCustomFieldValue[1] { remoteCustomFieldValue } }; jira.SoapService.Setup(s => s.GetIssuesFromJqlSearch(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())).Returns(new RemoteIssue[1] { remoteIssue }); jira.SoapService.Setup(s => s.GetFieldsForEdit(It.IsAny <string>(), It.IsAny <string>())).Returns(new RemoteField[1] { remoteField }); var issue = jira.GetIssuesFromJql("TST-1").First(); issue["My Custom Field"] = "My New Value"; var result = GetUpdatedFieldsForIssue(issue); Assert.Equal(1, result.Length); Assert.Equal("CustomField1", result.First().id); Assert.Equal("My New Value", result.First().values[0]); }
public void CanSwitchContextToRetrieveDifferentTypeOfCustomFields() { // Arrange var jira = TestableJira.Create(); jira.SoapService.Setup(c => c.GetFieldsForEdit(It.IsAny <string>(), "issueKey")).Returns(new RemoteField[] { new RemoteField() { id = "editField1", name = "EditCustomField" } }); jira.SoapService.Setup(c => c.GetFieldsForAction(It.IsAny <string>(), "issueKey", "action1")).Returns(new RemoteField[] { new RemoteField() { id = "actionField1", name = "ActionCustomField" } }); var issue = new RemoteIssue() { project = "projectKey", key = "issueKey", customFieldValues = new RemoteCustomFieldValue[] { new RemoteCustomFieldValue() { customfieldId = "editField1", values = new string[] { "editFieldValue" } }, new RemoteCustomFieldValue() { customfieldId = "actionField1", values = new string[] { "actionFieldValue" } }, } }.ToLocal(jira); // Act/Assert var fields = issue.CustomFields; Assert.Equal("actionFieldValue", fields.ForAction("action1")["ActionCustomField"].Values[0]); Assert.Equal("editFieldValue", fields.ForEdit()["EditCustomField"].Values[0]); }
public void BulkLoadNewIssues(ExcelSheet sheet) { if (sheet.Rows.Count != 0) { foreach (System.Data.DataRow row in sheet.Rows) { RemoteIssue issue = this.convertRowToIssue(row, "New Feature"); var existingIssues = from existing in jira.Issues where existing.summary == issue.summary select existing; if (new List <RemoteIssue>(existingIssues).Count == 0) { jira.addNewIssue(issue); } else { String existingKey = "";//existingIssues.ToArray<RemoteIssue>[0].key; // jira.updateIssue(issue); } } } }
private RemoteIssue GetIssue(JiraSoapServiceService jss, string token, string jiraId) { if (loadedJiraItems.ContainsKey(jiraId)) { return((RemoteIssue)(loadedJiraItems[jiraId])); } else { try { RemoteIssue issue = jss.getIssue(token, jiraId); loadedJiraItems[jiraId] = issue; return(issue); } catch (Exception exp) { rp("Loading Jira issue failed..." + exp.Message); return(null); } } }
public JiraIssue getIssue(string key) { JiraIssue jiraIssue = null; if (jiraCache.Contains(key)) { jiraIssue = jiraCache[key]; } if (jiraIssue == null) { checkCredentials(); try { RemoteIssue issue = jira.getIssue(credentials, key); jiraIssue = new JiraIssue(issue.key, issue.created, getUserFullName(issue.reporter), getUserFullName(issue.assignee), issue.project, issue.summary, issue.description, issue.environment, issue.attachmentNames); jiraCache.Add(key, jiraIssue); } catch (Exception e) { LOG.Error("Problem retrieving Jira: " + key, e); } } return(jiraIssue); }
internal static RemoteIssue CreateIssue(string token, RemoteIssue remoteIssue) { if (!IsConfigured) { throw new InvalidOperationException("JIRA is not configured"); } if (Log.IsDebugEnabled) { Log.DebugFormat("Creating issue:\n{0}", remoteIssue.ToJson()); } remoteIssue = Service.createIssue(token, remoteIssue); if (Log.IsDebugEnabled) { Log.DebugFormat("Successfully created issue:\n{0}", remoteIssue.ToJson()); } return(remoteIssue); }
public async Task ExcludesCustomFieldsNotModified() { var jira = TestableJira.Create(); var customField = new CustomField(new RemoteField() { id = "CustomField1", name = "My Custom Field" }); var remoteCustomFieldValue = new RemoteCustomFieldValue() { customfieldId = "CustomField1", values = new string[1] { "My Value" } }; var remoteIssue = new RemoteIssue() { key = "TST-1", project = "TST", type = new RemoteIssueType() { id = "1" }, customFieldValues = new RemoteCustomFieldValue[1] { remoteCustomFieldValue } }; jira.IssueService.Setup(s => s.GetIssueAsync("TST-1", CancellationToken.None)) .Returns(Task.FromResult(new Issue(jira, remoteIssue))); jira.IssueFieldService.Setup(c => c.GetCustomFieldsAsync(CancellationToken.None)) .Returns(Task.FromResult(Enumerable.Repeat <CustomField>(customField, 1))); jira.IssueTypeService.Setup(s => s.GetIssueTypesAsync(CancellationToken.None)) .Returns(Task.FromResult(Enumerable.Repeat(new IssueType("1"), 1))); var issue = jira.Issues.GetIssueAsync("TST-1").Result; var result = await GetUpdatedFieldsForIssueAsync(issue); Assert.Empty(result); }
public void WillThrowErrorIfCustomFieldNotFound() { // Arrange var jira = TestableJira.Create(); var customField = new CustomField(new RemoteField() { id = "123", name = "CustomField" }); jira.IssueFieldService.Setup(c => c.GetCustomFieldsAsync(CancellationToken.None)) .Returns(Task.FromResult(Enumerable.Repeat <CustomField>(customField, 1))); var issue = new RemoteIssue() { project = "projectKey", key = "issueKey", customFieldValues = null, }.ToLocal(jira); // Act / Assert Assert.Throws <InvalidOperationException>(() => issue.CustomFields["NonExistantField"].Values[0]); }
public void IfIssueTypeWithNameNotChanged_ReturnsNoFieldsChanged() { var jira = TestableJira.Create(); jira.SoapService.Setup(s => s.GetIssueTypes(It.IsAny <string>(), It.IsAny <string>())) .Returns(new RemoteIssueType[] { new RemoteIssueType() { id = "5", name = "Task" } }); var remoteIssue = new RemoteIssue() { type = "5", }; var issue = remoteIssue.ToLocal(jira); issue.Type = "Task"; Assert.Equal(0, GetUpdatedFieldsForIssue(issue).Length); }
public void TestComments() { var issue = new RemoteIssue { key = "BTST-123", status = "2", created = new DateTime(2009, 01, 05), summary = "summary" }; const string comments = "some comments..."; var commandMock = NewCommand<IssueCommand>( mock => mock.Setup(proxy => proxy.GetIssue("BTST-123")).Returns(issue), mock => mock.Setup(proxy => proxy.GetComments("BTST-123")).Returns(comments)); Mock<IContext> contextMock = ContextMockFor("issue-user", issue.key, "comments"); var result = commandMock.Process(contextMock.Object); Assert.AreEqual( ExpectedResultFor(issue, comments), result.HumanReadable); Assert.AreEqual( issue.key, result.PipeValue); commandMock.Verify(); }
/// <summary> /// Creates a new instance of IssueFields. /// </summary> /// <param name="remoteIssue">The remote issue that contains the fields.</param> /// <param name="jiraUrl">The JIRA server url.</param> /// <param name="credentials">The credentials used to access server resources.</param> public IssueFields(RemoteIssue remoteIssue, string jiraUrl = null, JiraCredentials credentials = null) { _map = remoteIssue.fieldsReadOnly ?? new Dictionary <string, JToken>(); if (remoteIssue.remotePagedComments != null) { var pagedResults = remoteIssue.remotePagedComments; var comments = pagedResults.remoteComments.Select(remoteComment => new Comment(remoteComment)); this.Comments = new PagedQueryResult <Comment>(comments, pagedResults.startAt, pagedResults.maxResults, pagedResults.total); } if (remoteIssue.remotePagedWorklogs != null) { var pagedResults = remoteIssue.remotePagedWorklogs; var worklogs = pagedResults.remoteWorklogs.Select(remoteWorklog => new Worklog(remoteWorklog)); this.Worklogs = new PagedQueryResult <Worklog>(worklogs, pagedResults.startAt, pagedResults.maxResults, pagedResults.total); } if (remoteIssue.remoteAttachments != null) { this.Attachments = remoteIssue.remoteAttachments.Select(remoteAttachment => new Attachment(jiraUrl, new WebClientWrapper(credentials), remoteAttachment)); } }
/// <summary> /// Do the actual query by converting the rss into a list of issue items /// </summary> private IList <RemoteIssue> DoQuery(String queryUrl) { List <RemoteIssue> result = new List <RemoteIssue>(); // Make the request HttpWebRequest request = WebRequest.Create(queryUrl) as HttpWebRequest; // Handle credentials if (_username != null && _password != null) { CredentialCache creds = new CredentialCache(); creds.Add(new Uri(queryUrl), "Basic", new NetworkCredential(_username, _password)); request.Credentials = creds; } // Console.WriteLine( "Query: "+queryUrl ); HttpWebResponse response = request.GetResponse() as HttpWebResponse; // Parse the xml from the get all open issues query XmlDocument doc = new XmlDocument(); doc.Load(response.GetResponseStream()); foreach (XmlNode itemNode in doc.SelectNodes("//rss/channel/item")) { RemoteIssue issue = new RemoteIssue(); issue.key = itemNode.SelectSingleNode("key").InnerText; issue.summary = itemNode.SelectSingleNode("title").InnerText; issue.status = itemNode.SelectSingleNode("status").Attributes["id"].InnerText; result.Add(issue); } return(result); }
public void IndexByName_ShouldThrowIfUnableToFindRemoteValue() { var jira = TestableJira.Create(); jira.SetupIssues(new RemoteIssue() { key = "123" }); var issue = new RemoteIssue() { project = "bar", key = "foo", customFieldValues = new RemoteCustomFieldValue[] { new RemoteCustomFieldValue() { customfieldId = "123", values = new string[] { "abc" } } } }.ToLocal(jira); Assert.Throws <InvalidOperationException>(() => issue["CustomField"]); }
private void SubmitIssue() { if (!String.IsNullOrEmpty(Issue.Text) && !String.IsNullOrEmpty(Project.Text)) { try { var issue = new RemoteIssue(); issue.project = ((RemoteProject)Project.SelectedItem).key; issue.summary = Issue.Text; issue.description = Description.Text; // Defaulting to New Feature for the moment issue.type = IssueType.SelectedValue.ToString(); // Assumes assigning to yourself issue.assignee = _username; RemoteIssue result = _client.createIssue(_token, issue); IssuesCreated.Items.Add(result.summary); Issue.Text = String.Empty; Description.Text = String.Empty; } catch (Exception ex) { MessageBox.Show(ex.Message); } Issue.Focus(); } else { MessageBox.Show("Please fill in the Project and Issue fields"); } }
public override Dictionary <string, string> GetStatesForDefects(List <string> defectIds) { Dictionary <string, string> result = new Dictionary <string, string>(); List <string> failedIds = new List <string>(); Connect(); RemoteStatus[] remoteStatuses = jira.getStatuses(jiraToken); Dictionary <string, string> statusNames = remoteStatuses.ToDictionary(remoteStatus => remoteStatus.id, remoteStatus => remoteStatus.name); foreach (string defectId in defectIds) { try { RemoteIssue issue = jira.getIssue(jiraToken, defectId); if (statusNames.ContainsKey(issue.status)) { result.Add(defectId, statusNames[issue.status]); } } catch { failedIds.Add(defectId); } } Disconnect(); if (failedIds.Count > 0) { MessageBox.Show( "The status of the following Defects could not be retrieved:" + Environment.NewLine + string.Join(",", failedIds.ToArray()), "Synchronize Defect States"); } return(result); }
public void FromRemote_ShouldPopulateFields() { var remoteIssue = new RemoteIssue() { affectsVersions = new RemoteVersion[] { new RemoteVersion() { id = "remoteVersion" } }, assignee = "assignee", components = new RemoteComponent[] { new RemoteComponent() { id = "remoteComponent" } }, created = new DateTime(2011, 1, 1), customFieldValues = new RemoteCustomFieldValue[] { new RemoteCustomFieldValue() { customfieldId = "customField" } }, description = "description", duedate = new DateTime(2011, 3, 3), environment = "environment", fixVersions = new RemoteVersion[] { new RemoteVersion() { id = "remoteFixVersion" } }, key = "key", priority = new RemotePriority() { id = "priority" }, project = "project", reporter = "reporter", resolution = new RemoteResolution() { id = "resolution" }, status = new RemoteStatus() { id = "status" }, summary = "summary", type = new RemoteIssueType() { id = "type" }, updated = new DateTime(2011, 2, 2), votesData = new RemoteVotes() { votes = 1, hasVoted = true } }; var issue = remoteIssue.ToLocal(TestableJira.Create()); Assert.Single(issue.AffectsVersions); Assert.Equal("assignee", issue.Assignee); Assert.Single(issue.Components); Assert.Equal(new DateTime(2011, 1, 1), issue.Created); Assert.Single(issue.CustomFields); Assert.Equal("description", issue.Description); Assert.Equal(new DateTime(2011, 3, 3), issue.DueDate); Assert.Equal("environment", issue.Environment); Assert.Equal("key", issue.Key.Value); Assert.Equal("priority", issue.Priority.Id); Assert.Equal("project", issue.Project); Assert.Equal("reporter", issue.Reporter); Assert.Equal("resolution", issue.Resolution.Id); Assert.Equal("status", issue.Status.Id); Assert.Equal("summary", issue.Summary); Assert.Equal("type", issue.Type.Id); Assert.Equal(new DateTime(2011, 2, 2), issue.Updated); Assert.Equal(1, issue.Votes); Assert.True(issue.HasUserVoted); }
private void WriteExcelRow(Excel.Worksheet oSheet, int index, reviewData rv, versionedLineCommentData vlcd, JiraSoapServiceService jss, string token) { int column = 1; rp(String.Format("[{0}] Processing comment [{1}] from [{2}]", CommentCount, vlcd.permaId.id, vlcd.user.displayName)); CommentCount++; Excel.Range rng = (Excel.Range)(oSheet.Cells[index, 1]); rng.EntireRow.Font.Size = 9; rng.EntireRow.WrapText = true; oSheet.Cells[index, column++] = rv.author.userName; oSheet.Cells[index, column++] = rv.author.displayName; oSheet.Cells[index, column++] = bf(rv.closeDate); oSheet.Cells[index, column++] = bf(rv.createDate); oSheet.Cells[index, column++] = rv.creator.userName; oSheet.Cells[index, column++] = rv.creator.displayName; oSheet.Cells[index, column++] = rv.description; oSheet.Cells[index, column++] = bf(rv.dueDate); oSheet.Cells[index, column++] = rv.jiraIssueKey; if (rv.jiraIssueKey != null && rv.jiraIssueKey != "") { RemoteIssue issue = GetIssue(jss, token, rv.jiraIssueKey); oSheet.Cells[index, column++] = verToString(issue.affectsVersions); oSheet.Cells[index, column++] = GetCvValue(issue, Properties.Settings.Default.JiraAddlCustomField); } else { column++; column++; } oSheet.Cells[index, column++] = rv.moderator.userName; oSheet.Cells[index, column++] = rv.moderator.displayName; oSheet.Cells[index, column++] = rv.name; oSheet.Cells[index, column++] = rv.permaId.id; oSheet.Cells[index, column++] = rv.projectKey; oSheet.Cells[index, column++] = rv.state.ToString(); oSheet.Cells[index, column++] = rv.summary; oSheet.Cells[index, column++] = vlcd.fromLineRange; oSheet.Cells[index, column++] = vlcd.toLineRange; if (vlcd.lineRanges != null) { string lineRanges = ""; foreach (lineRangeDetail lr in vlcd.lineRanges) { lineRanges += lr.revision + "-" + lr.range + "\r\n"; } oSheet.Cells[index, column++] = lineRanges; } else { column++; } oSheet.Cells[index, column++] = bf(vlcd.createDate); oSheet.Cells[index, column++] = Convert.ToString(vlcd.defectRaised); oSheet.Cells[index, column++] = Convert.ToString(vlcd.deleted); oSheet.Cells[index, column++] = Convert.ToString(vlcd.draft); oSheet.Cells[index, column++] = Convert.ToString(vlcd.message); oSheet.Cells[index, column++] = vlcd.user.userName; oSheet.Cells[index, column++] = vlcd.user.displayName; accepted = false; if (vlcd.replies.Any != null) { oSheet.Cells[index, column++] = ProcessReplies(vlcd.replies.Any, 1); } else { column++; } oSheet.Cells[index, column++] = Convert.ToString(accepted); }
/// <summary> /// Do the actual query by converting the rss into a list of issue items /// </summary> private IList<RemoteIssue> DoQuery( String queryUrl ) { List<RemoteIssue> result= new List<RemoteIssue>(); // Make the request HttpWebRequest request= WebRequest.Create( queryUrl ) as HttpWebRequest; // Handle credentials if( _username!=null && _password!=null ) { CredentialCache creds= new CredentialCache(); creds.Add( new Uri( queryUrl ), "Basic", new NetworkCredential( _username, _password ) ); request.Credentials= creds; } // Console.WriteLine( "Query: "+queryUrl ); HttpWebResponse response= request.GetResponse() as HttpWebResponse; // Parse the xml from the get all open issues query XmlDocument doc= new XmlDocument(); doc.Load( response.GetResponseStream() ); foreach( XmlNode itemNode in doc.SelectNodes( "//rss/channel/item" ) ) { RemoteIssue issue= new RemoteIssue(); issue.key= itemNode.SelectSingleNode( "key" ).InnerText; issue.summary= itemNode.SelectSingleNode( "title" ).InnerText; issue.status= itemNode.SelectSingleNode( "status" ).Attributes[ "id" ].InnerText; result.Add( issue ); } return result; }
/// <remarks/> public System.IAsyncResult BegincreateIssue(string in0, RemoteIssue in1, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("createIssue", new object[] { in0, in1}, callback, asyncState); }
internal List <string> GetSubTasksKey() { return(RemoteIssue.SelectTokens("$.fields.subtasks.[*]", false).Select(st => st.ExValue <string>("$.key")).ToList()); }
/// <summary> /// Create a new Issue from a RemoteIssue /// </summary> public static Issue ToLocal(this RemoteIssue remoteIssue, Jira jira = null) { return(new Issue(jira, remoteIssue)); }
internal List <JiraIssue> ConvertToListJiraRemoteIssue(IEnumerable <Issue> issuesGmoore) { List <JiraIssue> issues = new List <JiraIssue>(); foreach (Issue I in issuesGmoore) { // Converting an Atlassian.Jira.Issue to JiraSVN.Jira.Jira.RemoteIssue RemoteIssue remote = new RemoteIssue { summary = I.Summary, assignee = I.Assignee, reporter = I.Reporter, updated = I.Updated, created = I.Created, project = I.Project, description = I.Description, environment = I.Environment, votes = I.Votes, duedate = I.DueDate, id = I.JiraIdentifier }; // got the following code from /c/devLicenseGeneration/atlassian.net-sdk/Atlassian.Jira/Issue.cs remote.key = I.Key != null ? I.Key.Value : null; if (I.Status != null) { remote.status = I.Status.Id; // Using Status.Id rather than Status.Name, helped with the populating the drop down statuses box } if (I.Resolution != null) { remote.resolution = I.Resolution.Id; } if (I.Priority != null) { remote.priority = I.Priority.Id; } if (I.Type != null) { remote.type = I.Type.Id; } if (I.AffectsVersions.Count > 0) { List <RemoteVersion> remoteVersions = new List <RemoteVersion>(); foreach (string s in I.AffectsVersions.Select(v => v.Name).ToArray()) { remoteVersions.Add(new RemoteVersion { name = s }); } remote.affectsVersions = remoteVersions.ToArray(); } if (I.FixVersions.Count > 0) { List <RemoteVersion> remoteVersions = new List <RemoteVersion>(); foreach (string s in I.FixVersions.Select(v => v.Name).ToArray()) { remoteVersions.Add(new RemoteVersion { name = s }); } remote.fixVersions = remoteVersions.ToArray(); } /* * if (I.Components.Count > 0) * { * remote.components = I.Components.Select(c => c.Name).ToArray(); * } * * if (I.CustomFields.Count > 0) * { * remote.customFieldValues = I.CustomFields.Select(f => new RemoteCustomFieldValue() * { * customfieldId = f.Id, * values = f.Values * }).ToArray(); * } */ /* * Log.Info("Inside GetAllIssues: {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}.", * remote.key, * remote.summary, * remote.assignee, * remote.reporter, * remote.updated, * remote.created, * remote.project, * remote.description, * remote.environment, * remote.votes, * remote.duedate, * remote.status, * remote.id, * remote.resolution * ); */ issues.Add(new JiraIssue(this, remote)); } // end foreach return(issues); }
private static string ExpectedResultFor(RemoteIssue issue, string comments) { if (!string.IsNullOrEmpty(comments)) { comments = "\r\n" + comments; } return string.Format("{0}{1}\r\nhttp://sei.la.com/browse/{2}\r\n", issue.Format(), comments, issue.key); }
public JiraIssue(RemoteIssue remoteIssue, Dictionary <string, string> statuses, string baseUrl) { this.remoteIssue = remoteIssue; this.statuses = statuses; this.baseUrl = baseUrl; }
public string createIssue(JiraIssue issue) { #if PLVS_133_WORKAROUND object[] issuesTable = service.getIssuesFromTextSearch(Token, "<<<<<<<<<<<<<IHOPETHEREISNOSUCHTEXT>>>>>>>>>>>>>>"); Type issueObjectType = issuesTable.GetType().GetElementType(); object ri = issueObjectType.GetConstructor(new Type[] {}).Invoke(new object[] {}); setObjectProperty(ri, "project", issue.ProjectKey); setObjectProperty(ri, "type", issue.IssueTypeId.ToString()); setObjectProperty(ri, "priority", issue.PriorityId.ToString()); setObjectProperty(ri, "summary", issue.Summary); setObjectProperty(ri, "description", issue.Description); if (issue.Assignee != null) { setObjectProperty(ri, "assignee", issue.Assignee); } if (issue.Components != null && issue.Components.Count > 0) { object[] components = service.getComponents(Token, issue.ProjectKey); setObjectTablePropertyFromObjectList(ri, "components", issue.Components, components); } object[] versions = service.getVersions(Token, issue.ProjectKey); if (issue.Versions != null && issue.Versions.Count > 0) { setObjectTablePropertyFromObjectList(ri, "affectsVersions", issue.Versions, versions); } if (issue.FixVersions != null && issue.FixVersions.Count > 0) { setObjectTablePropertyFromObjectList(ri, "fixVersions", issue.FixVersions, versions); } object createdIssue = service.createIssue(Token, ri); return((string)createdIssue.GetType().GetProperty("key").GetValue(createdIssue, null)); #else RemoteIssue ri = new RemoteIssue { project = issue.ProjectKey, type = issue.IssueTypeId.ToString(), priority = issue.PriorityId.ToString(), summary = issue.Summary, description = issue.Description, }; if (issue.Assignee != null) { ri.assignee = issue.Assignee; } if (issue.Components != null && issue.Components.Count > 0) { IEnumerable <JiraNamedEntity> components = getComponents(issue.ProjectKey); // RemoteComponent[] objects = service.getComponents(Token, issue.ProjectKey); List <RemoteComponent> comps = new List <RemoteComponent>(); foreach (string t in issue.Components) { // fixme: a bit problematic part. What if two objects have the same name? // I suppose JiraIssue class has to be fixed, but that would require more problematic // construction of it during server query string tCopy = t; foreach (JiraNamedEntity component in components.Where(component => component.Name.Equals(tCopy))) { comps.Add(new RemoteComponent { id = component.Id.ToString(), name = component.Name }); break; } } ri.components = comps.ToArray(); } List <JiraNamedEntity> versions = getVersions(issue.ProjectKey); // RemoteVersion[] versions = service.getVersions(Token, issue.ProjectKey); if (issue.Versions != null && issue.Versions.Count > 0) { List <RemoteVersion> vers = new List <RemoteVersion>(); foreach (string t in issue.Versions) { // fixme: a bit problematic part. same as for objects string tCopy = t; foreach (JiraNamedEntity version in versions.Where(version => version.Name.Equals(tCopy))) { vers.Add(new RemoteVersion { id = version.Id.ToString(), name = version.Name }); break; } } ri.affectsVersions = vers.ToArray(); } if (issue.FixVersions != null && issue.FixVersions.Count > 0) { List <RemoteVersion> vers = new List <RemoteVersion>(); foreach (string t in issue.FixVersions) { // fixme: a bit problematic part. same as for objects string tCopy = t; foreach (JiraNamedEntity version in versions.Where(version => version.Name.Equals(tCopy))) { vers.Add(new RemoteVersion { id = version.Id.ToString(), name = version.Name }); break; } } ri.fixVersions = vers.ToArray(); } RemoteIssue createdIssue = service.createIssue(Token, ri); return(createdIssue.key); #endif }
/// <remarks/> public void createIssueAsync(string in0, RemoteIssue in1) { this.createIssueAsync(in0, in1, null); }
//slow but functional public bool IssueIsDuplicate(RemoteIssue issue) { var i = from dup in jira.Issues where dup.summary == issue.summary select dup; return(new List <RemoteIssue>(i).Count > 0); }
public RemoteIssue CreateIssue(IAuthenticationToken token, RemoteIssue issue) { return _soapServiceClient.createIssue(token.Token, issue); }
private static IssueField UpdateLabels(RemoteIssue issue, IEnumerable<Action<IList<string>>> labelOperations) { var newLabels = LabelFormatConveter.From(issue).To(labelArray => new List<string>(labelArray)); foreach (var operation in labelOperations) { operation(newLabels); } return IssueField.CustomField(CustomFieldId.Labels) <= LabelFormatConveter.From(newLabels).ToJira(); }
private static string ExpectedResultFor(RemoteIssue issue) { return ExpectedResultFor(issue, string.Empty); }
public RemoteIssue GenerateIssue() { var issue = new RemoteIssue(); return issue; }
public RemoteIssue createIssue(string in0, RemoteIssue in1) { object[] results = this.Invoke("createIssue", new object[] { in0, in1}); return ((RemoteIssue)(results[0])); }
public async Task StartJob_RegularInvocation_ShouldUpsertTwice() { //arange var client = CreateRestClient("https://your_jira_address/"); var fields = new RemoteIssue { updated = DateTime.UtcNow, id = "id4", key = "key4", description = "description4", summary = "summary4" }; var myIssue = new Issue(client, fields); var firstIssues = new List <Issue> { myIssue, myIssue, myIssue }; var secondIssues = new List <Issue> { myIssue }; var firstResponse = new MockPagedQueryResult <Issue>(firstIssues) { TotalItems = 4 }; var secondResponse = new MockPagedQueryResult <Issue>(secondIssues) { TotalItems = 1 }; _applicationPropertyDaoMock .Setup(s => s.GetAsync()) .ReturnsAsync(new ApplicationProperty()); _applicationPropertyDaoMock .Setup(s => s.UpsertPropertyAsync(It.IsAny <Expression <Func <ApplicationProperty, DateTime> > >(), It.IsAny <DateTime>())) .Returns(Task.CompletedTask); _jiraClientMock .SetupSequence(s => s.GetLatestIssuesAsync(It.IsAny <string[]>(), It.IsAny <DateTime>(), It.IsAny <int>(), It.IsAny <int>())) .ReturnsAsync(firstResponse) .ReturnsAsync(secondResponse); _elasticsearchClientMock .Setup(s => s.UpsertManyAsync(It.IsAny <JiraElasticUpsertRequest>())) .Returns(Task.CompletedTask); //act await _job.StartJob(); //assert _jiraClientMock.Verify(v => v .GetLatestIssuesAsync(It.IsAny <string[]>(), It.IsAny <DateTime>(), It.IsAny <int>(), It.IsAny <int>()), Times.Exactly(2)); _jiraClientMock.VerifyNoOtherCalls(); _elasticsearchClientMock.Verify(v => v .UpsertManyAsync(It.IsAny <JiraElasticUpsertRequest>()), Times.Exactly(2)); _elasticsearchClientMock.VerifyNoOtherCalls(); _applicationPropertyDaoMock.Verify(v => v .UpsertPropertyAsync(It.IsAny <Expression <Func <ApplicationProperty, DateTime> > >(), It.IsAny <DateTime>()), Times.Exactly(2)); _applicationPropertyDaoMock.Verify(v => v .GetAsync(), Times.Exactly(1)); _applicationPropertyDaoMock.VerifyNoOtherCalls(); }
public JiraJobTests() { _applicationPropertyDaoMock = new Mock <IApplicationPropertyDao>(); _elasticsearchClientMock = new Mock <IElasticsearchClient>(); _jiraClientMock = new Mock <IJiraClient>(); var loggerMock = new Mock <ILogger <JiraJob> >(); _settingsMock = new Mock <IOptions <JiraSettings> >(); _settingsMock .SetupGet(m => m.Value) .Returns(() => new JiraSettings { User = "******", Password = "******", BaseAddress = "https://your_jira_address/", BatchSize = 3, ProjectNames = new[] { "test", "test1", "test2" } }); _job = new JiraJob(loggerMock.Object, _elasticsearchClientMock.Object, _applicationPropertyDaoMock.Object, _jiraClientMock.Object, _settingsMock.Object); var client = CreateRestClient("https://your_jira_address/"); var fields = new RemoteIssue { updated = DateTime.UtcNow, id = "id1", key = "key1", description = "description1", summary = "summary1" }; var myIssue1 = new Issue(client, fields); fields = new RemoteIssue { updated = DateTime.UtcNow, id = "id2", key = "key2", description = "description2", summary = "summary2" }; var myIssue2 = new Issue(client, fields); fields = new RemoteIssue { updated = DateTime.UtcNow, id = "id3", key = "key3", description = "description3", summary = "summary3" }; var myIssue3 = new Issue(client, fields); var issues = new List <Issue> { myIssue1, myIssue2, myIssue3 }; var orderedIssues = issues.OrderBy(i => i.Updated); _response = new MockPagedQueryResult <Issue>(orderedIssues) { TotalItems = 3 }; }
public override string CreateDefect(Dictionary <string, string> defectInfos) { Connect(); RemoteIssue issue = new RemoteIssue(); RemotePriority[] priorities = jira.getPriorities(jiraToken); RemoteIssueType[] issueTypes = jira.getIssueTypes(jiraToken); jira.getProjectRoles(jiraToken); issue.created = DateTime.Now; issue.summary = "TOSCA[" + defectInfos["Workspace-User"] + "]: Error in Testcase \"" + defectInfos["TestCase-Name"] + "\""; string description = defectInfos["Log-Description"]; if (!String.IsNullOrEmpty(description)) { issue.description = description; } else { String compressedLog = defectInfos["CompressedLogDetails"]; issue.description = String.IsNullOrEmpty(compressedLog) ? String.Empty : GetLogInfoFromCompressedLogDetails(compressedLog); } issue.assignee = GetDefectIntegrationSetting("DefectAssignee", defectInfos); if (issue.assignee == string.Empty) { issue.assignee = "-1"; } issue.project = GetDefectIntegrationSetting("DefectProject", defectInfos); issue.priority = GetDefectIntegrationSetting("DefectPriority", defectInfos); foreach (RemotePriority priority in priorities) { if (priority.name == issue.priority) { issue.priority = priority.id; break; } } issue.status = GetDefectIntegrationSetting("DefectStatus", defectInfos); issue.type = GetDefectIntegrationSetting("DefectType", defectInfos); foreach (RemoteIssueType issueType in issueTypes) { if (issueType.name == issue.type) { issue.type = issueType.id; break; } } issue.components = GetComponents(GetDefectIntegrationSetting("DefectComponents", defectInfos)); issue.customFieldValues = GetCustomDefectProperties(defectInfos).Select(property => new RemoteCustomFieldValue { customfieldId = "customfield_" + property.id, values = property.value.Split(',') }).ToArray(); issue = jira.createIssue(jiraToken, issue); Disconnect(); return(issue != null ? issue.key : string.Empty); }
/// <remarks/> public void createIssueAsync(string in0, RemoteIssue in1, object userState) { if ((this.createIssueOperationCompleted == null)) { this.createIssueOperationCompleted = new System.Threading.SendOrPostCallback(this.OncreateIssueOperationCompleted); } this.InvokeAsync("createIssue", new object[] { in0, in1}, this.createIssueOperationCompleted, userState); }