コード例 #1
0
        void BtnCompareAPIClicked(object sender, RoutedEventArgs e)
        {
            ObservableList <ApplicationAPIModel> selectedAPIModels = GingerCore.General.ConvertListToObservableList <ApplicationAPIModel>(AddAPIModelWizard.LearnedAPIModelsList.Where(m => m.IsSelected == true).ToList());

            AddAPIModelWizard.DeltaModelsList = new ObservableList <DeltaAPIModel>(APIDeltaUtils.DoAPIModelsCompare(selectedAPIModels).OrderBy(d => d.comparisonStatus));

            if (AddAPIModelWizard.DeltaModelsList.GroupBy(m => m.matchingAPIModel).SelectMany(m => m.Skip(1)).Count() != 0)
            {
                foreach (DeltaAPIModel deltaAPIMod in AddAPIModelWizard.DeltaModelsList.GroupBy(m => m.matchingAPIModel).SelectMany(m => m.Skip(1)))
                {
                    deltaAPIMod.MatchingAPIName = "[Warning] " + deltaAPIMod.MatchingAPIName;
                }
                Reporter.ToUser(eUserMsgKey.MultipleMatchingAPI, "Same existing API Models found as Matching for multiple Learned API Models. Consider the ones marked with 'Warning' tag in the list before selecting Overwriting operation for the same.", eUserMsgOption.OK);
            }

            xApisSelectionGrid.InitViewItems();

            xApisSelectionGrid.btnMarkAll.Visibility = Visibility.Collapsed;
            xCompareBtnRow.Height = new GridLength(0);

            //In case any item was selected on the Import Grid throws exception/error
            //as selected Item won't anymore exist after updating the DataSource, hence, setting to null
            xApisSelectionGrid.grdMain.SelectedItem = null;

            xApisSelectionGrid.DataSourceList = AddAPIModelWizard.DeltaModelsList;
        }
コード例 #2
0
        public void APIComparison_MatchingTest()
        {
            // Arrange
            ObservableList <ApplicationAPIModel> learnedModels = new ObservableList <ApplicationAPIModel>(learnedAPIsList);

            //Act
            ObservableList <DeltaAPIModel> deltaAPIsList = APIDeltaUtils.DoAPIModelsCompare(learnedModels);

            //Assert - Check Count
            Assert.AreEqual(deltaAPIsList.Count, 6, "Is Delta Models count is 6");

            Assert.AreEqual(deltaAPIsList.Where(d => d.matchingAPIModel != null).Count(), 4, "Confirm if 4 API Models already exists in the solution.");
        }
コード例 #3
0
        void BtnCompareAPIClicked(object sender, RoutedEventArgs e)
        {
            ObservableList <ApplicationAPIModel> selectedAPIModels = GingerCore.General.ConvertListToObservableList <ApplicationAPIModel>(AddAPIModelWizard.LearnedAPIModelsList.Where(m => m.IsSelected == true).ToList());

            AddAPIModelWizard.DeltaModelsList = new ObservableList <DeltaAPIModel>(APIDeltaUtils.DoAPIModelsCompare(selectedAPIModels).OrderBy(d => d.comparisonStatus));

            xApisSelectionGrid.InitViewItems();

            xApisSelectionGrid.btnMarkAll.Visibility = Visibility.Collapsed;
            xCompareBtnRow.Height = new GridLength(0);

            //In case any item was selected on the Import Grid throws exception/error
            //as selected Item won't anymore exist after updating the DataSource, hence, setting to null
            xApisSelectionGrid.grdMain.SelectedItem = null;

            xApisSelectionGrid.DataSourceList = AddAPIModelWizard.DeltaModelsList;
        }
コード例 #4
0
        public void Unchanged_APIComparisonStatusTest()
        {
            // Arrange
            ObservableList <ApplicationAPIModel> learnedModels = new ObservableList <ApplicationAPIModel>()
            {
                learnedAPIsList[2], learnedAPIsList[4]
            };

            //Act
            ObservableList <DeltaAPIModel> deltaAPIsList = APIDeltaUtils.DoAPIModelsCompare(learnedModels);

            // Assert - Confirm Default Selected Operation = Do Not Add, for API with Comparison Status = UnChanged
            Assert.AreEqual(deltaAPIsList[0].comparisonStatus, DeltaAPIModel.eComparisonOutput.Unchanged, deltaAPIsList[0].learnedAPI.Name + " is UnChanged.");
            Assert.AreEqual(deltaAPIsList[0].SelectedOperationEnum, DeltaAPIModel.eHandlingOperations.DoNotAdd, deltaAPIsList[0].learnedAPI.Name + " is UnChanged and thus Default Selected Operation is 'Do Not Add'.");

            Assert.AreEqual(deltaAPIsList[1].comparisonStatus, DeltaAPIModel.eComparisonOutput.Unchanged, deltaAPIsList[1].learnedAPI.Name + " is UnChanged.");
            Assert.AreEqual(deltaAPIsList[1].SelectedOperationEnum, DeltaAPIModel.eHandlingOperations.DoNotAdd, deltaAPIsList[1].learnedAPI.Name + " is UnChanged and thus Default Selected Operation is 'Do Not Add'.");
        }
