Skip to content

Commit

Permalink
[preview] Patch for Failing tests due to null value...no functional i…
Browse files Browse the repository at this point in the history
…mpact. (#1966)
  • Loading branch information
MrHinsh authored Mar 4, 2024
1 parent f7dad39 commit dacb634
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 20 deletions.
4 changes: 2 additions & 2 deletions configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"Processors": [
{
"$type": "WorkItemMigrationConfig",
"Enabled": false,
"Enabled": true,
"UpdateCreatedDate": true,
"UpdateCreatedBy": true,
"WIQLQuery": "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc",
Expand All @@ -96,7 +96,7 @@
"SkipRevisionWithInvalidAreaPath": false
}
],
"Version": "14.2",
"Version": "15.0",
"workaroundForQuerySOAPBugEnabled": false,
"WorkItemTypeDefinition": {
"sourceWorkItemTypeName": "targetWorkItemTypeName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"execute": {
"commandName": "Project",
"commandLineArgs": "execute -c \"C:\\temp\\configuration.json\""
"commandLineArgs": "execute -c \"configuration.json\""
},
"executepipe": {
"commandName": "Project",
Expand Down
10 changes: 8 additions & 2 deletions src/MigrationTools.Host/MigrationToolHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static IHostBuilder CreateDefaultBuilder(string[] args)
.Enrich.WithProcessId()
.WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug, theme: AnsiConsoleTheme.Code, outputTemplate: outputTemplate)
.WriteTo.ApplicationInsights(services.GetService<TelemetryClient>(), new CustomConverter(), LogEventLevel.Error)
.WriteTo.File(logPath, LogEventLevel.Verbose);
.WriteTo.File(logPath, LogEventLevel.Verbose, outputTemplate: outputTemplate);
})
.ConfigureLogging((context, logBuilder) =>
{
Expand Down Expand Up @@ -94,7 +94,13 @@ public static IHostBuilder CreateDefaultBuilder(string[] args)
});
// Application Insights
services.AddApplicationInsightsTelemetryWorkerService(new ApplicationInsightsServiceOptions { ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(), ConnectionString = "InstrumentationKey=2d666f84-b3fb-4dcf-9aad-65de038d2772" });
ApplicationInsightsServiceOptions aiso = new ApplicationInsightsServiceOptions();
aiso.ApplicationVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
aiso.ConnectionString = "InstrumentationKey=2d666f84-b3fb-4dcf-9aad-65de038d2772";
//# if DEBUG
//aiso.DeveloperMode = true;
//#endif
services.AddApplicationInsightsTelemetryWorkerService(aiso);
// Services
services.AddTransient<IDetectOnlineService, DetectOnlineService>();
Expand Down
1 change: 1 addition & 0 deletions src/MigrationTools/Services/TelemetryClientAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class TelemetryClientAdapter : ITelemetryLogger

