///<summary> /// A Workitem in VersionOne that was created as a result of an Issue in JIRA has changed /// state. We must now reflect that change of state in the Issue in JIRA. We can relfect /// that change in one of two ways: /// 1) Updating a field (probably a custom field) to some value. /// 2) Progressing the workflow to another status. ///</summary> ///<param name = "stateChangeResult">Tells us what Workitem state changed and what Issue to update.</param> public bool OnWorkitemStateChanged(WorkitemStateChangeResult stateChangeResult) { var issueId = stateChangeResult.ExternalId; var fieldName = configuration.OnStateChangeFieldName; var fieldValue = configuration.OnStateChangeFieldValue; var workflowId = configuration.ProgressWorkflowStateChanged; var messages = stateChangeResult.Messages; var assignee = configuration.AssigneeStateChanged; return(UpdateJiraIssue(issueId, fieldName, fieldValue, messages, workflowId, assignee)); }
public void OnWorkitemStateChangedWithEmptyData() { const string workitemId = "D-00001"; var workitemResult = new WorkitemStateChangeResult(ExternalId, workitemId); var localReader = new JiraIssueReaderUpdater(new JiraServiceConfiguration(), LoggerMock, ConnectorMock); Expect.Call(ConnectorMock.Login); Expect.Call(ConnectorMock.Logout); Repository.ReplayAll(); localReader.OnWorkitemStateChanged(workitemResult); Repository.VerifyAll(); }
public void OnWorkitemStateChanged() { const string workitemId = "D-00001"; var workitemResult = new WorkitemStateChangeResult(ExternalId, workitemId); workitemResult.Messages.Add("message 1"); FullUpdateJiraIssue(ExternalId, config.OnStateChangeFieldName, config.OnStateChangeFieldValue, workitemResult.Messages, config.ProgressWorkflowStateChanged, config.AssigneeStateChanged); Repository.ReplayAll(); reader.OnWorkitemStateChanged(workitemResult); Repository.VerifyAll(); }
public void OnWorkitemStateChangedWithoutWorkflowProgress() { const string workitemId = "D-00001"; var workitemResult = new WorkitemStateChangeResult(ExternalId, workitemId); workitemResult.Messages.Add("message 1"); Expect.Call(ConnectorMock.Login); Expect.Call(ConnectorMock.UpdateIssue(ExternalId, config.OnStateChangeFieldName, config.OnStateChangeFieldValue)).Return(null); Expect.Call(() => ConnectorMock.AddComment(ExternalId, workitemResult.Messages[0])).Repeat.Once(); Expect.Call(ConnectorMock.GetAvailableActions(ExternalId)).Return(new List <Item>()); Expect.Call(ConnectorMock.Logout); Repository.ReplayAll(); reader.OnWorkitemStateChanged(workitemResult); Repository.VerifyAll(); }
public bool OnDefectStateChange(WorkitemStateChangeResult stateChangeResult) { logger.Log(LogMessage.SeverityType.Debug, stateChangeResult.ToString()); var bugId = int.Parse(stateChangeResult.ExternalId); var bugzillaClient = bugzillaClientFactory.CreateNew(); bugzillaClient.Login(); if (configuration.OnStateChangeAccept && !bugzillaClient.AcceptBug(bugId, configuration.OnCreateResolveValue)) { logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to accept bug {0}.", bugId)); } if (!string.IsNullOrEmpty(configuration.OnStateChangeFieldName)) { if (!bugzillaClient.UpdateBug(bugId, configuration.OnStateChangeFieldName, configuration.OnStateChangeFieldValue)) { logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to set {0} to {1}.", configuration.OnStateChangeFieldName, configuration.OnStateChangeFieldValue)); } } if (!string.IsNullOrEmpty(configuration.OnStateChangeReassignValue)) { if (!bugzillaClient.ReassignBug(bugId, configuration.OnStateChangeReassignValue)) { logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to reassign bug to {0}.", configuration.OnStateChangeReassignValue)); } } ResolveBugIfRequired(configuration.OnStateChangeResolveValue, bugId, bugzillaClient); bugzillaClient.Logout(); return(true); }