public IndexResult RemoveTestCaseIndex(TestCaseDTO testCase) { if (testCase.TestCaseID == null) { return(new IndexResult()); } var entityIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.Entity); var doc = entityIndex.FindDocumentByName <EntityDocument>(EntityDocument.CreateName(testCase.TestCaseID)); if (doc == null) { _log.Error(string.Format("CANNOT PROCESS UPDATE '{0}DeletedMessage' FOR ENTITY #{1} - '{2}'. ENTITY WAS NOT ADDED DURING PROFILE INITIALIZATION OR ENTITY CREATION !!!", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name)); return(new IndexResult()); } var indexResult = entityIndex.Rebuild(CreateEmptyEntityDocument(doc.DocNumber, EntityDocument.CreateName(testCase.TestCaseID))); _log.Debug(string.Format("Removed {0} #{1} - '{2}'", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name)); if (doc.DocNumber >= 0) { IDocumentIndex entityProjectIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityProject); entityProjectIndex.Update(doc.DocNumber, string.Empty); IDocumentIndex entityTypeIndices = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityType); entityTypeIndices.Update(doc.DocNumber, string.Empty); } return(indexResult); }
public void Handle(TestCaseRunUpdatedMessage message) { if (message.Dto != null && message.Dto.TestPlanRunID == Data.TestPlanRunId) { Data.TestCaseRunsUpdatedCount++; var testCaseTestPlanDto = StorageRepository().Get <TestCaseTestPlanDTO>(message.Dto.TestCaseTestPlanID.ToString()).FirstOrDefault(); if (testCaseTestPlanDto != null) { var changedFields = new Enum[] { TestCaseField.LastFailureComment, TestCaseField.LastRunDate, TestCaseField.LastStatus, TestCaseField.LastRunStatus }; var testCaseDto = new TestCaseDTO { TestCaseID = testCaseTestPlanDto.TestCaseID, LastFailureComment = message.Dto.Comment, LastRunDate = message.Dto.RunDate, #pragma warning disable 612 LastStatus = message.Dto.Passed, #pragma warning restore 612 LastRunStatus = message.Dto.Status }; Send(new UpdateCommand { ChangedFields = changedFields.Select(x => x.ToString()).ToArray(), Dto = testCaseDto }); } } if (Data.NumberOfTestCasesToUpdate == Data.TestCaseRunsUpdatedCount) { Log().Info("Finished updating test case runs with imported results"); CompleteSaga(); } }
private void UpdateTestCaseIndex(TestCaseDTO testCaseDto, ICollection <TestCaseField> changedTestCaseFields) { if (!changedTestCaseFields.Any( f => f == TestCaseField.Steps || f == TestCaseField.Success || f == TestCaseField.Name || f == TestCaseField.ProjectID || f == TestCaseField.EntityTypeID)) { return; } _entityIndexer.UpdateTestCaseIndex(testCaseDto, changedTestCaseFields, isIndexing: false); _entityIndexer.OptimizeTestCaseIndex(); }
public EntityDocument CreateTestCase(TestCaseDTO testCase) { var description = string.IsNullOrEmpty(testCase.Description) ? string.Empty : string.Format(" {0}", testCase.Description); string format = string.Format("{0}{1} ", testCase.Name, description); var text = _textOperations.Prepare(AppendCustomFields(format, testCase.CustomFieldsMetaInfo)); return(new EntityDocument(testCase.TestCaseID.Value.ToString(CultureInfo.InvariantCulture), text) { ProjectId = _documentIdFactory.CreateProjectId(testCase.ProjectID.GetValueOrDefault()), EntityTypeId = _documentIdFactory.CreateEntityTypeId(testCase.EntityTypeID.GetValueOrDefault()), SquadId = _documentIdFactory.CreateSquadId(0), DocNumber = -1 }); }
public EntityDocument CreateTestCase(TestCaseDTO testCase) { var steps = string.IsNullOrEmpty(testCase.Steps) ? string.Empty : string.Format(" {0}", testCase.Steps); var success = string.IsNullOrEmpty(testCase.Success) ? string.Empty : string.Format(" {0}", testCase.Success); var text = _textOperations.Prepare(string.Format("{0}{1}{2} ", testCase.Name, steps, success)); return(new EntityDocument(testCase.TestCaseID.Value.ToString(CultureInfo.InvariantCulture), text) { ProjectId = _documentIdFactory.CreateProjectId(testCase.ProjectID.GetValueOrDefault()), EntityTypeId = _documentIdFactory.CreateEntityTypeId(testCase.EntityTypeID.GetValueOrDefault()), SquadId = _documentIdFactory.CreateSquadId(0), DocNumber = -1 }); }
public IndexResult AddTestCaseIndex(TestCaseDTO testCase) { if (testCase.TestCaseID == null) { return(new IndexResult()); } if (Exists <EntityDocument>(testCase.TestCaseID.Value, DocumentIndexTypeToken.Entity)) { if (_profile.Initialized) { _log.WarnFormat("CANNOT PROCESS '{0}CreatedMessage' FOR ENTITY #{1} - '{2}'. ENTITY HAS ALREADY BEEN ADDED ON PROFILE INITIALIZATION OR ENTITY CREATION !!!", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name); } else { _log.ErrorFormat("CANNOT PROCESS '{0}CreatedMessage' FOR ENTITY #{1} - '{2}'. ENTITY HAS ALREADY BEEN ADDED !!!", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name); } return(new IndexResult()); } var entityIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.Entity); var doc = _documentFactory.CreateTestCase(testCase); var indexResult = doc == null ? new IndexResult() : entityIndex.Index(doc, false); if (indexResult.DocNumber != -1) { IDocumentIndex entityProjectIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityProject); entityProjectIndex.Index(indexResult.DocNumber, _documentIdFactory.EncodeProjectId(testCase.ProjectID)); if (testCase.EntityTypeID != null) { Maybe <string> maybeEntityTypeName = _entityTypeProvider.GetEntityTypeName(testCase.EntityTypeID); string entityTypeName = maybeEntityTypeName.FailIfNothing(() => new ApplicationException("Entity type name was not found {0}".Fmt(testCase.EntityTypeID))); IDocumentIndex entityTypeIndices = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityType); entityTypeIndices.Index(indexResult.DocNumber, entityTypeName); } } _log.Debug(string.Format("Added {0} #{1} - '{2}':{3}", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name, indexResult.WordsAdded.Any() ? string.Format(" added words - {0};", string.Join(",", indexResult.WordsAdded.Keys)) : " NO WORDS ADDED;")); return(indexResult); }
private void RemoveTestCaseIndex(TestCaseDTO testCaseDto) { RebuildOrAction(() => _entityIndexer.RemoveTestCaseIndex(testCaseDto, DocumentIndexOptimizeSetup.DeferredOptimize)); }
private void UpdateTestCaseIndex(TestCaseDTO testCaseDto, ICollection <TestCaseField> changedTestCaseFields) { RebuildOrAction(() => _entityIndexer.UpdateTestCaseIndex(testCaseDto, changedTestCaseFields, false, DocumentIndexOptimizeSetup.DeferredOptimize)); }
private void RemoveTestCaseIndex(TestCaseDTO testCaseDto) { _entityIndexer.RemoveTestCaseIndex(testCaseDto); }
private void AddTestCaseIndex(TestCaseDTO testCaseDto) { _entityIndexer.AddTestCaseIndex(testCaseDto); _entityIndexer.OptimizeTestCaseIndex(); }
public IndexResult UpdateTestCaseIndex(TestCaseDTO testCase, ICollection <TestCaseField> changedFields, bool isIndexing) { if (testCase.TestCaseID == null) { return(new IndexResult()); } var indexes = _documentIndexProvider.GetOrCreateDocumentIndexes(_pluginContext.AccountName, DocumentIndexTypeToken.Entity, DocumentIndexTypeToken.EntityProject, DocumentIndexTypeToken.EntityType); if (!changedFields.Any(f => indexes.Any(i => i.Type.IsBelongedToDocumentFields(f) || i.Type.IsBelongedToIndexFields(f)))) { return(new IndexResult()); } var entityIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.Entity); var doc = entityIndex.FindDocumentByName <EntityDocument>(EntityDocument.CreateName(testCase.TestCaseID)); if (doc == null) { _log.Error(string.Format("CANNOT PROCESS UPDATE '{0}UpdatedMessage' FOR ENTITY #{1} - '{2}'. ENTITY WAS NOT ADDED DURING PROFILE INITIALIZATION OR ENTITY CREATION !!!", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name)); return(new IndexResult()); } if (changedFields.Any(f => entityIndex.Type.IsBelongedToDocumentFields(f))) { doc.ProjectId = _documentIdFactory.CreateProjectId(testCase.ProjectID.GetValueOrDefault()); doc.EntityTypeId = _documentIdFactory.CreateEntityTypeId(testCase.EntityTypeID.GetValueOrDefault()); entityIndex.SaveDocument(doc, false); _log.Debug(string.Format("Updated {0} #{1} - '{2}':{3}{4}", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name, changedFields.Contains(TestCaseField.ProjectID) ? string.Format(" Project - {0};", string.Join(",", testCase.ProjectName)) : string.Empty, changedFields.Contains(TestCaseField.EntityTypeID) ? string.Format(" EntityType - {0};", string.Join(",", testCase.EntityTypeName)) : string.Empty)); } var indexResult = new IndexResult(); if (doc.DocNumber >= 0) { if (changedFields.Any(f => entityIndex.Type.IsBelongedToIndexFields(f))) { var newText = _textOperations.Prepare(string.Format("{0}{1}{2} ", testCase.Name, string.IsNullOrEmpty(testCase.Steps) ? string.Empty : string.Format(" {0}", testCase.Steps), string.IsNullOrEmpty(testCase.Success) ? string.Empty : string.Format(" {0}", testCase.Success))); indexResult = entityIndex.Update(doc.DocNumber, newText); _log.Debug(string.Format("Updated {0} #{1} - '{2}':{3}{4}", testCase.EntityTypeName, testCase.TestCaseID.GetValueOrDefault(), testCase.Name, indexResult.WordsAdded.Any() ? string.Format(" added words - {0};", string.Join(",", indexResult.WordsAdded.Keys)) : " NO WORDS ADDED;", indexResult.WordsRemoved.Any() ? string.Format(" removed words - {0};", string.Join(",", indexResult.WordsRemoved)) : " NO WORDS REMOVED;")); } IDocumentIndex entityProjectIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityProject); if (changedFields.Any(f => entityProjectIndex.Type.IsBelongedToIndexFields(f))) { entityProjectIndex.Update(doc.DocNumber, _documentIdFactory.EncodeProjectId(testCase.ProjectID)); if (!isIndexing) { _localBus.SendLocal(new GeneralProjectChangedLocalMessage { GeneralId = testCase.TestCaseID.Value, ProjectId = testCase.ProjectID }); } } IDocumentIndex entityTypeIndex = _documentIndexProvider.GetOrCreateDocumentIndex(_pluginContext.AccountName, DocumentIndexTypeToken.EntityType); if (changedFields.Any(f => entityTypeIndex.Type.IsBelongedToIndexFields(f))) { entityTypeIndex.Update(doc.DocNumber, testCase.EntityTypeName); } } return(indexResult); }