Example #1
0
        public void EditEditConflictIgnoreByFieldChangeTest()
        {
            int sourceId;
            int targetId;

            EditEditConflictScenario(out sourceId, out targetId);

            string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by ignoring conflicts it edits are on different fields
            bool isResolved = m_conflictResolver.TryResolveConflict(conflicts[0],
                                                                    new WITEditEditConflictIgnoreByFieldChangeAction(), "/" + sourceId);

            Assert.IsFalse(isResolved, "Conflict resolution should fail as both ends edited a same field");

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + targetId);
            }
            else
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + sourceId);
            }
            Assert.IsTrue(isResolved, "Conflict resolution should succeed");

            // restart the migration tool
            RunAndNoValidate(true);

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });

            srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);
            Assert.AreEqual(srcDesc, SOURCE_R1_DESC);
            Assert.AreEqual(tarDesc, SOURCE_R1_DESC);
        }
Example #2
0
        public void EditEditConflictTakeSourceTest()
        {
            int workitemId, mirroredId;

            EditEditConflictScenario(out workitemId, out mirroredId);

            string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(mirroredId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by taking source side changes
            m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + workitemId);

            // restart the migration tool
            RunAndNoValidate(true);

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });

            srcDesc = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);
            Assert.AreEqual(srcDesc, SOURCE_R1_DESC);
            Assert.AreEqual(tarDesc, SOURCE_R1_DESC);
        }
Example #3
0
        private ConflictResolutionResult TryResolveConflict(
            string sourceSideItemId,
            IMigrationAction sourceSideAction,
            string targetWiId,
            IMigrationAction targetSideAction)
        {
            string conflictDetails = WITEditEditConflictType.CreateConflictDetails(sourceSideItemId,
                                                                                   sourceSideAction,
                                                                                   targetWiId,
                                                                                   targetSideAction);
            string scopeHint = WITEditEditConflictType.CreateScopeHint(sourceSideItemId,
                                                                       sourceSideAction.Version,
                                                                       targetWiId,
                                                                       targetSideAction.Version);
            MigrationConflict editEditConflict = new WITEditEditConflictType().CreateConflict(conflictDetails, scopeHint, sourceSideAction);

            List <MigrationAction> resolutionActions;

            return(ConflictManager.TryResolveNewConflict(ConflictManager.SourceId, editEditConflict, out resolutionActions));
        }
Example #4
0
        public void EditEditConflictTakeTargetTest()
        {
            int sourceId;
            int targetId;

            EditEditConflictScenario(out sourceId, out targetId);

            string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            // verify we have edit/edit conflict
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // resolve the conflict by taking target side changes
            bool isResolved = false;

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + targetId);
            }
            else
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + sourceId);
            }
            Assert.IsTrue(isResolved, "Conflict resolution should succeed");

            // restart the migration tool
            RunAndNoValidate(true);

            srcDesc = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreEqual(TARGET_R1_DESC, tarDesc);

            if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay)
            {
                // VerifySyncResult does not apply to Oneway since we expect differences when we
                // resolve conflicts by taking Target changes

                // Source does not get updated on one-way migration
                Assert.AreEqual(SOURCE_R1_DESC, srcDesc);
            }
            else
            {
                // verify sync result
                WitDiffResult result = GetDiffResult();

                // ignore Area/Iteration path mismatches due to test environments
                VerifySyncResult(result, new List <string> {
                    FIELD_ITERATION_PATH, FIELD_AREA_PATH
                });

                Assert.AreEqual(TARGET_R1_DESC, srcDesc);
            }
        }
