Ejemplo n.º 1
0
        private void grdActivitiesGroups_ItemDropped(object sender, EventArgs e)
        {
            object   droppedItem      = ((DragInfo)sender).Data;
            Activity previousActivity = null;

            if ((ActivitiesGroup)grdActivitiesGroups.CurrentItem != null && ((ActivitiesGroup)grdActivitiesGroups.CurrentItem).ActivitiesIdentifiers.Count > 0)
            {
                previousActivity = (Activity)(((ActivitiesGroup)grdActivitiesGroups.CurrentItem).ActivitiesIdentifiers[((ActivitiesGroup)grdActivitiesGroups.CurrentItem).ActivitiesIdentifiers.Count - 1].IdentifiedActivity);
            }
            if (droppedItem.GetType() == typeof(ActivitiesGroup))
            {
                ActivitiesGroup droppedGroupIns = (ActivitiesGroup)((ActivitiesGroup)droppedItem).CreateInstance(true);
                mBusinessFlow.AddActivitiesGroup(droppedGroupIns);
                ObservableList <Activity> activities = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();
                mBusinessFlow.ImportActivitiesGroupActivitiesFromRepository(droppedGroupIns, activities, false, false, previousActivity);
                mBusinessFlow.AttachActivitiesGroupsAndActivities();

                int selectedActIndex = -1;
                ObservableList <ActivitiesGroup> actsList = mBusinessFlow.ActivitiesGroups;
                if (actsList.CurrentItem != null)
                {
                    selectedActIndex = actsList.IndexOf((ActivitiesGroup)actsList.CurrentItem);
                }
                if (selectedActIndex >= 0)
                {
                    actsList.Move(actsList.Count - 1, selectedActIndex + 1);
                }
            }
        }
Ejemplo n.º 2
0
        private void AddFromRepository(object sender, RoutedEventArgs e)
        {
            if (mInTreeModeView == false)
            {
                if (grdActivitiesGroupsRepository.Grid.SelectedItems != null && grdActivitiesGroupsRepository.Grid.SelectedItems.Count > 0)
                {
                    if (mBusinessFlow == null)
                    {
                        return;
                    }
                    foreach (ActivitiesGroup selectedItem in grdActivitiesGroupsRepository.Grid.SelectedItems)
                    {
                        ActivitiesGroup droppedGroupIns = (ActivitiesGroup)selectedItem.CreateInstance(true);
                        mBusinessFlow.AddActivitiesGroup(droppedGroupIns);
                        mBusinessFlow.ImportActivitiesGroupActivitiesFromRepository(droppedGroupIns, App.LocalRepository.GetSolutionRepoActivities(), false);

                        int selectedActIndex = -1;
                        ObservableList <ActivitiesGroup> actsList = App.BusinessFlow.ActivitiesGroups;
                        if (actsList.CurrentItem != null)
                        {
                            selectedActIndex = actsList.IndexOf((ActivitiesGroup)actsList.CurrentItem);
                        }
                        if (selectedActIndex >= 0)
                        {
                            actsList.Move(actsList.Count - 1, selectedActIndex + 1);
                        }
                    }
                    mBusinessFlow.AttachActivitiesGroupsAndActivities();
                }
                else
                {
                    Reporter.ToUser(eUserMsgKeys.NoItemWasSelected);
                }
            }
        }
Ejemplo n.º 3
0
        public void AddActivityToExistingGroupTest()
        {
            //Arrange
            BusinessFlow busFlow = new BusinessFlow();

            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);

            Activity activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };

            busFlow.AddActivity(activity1, group1);
            busFlow.AddActivity(activity2, group1);
            busFlow.AddActivity(activity3, group1);

            busFlow.AddActivity(activity4, group2);
            busFlow.AddActivity(activity5, group2);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();
            Activity activity6 = new Activity()
            {
                ActivityName = "Activity6"
            };

            busFlow.AddActivity(activity6, group1);

            //Assert
            Assert.IsTrue(busFlow.Activities[3] == activity6, "Validate new Activity added in last of existing group Activities");
            Assert.IsTrue(activity6.ActivitiesGroupID == group1.Name, "Validate new Activity is mapped to existing group");
            Assert.IsTrue(group1.ActivitiesIdentifiers[group1.ActivitiesIdentifiers.Count - 1].IdentifiedActivity == activity6, "Validate new Activity is mapped to existing group");
        }
Ejemplo n.º 4
0
        private void BindControlsToBusinessFlow()
        {
            //General Info Section Bindings
            BindingHandler.ObjFieldBinding(xNameTextBlock, TextBlock.TextProperty, mBusinessFlow, nameof(BusinessFlow.Name));
            BindingHandler.ObjFieldBinding(xNameTextBlock, TextBlock.ToolTipProperty, mBusinessFlow, nameof(BusinessFlow.Name));
            mBusinessFlow.PropertyChanged -= mBusinessFlow_PropertyChanged;
            mBusinessFlow.PropertyChanged += mBusinessFlow_PropertyChanged;
            UpdateDescription();

            //Activities Tab Bindings
            mBusinessFlow.AttachActivitiesGroupsAndActivities();
            mBusinessFlow.Activities.CollectionChanged -= Activities_CollectionChanged;
            mBusinessFlow.Activities.CollectionChanged += Activities_CollectionChanged;
            UpdateActivitiesTabHeader();
            if (mActivitiesPage != null && xActivitisTab.IsSelected)
            {
                mActivitiesPage.UpdateBusinessFlow(mBusinessFlow);
            }

            //Variables Tab Bindings
            mBusinessFlow.Variables.CollectionChanged -= Variables_CollectionChanged;
            mBusinessFlow.Variables.CollectionChanged += Variables_CollectionChanged;
            UpdateVariabelsTabHeader();
            if (mVariabelsPage != null && xVariablesTab.IsSelected)
            {
                mVariabelsPage.UpdateParent(mBusinessFlow);
            }

            //Configurations Tab Bindings
            if (mConfigurationsPage != null && xConfigurationsTab.IsSelected)
            {
                mConfigurationsPage.UpdateBusinessFlow(mBusinessFlow);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Adding Activities Groups from Shared Repository to the Business Flow in Context
 /// </summary>
 /// <param name="sharedActivitiesGroupsToAdd">Shared Repository Activities Groups to Add Instances from</param>
 /// <param name="businessFlow">Business Flow to add to</param>
 public static void AddActivitiesGroupsFromSRHandler(List <ActivitiesGroup> sharedActivitiesGroupsToAdd, BusinessFlow businessFlow)
 {
     foreach (ActivitiesGroup sharedGroup in sharedActivitiesGroupsToAdd)
     {
         ActivitiesGroup droppedGroupIns = (ActivitiesGroup)sharedGroup.CreateInstance(true);
         businessFlow.AddActivitiesGroup(droppedGroupIns);
         ObservableList <Activity> activities = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();
         businessFlow.ImportActivitiesGroupActivitiesFromRepository(droppedGroupIns, activities, false);
     }
     businessFlow.AttachActivitiesGroupsAndActivities();
 }
Ejemplo n.º 6
0
        public ActivitiesGroupsManagerPage(BusinessFlow businessFlow)
        {
            InitializeComponent();

            mBusinessFlow = businessFlow;
            mBusinessFlow.SaveBackup();

            mBusinessFlow.AttachActivitiesGroupsAndActivities();
            mBusinessFlow.UpdateActivitiesGroupDetails(BusinessFlow.eUpdateActivitiesGroupDetailsType.All);

            SetGridsView();
            SetGroupsGridData();
        }
Ejemplo n.º 7
0
        public void AddDefualtGroupTest()
        {
            //Arrange
            BusinessFlow busFlow   = new BusinessFlow();
            Activity     activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };

            busFlow.AddActivity(activity1);
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };

            busFlow.AddActivity(activity2);
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };

            busFlow.AddActivity(activity3);
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };

            busFlow.AddActivity(activity4);
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };

            busFlow.AddActivity(activity5);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();

            //Assert
            Assert.IsTrue(busFlow.ActivitiesGroups.Count == 1, "Validate defualt Activities Group was added");
            Assert.IsTrue(busFlow.ActivitiesGroups[0].ActivitiesIdentifiers.Count == 5, "Validate all Activities are attached to defualt Activities Group");
            Assert.IsTrue(busFlow.ActivitiesGroups[0].ActivitiesIdentifiers[2].ActivityName == activity3.ActivityName, "Validate group has correct activities mapped to it");
            Assert.IsTrue(activity1.ActivitiesGroupID == busFlow.ActivitiesGroups[0].Name, "Validate Activities mapped to defualt group");
            Assert.IsTrue(activity5.ActivitiesGroupID == busFlow.ActivitiesGroups[0].Name, "Validate Activities mapped to defualt group");
        }
Ejemplo n.º 8
0
        private void grdActivities_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data;

            if (droppedItem.GetType() == typeof(Activity))
            {
                Activity instance = (Activity)((Activity)droppedItem).CreateInstance(true);
                instance.Active = true;

                mBusinessFlow.SetActivityTargetApplication(instance);
                mBusinessFlow.AddActivity(instance);

                //Placing the item after current item
                int selectedActIndex = -1;
                ObservableList <Activity> actsList = mBusinessFlow.Activities;
                if (actsList.CurrentItem != null)
                {
                    selectedActIndex = actsList.IndexOf((Activity)actsList.CurrentItem);
                }
                if (selectedActIndex >= 0)
                {
                    actsList.Move(actsList.Count - 1, selectedActIndex + 1);
                }
            }
            else if (droppedItem.GetType() == typeof(ActivitiesGroup))
            {
                ActivitiesGroup droppedGroupIns = (ActivitiesGroup)((ActivitiesGroup)droppedItem).CreateInstance(true);
                mBusinessFlow.AddActivitiesGroup(droppedGroupIns);
                ObservableList <Activity> activities = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();
                mBusinessFlow.ImportActivitiesGroupActivitiesFromRepository(droppedGroupIns, activities, false);
                mBusinessFlow.AttachActivitiesGroupsAndActivities();

                int selectedActIndex = -1;
                ObservableList <ActivitiesGroup> actsList = App.BusinessFlow.ActivitiesGroups;
                if (actsList.CurrentItem != null)
                {
                    selectedActIndex = actsList.IndexOf((ActivitiesGroup)actsList.CurrentItem);
                }
                if (selectedActIndex >= 0)
                {
                    actsList.Move(actsList.Count - 1, selectedActIndex + 1);
                }
            }
        }
Ejemplo n.º 9
0
        private string CraeteGroupActivitiesStatusXml(BusinessFlow BF, ref int passCount, ref int failedCount, ref int blockedCount)
        {
            string   BFResults  = string.Empty;
            long?    elapsed    = 0;
            DateTime startedAt  = new DateTime();
            DateTime finishedAt = new DateTime();

            if (BF.ActivitiesGroups.Count > 0)
            {
                BF.AttachActivitiesGroupsAndActivities();
                foreach (var item in BF.ActivitiesGroups)
                {
                    if (item.ActivitiesIdentifiers.Count > 0)
                    {
                        List <Activity> acts = item.ActivitiesIdentifiers.Select(a => a.IdentifiedActivity).ToList();
                        Amdocs.Ginger.CoreNET.Execution.eRunStatus status = getGroupActivityStatus(acts, ref elapsed, ref startedAt, ref finishedAt);
                        BFResults += buildXml(status, ref passCount, ref failedCount, ref blockedCount, General.ConvertInvalidXMLCharacters(BF.Name), General.ConvertInvalidXMLCharacters(item.Name), General.ConvertInvalidXMLCharacters(item.Description), elapsed, startedAt, finishedAt);
                    }
                }

                //create ungrouped for activities that are not in any group
                List <Activity> unGroupedAct = new List <Activity>();
                foreach (var item in BF.Activities)
                {
                    if (item.ActivitiesGroupID == string.Empty)
                    {
                        unGroupedAct.Add(item);
                    }
                }
                if (unGroupedAct.Count > 0)
                {
                    Amdocs.Ginger.CoreNET.Execution.eRunStatus status = getGroupActivityStatus(unGroupedAct, ref elapsed, ref startedAt, ref finishedAt);
                    BFResults += buildXml(status, ref passCount, ref failedCount, ref blockedCount, General.ConvertInvalidXMLCharacters(BF.Name), "Ungrouped", "Ungrouped", elapsed, startedAt, finishedAt);
                }
            }
            else//if there are no groups create default group
            {
                Amdocs.Ginger.CoreNET.Execution.eRunStatus status = getGroupActivityStatus(BF.Activities.ToList(), ref elapsed, ref startedAt, ref finishedAt);
                BFResults += buildXml(status, ref passCount, ref failedCount, ref blockedCount, General.ConvertInvalidXMLCharacters(BF.Name), "Ungrouped", "Ungrouped", elapsed, startedAt, finishedAt);
            }

            return(BFResults);
        }
        private void grdGroups_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data;

            if (droppedItem.GetType() == typeof(Activity))
            {
                Activity instance = (Activity)((Activity)droppedItem).CreateInstance();
                instance.Active = true;
                mBusinessFlow.SetActivityTargetApplication(instance);
                mBusinessFlow.AddActivity(instance);
            }
            else if (droppedItem.GetType() == typeof(ActivitiesGroup))
            {
                ActivitiesGroup droppedGroupIns = (ActivitiesGroup)((ActivitiesGroup)droppedItem).CreateInstance();
                mBusinessFlow.AddActivitiesGroup(droppedGroupIns);
                ObservableList <Activity> activities = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();
                mBusinessFlow.ImportActivitiesGroupActivitiesFromRepository(droppedGroupIns, activities, false);
                mBusinessFlow.AttachActivitiesGroupsAndActivities();
            }
        }
Ejemplo n.º 11
0
        private void grdActivitiesGroups_ItemDropped(object sender, EventArgs e)
        {
            object droppedItem = ((DragInfo)sender).Data;

            if (droppedItem.GetType() == typeof(ActivitiesGroup))
            {
                ActivitiesGroup droppedGroupIns = (ActivitiesGroup)((ActivitiesGroup)droppedItem).CreateInstance(true);
                mBusinessFlow.AddActivitiesGroup(droppedGroupIns);
                mBusinessFlow.ImportActivitiesGroupActivitiesFromRepository(droppedGroupIns, App.LocalRepository.GetSolutionRepoActivities(), false);
                mBusinessFlow.AttachActivitiesGroupsAndActivities();

                int selectedActIndex = -1;
                ObservableList <ActivitiesGroup> actsList = mBusinessFlow.ActivitiesGroups;
                if (actsList.CurrentItem != null)
                {
                    selectedActIndex = actsList.IndexOf((ActivitiesGroup)actsList.CurrentItem);
                }
                if (selectedActIndex >= 0)
                {
                    actsList.Move(actsList.Count - 1, selectedActIndex + 1);
                }
            }
        }
Ejemplo n.º 12
0
        public void GroupsActivitiesOrderTest()
        {
            //Arrange
            BusinessFlow busFlow   = new BusinessFlow();
            Activity     activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };

            busFlow.AddActivity(activity1);
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };

            busFlow.AddActivity(activity2);
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };

            busFlow.AddActivity(activity3);
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };

            busFlow.AddActivity(activity4);
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };

            busFlow.AddActivity(activity5);

            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);

            group1.AddActivityToGroup(activity3);
            group1.AddActivityToGroup(activity2);
            group1.AddActivityToGroup(activity1);
            group2.AddActivityToGroup(activity4);
            group2.AddActivityToGroup(activity5);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();

            //Assert
            Assert.IsTrue(group1.ActivitiesIdentifiers[0].IdentifiedActivity == activity1, "Validate group 1 Activity 1 order is same as in Activities flow");
            Assert.IsTrue(group1.ActivitiesIdentifiers[1].IdentifiedActivity == activity2, "Validate group 1 Activity 2 order is same as in Activities flow");
            Assert.IsTrue(group1.ActivitiesIdentifiers[2].IdentifiedActivity == activity3, "Validate group 1 Activity 3 order is same as in Activities flow");
            Assert.IsTrue(group2.ActivitiesIdentifiers[0].IdentifiedActivity == activity4, "Validate group 2 Activity 4 order is same as in Activities flow");
            Assert.IsTrue(group2.ActivitiesIdentifiers[1].IdentifiedActivity == activity5, "Validate group 2 Activity 5 order is same as in Activities flow");
        }
Ejemplo n.º 13
0
        public BusinessFlowPage(BusinessFlow BizFlow, bool showMiniView = false, General.RepositoryItemPageViewMode editMode = General.RepositoryItemPageViewMode.SharedReposiotry)
        {
            InitializeComponent();

            mBusinessFlow = BizFlow;
            RunDescritpion.Init(BizFlow, BusinessFlow.Fields.RunDescription);
            mEditMode = editMode;
            LoadBizFlowData();
            App.PropertyChanged += AppPropertychanged;

            if (mBusinessFlow.TargetApplications == null)
            {
                mBusinessFlow.TargetApplications = new ObservableList <TargetApplication>();
            }
            PlatformListBox.ItemsSource       = mBusinessFlow.TargetApplications;
            PlatformListBox.DisplayMemberPath = nameof(TargetApplication.AppName);
            TagsViewer.Init(mBusinessFlow.Tags);

            TrackBusinessFlowAutomationPrecentage();
            mBusinessFlow.AttachActivitiesGroupsAndActivities();

            if (!showMiniView)
            {
                mActivitiesPage = new ActivitiesPage(mBusinessFlow, mEditMode);
                if (mEditMode != General.RepositoryItemPageViewMode.View)
                {
                    mActivitiesPage.grdActivities.ChangeGridView(eAutomatePageViewStyles.Design.ToString());
                    mBusinessFlow.SaveBackup();
                }
                mActivitiesPage.grdActivities.ShowTitle = System.Windows.Visibility.Collapsed;
                BfActivitiesFrame.Content = mActivitiesPage;

                mActivitiesGroupsPage = new ActivitiesGroupsPage(mBusinessFlow, mEditMode);
                mActivitiesGroupsPage.grdActivitiesGroups.ShowTitle = System.Windows.Visibility.Collapsed;
                BfActivitiesGroupsFrame.Content = mActivitiesGroupsPage;
                if (mBusinessFlow.ActivitiesGroups.Count == 0)
                {
                    ActivitiesGroupsExpander.IsExpanded = false;
                }

                mVariablesPage = new VariablesPage(GingerCore.Variables.eVariablesLevel.BusinessFlow, mBusinessFlow, mEditMode);
                mVariablesPage.grdVariables.ShowTitle = System.Windows.Visibility.Collapsed;
                BfVariablesFrame.Content = mVariablesPage;
                if (mBusinessFlow.Variables.Count == 0)
                {
                    VariablesExpander.IsExpanded = false;
                }

                mReposiotryPage = new RepositoryPage(mBusinessFlow);
                mReposiotryPage.ShowActionsRepository   = System.Windows.Visibility.Collapsed;
                mReposiotryPage.ShowVariablesRepository = System.Windows.Visibility.Collapsed;
                RepositoryFrame.Content = mReposiotryPage;
            }
            else
            {
                //hide Variables / Activities groups/ Activities / Repository
                Row3.MinHeight = 0;
                Row3.Height    = new GridLength(0);
                Row4.MinHeight = 0;
                Row4.Height    = new GridLength(0);
                Row5.MinHeight = 0;
                Row5.Height    = new GridLength(0);
            }
            if (mEditMode == General.RepositoryItemPageViewMode.View)
            {
                txtName.IsEnabled            = false;
                txtDescription.IsEnabled     = false;
                RunDescritpion.IsEnabled     = false;
                TagsViewer.IsEnabled         = false;
                xBusinessflowinfo.IsEnabled  = false;
                xTargetApplication.IsEnabled = false;
                RepositoryExpander.IsEnabled = false;
                xAutomateBtn.Visibility      = Visibility.Collapsed;
            }

            if (!App.UserProfile.UserTypeHelper.IsSupportAutomate)
            {
                xAutomateBtn.Visibility = Visibility.Collapsed;
            }
        }
Ejemplo n.º 14
0
        public void MoveActivityInGroupsTest2()
        {
            //Arrange
            BusinessFlow busFlow = new BusinessFlow();

            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);
            ActivitiesGroup group3 = new ActivitiesGroup()
            {
                Name = "Group3"
            };

            busFlow.AddActivitiesGroup(group3);

            Activity activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };
            Activity activity6 = new Activity()
            {
                ActivityName = "Activity6"
            };

            busFlow.AddActivity(activity1, group1);

            busFlow.AddActivity(activity2, group2);
            busFlow.AddActivity(activity3, group2);
            busFlow.AddActivity(activity4, group2);
            busFlow.AddActivity(activity5, group2);

            busFlow.AddActivity(activity6, group3);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();
            busFlow.MoveActivityInGroup(activity5, 1);

            //Assert
            Assert.IsTrue(busFlow.Activities.IndexOf(activity5) == 1, "Validate Activity moved to correct index in Activities list");
            Assert.IsTrue(group2.ActivitiesIdentifiers.IndexOf(group2.ActivitiesIdentifiers.Where(x => x.IdentifiedActivity == activity5).First()) == 0, "Validate Activity moved to correct indx in target group");
        }
Ejemplo n.º 15
0
        public void GroupUnGroupedActivitiesTest()
        {
            //Arrange
            BusinessFlow busFlow   = new BusinessFlow();
            Activity     activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };

            busFlow.AddActivity(activity1);
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };

            busFlow.AddActivity(activity2);
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };

            busFlow.AddActivity(activity3);
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };

            busFlow.AddActivity(activity4);
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };

            busFlow.AddActivity(activity5);
            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);
            group1.AddActivityToGroup(activity1);
            group2.AddActivityToGroup(activity4);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();

            //Assert
            Assert.IsTrue(busFlow.ActivitiesGroups.Count == 2, "Validate no extra groups were added");
            Assert.IsTrue(group1.ActivitiesIdentifiers.Count == 3, "Validate first three Activities were attached to first group");
            Assert.IsTrue(group2.ActivitiesIdentifiers.Count == 2, "Validate last two Activities were attached to second group");
            Assert.IsTrue(group1.ActivitiesIdentifiers[2].ActivityName == activity3.ActivityName, "Validate group 1 has correct activities mapped to it");
            Assert.IsTrue(group2.ActivitiesIdentifiers[1].ActivityName == activity5.ActivityName, "Validate group 2 has correct activities mapped to it");
            Assert.IsTrue(activity2.ActivitiesGroupID == group1.Name, "Validate Activities mapped to group 1");
            Assert.IsTrue(activity5.ActivitiesGroupID == group2.Name, "Validate Activities mapped to group 2");
        }
Ejemplo n.º 16
0
        public void MoveActivityBetweenGroupsTest3()
        {
            //Arrange
            BusinessFlow busFlow = new BusinessFlow();

            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);
            ActivitiesGroup group3 = new ActivitiesGroup()
            {
                Name = "Group3"
            };

            busFlow.AddActivitiesGroup(group3);

            Activity activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };
            Activity activity6 = new Activity()
            {
                ActivityName = "Activity6"
            };

            busFlow.AddActivity(activity1, group1);
            busFlow.AddActivity(activity2, group1);

            busFlow.AddActivity(activity3, group2);
            busFlow.AddActivity(activity4, group2);

            busFlow.AddActivity(activity5, group3);
            busFlow.AddActivity(activity6, group3);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();
            busFlow.MoveActivityBetweenGroups(activity6, group2, 2);

            //Assert
            Assert.IsTrue(group3.ActivitiesIdentifiers.Where(x => x.IdentifiedActivity == activity6).FirstOrDefault() == null, "Validate Activity removed from original group");
            Assert.IsTrue(activity6.ActivitiesGroupID == group2.Name, "Validate Activity moved to target group");
            Assert.IsTrue(busFlow.Activities.IndexOf(activity6) == 2, "Validate Activity moved to correct index in Activities list");
            Assert.IsTrue(group2.ActivitiesIdentifiers.IndexOf(group2.ActivitiesIdentifiers.Where(x => x.IdentifiedActivity == activity6).First()) == 0, "Validate Activity moved to correct indx in target group");
        }
