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 async Task UpdateSolutionAsync_ValidParameters_ExpectedClientCall() { IUKFastDRaaSClient client = Substitute.For <IUKFastDRaaSClient>(); UpdateSolutionRequest req = new UpdateSolutionRequest { IOPSTierID = "11111111-1111-1111-1111-111111111111" }; var ops = new SolutionOperations <Solution>(client); await ops.UpdateSolutionAsync("00000000-0000-0000-0000-000000000000", req); await client.Received().PatchAsync("/draas/v1/solutions/00000000-0000-0000-0000-000000000000", req); }
public async Task GetSolutionAsync_ValidParameters_ExpectedResult() { IUKFastDRaaSClient client = Substitute.For <IUKFastDRaaSClient>(); client.GetAsync <Solution>("/draas/v1/solutions/00000000-0000-0000-0000-000000000000").Returns(new Solution() { ID = "00000000-0000-0000-0000-000000000000" }); var ops = new SolutionOperations <Solution>(client); var solution = await ops.GetSolutionAsync("00000000-0000-0000-0000-000000000000"); Assert.AreEqual("00000000-0000-0000-0000-000000000000", solution.ID); }
public async Task UpdateSolutionAsync_ExpectedResult() { UpdateSolutionRequest req = new UpdateSolutionRequest() { Name = "testsolution" }; IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>(); var ops = new SolutionOperations <Solution>(client); await ops.UpdateSolutionAsync(123, req); await client.Received().PatchAsync("/ecloud/v1/solutions/123", req); }
public async Task GetSolutionAsync_ValidParameters_ExpectedResult() { IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>(); client.GetAsync <Solution>("/ecloud/v1/solutions/123").Returns(new Solution() { ID = 123 }); var ops = new SolutionOperations <Solution>(client); var solution = await ops.GetSolutionAsync(123); Assert.AreEqual(123, solution.ID); }
public async Task GetSolutionsAsync_ExpectedResult() { IUKFastDRaaSClient client = Substitute.For <IUKFastDRaaSClient>(); client.GetAllAsync(Arg.Any <UKFastClient.GetPaginatedAsyncFunc <Solution> >(), null).Returns(Task.Run <IList <Solution> >(() => new List <Solution>() { new Solution(), new Solution() })); var ops = new SolutionOperations <Solution>(client); var solutions = await ops.GetSolutionsAsync(); Assert.AreEqual(2, solutions.Count); }
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 async Task GetSolutionsPaginatedAsync_ExpectedResult() { IUKFastDRaaSClient client = Substitute.For <IUKFastDRaaSClient>(); client.GetPaginatedAsync <Solution>("/draas/v1/solutions").Returns(Task.Run(() => new Paginated <Solution>(client, "/draas/v1/solutions", null, new ClientResponse <IList <Solution> >() { Body = new ClientResponseBody <IList <Solution> >() { Data = new List <Solution>() { new Solution(), new Solution() } } }))); var ops = new SolutionOperations <Solution>(client); var solutions = await ops.GetSolutionsPaginatedAsync(null); Assert.AreEqual(2, solutions.Items.Count); }
public async Task GetSolutionsPaginatedAsync_ExpectedClientCall() { IUKFastECloudClient client = Substitute.For <IUKFastECloudClient>(); client.GetPaginatedAsync <Solution>("/ecloud/v1/solutions").Returns(Task.Run(() => { return(new Paginated <Solution>(client, "/ecloud/v1/solutions", null, new Response.ClientResponse <System.Collections.Generic.IList <Solution> >() { Body = new Response.ClientResponseBody <System.Collections.Generic.IList <Solution> >() { Data = new List <Solution>() { new Solution(), new Solution() } } })); })); var ops = new SolutionOperations <Solution>(client); var paginated = await ops.GetSolutionsPaginatedAsync(); Assert.AreEqual(2, paginated.Items.Count); }
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 async Task UpdateSolutionAsync_InvalidSolutionID_ThrowsUKFastClientValidationException() { var ops = new SolutionOperations <Solution>(null); await Assert.ThrowsExceptionAsync <UKFastClientValidationException>(() => ops.UpdateSolutionAsync("", null)); }
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; } }