What gets returned when we attempt to create a Workitem to match a workitem in an external system.
Inheritance: WorkitemUpdateResult
        public void ProcessWorkitemSuccess()
        {
            var defect = new Defect();
            var result = new WorkitemCreationResult(defect);

            Expect.Call(workitemWriterMock.CheckForDuplicate(defect)).Return(false);
            Expect.Call(workitemWriterMock.CreateWorkitem(defect)).Return(result);
            Expect.Call(() => eventManagerMock.Publish(result));

            Repository.ReplayAll();
            eventManager.Publish(defect);
            Repository.VerifyAll();
        }
        public void OnWorkitemCreated()
        {
            var workitem = new Story("Title", "description", "project", "owners");
            var workitemResult = new WorkitemCreationResult(workitem)
            {
                Source = { ExternalId = ExternalId, },
                Permalink = "link",
            };
            workitemResult.Messages.Add("external id");

            FullUpdateJiraIssue(ExternalId, config.OnCreateFieldName, config.OnCreateFieldValue, workitemResult.Messages, config.ProgressWorkflow, null);
            UpdateWorkitemLinkInJira(workitemResult);

            Repository.ReplayAll();
            reader.OnWorkitemCreated(workitemResult);
            Repository.VerifyAll();
        }
示例#3
0
        private WorkitemCreationResult ConvertToWorkitemCreationResult(Workitem item, ServerConnector.Entities.Workitem newWorkitem)
        {
            var result = new WorkitemCreationResult(item)
            {
                Source =
                {
                    Number             = newWorkitem.Number,
                    ExternalId         = item.ExternalId,
                    Description        = newWorkitem.Description,
                    ExternalSystemName = item.ExternalSystemName,
                    ProjectId          = newWorkitem.Project.Key,
                    Project            = newWorkitem.Project.Value,
                    Title    = newWorkitem.Name,
                    Priority = newWorkitem.PriorityToken,
                },
                WorkitemId = newWorkitem.Id,
                Permalink  = v1Processor.GetWorkitemLink(newWorkitem),
            };

            return(result);
        }
        public void OnWorkitemCreated()
        {
            var workitem = new Story("Title", "description", "project", "owners", "priority");
            var workitemResult = new WorkitemCreationResult(workitem) {
                Source = { ExternalId = ExternalId, },
                Permalink = "link",
            };
            workitemResult.Messages.Add("external id"); ;

            Expect.Call(ServiceFactory.CreateNew(Url)).Repeat.Times(3).Return(SoapService);
            Expect.Call(SoapService.Dispose).Repeat.Times(3);

            FullUpdateJiraIssue(ExternalId, config.OnCreateFieldName, config.OnCreateFieldValue,
                workitemResult.Messages, config.ProgressWorkflow, null);

            UpdateWorkitemLinkInJira(workitemResult);

            Repository.ReplayAll();
            reader.OnWorkitemCreated(workitemResult);
            Repository.VerifyAll();
        }
        public void OnWorkitemCreatedInsufficientPermissions()
        {
            var workitem = new Story("Title", "description", "project", "owners", "priority");
            var workitemResult = new WorkitemCreationResult(workitem) {
                Source = { ExternalId = ExternalId, },
                Permalink = "link",
            };
            workitemResult.Messages.Add("external id"); ;

            Expect.Call(ServiceFactory.CreateNew(Url)).Repeat.Twice().Return(SoapService);
            Expect.Call(SoapService.Dispose).Repeat.Twice();

            Expect.Call(SoapService.Login(Username, Password)).Return(Token);
            Expect.Call(SoapService.UpdateIssue(Token, ExternalId, config.OnCreateFieldName, config.OnCreateFieldValue)).Throw(new JiraException("Can't update issue", new Exception()));
            Expect.Call(SoapService.Logout(Token)).Return(true);

            UpdateWorkitemLinkInJira(workitemResult);

            Repository.ReplayAll();
            reader.OnWorkitemCreated(workitemResult);
            Repository.VerifyAll();
        }
		public void OnDefectCreated(WorkitemCreationResult createdResult) 
        {
			var bugId = int.Parse(createdResult.Source.ExternalId);
			var bugzillaClient = bugzillaClientFactory.CreateNew(configuration.Url);

            bugzillaClient.Login(configuration.UserName, configuration.Password, true, configuration.IgnoreCert);

			if (configuration.OnCreateAccept && !bugzillaClient.AcceptBug(bugId, configuration.OnCreateResolveValue)) 
            {
				logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to accept bug {0}.", bugId));
			}

			if (!string.IsNullOrEmpty(configuration.OnCreateFieldName) && !bugzillaClient.UpdateBug(bugId, configuration.OnCreateFieldName, configuration.OnCreateFieldValue)) 
            {
    			logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to set {0} to {1}.", configuration.OnCreateFieldName, configuration.OnCreateFieldValue));
			}

			if (!string.IsNullOrEmpty(configuration.DefectLinkFieldName)) 
            {
				if (!bugzillaClient.UpdateBug(bugId, configuration.DefectLinkFieldName, createdResult.Permalink)) 
                {
					logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to set {0} to {1}.", configuration.DefectLinkFieldName, createdResult.Permalink));
				}
			}

			if (!string.IsNullOrEmpty(configuration.OnCreateReassignValue)) 
            {
				if (!bugzillaClient.ReassignBug(bugId, configuration.OnCreateReassignValue)) 
                {
					logger.Log(LogMessage.SeverityType.Error, string.Format("Failed to reassign bug to {0}.", configuration.OnCreateReassignValue));
				}
			}

            ResolveBugIfRequired(configuration.OnCreateResolveValue, bugId, bugzillaClient);
			bugzillaClient.Logout();
		}
 private WorkitemCreationResult ConvertToWorkitemCreationResult(Workitem item, ServerConnector.Entities.Workitem newWorkitem) {
     var result = new WorkitemCreationResult(item) {
         Source = {
             Number = newWorkitem.Number,
             ExternalId = item.ExternalId,
             Description = newWorkitem.Description,
             ExternalSystemName = item.ExternalSystemName,
             ProjectId = newWorkitem.Project.Key,
             Project = newWorkitem.Project.Value,
             Title = newWorkitem.Name,
             Priority = newWorkitem.PriorityToken,
         },
         WorkitemId = newWorkitem.Id,
         Permalink = v1Processor.GetWorkitemLink(newWorkitem),
     };
     return result;
 }
		private void OnDefectCreated(BugzillaServiceConfiguration config)
		{
			BugzillaMocks mocks = new BugzillaMocks();

			Defect defect = GetStockBug();
			int expectedExternalId = 1234;
			string expectedDefectLinkValue = "http://localhost/VersionOne.Web/assetdetail.v1?Oid=Defect:1000";

			defect.ExternalId = expectedExternalId.ToString();
			WorkitemCreationResult workitemCreationResult = new WorkitemCreationResult(defect);
			workitemCreationResult.Messages.Add("Message1");
			workitemCreationResult.Permalink = expectedDefectLinkValue;

			SetupResult.For(mocks.ServiceFactory.CreateNew(config.Url)).Return(mocks.Client);

			Expect.Call(mocks.Client.Login(config.UserName, config.Password, true, false)).Return(expectedUserId);
			
			if (!string.IsNullOrEmpty(config.OnCreateFieldName))
			{
				Expect.Call(mocks.Client.UpdateBug(expectedExternalId, config.OnCreateFieldName, config.OnCreateFieldValue)).Return(true);
			}

			if (!string.IsNullOrEmpty(config.DefectLinkFieldName))
			{
				Expect.Call(mocks.Client.UpdateBug(expectedExternalId, config.DefectLinkFieldName, expectedDefectLinkValue)).Return(true);
			}

			if (!string.IsNullOrEmpty(config.OnCreateReassignValue))
			{
				Expect.Call(mocks.Client.ReassignBug(expectedExternalId, config.OnCreateReassignValue)).Return(true);
			}

			if (!string.IsNullOrEmpty(config.OnCreateResolveValue))
			{
				Expect.Call(mocks.Client.ResolveBug(expectedExternalId, config.OnCreateResolveValue, string.Empty)).Return(true);
			}

			mocks.Client.Logout();

			mocks.Repository.ReplayAll();

			BugzillaReaderUpdater updater = new BugzillaReaderUpdater(config, mocks.ServiceFactory, mocks.Logger);

			updater.OnDefectCreated(workitemCreationResult);

			mocks.Repository.VerifyAll();

		}
        public void Update_ChangeVersionOneStateToReady_OnPilotIssue()
        {
            var createdResult = new WorkitemCreationResult(new Defect()) {
                Source = { ExternalId = "PILOT-416" },
            };

            jiraIssueReaderUpdater.OnWorkitemCreated(createdResult);
        }
 public void Update_CreationResultSuccess_OnPilotIssue()
 {
     WorkitemCreationResult creationResult = new WorkitemCreationResult(new Defect()){
         Source = { ExternalId = "PILOT-416" },
     };
     creationResult.Messages.Add("Integration Test Comment - Creation Success");
     jiraIssueReaderUpdater.OnWorkitemCreated( creationResult );
 }
 private void UpdateWorkitemLinkInJira(WorkitemCreationResult workitemResult)
 {
     Expect.Call(ConnectorMock.Login);
     Expect.Call(ConnectorMock.UpdateIssue(workitemResult.Source.ExternalId, config.WorkitemLinkField, workitemResult.Permalink)).Return(null);
     Expect.Call(ConnectorMock.Logout);
 }
        public void OnWorkitemCreatedInsufficientPermissions()
        {
            var workitem = new Story("Title", "description", "project", "owners");
            var workitemResult = new WorkitemCreationResult(workitem)
            {
                Source = { ExternalId = ExternalId, },
                Permalink = "link",
            };
            workitemResult.Messages.Add("external id");

            Expect.Call(ConnectorMock.Login);
            Expect.Call(ConnectorMock.UpdateIssue(ExternalId, config.OnCreateFieldName, config.OnCreateFieldValue)).Throw(new JiraException("Can't update issue", new Exception()));
            Expect.Call(ConnectorMock.Logout);

            UpdateWorkitemLinkInJira(workitemResult);

            Repository.ReplayAll();
            reader.OnWorkitemCreated(workitemResult);
            Repository.VerifyAll();
        }
		public void OnDefectCreated(WorkitemCreationResult createdResult)
		{
			query.UpdateStatesToSubmittedToV1(createdResult.Source.ExternalId);
		}
        public WorkitemUpdateResult CreateWorkitem(Workitem item)
        {
            if(item == null) {
                throw new ArgumentNullException("item");
            }

            var type = item.Type;

            logger.Log(LogMessage.SeverityType.Info,
                string.Format("Creating VersionOne {0} for item from {1} system with identifier {2}", type, item.ExternalSystemName, item.ExternalId));

            var url = string.Empty;
            var urlTitle = string.Empty;

            if(item.ExternalUrl != null) {
                url = item.ExternalUrl.Url;
                urlTitle = item.ExternalUrl.Title;
            }

            ServerConnector.Entities.Workitem newWorkitem = null;
            string failureMessage = null;

            try {
                newWorkitem = v1Processor.CreateWorkitem(type, item.Title, item.Description, item.ProjectId, item.Project, externalFieldName, item.ExternalId,
                    item.ExternalSystemName, item.Priority, item.Owners, urlTitle, url, item.Environment, item.FoundBy, item.VersionAffected, item.BuildNumber, item.SeverityLevel);
                logger.Log(LogMessage.SeverityType.Info, string.Format("VersionOne asset {0} succesfully created.", newWorkitem.Id));
            } catch (Exception ex) {
                logger.Log(LogMessage.SeverityType.Error, string.Format("Error during saving workitems: {0}", ex.Message));
                failureMessage = string.Format("Faild to create item in versionOne, reason: \"{0}\"", ex.Message);
            }

            if(newWorkitem != null) {
                var result = new WorkitemCreationResult(item) {
                    Source = {
                        Number = newWorkitem.Number,
                        ExternalId = item.ExternalId,
                        Description = newWorkitem.Description,
                        ExternalSystemName = item.ExternalSystemName,
                        ProjectId = newWorkitem.Project.Key,
                        Project = newWorkitem.Project.Value,
                        Title = newWorkitem.Name,
                        Priority = newWorkitem.PriorityToken,
                        Environment = newWorkitem.Environment,
                    },
                    WorkitemId = newWorkitem.Id,
                    Permalink = v1Processor.GetWorkitemLink(newWorkitem),
                };

                result.Messages.Add(string.Format("Created item \"{0}\" ({1}) in Project \"{2}\" URL: {3}",
                    item.Title,
                    result.Source.Number,
                    item.Project,
                    result.Permalink));

                return result;
            }

            var failureResult = new WorkitemCreationFailureResult(item);
            failureResult.Messages.Add(failureMessage);
            failureResult.Warnings.Add(string.Format("[{0}] {1}", item.ExternalId, failureMessage));
            return failureResult;
        }
        public void OnDefectCreated(WorkitemCreationResult createdResult) {
            IQualityCenterClient project = GetProjectFromExternalId(createdResult.Source.ExternalId);

            if (project == null) {
                return;
            }

            lock (this) {
                project.OnDefectCreated(createdResult.Source.ExternalId,
                                        Combine(createdResult.Messages, createdResult.Warnings),
                                        createdResult.Permalink);
            }
        }
 private void UpdateWorkitemLinkInJira(WorkitemCreationResult workitemResult)
 {
     Expect.Call(SoapService.Login(Username, Password)).Return(Token);
     Expect.Call(SoapService.UpdateIssue(Token, workitemResult.Source.ExternalId, config.WorkitemLinkField,
         workitemResult.Permalink)).Return(null);
     Expect.Call(SoapService.Logout(Token)).Return(true);
 }