Example #5
0
        public void EditEditConflictTakeTargetAfterMoreDeltaFromSourceTest()
        {
            int sourceId;
            int targetId;

            EditEditConflictScenario(out sourceId, out targetId);

            string srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("verify we have edit/edit conflict");
            Trace.WriteLine("---------------------------------");
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.AreEqual(1, conflicts.Count, "There should be one edit/edit conflict");

            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            // ---- start *5.5
            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("update work items on both sides");
            Trace.WriteLine("---------------------------------");
            WITChangeAction action1 = new WITChangeAction();
            WITChangeAction action2 = new WITChangeAction();

            const string SourceLastDesc = "New Description 5.5.1";

            action1.Description = SourceLastDesc;
            SourceAdapter.UpdateWorkItem(sourceId, action1);

            const string TargetLastTitle = "New Title 5.5.2";

            action2.Title = TargetLastTitle;
            TargetAdapter.UpdateWorkItem(targetId, action2);

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);

            // ----- end *5.5

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("resolve the conflict by taking target side changes");
            Trace.WriteLine("---------------------------------");
            bool isResolved = false;

            if (TestEnvironment.MigrationTestType == MigrationTestType.TwoWayRight)
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeSourceChangesAction(), "/" + targetId);
            }
            else
            {
                isResolved = m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + sourceId);
            }
            Assert.IsTrue(isResolved, "Conflict resolution should succeed");
            conflicts = m_conflictResolver.GetConflicts();
            Assert.AreEqual(0, conflicts.Count, "There should be no conflicts");

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            RunAndNoValidate(true);

            srcDesc  = SourceAdapter.GetFieldValue(sourceId, FIELD_DESCRIPTION);
            tarDesc  = TargetAdapter.GetFieldValue(targetId, FIELD_DESCRIPTION);
            srcTitle = SourceAdapter.GetFieldValue(sourceId, FIELD_TITLE);
            tarTitle = TargetAdapter.GetFieldValue(targetId, FIELD_TITLE);

            if (TestEnvironment.MigrationTestType == MigrationTestType.OneWay)
            {
                // For one-way we took the target changes, but those changes should not migrate back to source
                Assert.AreEqual(SourceLastDesc, srcDesc);
                Assert.AreEqual(SourceLastDesc, tarDesc);

                Assert.IsTrue(srcTitle.EndsWith(SOURCE_R2_TITLE));
                Assert.IsTrue(tarTitle.EndsWith(SOURCE_R2_TITLE));
            }
            else
            {
                Assert.AreEqual(TARGET_R1_DESC, srcDesc);
                Assert.AreEqual(TARGET_R1_DESC, tarDesc);
                Assert.IsTrue(srcTitle.EndsWith(TargetLastTitle));
                Assert.IsTrue(tarTitle.EndsWith(TargetLastTitle));
            }

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });
        }
Example #6
0
        public void EditEditConflictTakeTargetAfterMoreDeltaFromSourceTest()
        {
            int workitemId, mirroredId;

            EditEditConflictScenario(out workitemId, out mirroredId);

            string srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            string srcDesc  = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            string tarTitle = TargetAdapter.GetFieldValue(mirroredId, FIELD_TITLE);
            string tarDesc  = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);

            Assert.AreNotEqual(srcTitle, tarTitle, "Title should not match due to conflict");
            Assert.AreNotEqual(srcDesc, tarDesc, "Description should not match due to conflict");

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("verify we have edit/edit conflict");
            Trace.WriteLine("---------------------------------");
            List <RTConflict> conflicts = m_conflictResolver.GetConflicts();

            Assert.IsTrue(conflicts.Count >= 1, "There should be edit/edit conflict");
            WITEditEditConflictType contentConflict = new WITEditEditConflictType();

            Assert.IsTrue(contentConflict.ReferenceName.Equals(conflicts[0].ConflictTypeReference.Value.ReferenceName),
                          "It should be WIT edit/edit conflict");

            #region *5.5
            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("update work items on both sides");
            Trace.WriteLine("---------------------------------");
            WITChangeAction action1 = new WITChangeAction();
            WITChangeAction action2 = new WITChangeAction();

            const string SourceLastDesc  = "New Desc 5.5.1";
            const string TargetLastTitle = "New Title 5.5.2";
            action1.Description = SourceLastDesc;
            SourceAdapter.UpdateWorkItem(workitemId, action1);

            action2.Title = TargetLastTitle;
            TargetAdapter.UpdateWorkItem(mirroredId, action2);

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            // 1 edit/edit conflict with chained conflicts
            RunAndNoValidate(true);

            #endregion

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("resolve the conflict by taking target side changes");
            Trace.WriteLine("---------------------------------");
            m_conflictResolver.TryResolveConflict(conflicts[0], new WITEditEditConflictTakeTargetChangesAction(), "/" + workitemId);

            Trace.WriteLine("---------------------------------");
            Trace.WriteLine("sync again");
            Trace.WriteLine("---------------------------------");
            RunAndNoValidate(true);

            // verify sync result
            WitDiffResult result = GetDiffResult();

            // ignore Area/Iteration path mismatches due to test environments
            VerifySyncResult(result, new List <string> {
                FIELD_ITERATION_PATH, FIELD_AREA_PATH
            });

            srcDesc = SourceAdapter.GetFieldValue(workitemId, FIELD_DESCRIPTION);
            tarDesc = TargetAdapter.GetFieldValue(mirroredId, FIELD_DESCRIPTION);
            Assert.AreEqual(TARGET_R1_DESC, srcDesc);
            Assert.AreEqual(TARGET_R1_DESC, tarDesc);

            srcTitle = SourceAdapter.GetFieldValue(workitemId, FIELD_TITLE);
            tarTitle = TargetAdapter.GetFieldValue(mirroredId, FIELD_TITLE);
            Assert.AreEqual(TargetLastTitle, srcTitle);
            Assert.AreEqual(TargetLastTitle, tarTitle);
        }