Ejemplo n.º 17
0
        public BusinessFlow ConvertQCTestSetToBF(QC.ALMTestSet testSet)
        {
            GingerActivitiesGroupsRepo = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ActivitiesGroup>();
            GingerActivitiesRepo       = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Activity>();
            try
            {
                if (testSet == null)
                {
                    return(null);
                }

                //Create Business Flow
                BusinessFlow busFlow = new BusinessFlow();
                busFlow.Name       = testSet.TestSetName;
                busFlow.ExternalID = testSet.TestSetID;
                busFlow.Status     = BusinessFlow.eBusinessFlowStatus.Development;
                busFlow.Activities = new ObservableList <Activity>();
                busFlow.Variables  = new ObservableList <VariableBase>();
                Dictionary <string, string> busVariables = new Dictionary <string, string>();//will store linked variables

                //Create Activities Group + Activities for each TC
                foreach (QC.ALMTSTest tc in testSet.Tests)
                {
                    //check if the TC is already exist in repository
                    ActivitiesGroup tcActivsGroup;
                    ActivitiesGroup repoActivsGroup = null;
                    if (repoActivsGroup == null)
                    {
                        repoActivsGroup = GingerActivitiesGroupsRepo.Where(x => x.ExternalID == tc.TestID).FirstOrDefault();
                    }
                    if (repoActivsGroup != null)
                    {
                        List <Activity> repoNotExistsStepActivity = GingerActivitiesRepo.Where(z => repoActivsGroup.ActivitiesIdentifiers.Select(y => y.ActivityExternalID).ToList().Contains(z.ExternalID))
                                                                    .Where(x => !tc.Steps.Select(y => y.StepID).ToList().Contains(x.ExternalID)).ToList();

                        tcActivsGroup = (ActivitiesGroup)repoActivsGroup.CreateInstance();

                        var ActivitySIdentifiersToRemove = tcActivsGroup.ActivitiesIdentifiers.Where(x => repoNotExistsStepActivity.Select(z => z.ExternalID).ToList().Contains(x.ActivityExternalID));
                        for (int indx = 0; indx < tcActivsGroup.ActivitiesIdentifiers.Count; indx++)
                        {
                            if ((indx < tcActivsGroup.ActivitiesIdentifiers.Count) && (ActivitySIdentifiersToRemove.Contains(tcActivsGroup.ActivitiesIdentifiers[indx])))
                            {
                                tcActivsGroup.ActivitiesIdentifiers.Remove(tcActivsGroup.ActivitiesIdentifiers[indx]);
                                indx--;
                            }
                        }

                        tcActivsGroup.ExternalID2 = tc.TestID;
                        busFlow.AddActivitiesGroup(tcActivsGroup);
                        busFlow.ImportActivitiesGroupActivitiesFromRepository(tcActivsGroup, GingerActivitiesRepo, ApplicationPlatforms, true);
                        busFlow.AttachActivitiesGroupsAndActivities();
                    }
                    else //TC not exist in Ginger repository so create new one
                    {
                        tcActivsGroup             = new ActivitiesGroup();
                        tcActivsGroup.Name        = tc.TestName;
                        tcActivsGroup.ExternalID  = tc.TestID;
                        tcActivsGroup.ExternalID2 = tc.LinkedTestID;
                        tcActivsGroup.Description = tc.Description;
                        busFlow.AddActivitiesGroup(tcActivsGroup);
                    }

                    //Add the TC steps as Activities if not already on the Activities group
                    foreach (QC.ALMTSTestStep step in tc.Steps)
                    {
                        Activity stepActivity;
                        bool     toAddStepActivity = false;

                        //check if mapped activity exist in repository
                        Activity repoStepActivity = (Activity)GingerActivitiesRepo.Where(x => x.ExternalID == step.StepID).FirstOrDefault();
                        if (repoStepActivity != null)
                        {
                            //check if it is part of the Activities Group
                            ActivityIdentifiers groupStepActivityIdent = (ActivityIdentifiers)tcActivsGroup.ActivitiesIdentifiers.Where(x => x.ActivityExternalID == step.StepID).FirstOrDefault();
                            if (groupStepActivityIdent != null)
                            {
                                //already in Activities Group so get link to it
                                stepActivity = (Activity)busFlow.Activities.Where(x => x.Guid == groupStepActivityIdent.ActivityGuid).FirstOrDefault();
                                // in any case update description/expected/name - even if "step" was taken from repository
                                stepActivity.Description  = StripHTML(step.Description);
                                stepActivity.Expected     = StripHTML(step.Expected);
                                stepActivity.ActivityName = tc.TestName + ">" + step.StepName;
                            }
                            else//not in ActivitiesGroup so get instance from repo
                            {
                                stepActivity      = (Activity)repoStepActivity.CreateInstance();
                                toAddStepActivity = true;
                            }
                        }
                        else//Step not exist in Ginger repository so create new one
                        {
                            stepActivity = new Activity();
                            stepActivity.ActivityName = tc.TestName + ">" + step.StepName;
                            stepActivity.ExternalID   = step.StepID;
                            stepActivity.Description  = StripHTML(step.Description);

                            toAddStepActivity = true;
                        }

                        if (toAddStepActivity)
                        {
                            //not in group- need to add it
                            busFlow.AddActivity(stepActivity, tcActivsGroup);
                        }

                        //pull TC-Step parameters and add them to the Activity level
                        List <string> stepParamsList = new List <string>();
                        foreach (string param in stepParamsList)
                        {
                            //get the param value
                            string paramSelectedValue         = string.Empty;
                            bool?  isflowControlParam         = null;
                            QC.ALMTSTestParameter tcParameter = tc.Parameters.Where(x => x.Name.ToUpper() == param.ToUpper()).FirstOrDefault();

                            //get the param value
                            if (tcParameter != null && tcParameter.Value != null && tcParameter.Value != string.Empty)
                            {
                                paramSelectedValue = tcParameter.Value;
                            }
                            else
                            {
                                isflowControlParam = null;//empty value
                                paramSelectedValue = "<Empty>";
                            }

                            //check if parameter is part of a link
                            string linkedVariable = null;
                            if (paramSelectedValue.StartsWith("#$#"))
                            {
                                string[] valueParts = paramSelectedValue.Split(new [] { "#$#" }, StringSplitOptions.None);
                                if (valueParts.Count() == 3)
                                {
                                    linkedVariable     = valueParts[1];
                                    paramSelectedValue = "$$_" + valueParts[2];//so it still will be considered as non-flow control

                                    if (!busVariables.Keys.Contains(linkedVariable))
                                    {
                                        busVariables.Add(linkedVariable, valueParts[2]);
                                    }
                                }
                            }

                            //determine if the param is Flow Control Param or not based on it value and agreed sign "$$_"
                            if (paramSelectedValue.StartsWith("$$_"))
                            {
                                isflowControlParam = false;
                                if (paramSelectedValue.StartsWith("$$_"))
                                {
                                    paramSelectedValue = paramSelectedValue.Substring(3);//get value without "$$_"
                                }
                            }
                            else if (paramSelectedValue != "<Empty>")
                            {
                                isflowControlParam = true;
                            }
                            //check if already exist param with that name
                            VariableBase stepActivityVar = stepActivity.Variables.Where(x => x.Name.ToUpper() == param.ToUpper()).FirstOrDefault();
                            if (stepActivityVar == null)
                            {
                                //#Param not exist so add it
                                if (isflowControlParam == true)
                                {
                                    //add it as selection list param
                                    stepActivityVar      = new VariableSelectionList();
                                    stepActivityVar.Name = param;
                                    stepActivity.AddVariable(stepActivityVar);
                                    stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because new flow control param was added
                                }
                                else
                                {
                                    //add as String param
                                    stepActivityVar      = new VariableString();
                                    stepActivityVar.Name = param;
                                    ((VariableString)stepActivityVar).InitialStringValue = paramSelectedValue;
                                    stepActivity.AddVariable(stepActivityVar);
                                }
                            }
                            else
                            {
                                //#param exist
                                if (isflowControlParam == true)
                                {
                                    if (!(stepActivityVar is VariableSelectionList))
                                    {
                                        //flow control param must be Selection List so transform it
                                        stepActivity.Variables.Remove(stepActivityVar);
                                        stepActivityVar      = new VariableSelectionList();
                                        stepActivityVar.Name = param;
                                        stepActivity.AddVariable(stepActivityVar);
                                        stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because flow control param was added
                                    }
                                }
                                else if (isflowControlParam == false)
                                {
                                    if (stepActivityVar is VariableSelectionList)
                                    {
                                        //change it to be string variable
                                        stepActivity.Variables.Remove(stepActivityVar);
                                        stepActivityVar      = new VariableString();
                                        stepActivityVar.Name = param;
                                        ((VariableString)stepActivityVar).InitialStringValue = paramSelectedValue;
                                        stepActivity.AddVariable(stepActivityVar);
                                        stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because flow control param was removed
                                    }
                                }
                            }

                            //add the variable selected value
                            if (stepActivityVar is VariableSelectionList)
                            {
                                OptionalValue stepActivityVarOptionalVar = ((VariableSelectionList)stepActivityVar).OptionalValuesList.Where(x => x.Value == paramSelectedValue).FirstOrDefault();
                                if (stepActivityVarOptionalVar == null)
                                {
                                    //no such variable value option so add it
                                    stepActivityVarOptionalVar = new OptionalValue(paramSelectedValue);
                                    ((VariableSelectionList)stepActivityVar).OptionalValuesList.Add(stepActivityVarOptionalVar);
                                    if (isflowControlParam == true)
                                    {
                                        stepActivity.AutomationStatus = eActivityAutomationStatus.Development;//reset status because new param value was added
                                    }
                                }
                                //set the selected value
                                ((VariableSelectionList)stepActivityVar).SelectedValue = stepActivityVarOptionalVar.Value;
                            }
                            else
                            {
                                //try just to set the value
                                try
                                {
                                    stepActivityVar.Value = paramSelectedValue;
                                    if (stepActivityVar is VariableString)
                                    {
                                        ((VariableString)stepActivityVar).InitialStringValue = paramSelectedValue;
                                    }
                                }
                                catch (Exception ex) { Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex); }
                            }

                            //add linked variable if needed
                            if (!string.IsNullOrEmpty(linkedVariable))
                            {
                                stepActivityVar.LinkedVariableName = linkedVariable;
                            }
                            else
                            {
                                stepActivityVar.LinkedVariableName = string.Empty;//clear old links
                            }
                        }
                    }

                    //order the Activities Group activities according to the order of the matching steps in the TC
                    try
                    {
                        int startGroupActsIndxInBf = 0;
                        if (busFlow.Activities.Count > 0)
                        {
                            startGroupActsIndxInBf = busFlow.Activities.IndexOf(tcActivsGroup.ActivitiesIdentifiers[0].IdentifiedActivity);
                        }
                        foreach (QC.ALMTSTestStep step in tc.Steps)
                        {
                            int stepIndx = tc.Steps.IndexOf(step) + 1;
                            ActivityIdentifiers actIdent = (ActivityIdentifiers)tcActivsGroup.ActivitiesIdentifiers.Where(x => x.ActivityExternalID == step.StepID).FirstOrDefault();
                            if (actIdent == null || actIdent.IdentifiedActivity == null)
                            {
                                break;//something wrong- shouldn't be null
                            }
                            Activity act          = (Activity)actIdent.IdentifiedActivity;
                            int      groupActIndx = tcActivsGroup.ActivitiesIdentifiers.IndexOf(actIdent);
                            int      bfActIndx    = busFlow.Activities.IndexOf(act);

                            //set it in the correct place in the group
                            int numOfSeenSteps = 0;
                            int groupIndx      = -1;
                            foreach (ActivityIdentifiers ident in tcActivsGroup.ActivitiesIdentifiers)
                            {
                                groupIndx++;
                                if (string.IsNullOrEmpty(ident.ActivityExternalID) ||
                                    tc.Steps.Where(x => x.StepID == ident.ActivityExternalID).FirstOrDefault() == null)
                                {
                                    continue;//activity which not originally came from the TC
                                }
                                numOfSeenSteps++;

                                if (numOfSeenSteps >= stepIndx)
                                {
                                    break;
                                }
                            }
                            ActivityIdentifiers identOnPlace = (ActivityIdentifiers)tcActivsGroup.ActivitiesIdentifiers[groupIndx];
                            if (identOnPlace.ActivityGuid != act.Guid)
                            {
                                //replace places in group
                                tcActivsGroup.ActivitiesIdentifiers.Move(groupActIndx, groupIndx);
                                //replace places in business flow
                                busFlow.Activities.Move(bfActIndx, startGroupActsIndxInBf + groupIndx);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex);
                        //failed to re order the activities to match the tc steps order, not worth breaking the import because of this
                    }
                }

                //Add the BF variables (linked variables)
                if (busVariables.Keys.Count > 0)
                {
                    foreach (KeyValuePair <string, string> var in busVariables)
                    {
                        //add as String param
                        VariableString busVar = new VariableString();
                        busVar.Name = var.Key;
                        busVar.InitialStringValue = var.Value;
                        busFlow.AddVariable(busVar);
                    }
                }

                return(busFlow);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eLogLevel.ERROR, "Failed to import QC test set and convert it into " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), ex);
                return(null);
            }
        }
Ejemplo n.º 18
0
        public void AddActivityWithNewGroupTest()
        {
            //Arrange
            BusinessFlow busFlow = new BusinessFlow();

            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);

            Activity activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };

            busFlow.AddActivity(activity1, group1);
            busFlow.AddActivity(activity2, group1);
            busFlow.AddActivity(activity3, group1);

            busFlow.AddActivity(activity4, group2);
            busFlow.AddActivity(activity5, group2);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();
            ActivitiesGroup group3 = new ActivitiesGroup()
            {
                Name = "Group3"
            };

            busFlow.AddActivitiesGroup(group3);
            Activity activity6 = new Activity()
            {
                ActivityName = "Activity6"
            };

            busFlow.AddActivity(activity6, group3);

            //Assert
            Assert.IsTrue(busFlow.Activities[5] == activity6, "Validate new Activity added in last");
            Assert.IsTrue(busFlow.ActivitiesGroups[2] == group3, "Validate new group was added to BF");
            Assert.IsTrue(activity6.ActivitiesGroupID == group3.Name, "Validate new Activity is mapped to new group");
            Assert.IsTrue(group3.ActivitiesIdentifiers[0].IdentifiedActivity == activity6, "Validate new Activity is mapped to new group");
        }
Ejemplo n.º 19
0
        public override void UpdateInstance(RepositoryItemBase instance, string partToUpdate, RepositoryItemBase hostItem = null, object extraDetails = null)
        {
            ActivitiesGroup activitiesGroupInstance = (ActivitiesGroup)instance;

            //Create new instance of source
            ActivitiesGroup newInstance = (ActivitiesGroup)this.CreateInstance();

            newInstance.IsSharedRepositoryInstance = true;

            //update required part
            ActivitiesGroup.eItemParts ePartToUpdate = (ActivitiesGroup.eItemParts)Enum.Parse(typeof(ActivitiesGroup.eItemParts), partToUpdate);

            if (hostItem != null)
            {
                //replace old instance object with new
                BusinessFlow currentBF = ((BusinessFlow)hostItem);

                // Update details
                activitiesGroupInstance.Name        = newInstance.Name;
                activitiesGroupInstance.Description = newInstance.Description;
                activitiesGroupInstance.Tags        = newInstance.Tags;

                // Confirm if no group exists in the Business Flow with same name
                currentBF.SetUniqueActivitiesGroupName(activitiesGroupInstance);

                if (ePartToUpdate == eItemParts.Details)
                {
                    currentBF.AttachActivitiesGroupsAndActivities();
                    return;
                }

                int grpIndex = currentBF.ActivitiesGroups.IndexOf(activitiesGroupInstance);
                if (grpIndex >= 0)
                {
                    int insertIndex = currentBF.Activities.IndexOf(currentBF.Activities.Where(a => a.Guid == activitiesGroupInstance.ActivitiesIdentifiers[0].ActivityGuid).FirstOrDefault());

                    List <Activity> existingActivities = new List <Activity>();

                    int exActCount = activitiesGroupInstance.ActivitiesIdentifiers.Count;
                    for (int i = exActCount - 1; i >= 0; i--)
                    {
                        ActivityIdentifiers actIDexist = activitiesGroupInstance.ActivitiesIdentifiers[i];

                        Activity exAct = currentBF.Activities.Where(g => g.Guid == actIDexist.ActivityGuid).FirstOrDefault();

                        if (exAct == null)
                        {
                            exAct = currentBF.Activities.Where(g => g.ParentGuid == actIDexist.ActivityGuid).FirstOrDefault();
                        }

                        if (exAct != null)
                        {
                            // Add to the list of deleted activities
                            existingActivities.Add(exAct);

                            // Remove the activity from the Business Flow
                            currentBF.DeleteActivity(exAct);
                        }
                    }

                    // Add the activities to the Business Flow in sequence they appear in the Updated Shared Group
                    foreach (ActivityIdentifiers actID in newInstance.ActivitiesIdentifiers)
                    {
                        Activity updatedAct = null;

                        // Activity still exist in the group, thus re-add the same activity to the group
                        updatedAct = existingActivities.Where(a => a.Guid == actID.ActivityGuid).FirstOrDefault();

                        // In case, group was Replaced/Overwritten
                        if (updatedAct == null)
                        {
                            updatedAct = existingActivities.Where(a => a.ParentGuid == actID.ActivityGuid).FirstOrDefault();
                        }

                        if (updatedAct != null)
                        {
                            currentBF.AddActivity(updatedAct, activitiesGroupInstance, insertIndex);
                            insertIndex++;
                            existingActivities.Remove(updatedAct);
                        }
                        // Activity doesn't exist in the group and the shared group is recently updated by addition of this activity, thus add this activity to the group instance in the Business Flow
                        else if (extraDetails != null)
                        {
                            updatedAct = (extraDetails as ObservableList <Activity>).Where(a => a.ActivityName == actID.ActivityName && a.Guid == actID.ActivityGuid).FirstOrDefault();
                            if (updatedAct == null)
                            {
                                updatedAct = (extraDetails as ObservableList <Activity>).Where(a => a.Guid == actID.ActivityGuid).FirstOrDefault();
                            }
                            if (updatedAct == null)
                            {
                                updatedAct = (extraDetails as ObservableList <Activity>).Where(a => a.ActivityName == actID.ActivityName).FirstOrDefault();
                            }

                            if (updatedAct != null)
                            {
                                updatedAct = updatedAct.CreateInstance(true) as Activity;
                                currentBF.AddActivity(updatedAct, activitiesGroupInstance, insertIndex);
                                insertIndex++;
                            }
                        }
                    }

                    currentBF.AttachActivitiesGroupsAndActivities();
                }
            }
        }
Ejemplo n.º 20
0
        private static ActivitiesGroup CheckIfTCAlreadyExistInRepo(BusinessFlow busFlow, QCTestInstance testInstance, QCTestCaseStepsColl tSTestCaseSteps)
        {
            ActivitiesGroup     tcActivsGroup;
            ActivitiesGroup     repoActivsGroup       = null;
            QCTestCaseStepsColl relevantTestCaseSteps = QCRestAPIConnect.GetTestCaseSteps(testInstance.TestId);
            QCTestCaseStep      relevantStep          = null;

            foreach (QCTestCaseStep testcaseStep in relevantTestCaseSteps)
            {
                if (testcaseStep.ElementsField.ContainsKey("link-test"))
                {
                    relevantStep = testcaseStep;
                }
            }
            if (relevantStep != null)
            {
                repoActivsGroup = GingerActivitiesGroupsRepo.Where(x => x.ExternalID == relevantStep.ElementsField["link-test"].ToString()).FirstOrDefault();
            }
            if (repoActivsGroup == null)
            {
                repoActivsGroup = GingerActivitiesGroupsRepo.Where(x => x.ExternalID == testInstance.Id).FirstOrDefault();
            }
            if (repoActivsGroup != null)
            {
                List <Activity> repoNotExistsStepActivity = GingerActivitiesRepo.Where(z => repoActivsGroup.ActivitiesIdentifiers.Select(y => y.ActivityExternalID).ToList().Contains(z.ExternalID))
                                                            .Where(x => !tSTestCaseSteps.Where(item => item.TestId == testInstance.TestId).Select(y => y.Id).ToList().Contains(x.ExternalID)).ToList();

                tcActivsGroup = (ActivitiesGroup)repoActivsGroup.CreateInstance();

                var ActivitySIdentifiersToRemove = tcActivsGroup.ActivitiesIdentifiers.Where(x => repoNotExistsStepActivity.Select(z => z.ExternalID).ToList().Contains(x.ActivityExternalID));
                for (int indx = 0; indx < tcActivsGroup.ActivitiesIdentifiers.Count; indx++)
                {
                    if ((indx < tcActivsGroup.ActivitiesIdentifiers.Count) && (ActivitySIdentifiersToRemove.Contains(tcActivsGroup.ActivitiesIdentifiers[indx])))
                    {
                        tcActivsGroup.ActivitiesIdentifiers.Remove(tcActivsGroup.ActivitiesIdentifiers[indx]);
                        indx--;
                    }
                }

                tcActivsGroup.ExternalID2 = testInstance.Id;
                busFlow.AddActivitiesGroup(tcActivsGroup);
                busFlow.ImportActivitiesGroupActivitiesFromRepository(tcActivsGroup, GingerActivitiesRepo, true, true);
                busFlow.AttachActivitiesGroupsAndActivities();
            }
            else //TC not exist in Ginger repository so create new one
            {
                tcActivsGroup      = new ActivitiesGroup();
                tcActivsGroup.Name = testInstance.Name;
                if (relevantStep == null)
                {
                    tcActivsGroup.ExternalID  = testInstance.Id;
                    tcActivsGroup.ExternalID2 = testInstance.Id;
                }
                else
                {
                    tcActivsGroup.ExternalID  = relevantStep.ElementsField["link-test"].ToString();
                    tcActivsGroup.ExternalID2 = testInstance.Id;
                }
                busFlow.AddActivitiesGroup(tcActivsGroup);
            }

            return(tcActivsGroup);
        }
Ejemplo n.º 21
0
        public void CreateNewGroupToUnSyncedGroupedActivitiesTest()
        {
            //Arrange
            BusinessFlow busFlow   = new BusinessFlow();
            Activity     activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };

            busFlow.AddActivity(activity1);
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };

            busFlow.AddActivity(activity2);
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };

            busFlow.AddActivity(activity3);
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };

            busFlow.AddActivity(activity4);
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };

            busFlow.AddActivity(activity5);

            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);

            group1.AddActivityToGroup(activity1);
            group1.AddActivityToGroup(activity2);
            group2.AddActivityToGroup(activity3);
            group1.AddActivityToGroup(activity4);
            group1.AddActivityToGroup(activity5);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();

            //Assert
            Assert.IsTrue(busFlow.ActivitiesGroups.Count == 3, "Validate 1 extra groups were added");
            Assert.IsTrue(group1.ActivitiesIdentifiers.Count == 2, "Validate only 2 Activities are attached to first group");
            Assert.IsTrue(group2.ActivitiesIdentifiers.Count == 1, "Validate 1 Activities were attached to second group");
            Assert.IsTrue(busFlow.ActivitiesGroups.Where(x => x.Name == group1.Name + "_2").FirstOrDefault() != null, "Validate new added group name");
            Assert.IsTrue(activity4.ActivitiesGroupID == group1.Name + "_2", "Validate Activity was re-grouped to new added group");
            Assert.IsTrue(activity5.ActivitiesGroupID == group1.Name + "_2", "Validate Activity was re-grouped to new added group");
        }