public TelemetryClientAdapter(TelemetryClient telemetryClient)
{
telemetryClient.InstrumentationKey = "2d666f84-b3fb-4dcf-9aad-65de038d2772";
telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();
telemetryClient.Context.Device.OperatingSystem = Environment.OSVersion.ToString();
if (!(System.Reflection.Assembly.GetEntryAssembly() is null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public EngineConfiguration()
public IMigrationClientConfig Source { get; set; }
public IMigrationClientConfig Target { get; set; }

public List<IFieldMapConfig> FieldMaps { get; set; }
public Dictionary<string, string> GitRepoMapping { get; set; }
public List<IFieldMapConfig> FieldMaps { get; set; } = new List<IFieldMapConfig>();
public Dictionary<string, string> GitRepoMapping { get; set; } = new Dictionary<string, string>();

public string LogLevel { get; private set; }
public List<IProcessorEnricherOptions> CommonEnrichersConfig { get; set; }
public List<IProcessorEnricherOptions> CommonEnrichersConfig { get; set; } = new List<IProcessorEnricherOptions>();
public List<IProcessorConfig> Processors { get; set; }
public string Version { get; set; }
public bool workaroundForQuerySOAPBugEnabled { get; set; }
public Dictionary<string, string> WorkItemTypeDefinition { get; set; }
public Dictionary<string, string> WorkItemTypeDefinition { get; set; } = new Dictionary<string, string>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ protected void PullCommonEnrichersConfig<TEnricher, TEnricherOptions> (List<IPro
where TEnricherOptions : IProcessorEnricherOptions, new()
where TEnricher : IProcessorEnricher
{
var config = commonEnrichersStore.OfType<TEnricherOptions>().FirstOrDefault();
TEnricherOptions config = default(TEnricherOptions);
if (commonEnrichersStore != null)
{
config = commonEnrichersStore.OfType<TEnricherOptions>().FirstOrDefault();
}
if (config == null)
{
var result = new TEnricherOptions();
Expand Down
26 changes: 16 additions & 10 deletions src/VstsSyncMigrator.Core.Tests/WorkItemMigrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public void Setup()
},
});

//IMigrationEngine xx = _services.GetRequiredService<IMigrationEngine>();
// IOptions < EngineConfiguration> engine = _services.GetRequiredService<IOptions<EngineConfiguration>>();


_underTest = new WorkItemMigrationContext(_services.GetRequiredService<IMigrationEngine>(),
_services,
_services.GetRequiredService<ITelemetryLogger>(),
Expand All @@ -54,13 +58,15 @@ public void Setup()
_services.GetRequiredService<TfsWorkItemEmbededLinkEnricher>(),
_services.GetRequiredService<TfsValidateRequiredField>(),
_services.GetRequiredService<IOptions<EngineConfiguration>>());

_underTest.Configure(new WorkItemMigrationConfig
{

});

}

[TestMethod]
[TestMethod, TestCategory("L0")]
public void TestFixAreaPath_WhenNoAreaPathOrIterationPath_DoesntChangeQuery()
{
string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";
Expand All @@ -71,7 +77,7 @@ public void TestFixAreaPath_WhenNoAreaPathOrIterationPath_DoesntChangeQuery()
}


[TestMethod]
[TestMethod, TestCategory("L0")]
public void TestFixAreaPath_WhenAreaPathInQuery_ChangesQuery()
{
string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.AreaPath] = 'SourceServer\Area\Path1' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";
Expand All @@ -82,7 +88,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_ChangesQuery()
Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
}

[TestMethod]
[TestMethod, TestCategory("L1")]
public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_ChangesQuery()
{
var nodeStructure = _services.GetRequiredService<TfsNodeStructure>();
Expand All @@ -102,7 +108,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_
Assert.AreEqual(expectTargetQueryBit, targetWIQLQuery);
}

[TestMethod]
[TestMethod, TestCategory("L1")]
public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesDisabled_SupportsWhitespaces()
{
var nodeStructure = _services.GetRequiredService<TfsNodeStructure>();
Expand All @@ -129,7 +135,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesDisabled
Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
}

[TestMethod]
[TestMethod, TestCategory("L1")]
public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_SupportsWhitespaces()
{
var nodeStructure = _services.GetRequiredService<TfsNodeStructure>();
Expand All @@ -156,7 +162,7 @@ public void TestFixAreaPath_WhenAreaPathInQuery_WithPrefixProjectToNodesEnabled_
Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
}

[TestMethod]
[TestMethod, TestCategory("L0")]
public void TestFixAreaPath_WhenMultipleAreaPathInQuery_ChangesQuery()
{
string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.AreaPath] = 'SourceServer\Area\Path1' OR [System.AreaPath] = 'SourceServer\Area\Path2' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";
Expand All @@ -167,7 +173,7 @@ public void TestFixAreaPath_WhenMultipleAreaPathInQuery_ChangesQuery()
Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
}

[TestMethod]
[TestMethod, TestCategory("L0")]
public void TestFixAreaPath_WhenAreaPathAtEndOfQuery_ChangesQuery()
{
string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan') AND [System.AreaPath] = 'SourceServer\Area\Path1'";
Expand All @@ -178,7 +184,7 @@ public void TestFixAreaPath_WhenAreaPathAtEndOfQuery_ChangesQuery()
Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
}

[TestMethod]
[TestMethod, TestCategory("L0")]
public void TestFixIterationPath_WhenInQuery_ChangesQuery()
{
string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND [System.IterationPath] = 'SourceServer\Iteration\Path1' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";
Expand All @@ -189,7 +195,7 @@ public void TestFixIterationPath_WhenInQuery_ChangesQuery()
Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
}

[TestMethod]
[TestMethod, TestCategory("L0")]
public void TestFixAreaPathAndIteration_WhenMultipleOccuranceInQuery_ChangesQuery()
{
string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND ([System.AreaPath] = 'SourceServer\Area\Path1' OR [System.AreaPath] = 'SourceServer\Area\Path2') AND ([System.IterationPath] = 'SourceServer\Iteration\Path1' OR [System.IterationPath] = 'SourceServer\Iteration\Path2') AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";
Expand All @@ -200,7 +206,7 @@ public void TestFixAreaPathAndIteration_WhenMultipleOccuranceInQuery_ChangesQuer
Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
}

[TestMethod]
[TestMethod, TestCategory("L0")]
public void TestFixAreaPathAndIteration_WhenMultipleOccuranceWithMixtureOrEqualAndUnderOperatorsInQuery_ChangesQuery()
{
string WIQLQueryBit = @"SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject AND ([System.AreaPath] = 'SourceServer\Area\Path1' OR [System.AreaPath] UNDER 'SourceServer\Area\Path2') AND ([System.IterationPath] UNDER 'SourceServer\Iteration\Path1' OR [System.IterationPath] = 'SourceServer\Iteration\Path2') AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";
Expand Down

0 comments on commit dacb634

Please sign in to comment.