コード例 #5
0
        public void Modified_APIComparisonStatusTest()
        {
            // Arrange
            ObservableList <ApplicationAPIModel> learnedModels = new ObservableList <ApplicationAPIModel>()
            {
                learnedAPIsList[1], learnedAPIsList[3]
            };

            //Act
            ObservableList <DeltaAPIModel> deltaAPIsList = APIDeltaUtils.DoAPIModelsCompare(learnedModels);

            // Assert - Confirm Default Selected Operation = Replace Existing with New, for API with Comparison Status = Modified
            Assert.AreEqual(deltaAPIsList[0].comparisonStatus, DeltaAPIModel.eComparisonOutput.Modified, deltaAPIsList[0].learnedAPI.Name + " is Modified and having modified RequestBody.");
            Assert.AreEqual(deltaAPIsList[0].SelectedOperationEnum, DeltaAPIModel.eHandlingOperations.ReplaceExisting, deltaAPIsList[0].learnedAPI.Name + " is Modified and thus Default Selected Operation is 'Replace Existing with New'.");

            Assert.AreEqual(deltaAPIsList[1].comparisonStatus, DeltaAPIModel.eComparisonOutput.Modified, deltaAPIsList[1].learnedAPI.Name + " is Modified and having modified RequestBody.");
            Assert.AreEqual(deltaAPIsList[1].SelectedOperationEnum, DeltaAPIModel.eHandlingOperations.ReplaceExisting, deltaAPIsList[1].learnedAPI.Name + " is Modified and thus Default Selected Operation is 'Replace Existing with New'.");
        }
コード例 #6
0
        public void New_APIComparisonStatusTest()
        {
            // Arrange
            ObservableList <ApplicationAPIModel> learnedModels = new ObservableList <ApplicationAPIModel>()
            {
                learnedAPIsList[0], learnedAPIsList[5]
            };

            //Act
            ObservableList <DeltaAPIModel> deltaAPIsList = APIDeltaUtils.DoAPIModelsCompare(learnedModels);

            // Assert - Confirm Default Selected Operation = Add New, for API with Comparison Status = New
            Assert.AreEqual(deltaAPIsList[0].comparisonStatus, DeltaAPIModel.eComparisonOutput.New, deltaAPIsList[0].learnedAPI.Name + " is NEW API.");
            Assert.AreEqual(deltaAPIsList[0].SelectedOperationEnum, DeltaAPIModel.eHandlingOperations.Add, deltaAPIsList[0].learnedAPI.Name + " is New API and thus, Default Selected Operation is 'Add New'.");

            Assert.AreEqual(deltaAPIsList[1].comparisonStatus, DeltaAPIModel.eComparisonOutput.New, deltaAPIsList[1].learnedAPI.Name + " is NEW API.");
            Assert.AreEqual(deltaAPIsList[1].SelectedOperationEnum, DeltaAPIModel.eHandlingOperations.Add, deltaAPIsList[1].learnedAPI.Name + " is New API and thus, Default Selected Operation is 'Add New'.");
        }
コード例 #7
0
        private void XManualMatchBtn_Click(object sender, RoutedEventArgs e)
        {
            DeltaAPIModel deltaAPI = null;

            deltaAPI = GetFrameElementDataContext(sender) as DeltaAPIModel;

            if (deltaAPI != null)
            {
                int indexOfCurrentDelta = xApisSelectionGrid.DataSourceList.IndexOf(deltaAPI);
                SingleItemTreeViewSelectionPage apiModelTreeSelectionPage = null;
                AppApiModelsFolderTreeItem      apiRoot = new AppApiModelsFolderTreeItem(WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <ApplicationAPIModel>());

                apiModelTreeSelectionPage = new SingleItemTreeViewSelectionPage("API Models", eImageType.APIModel, apiRoot, SingleItemTreeViewSelectionPage.eItemSelectionType.Single, true,
                                                                                new System.Tuple <string, string>(nameof(ApplicationAPIModel.APIType), deltaAPI.learnedAPI.APIType.ToString()));

                apiModelTreeSelectionPage.xTreeView.Tree.RefresTreeNodeChildrens(apiRoot);

                List <object> selectedList = apiModelTreeSelectionPage.ShowAsWindow("Matching API Models", (Window)AddAPIModelWizard.mWizardWindow);

                ApplicationAPIModel selectedAPIModel = null;
                if (selectedList != null)
                {
                    selectedAPIModel = selectedList.FirstOrDefault() as ApplicationAPIModel;
                    //deltaAPI.matchingAPIModel = selectedAPIModel;

                    ObservableList <ApplicationAPIModel> selectedMatchingAPIList = new ObservableList <ApplicationAPIModel>()
                    {
                        selectedAPIModel
                    };
                    ObservableList <ApplicationAPIModel> apiModelsListLearned = new ObservableList <ApplicationAPIModel>()
                    {
                        deltaAPI.learnedAPI
                    };

                    ObservableList <DeltaAPIModel> comparisonOutputDelta = APIDeltaUtils.DoAPIModelsCompare(apiModelsListLearned, selectedMatchingAPIList);

                    deltaAPI = comparisonOutputDelta.FirstOrDefault();

                    xApisSelectionGrid.DataSourceList[indexOfCurrentDelta] = deltaAPI;
                }
            }
        }