public void Full() { string configTmpFile = Path.GetTempFileName(); try { File.WriteAllText(configTmpFile, BotConfigsForTesting.Full()); MultilinerBotConfiguration config = MultilinerBotConfiguration.BuidFromConfigFile(configTmpFile); Assert.That(config.Server, Is.EqualTo("localhost:8084")); Assert.That(config.Repository, Is.EqualTo("assets")); Assert.That(config.BranchPrefix, Is.EqualTo("AST-")); Assert.That(config.MergeToBranchesAttrName, Is.EqualTo("target")); Assert.That(config.UserApiKey, Is.EqualTo("BAEE806DB01")); Assert.That(config.Plastic, Is.Not.Null); Assert.That(config.Plastic.IsApprovedCodeReviewFilterEnabled, Is.False); Assert.That(config.Plastic.IsBranchAttrFilterEnabled, Is.True); Assert.That(config.Plastic.StatusAttribute, Is.Not.Null); Assert.That(config.Plastic.StatusAttribute.Name, Is.EqualTo("status")); Assert.That(config.Plastic.StatusAttribute.ResolvedValue, Is.EqualTo("resolved")); Assert.That(config.Plastic.StatusAttribute.TestingValue, Is.EqualTo("testing")); Assert.That(config.Plastic.StatusAttribute.FailedValue, Is.EqualTo("failed")); Assert.That(config.Plastic.StatusAttribute.MergedValue, Is.EqualTo("merged")); Assert.That(config.Issues, Is.Not.Null); Assert.That(config.Issues.Plug, Is.EqualTo("tts")); Assert.That(config.Issues.ProjectKey, Is.EqualTo("AST")); Assert.That(config.Issues.TitleField, Is.EqualTo("title")); Assert.That(config.Issues.StatusField, Is.Not.Null); Assert.That(config.Issues.StatusField.Name, Is.EqualTo("status")); Assert.That(config.Issues.StatusField.ResolvedValue, Is.EqualTo("validated")); Assert.That(config.Issues.StatusField.TestingValue, Is.EqualTo("testing")); Assert.That(config.Issues.StatusField.FailedValue, Is.EqualTo("open")); Assert.That(config.Issues.StatusField.MergedValue, Is.EqualTo("closed")); Assert.That(config.CI, Is.Not.Null); Assert.That(config.CI.Plug, Is.EqualTo("My Jenkins")); Assert.That(config.CI.PlanBranch, Is.EqualTo("debug plan")); Assert.That(config.CI.PlanAfterCheckin, Is.EqualTo("release plan")); Assert.That(config.Notifiers, Is.Not.Null.And.Count.EqualTo(1)); Assert.That(config.Notifiers[0].Name, Is.EqualTo("notifier1")); Assert.That(config.Notifiers[0].Plug, Is.EqualTo("email")); Assert.That(config.Notifiers[0].UserProfileField, Is.EqualTo("email")); Assert.That( config.Notifiers[0].FixedRecipients, Is.Not.Null.And.Length.EqualTo(2).And.Contains("me").And.Contains("you")); } finally { if (File.Exists(configTmpFile)) { File.Delete(configTmpFile); } } }
public void OnlyCIPlug() { string configTmpFile = Path.GetTempFileName(); try { File.WriteAllText(configTmpFile, BotConfigsForTesting.OnlyCIPlug()); MultilinerBotConfiguration config = MultilinerBotConfiguration.BuidFromConfigFile(configTmpFile); Assert.That(config.Server, Is.EqualTo("localhost:8084")); Assert.That(config.Repository, Is.EqualTo("assets")); Assert.That(config.BranchPrefix, Is.EqualTo("AST-")); Assert.That(config.MergeToBranchesAttrName, Is.EqualTo("target")); Assert.That(config.UserApiKey, Is.EqualTo("BAEE806DB01")); Assert.That(config.Plastic, Is.Not.Null); Assert.That(config.Plastic.IsApprovedCodeReviewFilterEnabled, Is.False); Assert.That(config.Plastic.IsBranchAttrFilterEnabled, Is.True); Assert.That(config.Plastic.StatusAttribute, Is.Not.Null); Assert.That(config.Plastic.StatusAttribute.Name, Is.EqualTo("status")); Assert.That(config.Plastic.StatusAttribute.ResolvedValue, Is.EqualTo("resolved")); Assert.That(config.Plastic.StatusAttribute.TestingValue, Is.EqualTo("testing")); Assert.That(config.Plastic.StatusAttribute.FailedValue, Is.EqualTo("failed")); Assert.That(config.Plastic.StatusAttribute.MergedValue, Is.EqualTo("merged")); Assert.That(config.Issues, Is.Null); Assert.That(config.CI, Is.Not.Null); Assert.That(config.CI.Plug, Is.EqualTo("My Jenkins")); Assert.That(config.CI.PlanBranch, Is.EqualTo("debug plan")); Assert.That(config.CI.PlanAfterCheckin, Is.EqualTo("release plan")); Assert.That(config.Notifiers, Is.Not.Null.And.Empty); } finally { if (File.Exists(configTmpFile)) { File.Delete(configTmpFile); } } }
static int Main(string[] args) { string botName = null; try { MultilinerBotArguments botArgs = new MultilinerBotArguments(args); bool bValidArgs = botArgs.Parse(); botName = botArgs.BotName; ConfigureLogging(botName); mLog.InfoFormat("MultilinerBot [{0}] started. Version [{1}]", botName, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); string argsStr = args == null ? string.Empty : string.Join(" ", args); mLog.DebugFormat("Args: [{0}]. Are valid args?: [{1}]", argsStr, bValidArgs); if (!bValidArgs || botArgs.ShowUsage) { PrintUsage(); if (botArgs.ShowUsage) { mLog.InfoFormat( "MultilinerBot [{0}] is going to finish: " + "user explicitly requested to show usage.", botName); return(0); } mLog.ErrorFormat( "MultilinerBot [{0}] is going to finish: " + "invalid arguments found in command line.", botName); return(0); } string errorMessage = null; if (!MultilinerBotArgumentsChecker.CheckArguments( botArgs, out errorMessage)) { Console.WriteLine(errorMessage); mLog.ErrorFormat( "MultilinerBot [{0}] is going to finish: error found on arguments check", botName); mLog.Error(errorMessage); return(1); } MultilinerBotConfiguration botConfig = MultilinerBotConfiguration. BuidFromConfigFile(botArgs.ConfigFilePath); errorMessage = null; if (!MultilinerBotConfigurationChecker.CheckConfiguration( botConfig, out errorMessage)) { Console.WriteLine(errorMessage); mLog.ErrorFormat( "MultilinerBot [{0}] is going to finish: error found on configuration check", botName); mLog.Error(errorMessage); return(1); } ConfigureServicePoint(); string escapedBotName = GetEscapedBotName(botName); LaunchMultilinerMergebot( botArgs.WebSocketUrl, botArgs.RestApiUrl, botConfig, ToolConfig.GetBranchesFile(escapedBotName), ToolConfig.GetCodeReviewsFile(escapedBotName), botName, botArgs.ApiKey); mLog.InfoFormat( "MultilinerBot [{0}] is going to finish: orderly shutdown.", botName); return(0); } catch (Exception e) { Console.WriteLine(e.Message); mLog.FatalFormat( "MultilinerBot [{0}] is going to finish: uncaught exception " + "thrown during execution. Message: {1}", botName, e.Message); mLog.DebugFormat("Stack trace:{0}{1}", Environment.NewLine, e.StackTrace); return(1); } }