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

MapSprint(): Handle case where the full Sprint object is returned from the Fields API #1074

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: 18 additions & 0 deletions src/WorkItemMigrator/JiraExport/RevisionUtils/FieldMapperUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,24 @@ public static object MapSprint(string iterationPathsString)
if (string.IsNullOrWhiteSpace(iterationPathsString))
return null;

// For certain configurations of Jira, the entire Sprint object is returned by the
// fields Rest API instead of the Sprint name
if (iterationPathsString.StartsWith("com.atlassian.greenhopper.service.sprint.Sprint@"))
{
Regex regex = new Regex(@",name=([^,]+),");
Match match = regex.Match(iterationPathsString);
if (match.Success)
{
iterationPathsString = match.Groups[1].Value;
}
else
{
Logger.Log(LogLevel.Error, "Missing 'name' property for Sprint object. "
+ $"Skipping mapping this sprint. The full object was: '{iterationPathsString}'."
);
}
}

var iterationPaths = iterationPathsString.Split(',').AsEnumerable();
iterationPaths = iterationPaths.Select(ip => ip.Trim());
var iterationPath = iterationPaths.Last();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ public void When_calling_map_sprint_with_invalid_azdo_chars_Then_expected_output
Assert.AreEqual(expected, output);
}

[Test]
public void When_calling_map_sprint_with_full_sprint_object_as_str_Then_expected_output_is_returned()
{
string sprintPath = "com.atlassian.greenhopper.service.sprint.Sprint@7c6e1967[id=442906,rapidViewId"
+ "=187524,state=ACTIVE,name=LMS 2024_05,startDate=2024-10-14T00:00:00.000Z,endDate=2024-11-01T"
+ "23:00:00.000Z,completeDate=<null>,activatedDate=2024-10-13T18:14:54.334Z,sequence=449386,goa"
+ "l=,synced=false,autoStartStop=false,incompleteIssuesDestinationId=<null>]";
string expectedOutput = "LMS 2024_05";
object output = FieldMapperUtils.MapSprint(sprintPath);
Assert.AreEqual(expectedOutput, output);
}

[Test]
public void When_calling_map_value_with_valid_args_Then_expected_output_is_returned()
{
Expand Down
Loading