Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v16 Niggles - #4! Validation #2343

Merged
merged 15 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions MigrationTools.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitattributes = .gitattributes
.gitignore = .gitignore
appsettings.json = appsettings.json
configuration-classic.json = configuration-classic.json
configuration-classic2-pipeline.json = configuration-classic2-pipeline.json
configuration-classic2-wit.json = configuration-classic2-wit.json
configuration-classic2.json = configuration-classic2.json
configuration.json = configuration.json
configuration2-wit.json = configuration2-wit.json
configuration2.json = configuration2.json
Directory.Build.props = Directory.Build.props
GitVersion.yml = GitVersion.yml
mkdocs.yml = mkdocs.yml
Expand Down Expand Up @@ -75,17 +72,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.Clients.TfsO
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.Clients.AzureDevops.Rest.Tests", "src\MigrationTools.Clients.AzureDevops.Rest.Tests\MigrationTools.Clients.AzureDevops.Rest.Tests.csproj", "{70EA792C-E84C-4A5D-8280-FCC47F4AE150}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".workflows", ".workflows", "{8A70932A-F6C7-45D1-8E72-608B6BF0F9FD}"
ProjectSection(SolutionItems) = preProject
.github\workflows\code-review.yml = .github\workflows\code-review.yml
.github\workflows\main.yml = .github\workflows\main.yml
.github\workflows\MigrationToolsTelemetery.yml = .github\workflows\MigrationToolsTelemetery.yml
.github\workflows\open-pr-describer.yml = .github\workflows\open-pr-describer.yml
.github\workflows\opencommit.yml = .github\workflows\opencommit.yml
.github\workflows\stale.yml = .github\workflows\stale.yml
triggertest.yml = triggertest.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MigrationTools.ConsoleDataGenerator", "src\MigrationTools.ConsoleDataGenerator\MigrationTools.ConsoleDataGenerator.csproj", "{6A259EA6-860B-448A-8943-594DC1A15105}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Classic", "Classic", "{1F5E9C8C-AD05-4C4F-B370-FF3D080A6541}"
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ The documentation for the preview is on [Preview](https://nkdagility.com/docs/az

These metrics come directly from Custo Metrics in Application Insights and are updated every 10 minutes. They are experimental and may not be accurate.

| Metric | Category | Type | All | v16 | Notes |
| Metric | Category | Type | All (last 30 days) | v16 (05/09/2024) | Notes |
|-----------------|------------|------------|-------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|-------------------|
| WorkItemMetrics | Work Items | Count | ![Work Items Total](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemTotals%3Fcode%3Dgithub%26version%3D&label=%20) | ![Work Items v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemTotals%3Fcode%3Dgithub%26version%3D16.0&label=%20) | This counts the number of work items processed |
| WorkItemMetrics | Work Items | Ave | ![Work Items Avg](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemProcessingDuration%3Fcode%3Dgithub%26version%3D&label=%20) | ![Work Items Avg v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemProcessingDuration%3Fcode%3Dgithub%26version%3D16.0&label=%20) | the average amount of time a work item takes to process |
| WorkItemMetrics | Revisions | Count | ![Revisions Total](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisionsTotal%3Fcode%3Dgithub&label=%20) | ![Revisions v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisionsTotal%3Fcode%3Dgithub%26version%3D16.0&label=%20) | the total number of revisions procesed |
| WorkItemMetrics | Revisions | Ave | ![Revisions Avg](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisions%3Fcode%3Dgithub&label=%20) | ![Revisions Avg v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisions%3Fcode%3Dgithub%26version%3D16.0&label=%20) | the avaerge number of revisions per work item |
| WorkItemMetrics | WorkItems | Count | ![Work Items Total](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemTotals%3Fcode%3Dgithub%26version%3D&label=%20) | ![Work Items v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemTotals%3Fcode%3Dgithub%26version%3D16.0&label=%20) | This counts the number of work items processed |
| | | Ave | ![Work Items Avg](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemProcessingDuration%3Fcode%3Dgithub%26version%3D&label=%20) | ![Work Items Avg v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemProcessingDuration%3Fcode%3Dgithub%26version%3D16.0&label=%20) | the average amount of time a work item takes to process |
| | Revisions | Count | ![Revisions Total](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisionsTotal%3Fcode%3Dgithub&label=%20) | ![Revisions v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisionsTotal%3Fcode%3Dgithub%26version%3D16.0&label=%20) | the total number of revisions procesed |
| | | Ave | ![Revisions Avg](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisions%3Fcode%3Dgithub&label=%20) | ![Revisions Avg v16](https://img.shields.io/endpoint?url=https%3A%2F%2Fmigrationtoolstelemetery.azurewebsites.net%2Fapi%2FGetShieldIoWorkItemMetrics_WorkItemRevisions%3Fcode%3Dgithub%26version%3D16.0&label=%20) | the avaerge number of revisions per work item |

![Work Items in last 30 days](https://migrationtoolstelemetery.azurewebsites.net/api/GetGraphWorkItemMetrics_WorkItems?code=github)

Expand Down
4 changes: 2 additions & 2 deletions configuration.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Serilog": {
"MinimumLevel": "Information"
"MinimumLevel": "Debug"
},
"MigrationTools": {
"Version": "16.0",
Expand Down Expand Up @@ -140,7 +140,7 @@
"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",
"WIQLQuery": "SELECT [System.Id] FROM WorkItem WHERE [System.TeamProject] = @TeamProject AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan','Shared Steps','Shared Parameter','Feedback Request') ORDER BY [System.ChangedDate] desc",
"FixHtmlAttachmentLinks": false,
"WorkItemCreateRetryLimit": 5,
"FilterWorkItemsThatAlreadyExistInTarget": false,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions docs/Reference/Generated/MigrationTools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: "How-To: Creating area and iteration maps"
layout: page
toc: true
discussionId:
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="coverlet.collector" Version="6.0.2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.TeamFoundationServer.ExtendedClient" Version="19.225.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ namespace MigrationTools.Processors.Tests
[TestClass()]
public class TfsSharedQueryProcessorTests : TfsProcessorTests
{
[TestMethod(), TestCategory("L0")]
public void TfsSharedQueryProcessorTest()
[TestMethod("TfsSharedQueryProcessorTests_Incantate"), TestCategory("L0")]
public void Incantate()
{
var x = GetTfsSharedQueryProcessor();
Assert.IsNotNull(x);
}

[TestMethod(), TestCategory("L0")]
public void TfsSharedQueryProcessorConfigureTest()
[TestMethod("TfsSharedQueryProcessorTests_BasicConfigure"), TestCategory("L0")]
public void BasicConfigure()
{
var y = new TfsSharedQueryProcessorOptions
{
Expand All @@ -33,8 +33,8 @@ public void TfsSharedQueryProcessorConfigureTest()
Assert.AreEqual("fortyTwo", x.Options.RefName);
}

[TestMethod(), TestCategory("L0")]
public void TfsSharedQueryProcessorRunTest()
[TestMethod("TfsSharedQueryProcessorTests_BasicRun"), TestCategory("L0")]
public void BasicRun()
{
var y = new TfsSharedQueryProcessorOptions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace MigrationTools.Processors.Tests
{
[TestClass()]
public class TfsWorkItemMigrationProcessorTests
{

[TestMethod("TfsWorkItemMigrationProcessorTests_OptionsValidator_Empty"), TestCategory("L0")]
public void OptionsValidator_Empty()
{
var validator = new TfsWorkItemMigrationProcessorOptionsValidator();
var x = new TfsWorkItemMigrationProcessorOptions();
Assert.IsTrue(validator.Validate(null, x).Failed);
}

[TestMethod("TfsWorkItemMigrationProcessorTests_OptionsValidator_Valid"), TestCategory("L0")]
public void OptionsValidator_Valid()
{
var validator = new TfsWorkItemMigrationProcessorOptionsValidator();
var x = new TfsWorkItemMigrationProcessorOptions();
x.WIQLQuery = "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = @TeamProject";
Assert.IsTrue(validator.Validate(null, x).Succeeded);
}

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.Extensions.Options;
using MigrationTools.Endpoints.Infrastructure;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
Expand All @@ -26,17 +28,80 @@ public class TfsEndpointOptions : EndpointOptions

[Required]
public TfsLanguageMapOptions LanguageMaps { get; set; }
}

public class TfsEndpointOptionsValidator : IValidateOptions<TfsEndpointOptions>
{
public ValidateOptionsResult Validate(string name, TfsEndpointOptions options)
{
var errors = new List<string>();

// Validate Collection - Required and must be a valid URL
if (options.Collection == null)
{
errors.Add("The Collection property must not be null.");
}
else if (!Uri.IsWellFormedUriString(options.Collection.ToString(), UriKind.Absolute))
{
errors.Add("The Collection property must be a valid URL.");
}

// Validate Project - Must not be null or empty
if (string.IsNullOrWhiteSpace(options.Project))
{
errors.Add("The Project property must not be null or empty.");
}

// Validate ReflectedWorkItemIdField - Must not be null or empty
if (string.IsNullOrWhiteSpace(options.ReflectedWorkItemIdField))
{
errors.Add("The ReflectedWorkItemIdField property must not be null or empty.");
}

// Validate LanguageMaps - Must exist
if (options.LanguageMaps == null)
{
errors.Add("The LanguageMaps property must exist.");
}

// Validate Authentication - Must exist
if (options.Authentication == null)
{
errors.Add("The Authentication property must exist.");
}
else
{
// Validate Authentication properties based on AuthenticationMode
switch (options.Authentication.AuthenticationMode)
{
case AuthenticationMode.AccessToken:
if (string.IsNullOrWhiteSpace(options.Authentication.AccessToken))
{
errors.Add("The AccessToken must not be null or empty when AuthenticationMode is set to 'AccessToken'.");
}
break;

//[JsonIgnore]
//public string CollectionName { get { return GetCollectionName(); } }
case AuthenticationMode.Windows:
if (options.Authentication.NetworkCredentials == null)
{
errors.Add("The NetworkCredentials must be provided when AuthenticationMode is set to 'Windows'.");
}
break;
case AuthenticationMode.Prompt:
break;
default:
errors.Add($"The AuthenticationMode '{options.Authentication.AuthenticationMode}' is not supported.");
break;
}
}

//public string GetCollectionName()
//{
// //var repositoryDescription = new RepositoryDescription(Collection);
// //return repositoryDescription.CollectionName;
// // Pending fix from https://github.com/bbtsoftware/TfsUrlParser
// return Collection != null ? Collection.ToString() : "https://dev.azure.com/sampleAccount";
//}
// Return failure if there are errors, otherwise success
if (errors.Count > 0)
{
return ValidateOptionsResult.Fail(string.Join(Environment.NewLine, errors));
}

return ValidateOptionsResult.Success;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" Version="1.9.0" />
<PackageReference Include="TfsUrlParser" Version="1.4.1" />
<PackageReference Include="TfsUrlParser" Version="1.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading