示例#1
0
        public void TeamMapWithNoStatesShouldNotBeValid()
        {
            var invalidMap = new TeamMap
            {
                JiraQuery      = "project = 'TEST'",
                OutputFileName = "validname.csv",
                Workflow       = new List <WorkflowMap>()
            };

            TeamMapValidator.IsValid(invalidMap);
        }
示例#2
0
        public void TeamMapWithEmptyJiraQueryShouldNotBeValid()
        {
            var invalidMap = new TeamMap
            {
                JiraQuery      = string.Empty,
                OutputFileName = "validname.csv",
                Workflow       = new List <WorkflowMap>()
                {
                    new WorkflowMap(new string[] { "ToDo" }, "TODO", StateType.ToDo, "test_issue_type", 1),
                    new WorkflowMap(new string[] { "Doing" }, "DOING", StateType.InProgress, "test_issue_type", 2),
                    new WorkflowMap(new string[] { "Done" }, "DONE", StateType.Done, "test_issue_type", 3)
                }
            };

            TeamMapValidator.IsValid(invalidMap);
        }
示例#3
0
        public void TeamMapWithInvalidFileExtensionShouldNotBeValid()
        {
            var invalidMap = new TeamMap
            {
                JiraQuery      = "project = 'TEST'",
                OutputFileName = "missing_the_csv",
                Workflow       = new List <WorkflowMap>()
                {
                    new WorkflowMap(new string[] { "ToDo" }, "TODO", StateType.ToDo, "test_issue_type", 1),
                    new WorkflowMap(new string[] { "Doing" }, "DOING", StateType.InProgress, "test_issue_type", 2),
                    new WorkflowMap(new string[] { "Done" }, "DONE", StateType.Done, "test_issue_type", 3)
                }
            };

            TeamMapValidator.IsValid(invalidMap);
        }
示例#4
0
        public void TeamMapShouldBeValid()
        {
            var validMap = new TeamMap
            {
                JiraQuery      = "project = 'TEST'",
                OutputFileName = "validname.csv",
                Workflow       = new List <WorkflowMap>()
                {
                    new WorkflowMap(new string[] { "ToDo" }, "TODO", StateType.ToDo, "test_issue_type", 1),
                    new WorkflowMap(new string[] { "Doing" }, "DOING", StateType.InProgress, "test_issue_type", 2),
                    new WorkflowMap(new string[] { "Done" }, "DONE", StateType.Done, "test_issue_type", 3)
                }
            };

            Assert.IsTrue(TeamMapValidator.IsValid(validMap));
        }
示例#5
0
        public void TeamMapWithMultipleDoneStatesShouldNotBeValid()
        {
            var invalidMap = new TeamMap
            {
                JiraQuery      = "project = 'TEST'",
                OutputFileName = "validname.csv",
                Workflow       = new List <WorkflowMap>()
                {
                    new WorkflowMap(new string[] { "ToDo" }, "TODO", StateType.ToDo, "test_issue_type", 1),
                    new WorkflowMap(new string[] { "Doing" }, "DOING", StateType.InProgress, "test_issue_type", 2),
                    new WorkflowMap(new string[] { "Done" }, "DONE", StateType.Done, "test_issue_type", 3),
                    new WorkflowMap(new string[] { "Done2" }, "DONE_AGAIN", StateType.Done, "test_issue_type", 4)
                }
            };

            TeamMapValidator.IsValid(invalidMap);
        }
示例#6
0
        public void TeamMapWithDifferentMappedStateNamesAcrossIssueTypesShouldNotBeValid()
        {
            var invalidMap = new TeamMap
            {
                JiraQuery      = "project = 'TEST'",
                OutputFileName = "validname.csv",
                Workflow       = new List <WorkflowMap>()
                {
                    new WorkflowMap(new string[] { "ToDo" }, "TODO", StateType.ToDo, "test_issue_type", 1),
                    new WorkflowMap(new string[] { "Doing" }, "DOING", StateType.InProgress, "test_issue_type", 2),
                    new WorkflowMap(new string[] { "Done" }, "DONE", StateType.Done, "test_issue_type", 3),
                    new WorkflowMap(new string[] { "ToDo" }, "TODO", StateType.ToDo, "second_issue_type", 1),
                    new WorkflowMap(new string[] { "Doing" }, "DIFFERENT DOING", StateType.InProgress, "second_issue_type", 2),
                    new WorkflowMap(new string[] { "Done" }, "DONE", StateType.Done, "second_issue_type", 3),
                }
            };

            TeamMapValidator.IsValid(invalidMap);
        }
示例#7
0
        static void Main()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
            var configuration = builder.Build();

            try
            {
                var config = configuration.GetSection("AppSettings").GetSection("JiraConfig").Get <JiraConfig>();

                if (!JiraConfigValidator.IsValid(config))
                {
                    throw new Exception("Invalid configuration.");
                }

                var mappings = configuration.GetSection("AppSettings").GetSection("Mapping").Get <List <TeamMap> >();

                var enabledMappings = mappings.Where(map => map.Enabled).ToList();

                if (!enabledMappings.Any())
                {
                    Console.WriteLine("There are no team mappings enabled");
                    return;
                }

                Console.WriteLine($"Processing {enabledMappings.Count} team mappings...");

                enabledMappings.ForEach(map =>
                {
                    try
                    {
                        if (!TeamMapValidator.IsValid(map))
                        {
                            throw new Exception("Invalid map.");
                        }

                        var issueStore     = new IssueStore(config);
                        var changelogStore = new ChangelogStore(config);

                        var issueWriter   = new JiraStateWriter(map, issueStore, changelogStore);
                        var issuesToWrite = issueWriter.GetIssues();

                        Console.WriteLine($"Found {issuesToWrite.Count} issues for {map.TeamName}...");

                        issueWriter.WriteIssues(issuesToWrite);

                        Console.WriteLine($"Issues written to {map.OutputFileName}");
                    }
                    catch (InvalidMappingException exception)
                    {
                        Console.WriteLine($"{exception.Message}. Continuing to next map...");
                    }
                });

                Console.WriteLine("Complete");
            }
            catch (Exception exception)
            {
                Console.WriteLine($"Failed to process. {exception.Message}");
            }
        }