private void LoadRecentSolutionsAsObjects() { CleanRecentSolutionsList(); mRecentSolutionsAsObjects = new ObservableList <Solution>(); int counter = 0; foreach (string s in UserProfile.RecentSolutions) { string SolutionFile = Path.Combine(s, @"Ginger.Solution.xml"); if (File.Exists(SolutionFile)) { try { Solution sol = SolutionOperations.LoadSolution(SolutionFile, false); SolutionOperations solutionOperations = new SolutionOperations(sol); sol.SolutionOperations = solutionOperations; mRecentSolutionsAsObjects.Add(sol); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, string.Format("Failed to load the recent solution which in path '{0}'", s), ex); } counter++; if (counter >= 10) { break; // only first latest 10 solutions } } } return; }
public static void ClassInit(TestContext context) { mBF = new BusinessFlow(); mBF.Activities = new ObservableList <Activity>(); mBF.Name = "BF Test Fire Fox"; mBF.Active = true; Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString busFlowV1 = new VariableString() { Name = "BFV1", InitialStringValue = "1" }; mBF.AddVariable(busFlowV1); mGR = new GingerRunner(); mGR.Executor = new GingerExecutionEngine(mGR); mGR.Executor.CurrentSolution = new Ginger.SolutionGeneral.Solution(); Agent a = new Agent(); a.AgentType = Agent.eAgentType.Service; // Simple agent which anyhow we don't need to start for this test and will work on Linux ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(a); mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.Executor.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.Executor.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web, Description = "New application" }); mGR.Executor.BusinessFlows.Add(mBF); WorkSpace.Init(new WorkSpaceEventHandler()); WorkSpace.Instance.RunningFromUnitTest = true; WorkSpace.Instance.SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository(); string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "BasicSimple")); string solutionFile = System.IO.Path.Combine(path, @"Ginger.Solution.xml"); solution = SolutionOperations.LoadSolution(solutionFile); WorkSpace.Instance.SolutionRepository.Open(path); WorkSpace.Instance.Solution = solution; if (WorkSpace.Instance.Solution.SolutionOperations == null) { WorkSpace.Instance.Solution.SolutionOperations = new SolutionOperations(WorkSpace.Instance.Solution); } }
public void CreateNewSolutionWithMultiUnderscore() { // Arrange Solution createSol = new Solution(); createSol.Name = "Non_Ui_Solution_Test"; string solFile = TestResources.GetTempFile("Solution2.Ginger.Solution.xml"); //Act createSol.RepositorySerializer.SaveToFile(createSol, solFile); Solution loadSol = SolutionOperations.LoadSolution(solFile, false); //Assert Assert.AreEqual(loadSol.Name, createSol.Name); Assert.AreEqual(loadSol.MainPlatform, createSol.MainPlatform); }
public void TestInitialize() { mBF = new BusinessFlow(); mBF.Name = "BF Test Fire Fox"; mBF.Active = true; Activity activity = new Activity(); mBF.AddActivity(activity); ActDummy action1 = new ActDummy(); ActDummy action2 = new ActDummy(); mBF.Activities[0].Acts.Add(action1); mBF.Activities[0].Acts.Add(action2); Platform p = new Platform(); p.PlatformType = ePlatformType.Web; mBF.TargetApplications.Add(new TargetApplication() { AppName = "SCM" }); VariableString v1 = new VariableString() { Name = "v1", InitialStringValue = "1" }; mBF.AddVariable(v1); mGR = new GingerRunner(); mGR.Executor = new GingerExecutionEngine(mGR); mGR.Name = "Test Runner"; mGR.Executor.CurrentSolution = new Ginger.SolutionGeneral.Solution(); mGR.Executor.CurrentBusinessFlow = mBF; mGR.Executor.CurrentBusinessFlow.CurrentActivity = mBF.Activities[0]; environment = new ProjEnvironment(); environment.Name = "Default"; mBF.Environment = environment.Name; mGR.ProjEnvironment = environment; Agent a = new Agent(); //a.DriverType = Agent.eDriverType.SeleniumFireFox;//have known firefox issues with selenium 3 a.DriverType = Agent.eDriverType.SeleniumChrome; ((GingerExecutionEngine)mGR.Executor).SolutionAgents = new ObservableList <Agent>(); ((GingerExecutionEngine)mGR.Executor).SolutionAgents.Add(a); // p2.Agent = a; mGR.ApplicationAgents.Add(new ApplicationAgent() { AppName = "SCM", Agent = a }); mGR.Executor.SolutionApplications = new ObservableList <ApplicationPlatform>(); mGR.Executor.SolutionApplications.Add(new ApplicationPlatform() { AppName = "SCM", Platform = ePlatformType.Web, Description = "New application" }); mGR.Executor.BusinessFlows.Add(mBF); mGR.SpecificEnvironmentName = environment.Name; mGR.UseSpecificEnvironment = false; string path = Path.Combine(TestResources.GetTestResourcesFolder(@"Solutions" + Path.DirectorySeparatorChar + "BasicSimple")); string solutionFile = System.IO.Path.Combine(path, @"Ginger.Solution.xml"); solution = SolutionOperations.LoadSolution(solutionFile); SR = GingerSolutionRepository.CreateGingerSolutionRepository(); SR.Open(path); WorkSpace.Instance.Solution = solution; WorkSpace.Instance.Solution.LoggerConfigurations.CalculatedLoggerFolder = WorkSpace.Instance.Solution.LoggerConfigurations.ExecutionLoggerConfigurationExecResultsFolder; WorkSpace.Instance.Solution.SolutionOperations = new SolutionOperations(WorkSpace.Instance.Solution); WorkSpace.Instance.SolutionRepository = SR; }
public bool OpenSolution(string solutionFolder, string encryptionKey = null) { try { Reporter.ToLog(eLogLevel.INFO, string.Format("Loading the Solution '{0}'", solutionFolder)); LoadingSolution = true; //Cleaning previous Solution load Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Cleaning previous Solution items"); CloseSolution(); //Load Solution file //Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Opening Solution located at: " + solutionFolder); string solutionFile = System.IO.Path.Combine(solutionFolder, @"Ginger.Solution.xml"); Reporter.ToLog(eLogLevel.INFO, string.Format("Loading Solution- Loading Solution File: '{0}'", solutionFile)); if (System.IO.File.Exists(solutionFile)) { Reporter.ToLog(eLogLevel.DEBUG, "Loading Solution- Solution File exist"); } else { if (!File.Exists(Amdocs.Ginger.IO.PathHelper.GetLongPath(solutionFile))) { //Reporter.ToUser(eUserMsgKey.BeginWithNoSelectSolution); Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Solution File Not Found"); return(false); } } //Checking if Ginger upgrade is needed Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Checking if Ginger Solution items upgrade is needed"); IEnumerable <string> solutionFiles = Solution.SolutionFiles(solutionFolder); SolutionUpgrade.ClearPreviousScans(); if (SolutionUpgrade.IsGingerUpgradeNeeded(solutionFolder, solutionFiles)) { Reporter.ToLog(eLogLevel.WARN, "Loading Solution- Error: Current Ginger version can't load the Solution because it includes items from higher Ginger version"); return(false); } Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading Solution file xml into object"); Solution solution = SolutionOperations.LoadSolution(solutionFile, true, encryptionKey); SolutionOperations solutionOperations = new SolutionOperations(solution); solution.SolutionOperations = solutionOperations; if (solution == null) { Reporter.ToUser(eUserMsgKey.SolutionLoadError, "Failed to load the Solution file"); Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Failed to load the Solution file"); return(false); } EncryptionHandler.SetCustomKey(solution.EncryptionKey); if (!solution.SolutionOperations.ValidateKey()) { if (WorkSpace.Instance.RunningInExecutionMode == false && WorkSpace.Instance.RunningFromUnitTest == false) { if (string.IsNullOrEmpty(solution.EncryptedValidationString)) { // To support existing solutions, solution.EncryptionKey = EncryptionHandler.GetDefaultKey(); solution.NeedVariablesReEncryption = true; solution.SolutionOperations.SaveEncryptionKey(); solution.SolutionOperations.SaveSolution(false); } else if (!Instance.EventHandler.OpenEncryptionKeyHandler(solution)) { return(false); } } else { Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Error: Encryption key validation failed"); return(false); } } Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Creating Items Repository"); SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository(); SolutionRepository.Open(solutionFolder); Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Loading needed Plugins"); mPluginsManager = new PluginsManager(); mPluginsManager.SolutionChanged(SolutionRepository); Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Doing Source Control Configurations"); try { HandleSolutionLoadSourceControl(solution); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "exception occured while doing Solution Source Control Configurations", ex); } Reporter.ToLog(eLogLevel.INFO, "Loading Solution- Updating Application Functionalities to Work with Loaded Solution"); ValueExpression.SolutionFolder = solutionFolder; BusinessFlow.SolutionVariables = solution.Variables; solution.SolutionOperations.SetReportsConfigurations(); Solution = solution; UserProfile.UserProfileOperations.LoadRecentAppAgentMapping(); if (!RunningInExecutionMode) { AppSolutionRecover.DoSolutionAutoSaveAndRecover(); } //Solution items upgrade SolutionUpgrade.CheckSolutionItemsUpgrade(solutionFolder, solution.Name, solutionFiles.ToList()); if (!RunningInExecutionMode && mSolution.NeedVariablesReEncryption) { string msg = "Going forward each solution needs to have its own key for encrypting password values\n" + "Please make a note of Default key updated on Solution details page. This key is mandatory for accessing solution"; Reporter.ToUser(eUserMsgKey.SolutionEncryptionKeyUpgrade, msg); Instance.EventHandler.OpenEncryptionKeyHandler(null); } // No need to add solution to recent if running from CLI if (!RunningInExecutionMode) { ((UserProfileOperations)UserProfile.UserProfileOperations).AddSolutionToRecent(solution); } // PlugInsManager = new PluginsManager(); // mPluginsManager.Init(SolutionRepository); Reporter.ToLog(eLogLevel.INFO, string.Format("Finished Loading successfully the Solution '{0}'", solutionFolder)); return(true); } catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, "Loading Solution- Unexpected Error occurred while loading the solution", ex); CloseSolution(); throw ex; } finally { LoadingSolution = false; } }