Ejemplo n.º 22
0
        public static BusinessFlow ConvertRallyTestPlanToBF(RallyTestPlan testPlan)
        {
            try
            {
                if (testPlan == null)
                {
                    return(null);
                }

                //Create Business Flow
                BusinessFlow busFlow = new BusinessFlow();
                busFlow.Name       = testPlan.Name;
                busFlow.ExternalID = "RallyID=" + testPlan.RallyID;
                busFlow.Status     = BusinessFlow.eBusinessFlowStatus.Development;
                busFlow.Activities = new ObservableList <Activity>();
                busFlow.Variables  = new ObservableList <VariableBase>();

                //Create Activities Group + Activities for each TC
                foreach (RallyTestCase tc in testPlan.TestCases)
                {
                    //check if the TC is already exist in repository
                    ActivitiesGroup tcActivsGroup;
                    ActivitiesGroup repoActivsGroup = null;
                    if (repoActivsGroup == null)
                    {
                        repoActivsGroup = GingerActivitiesGroupsRepo.Where(x => x.ExternalID != null ? x.ExternalID.Split('|').First().Split('=').Last() == tc.RallyID : false).FirstOrDefault();
                    }
                    if (repoActivsGroup != null)
                    {
                        tcActivsGroup = (ActivitiesGroup)repoActivsGroup.CreateInstance();
                        busFlow.AddActivitiesGroup(tcActivsGroup);
                        busFlow.ImportActivitiesGroupActivitiesFromRepository(tcActivsGroup, GingerActivitiesRepo, true, true);
                        busFlow.AttachActivitiesGroupsAndActivities();
                    }
                    else // TC not exist in Ginger repository so create new one
                    {
                        tcActivsGroup             = new ActivitiesGroup();
                        tcActivsGroup.Name        = tc.Name;
                        tcActivsGroup.Description = tc.Description;
                        tcActivsGroup.ExternalID  = "RallyID=" + tc.RallyID + "|AtsID=" + tc.BTSID;
                        busFlow.AddActivitiesGroup(tcActivsGroup);
                    }

                    foreach (RallyTestStep step in tc.TestSteps)
                    {
                        Activity stepActivity;
                        bool     toAddStepActivity = false;

                        // check if mapped activity exist in repository
                        Activity repoStepActivity = GingerActivitiesRepo.Where(x => x.ExternalID != null ? x.ExternalID.Split('|').First().Split('=').Last() == step.RallyIndex : false).FirstOrDefault();
                        if (repoStepActivity != null)
                        {
                            //check if it is part of the Activities Group
                            ActivityIdentifiers groupStepActivityIdent = tcActivsGroup.ActivitiesIdentifiers.Where(x => x.ActivityExternalID == step.RallyIndex).FirstOrDefault();
                            if (groupStepActivityIdent != null)
                            {
                                //already in Activities Group so get link to it
                                stepActivity = busFlow.Activities.Where(x => x.Guid == groupStepActivityIdent.ActivityGuid).FirstOrDefault();
                            }
                            else // not in ActivitiesGroup so get instance from repo
                            {
                                stepActivity      = (Activity)repoStepActivity.CreateInstance();
                                toAddStepActivity = true;
                            }
                        }
                        else //Step not exist in Ginger repository so create new one
                        {
                            string strBtsID = string.Empty;
                            stepActivity = new Activity();
                            stepActivity.ActivityName = tc.Name + ">" + step.Name;
                            stepActivity.ExternalID   = "RallyID=" + step.RallyIndex + "|AtsID=" + strBtsID;
                            stepActivity.Description  = StripHTML(step.Description);
                            stepActivity.Expected     = StripHTML(step.ExpectedResult);

                            toAddStepActivity = true;
                        }

                        if (toAddStepActivity)
                        {
                            // not in group- need to add it
                            busFlow.AddActivity(stepActivity);
                            tcActivsGroup.AddActivityToGroup(stepActivity);
                        }

                        //pull TC-Step parameters and add them to the Activity level
                        foreach (RallyTestParameter param in tc.Parameters)   // Params taken from TestScriptLevel only!!!! Also exists parapameters at TestCase, to check if them should be taken!!!
                        {
                            bool?isflowControlParam = null;

                            //detrmine if the param is Flow Control Param or not based on it value and agreed sign "$$_"
                            if (param.Value.ToString().StartsWith("$$_"))
                            {
                                isflowControlParam = false;
                                if (param.Value.ToString().StartsWith("$$_"))
                                {
                                    param.Value = param.Value.ToString().Substring(3); //get value without "$$_"
                                }
                            }
                            else if (param.Value.ToString() != "<Empty>")
                            {
                                isflowControlParam = true;
                            }

                            //check if already exist param with that name
                            VariableBase stepActivityVar = stepActivity.Variables.Where(x => x.Name.ToUpper() == param.Name.ToUpper()).FirstOrDefault();
                            if (stepActivityVar == null)
                            {
                                //#Param not exist so add it
                                if (isflowControlParam == true)
                                {
                                    //add it as selection list param
                                    stepActivityVar      = new VariableSelectionList();
                                    stepActivityVar.Name = param.Name;
                                    stepActivity.AddVariable(stepActivityVar);
                                    stepActivity.AutomationStatus = Activity.eActivityAutomationStatus.Development;//reset status because new flow control param was added
                                }
                                else
                                {
                                    //add as String param
                                    stepActivityVar      = new VariableString();
                                    stepActivityVar.Name = param.Name;
                                    ((VariableString)stepActivityVar).InitialStringValue = param.Value;
                                    stepActivity.AddVariable(stepActivityVar);
                                }
                            }
                            else
                            {
                                //#param exist
                                if (isflowControlParam == true)
                                {
                                    if (!(stepActivityVar is VariableSelectionList))
                                    {
                                        //flow control param must be Selection List so transform it
                                        stepActivity.Variables.Remove(stepActivityVar);
                                        stepActivityVar      = new VariableSelectionList();
                                        stepActivityVar.Name = param.Name;
                                        stepActivity.AddVariable(stepActivityVar);
                                        stepActivity.AutomationStatus = Activity.eActivityAutomationStatus.Development;//reset status because flow control param was added
                                    }
                                }
                                else if (isflowControlParam == false)
                                {
                                    if (stepActivityVar is VariableSelectionList)
                                    {
                                        //change it to be string variable
                                        stepActivity.Variables.Remove(stepActivityVar);
                                        stepActivityVar      = new VariableString();
                                        stepActivityVar.Name = param.Name;
                                        ((VariableString)stepActivityVar).InitialStringValue = param.Value;
                                        stepActivity.AddVariable(stepActivityVar);
                                        stepActivity.AutomationStatus = Activity.eActivityAutomationStatus.Development;//reset status because flow control param was removed
                                    }
                                }
                            }

                            //add the variable selected value
                            if (stepActivityVar is VariableSelectionList)
                            {
                                OptionalValue stepActivityVarOptionalVar = ((VariableSelectionList)stepActivityVar).OptionalValuesList.Where(x => x.Value == param.Value).FirstOrDefault();
                                if (stepActivityVarOptionalVar == null)
                                {
                                    //no such variable value option so add it
                                    stepActivityVarOptionalVar = new OptionalValue(param.Value);
                                    ((VariableSelectionList)stepActivityVar).OptionalValuesList.Add(stepActivityVarOptionalVar);
                                    if (isflowControlParam == true)
                                    {
                                        stepActivity.AutomationStatus = Activity.eActivityAutomationStatus.Development;//reset status because new param value was added
                                    }
                                }
                                //set the selected value
                                ((VariableSelectionList)stepActivityVar).SelectedValue = stepActivityVarOptionalVar.Value;
                            }
                            else
                            {
                                //try just to set the value
                                try
                                {
                                    stepActivityVar.Value = param.Value;
                                    if (stepActivityVar is VariableString)
                                    {
                                        ((VariableString)stepActivityVar).InitialStringValue = param.Value;
                                    }
                                }
                                catch (Exception ex) { Reporter.ToLog(eAppReporterLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}", ex); }
                            }
                        }
                    }
                }

                return(busFlow);
            }
            catch (Exception ex)
            {
                Reporter.ToLog(eAppReporterLogLevel.ERROR, "Failed to import Rally test set and convert it into " + GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), ex);
                return(null);
            }
        }
