Skip to content

Commit 0a7aacc

Browse files
jjolidonMrHinsh
andauthored
Create test if tester not found (#1171)
Co-authored-by: Mohamed Bounzaha <Mohamed Bounzaha> Co-authored-by: Martin Hinshelwood nkdAgility.com <[email protected]>
1 parent ce9c897 commit 0a7aacc

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

src/VstsSyncMigrator.Core/Execution/MigrationContext/TestPlansAndSuitesMigrationContext.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,16 @@ private void AssignTesters(ITestSuiteBase sourceSuite, ITestSuiteBase targetSuit
397397

398398
if (tpa.AssignedTo != null)
399399
{
400+
400401
targetIdentity = GetTargetIdentity(tpa.AssignedTo.Descriptor);
402+
401403
if (targetIdentity == null)
402404
{
403-
_sourceIdentityManagementService.RefreshIdentity(tpa.AssignedTo.Descriptor);
405+
if (TryToRefreshTesterIdentity(targetSuite, tpa))
406+
{
407+
targetIdentity = GetTargetIdentity(tpa.AssignedTo.Descriptor);
408+
}
404409
}
405-
406-
targetIdentity = GetTargetIdentity(tpa.AssignedTo.Descriptor);
407410
}
408411

409412
// translate source configuration id to target configuration id and name
@@ -448,6 +451,20 @@ private void AssignTesters(ITestSuiteBase sourceSuite, ITestSuiteBase targetSuit
448451
targetSuite?.AssignTestPoints(assignmentsToAdd);
449452
}
450453

454+
private bool TryToRefreshTesterIdentity(ITestSuiteBase targetSuite, ITestPointAssignment tpa)
455+
{
456+
try
457+
{
458+
_sourceIdentityManagementService.RefreshIdentity(tpa.AssignedTo.Descriptor);
459+
return true;
460+
}
461+
catch (Exception ex)
462+
{
463+
InnerLog(targetSuite, string.Format(" Unable to refresh tester identity: {0}", ex.Message), 10);
464+
Log.LogWarning("Cannot refresh identity of [{tester}] in target. Cannot assign tester to it.", tpa.AssignedTo.DisplayName);
465+
return false;
466+
}
467+
}
451468
private bool CanSkipElementBecauseOfAreaPath(int workItemId)
452469
{
453470
if (_config.OnlyElementsUnderAreaPath == null)
@@ -526,8 +543,8 @@ private ITestPlan CreateNewTestPlanFromSource(ITestPlan sourcePlan, string newPl
526543
targetPlan = _targetTestStore.CreateTestPlan();
527544
targetPlan.CopyPropertiesFrom(sourcePlan);
528545
targetPlan.Name = newPlanName;
529-
targetPlan.StartDate = sourcePlan.StartDate;
530-
targetPlan.EndDate = sourcePlan.EndDate;
546+
targetPlan.StartDate = sourcePlan.StartDate != DateTime.MinValue ? sourcePlan.StartDate : DateTime.Now;
547+
targetPlan.EndDate = sourcePlan.EndDate != DateTime.MinValue ? sourcePlan.EndDate : targetPlan.StartDate.AddDays(1);
531548
targetPlan.Description = sourcePlan.Description;
532549
if (targetPlan is ITestPlan2)
533550
{
@@ -796,6 +813,10 @@ private void ProcessTestPlan(ITestPlan sourcePlan)
796813
{
797814
targetPlan.Links.Clear();
798815
}
816+
817+
InnerLog(sourcePlan, $" Starte Date {targetPlan.StartDate}", 5);
818+
InnerLog(sourcePlan, $" EndDate Plan {targetPlan.EndDate}", 5);
819+
799820
targetPlan.Save();
800821

801822
ApplyFieldMappings(sourcePlan.Id, targetPlan.Id);

0 commit comments

Comments
 (0)