Ejemplo n.º 23
0
        public void InitRunner(GingerRunner runner)
        {
            //Configure Runner for execution
            runner.Status = eRunStatus.Pending;
            ConfigureRunnerForExecution(runner);

            //Set the Apps agents
            foreach (ApplicationAgent appagent in runner.ApplicationAgents)
            {
                if (appagent.AgentName != null)
                {
                    ObservableList <Agent> agents = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Agent>();
                    appagent.Agent = (from a in agents where a.Name == appagent.AgentName select a).FirstOrDefault();
                }
            }

            //Load the biz flows
            ObservableList <BusinessFlow> runnerFlows = new ObservableList <BusinessFlow>();

            foreach (BusinessFlowRun businessFlowRun in runner.BusinessFlowsRunList)
            {
                ObservableList <BusinessFlow> businessFlows = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>();
                BusinessFlow businessFlow = (from x in businessFlows where x.Guid == businessFlowRun.BusinessFlowGuid select x).FirstOrDefault();
                //Fail over to try and find by name
                if (businessFlow == null)
                {
                    businessFlow = (from x in businessFlows where x.Name == businessFlowRun.BusinessFlowName select x).FirstOrDefault();
                }
                if (businessFlow == null)
                {
                    Reporter.ToLog(eLogLevel.ERROR, string.Format("Can not find the '{0}' {1} for the '{2}' {3}", businessFlowRun.BusinessFlowName, GingerDicser.GetTermResValue(eTermResKey.BusinessFlow), mRunSetConfig.Name, GingerDicser.GetTermResValue(eTermResKey.RunSet)));
                    continue;
                }
                else
                {
                    // Very slow
                    BusinessFlow BFCopy = (BusinessFlow)businessFlow.CreateCopy(false);
                    BFCopy.ContainingFolder = businessFlow.ContainingFolder;
                    BFCopy.Reset();
                    BFCopy.Active    = businessFlowRun.BusinessFlowIsActive;
                    BFCopy.Mandatory = businessFlowRun.BusinessFlowIsMandatory;
                    BFCopy.AttachActivitiesGroupsAndActivities();
                    if (businessFlowRun.BusinessFlowInstanceGuid == Guid.Empty)
                    {
                        BFCopy.InstanceGuid = Guid.NewGuid();
                    }
                    else
                    {
                        BFCopy.InstanceGuid = businessFlowRun.BusinessFlowInstanceGuid;
                    }
                    if (businessFlowRun.BusinessFlowCustomizedRunVariables != null && businessFlowRun.BusinessFlowCustomizedRunVariables.Count > 0)
                    {
                        foreach (VariableBase varb in BFCopy.GetBFandActivitiesVariabeles(true))
                        {
                            VariableBase runVar = businessFlowRun.BusinessFlowCustomizedRunVariables.Where(v => v.ParentGuid == varb.ParentGuid && v.ParentName == varb.ParentName && v.Name == varb.Name).FirstOrDefault();
                            if (runVar == null)//for supporting dynamic run set XML in which we do not have GUID
                            {
                                runVar = businessFlowRun.BusinessFlowCustomizedRunVariables.Where(v => v.ParentName == varb.ParentName && v.Name == varb.Name).FirstOrDefault();
                                if (runVar == null)
                                {
                                    runVar = businessFlowRun.BusinessFlowCustomizedRunVariables.Where(v => v.Name == varb.Name).FirstOrDefault();
                                }
                            }
                            if (runVar != null)
                            {
                                RepositoryItemBase.ObjectsDeepCopy(runVar, varb);
                                varb.DiffrentFromOrigin   = runVar.DiffrentFromOrigin;
                                varb.MappedOutputVariable = runVar.MappedOutputVariable;
                            }
                            else
                            {
                                varb.DiffrentFromOrigin   = false;
                                varb.MappedOutputVariable = null;
                            }
                        }
                    }
                    BFCopy.RunDescription = businessFlowRun.BusinessFlowRunDescription;
                    BFCopy.BFFlowControls = businessFlowRun.BFFlowControls;
                    runnerFlows.Add(BFCopy);
                }
            }

            runner.BusinessFlows = runnerFlows;
        }
Ejemplo n.º 24
0
        public void InitRunner(GingerRunner runner)
        {
            //Configure Runner for execution
            runner.Status = Amdocs.Ginger.CoreNET.Execution.eRunStatus.Pending;
            ConfigureRunnerForExecution(runner);

            //Set the Apps agents
            foreach (ApplicationAgent p in runner.ApplicationAgents)
            {
                if (p.AgentName != null)
                {
                    p.Agent = (from a in WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <Agent>() where a.Name == p.AgentName select a).FirstOrDefault();
                }
            }

            //Load the biz flows
            runner.BusinessFlows.Clear();
            foreach (BusinessFlowRun bf in runner.BusinessFlowsRunList)
            {
                ObservableList <BusinessFlow> businessFlows = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <BusinessFlow>();
                BusinessFlow BF1 = (from bfr in businessFlows where bfr.Guid == bf.BusinessFlowGuid select bfr).FirstOrDefault();
                if (BF1 == null)
                {
                    BF1 = (from bfr in businessFlows where bfr.Name == bf.BusinessFlowName select bfr).FirstOrDefault();
                }
                if (BF1 == null)
                {
                    Reporter.ToUser(eUserMsgKeys.CannontFindBusinessFlow, bf.BusinessFlowName);
                    continue;
                }
                else
                {
                    // Very slow
                    BusinessFlow BFCopy = (BusinessFlow)BF1.CreateCopy(false);
                    BFCopy.Reset();
                    BFCopy.Active    = bf.BusinessFlowIsActive;
                    BFCopy.Mandatory = bf.BusinessFlowIsMandatory;
                    BFCopy.AttachActivitiesGroupsAndActivities();
                    if (bf.BusinessFlowInstanceGuid == Guid.Empty)
                    {
                        BFCopy.InstanceGuid = Guid.NewGuid();
                    }
                    else
                    {
                        BFCopy.InstanceGuid = bf.BusinessFlowInstanceGuid;
                    }
                    if (bf.BusinessFlowCustomizedRunVariables != null && bf.BusinessFlowCustomizedRunVariables.Count > 0)
                    {
                        foreach (VariableBase varb in BFCopy.GetBFandActivitiesVariabeles(true))
                        {
                            VariableBase runVar = bf.BusinessFlowCustomizedRunVariables.Where(v => v.ParentGuid == varb.ParentGuid && v.ParentName == varb.ParentName && v.Name == varb.Name).FirstOrDefault();
                            if (runVar != null)
                            {
                                RepositoryItemBase.ObjectsDeepCopy(runVar, varb);
                                varb.DiffrentFromOrigin   = runVar.DiffrentFromOrigin;
                                varb.MappedOutputVariable = runVar.MappedOutputVariable;
                            }
                            else
                            {
                                varb.DiffrentFromOrigin   = false;
                                varb.MappedOutputVariable = null;
                            }
                        }
                    }
                    BFCopy.RunDescription = bf.BusinessFlowRunDescription;
                    BFCopy.BFFlowControls = bf.BFFlowControls;
                    runner.BusinessFlows.Add(BFCopy);
                }
            }
        }
Ejemplo n.º 25
0
        public void GroupsOrderTest()
        {
            //Arrange
            BusinessFlow busFlow   = new BusinessFlow();
            Activity     activity1 = new Activity()
            {
                ActivityName = "Activity1"
            };

            busFlow.AddActivity(activity1);
            Activity activity2 = new Activity()
            {
                ActivityName = "Activity2"
            };

            busFlow.AddActivity(activity2);
            Activity activity3 = new Activity()
            {
                ActivityName = "Activity3"
            };

            busFlow.AddActivity(activity3);
            Activity activity4 = new Activity()
            {
                ActivityName = "Activity4"
            };

            busFlow.AddActivity(activity4);
            Activity activity5 = new Activity()
            {
                ActivityName = "Activity5"
            };

            busFlow.AddActivity(activity5);

            ActivitiesGroup group3 = new ActivitiesGroup()
            {
                Name = "Group3"
            };

            busFlow.AddActivitiesGroup(group3);
            ActivitiesGroup group2 = new ActivitiesGroup()
            {
                Name = "Group2"
            };

            busFlow.AddActivitiesGroup(group2);
            ActivitiesGroup group1 = new ActivitiesGroup()
            {
                Name = "Group1"
            };

            busFlow.AddActivitiesGroup(group1);

            group1.AddActivityToGroup(activity1);
            group1.AddActivityToGroup(activity2);
            group2.AddActivityToGroup(activity3);
            group3.AddActivityToGroup(activity4);
            group3.AddActivityToGroup(activity5);

            //Act
            busFlow.AttachActivitiesGroupsAndActivities();

            //Assert
            Assert.IsTrue(busFlow.ActivitiesGroups[0] == group1, "Validate first group is group 1 same as in Activities flow");
            Assert.IsTrue(busFlow.ActivitiesGroups[1] == group2, "Validate first group is group 2 same as in Activities flow");
            Assert.IsTrue(busFlow.ActivitiesGroups[2] == group3, "Validate first group is group 3 same as in Activities flow");
        }
 private void UpdateActivitiesAfterGroupRemoved(object sender, RoutedEventArgs e)
 {
     //mBusinessFlow.UpdateActivitiesGroupDetails(BusinessFlow.eUpdateActivitiesGroupDetailsType.ClearUnExistedGroups);
     mBusinessFlow.AttachActivitiesGroupsAndActivities();
 }