コード例 #1
0
        public ActWebAPIModelEditPage(ActWebAPIModel Act)
        {
            InitializeComponent();
            mAct = Act;
            if (mAct.APImodelGUID != new Guid())
            {
                AAMB = WorkSpace.Instance.SolutionRepository.GetRepositoryItemByGuid <ApplicationAPIModel>(mAct.APImodelGUID);
            }

            bool mappedNew = false;

            if (AAMB == null)//API mapped for this action is missing, Map new API
            {
                mappedNew = true;
                ChangeAPIMapping(mappedNew);
            }

            if (AAMB != null)
            {
                WorkSpace.Instance.RefreshGlobalAppModelParams(AAMB);
                UpdateOptionalValuesAndParams(!mappedNew);
                SetFieldsGrid();
            }
            else
            {
                //Show empty page, action is not mapped to any API
            }
        }
コード例 #2
0
 public AddOptionalValuesModelSelectParamPage(ApplicationAPIModel AAMB)
 {
     InitializeComponent();
     AddModelOptionalValuesWizard.mAAMB = AAMB;
     AddModelOptionalValuesWizard.ImportOptionalValues.ParameterType = ImportOptionalValuesForParameters.eParameterType.Local;
     InitxModelParametersGrid();
 }
コード例 #3
0
        public override ObservableList <ApplicationAPIModel> ParseDocument(string FileName)
        {
            ObservableList <ApplicationAPIModel> AAMSList = new ObservableList <ApplicationAPIModel>();

            ApplicationAPIModel AAM = new ApplicationAPIModel();

            //ObservableList<APIParameter> APIPList = new ObservableList<APIParameter>();
            AAM.Name = Path.GetFileNameWithoutExtension(FileName);


            string JSOnText = System.IO.File.ReadAllText(FileName);



            JObject jo = JObject.Parse(JSOnText);



            IList <string> keys = jo.Properties().Select(p => p.Path).ToList();



            object[] BodyandModelParameters = GenerateBodyANdModelParameters(JSOnText);


            AAM.RequestBody        = (string)BodyandModelParameters[0];
            AAM.AppModelParameters = (ObservableList <AppModelParameter>)BodyandModelParameters[1];
            AAMSList.Add(AAM);

            return(AAMSList);
        }
コード例 #4
0
        /// <summary>
        /// Update optional values only for selected parameter according to json file
        /// </summary>
        /// <param name="AAM"></param>
        /// <param name="OptionalValuesPerParameterDict"></param>
        /// <param name="SelectedParametersGridList"></param>
        public void PopulateJSONOptionalValuesForAPIParameters(ApplicationAPIModel AAM, Dictionary <Tuple <string, string>, List <string> > OptionalValuesPerParameterDict, List <AppModelParameter> SelectedParametersGridList)
        {
            int UpdatedParametersCounter = 0;

            foreach (var tuple in SelectedParametersGridList.Zip(AAM.AppModelParameters, (x, y) => (x, y)))
            {
                if (tuple.x.RequiredAsInput)//selected
                {
                    Tuple <string, string> tupleKey = new Tuple <string, string>(tuple.y.TagName, tuple.y.Path);
                    if (OptionalValuesPerParameterDict.ContainsKey(tupleKey))
                    {
                        currentParser.PopulateOptionalValuesByTuple(tuple.y, OptionalValuesPerParameterDict, tupleKey);
                        if (APIConfigurationsDocumentParserBase.ParameterValuesUpdated)
                        {
                            UpdatedParametersCounter++;
                            APIConfigurationsDocumentParserBase.ParameterValuesUpdated = false;
                        }
                    }
                }
            }
            if (ShowMessage)
            {
                Reporter.ToUser(eUserMsgKeys.ParameterOptionalValues, UpdatedParametersCounter);
            }
        }
コード例 #5
0
        private bool ChangeAPIMapping(bool showNewMappingMessage = false)
        {
            RepositoryFolder <ApplicationAPIModel> APIModels = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <ApplicationAPIModel>();

            if (APIModels.GetFolderItems().Count == 0)
            {
                Reporter.ToUser(eUserMsgKeys.NoAPIExistToMappedTo);
                return(false);
            }

            if (showNewMappingMessage)
            {
                Reporter.ToUser(eUserMsgKeys.APIMappedToActionIsMissing);
            }

            if (apiModelPage == null)
            {
                AppApiModelsFolderTreeItem apiRoot = new AppApiModelsFolderTreeItem(APIModels);
                apiModelPage = new SingleItemTreeViewSelectionPage("API Models", eImageType.APIModel, apiRoot, SingleItemTreeViewSelectionPage.eItemSelectionType.Single);
            }
            List <object> selectedList = apiModelPage.ShowAsWindow();

            if (selectedList != null && selectedList.Count == 1)
            {
                AAMB = (ApplicationAPIModel)selectedList[0];
                mAct.APImodelGUID = AAMB.Guid;
                return(true);
            }

            return(false);
        }
コード例 #6
0
        private ActWebAPIRest CreateActWebAPIREST(ApplicationAPIModel AAMB, ActWebAPIModel ActWebAPIModel)
        {
            ActWebAPIRest actWebAPIBase = new ActWebAPIRest();

            FillAPIBaseFields(AAMB, actWebAPIBase, ActWebAPIModel);
            return(actWebAPIBase);
        }
コード例 #7
0
        private bool ChangeAPIMapping(bool showNewMappingMessage = false)
        {
            ObservableList <ApplicationAPIModel> APIModelsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ApplicationAPIModel>();

            if (APIModelsList.Count == 0)
            {
                Reporter.ToUser(eUserMsgKey.NoAPIExistToMappedTo);
                return(false);
            }

            if (showNewMappingMessage)
            {
                Reporter.ToUser(eUserMsgKey.APIMappedToActionIsMissing);
            }

            if (apiModelPage == null)
            {
                RepositoryFolder <ApplicationAPIModel> APIModelsFolder = WorkSpace.Instance.SolutionRepository.GetRepositoryItemRootFolder <ApplicationAPIModel>();
                AppApiModelsFolderTreeItem             apiRoot         = new AppApiModelsFolderTreeItem(APIModelsFolder);
                apiModelPage = new SingleItemTreeViewSelectionPage("API Models", eImageType.APIModel, apiRoot, SingleItemTreeViewSelectionPage.eItemSelectionType.Single, true,
                                                                   new Tuple <string, string>(nameof(ApplicationPOMModel.TargetApplicationKey) + "." +
                                                                                              nameof(ApplicationPOMModel.TargetApplicationKey.ItemName),
                                                                                              Convert.ToString(AAMB.TargetApplicationKey)));
            }
            List <object> selectedList = apiModelPage.ShowAsWindow();

            if (selectedList != null && selectedList.Count == 1)
            {
                AAMB = (ApplicationAPIModel)selectedList[0];
                mAct.APImodelGUID = AAMB.Guid;
                return(true);
            }

            return(false);
        }
コード例 #8
0
        private void GenerateFormParameters(ApplicationAPIModel aAM, SwaggerOperation operation, bool isMultiPartFormdata = false)
        {
            if (isMultiPartFormdata)
            {
                aAM.ContentType = ApplicationAPIUtils.eContentType.FormData;
            }
            else
            {
                aAM.ContentType = ApplicationAPIUtils.eContentType.XwwwFormUrlEncoded;
            }
            foreach (SwaggerParameter SP in operation.ActualParameters)
            {
                string ModelParameterName = "{" + SP.Name.ToUpper() + "}";

                aAM.AppModelParameters.Add(new AppModelParameter()
                {
                    ItemName = ModelParameterName,
                });

                aAM.APIModelBodyKeyValueHeaders.Add(new APIModelBodyKeyValue()
                {
                    Param     = SP.Name,
                    ValueType = SP.Type == JsonObjectType.File ? APIModelBodyKeyValue.eValueType.File : APIModelBodyKeyValue.eValueType.Text,
                    Value     = ModelParameterName,
                });
            }
        }
コード例 #9
0
        public APIModelPage(ApplicationAPIModel applicationAPIModelBase)
        {
            mApplicationAPIModel = applicationAPIModelBase;

            InitializeComponent();
            BindUiControls();
            InitializeUIByActionType();
            SetCustomCredPanel();
            SetCertificatePanel();
            SecondRow.MaxHeight = System.Windows.SystemParameters.PrimaryScreenHeight - 380;

            WorkSpace.Instance.RefreshGlobalAppModelParams(mApplicationAPIModel);
            page = new ModelParamsPage(mApplicationAPIModel);
            xDynamicParamsFrame.Content = page;

            OutputTemplatePage outputTemplatePage = new OutputTemplatePage(mApplicationAPIModel);

            xOutputTemplateFrame.Content = outputTemplatePage;

            mApplicationAPIModel.AppModelParameters.CollectionChanged       += AppModelParameters_CollectionChanged;
            mApplicationAPIModel.GlobalAppModelParameters.CollectionChanged += AppModelParameters_CollectionChanged;
            UpdateModelParametersTabHeader();
            mApplicationAPIModel.ReturnValues.CollectionChanged += ReturnValues_CollectionChanged;
            UpdateOutputTemplateTabHeader();
        }
コード例 #10
0
        private ActWebAPISoap CreateActWebAPISOAP(ApplicationAPIModel AAMB, ActWebAPIModel ActWebAPIModel)
        {
            ActWebAPISoap actWebAPISoap = new ActWebAPISoap();

            FillAPIBaseFields(AAMB, actWebAPISoap, ActWebAPIModel);
            return(actWebAPISoap);
        }
コード例 #11
0
 public AddModelOptionalValuesWizard(ApplicationAPIModel AAMB)//Local Parameters
 {
     mAAMB = AAMB;
     ImportOptionalValues.ParameterType = ImportOptionalValuesForParameters.eParameterType.Local;
     AddPage(Name: "Select Document", Title: "Import Source", SubTitle: "Select And Import Source For Optional Values", Page: new AddOptionalValuesModelSelectTypePage(eOptionalValuesTargetType.ModelLocalParams));
     AddPage(Name: "Select Parameters", Title: "Select Parameters", SubTitle: "Select Parameters For The Chosen Values", Page: new AddOptionalValuesModelSelectParamPage(eOptionalValuesTargetType.ModelLocalParams));
 }
コード例 #12
0
        public override ObservableList <ApplicationAPIModel> ParseDocument(string FileName, ObservableList <ApplicationAPIModel> AAMSList, bool avoidDuplicatesNodes = false)
        {
            ApplicationAPIModel AAM = new ApplicationAPIModel();

            AAM.Name = Path.GetFileNameWithoutExtension(FileName);

            string JSOnText = System.IO.File.ReadAllText(FileName);

            //JObject jo = JObject.Parse(JSOnText);
            //IList<string> keys = jo.Properties().Select(p => p.Path).ToList();

            if (avoidDuplicatesNodes)
            {
                JsonExtended fullJSOnObjectExtended = new JsonExtended(JSOnText);
                fullJSOnObjectExtended.RemoveDuplicatesNodes();
                JSOnText = fullJSOnObjectExtended.JsonString;
            }

            object[] BodyandModelParameters = GenerateBodyANdModelParameters(JSOnText);

            AAM.RequestBody        = (string)BodyandModelParameters[0];
            AAM.AppModelParameters = (ObservableList <AppModelParameter>)BodyandModelParameters[1];
            AAMSList.Add(AAM);

            return(AAMSList);
        }
コード例 #13
0
        public void ApplicationAPIModelMixSoapAndRestSaveAndLoad()
        {
            // Arrange
            ApplicationAPIModel AAMS1 = new ApplicationAPIModel();

            //AAMS1.GroupName = "Group1";
            AAMS1.Name = "Group1_Operation1";
            SR.AddRepositoryItem(AAMS1);

            ApplicationAPIModel AAMR1 = new ApplicationAPIModel();

            //AAMR1.GroupName = "Group2";
            AAMR1.Name = "Group2_Operation1";
            SR.AddRepositoryItem(AAMR1);


            //Act
            ObservableList <ApplicationAPIModel> AAMBList = SR.GetAllRepositoryItems <ApplicationAPIModel>();
            ApplicationAPIModel AAMS2 = (ApplicationAPIModel)(from x in AAMBList where x.Guid == AAMS1.Guid select x).FirstOrDefault();
            ApplicationAPIModel AAMR2 = (ApplicationAPIModel)(from x in AAMBList where x.Guid == AAMR1.Guid select x).FirstOrDefault();

            //Assert
            Assert.IsTrue(AAMS2 != null, "API SOAP Model loaded from disk");
            Assert.IsTrue(AAMR2 != null, "API REST Model loaded from disk");
        }
コード例 #14
0
        public static ApplicationAPIModel CreateAPIModelObject(ApplicationAPIModel sourceAPIModel)
        {
            AutoMapper.MapperConfiguration automapAPIModel   = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap <ApplicationAPIModel, ApplicationAPIModel>(); });
            ApplicationAPIModel            DuplicateAPIModel = automapAPIModel.CreateMapper().Map <ApplicationAPIModel, ApplicationAPIModel>(sourceAPIModel);

            return(DuplicateAPIModel);
        }
コード例 #15
0
        public static void ClassInitialize(TestContext TC)
        {
            Reporter.ToLog(eLogLevel.DEBUG, "Creating the GingerCoreNET WorkSpace");
            WorkSpaceEventHandler WSEH = new WorkSpaceEventHandler();

            WorkSpace.Init(WSEH);

            string TempSolutionFolder = TestResources.GetTestTempFolder(@"Solutions" + Path.DirectorySeparatorChar + "APIModelsComparisonUtilityTest");

            if (Directory.Exists(TempSolutionFolder))
            {
                Directory.Delete(TempSolutionFolder, true);
            }

            WorkSpace.Instance.SolutionRepository = GingerSolutionRepository.CreateGingerSolutionRepository();
            WorkSpace.Instance.SolutionRepository.CreateRepository(TempSolutionFolder);

            NewRepositorySerializer RS = new NewRepositorySerializer();

            NewRepositorySerializer.AddClassesFromAssembly(typeof(ApplicationAPIModel).Assembly);
            WorkSpace.Instance.SolutionRepository.Open(TempSolutionFolder);

            // Initialize ApplicationAPIModels XML file names to be fetched from TestResources
            xmlFiles = new List <string>()
            {
                @"Repository" + Path.DirectorySeparatorChar + "SampleAPIModels" + Path.DirectorySeparatorChar + "Create_User.Ginger.ApplicationAPIModel.xml",
                @"Repository" + Path.DirectorySeparatorChar + "SampleAPIModels" + Path.DirectorySeparatorChar + "Delete_User.Ginger.ApplicationAPIModel.xml",
                @"Repository" + Path.DirectorySeparatorChar + "SampleAPIModels" + Path.DirectorySeparatorChar + "PhoneVerifySOAP_CheckPhoneNumber.Ginger.ApplicationAPIModel.xml",
                @"Repository" + Path.DirectorySeparatorChar + "SampleAPIModels" + Path.DirectorySeparatorChar + "Update_User.Ginger.ApplicationAPIModel.xml",
                @"Repository" + Path.DirectorySeparatorChar + "SampleAPIModels" + Path.DirectorySeparatorChar + "PhoneVerifySOAP_CheckPhoneNumbers.Ginger.ApplicationAPIModel.xml",
                @"Repository" + Path.DirectorySeparatorChar + "SampleAPIModels" + Path.DirectorySeparatorChar + "GetQuote_DelayedStockQuoteSoap.Ginger.ApplicationAPIModel.xml",
            };

            existingAPIsList = new ObservableList <ApplicationAPIModel>();
            learnedAPIsList  = new List <ApplicationAPIModel>();

            // Importing API Models from XML files (listed in xmlFiles)
            foreach (String fileName in xmlFiles)
            {
                var tempFile = TestResources.GetTestResourcesFile(fileName);
                ApplicationAPIModel appModel = RS.DeserializeFromFile(typeof(ApplicationAPIModel), tempFile) as ApplicationAPIModel;
                appModel.FilePath = appModel.Name;//so it will get new file path when been added to repository later
                if (appModel != null)
                {
                    existingAPIsList.Add(appModel);
                    learnedAPIsList.Add(appModel.CreateCopy() as ApplicationAPIModel);
                }
            }

            // Modifying certain API Models for testing different Comparison status and scenarios
            existingAPIsList[1].RequestBody = existingAPIsList[1].RequestBody + "This is modified";
            existingAPIsList[3].RequestBody = existingAPIsList[3].RequestBody + "This is also modified";

            // Storing the API Models in the Solution Repository as will be utilized during Comparison process
            foreach (ApplicationAPIModel apiModel in existingAPIsList.Skip(1).Take(4))
            {
                WorkSpace.Instance.SolutionRepository.AddRepositoryItem(apiModel);
            }
        }
コード例 #16
0
        /// <summary>
        /// This method will convert the Activity Actions
        /// </summary>
        /// <param name="parameterizeRequestBody"></param>
        /// <param name="pullValidations"></param>
        /// <param name="activity"></param>
        /// <param name="ta"></param>
        private int ConvertActivity(bool parameterizeRequestBody, bool pullValidations, Activity activity, RepositoryItemKey ta, RepositoryFolder <ApplicationAPIModel> apiModelFolder)
        {
            int convertionConter = 0;

            for (int actionIndex = 0; actionIndex < activity.Acts.Count; actionIndex++)
            {
                try
                {
                    Act act = (Act)activity.Acts[actionIndex];
                    if (act.Active && (act.GetType() == typeof(ActWebAPIRest) || act.GetType() == typeof(ActWebAPISoap)))
                    {
                        // get the index of the action that is being converted
                        int selectedActIndex = activity.Acts.IndexOf(act);

                        //Create/Update API Model
                        bool isModelExists = true;
                        ApplicationAPIModel applicationModel = GetAPIModelIfExists(act);

                        if (applicationModel == null)
                        {
                            isModelExists    = false;
                            applicationModel = new ApplicationAPIModel();
                            applicationModel.TargetApplicationKey = ta;
                            CreateAPIModelFromWebserviceAction(ref applicationModel, act, pullValidations, parameterizeRequestBody);
                        }

                        //Parse optional values
                        Dictionary <System.Tuple <string, string>, List <string> > optionalValuesPulledFromConvertedAction = new Dictionary <Tuple <string, string>, List <string> >();
                        if (applicationModel.AppModelParameters != null && applicationModel.AppModelParameters.Count > 0)
                        {
                            optionalValuesPulledFromConvertedAction = ParseParametersOptionalValues(applicationModel, (ActWebAPIBase)act);
                        }

                        //Create WebAPIModel action
                        ActWebAPIModel actApiModel = GetNewAPIModelAction(applicationModel, act, optionalValuesPulledFromConvertedAction);

                        activity.Acts.Insert(selectedActIndex + 1, actApiModel);
                        actionIndex++;
                        act.Active = false;
                        if (!isModelExists)
                        {
                            apiModelFolder.AddRepositoryItem(applicationModel);
                        }
                        else
                        {
                            WorkSpace.Instance.SolutionRepository.SaveRepositoryItem(applicationModel);
                        }

                        convertionConter++;
                    }
                }
                catch (Exception ex)
                {
                    Reporter.ToLog(eLogLevel.ERROR, "Error occurred while trying to convert the action", ex);
                }
            }

            return(convertionConter);
        }
コード例 #17
0
        private ObservableList <AppModelParameter> GenerateJsonBody(ApplicationAPIModel aAM, JsonSchema4 operation)
        {
            string SampleBody = JsonSchemaTools.JsonSchemaFaker(operation);

            object[] BodyandModelParameters = JSONTemplateParser.GenerateBodyANdModelParameters(SampleBody);
            aAM.RequestBody = (string)BodyandModelParameters[0];
            return((ObservableList <AppModelParameter>)BodyandModelParameters[1]);
        }
コード例 #18
0
        public static ObservableList <DeltaAPIModel> DoAPIModelsCompare(ObservableList <ApplicationAPIModel> learnedAPIModelsList, ObservableList <ApplicationAPIModel> existingAPIModels = null)
        {
            ObservableList <DeltaAPIModel> deltaAPIModelsList = new ObservableList <DeltaAPIModel>();

            ObservableList <ApplicationAPIModel> existingAPIModelsList = WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems <ApplicationAPIModel>();

            //for (int i = 0; i < learnedAPIModelsList.Count; i++)
            foreach (ApplicationAPIModel apiModelLearned in learnedAPIModelsList)
            {
                //ApplicationAPIModel apiModelLearned = learnedAPIModelsList[i];

                DeltaAPIModel apiModelDelta = new DeltaAPIModel();
                apiModelDelta.learnedAPI = apiModelLearned;
                List <ApplicationAPIModel> matchingAPIModels;
                if (existingAPIModels == null)
                {
                    if (apiModelLearned.APIType == ApplicationAPIUtils.eWebApiType.SOAP)
                    {
                        matchingAPIModels = existingAPIModelsList.Where(m => (m.EndpointURL != null && m.EndpointURL.Equals(apiModelLearned.EndpointURL, StringComparison.OrdinalIgnoreCase)) && m.APIType == apiModelLearned.APIType && m.SOAPAction.Equals(apiModelLearned.SOAPAction)).ToList();
                    }
                    else
                    {
                        matchingAPIModels = existingAPIModelsList.Where(m => (m.EndpointURL != null && m.EndpointURL.Equals(apiModelLearned.EndpointURL, StringComparison.OrdinalIgnoreCase)) && m.APIType == apiModelLearned.APIType && m.RequestType == apiModelLearned.RequestType).ToList();
                    }
                }
                else
                {
                    matchingAPIModels = existingAPIModels.ToList();
                }

                if (matchingAPIModels != null && matchingAPIModels.Count > 0)
                {
                    ApplicationAPIModel matchingModel = matchingAPIModels[0];
                    matchingAPIModels = CompareAPIModels(apiModelLearned, matchingAPIModels);
                    if (matchingAPIModels.Count > 0)
                    {
                        apiModelDelta.comparisonStatus = DeltaAPIModel.eComparisonOutput.Unchanged;         // UNCHANGED
                        apiModelDelta.matchingAPIModel = matchingAPIModels[0];
                        apiModelDelta.IsSelected       = false;
                    }
                    else
                    {
                        apiModelDelta.comparisonStatus = DeltaAPIModel.eComparisonOutput.Modified;          // MODIFIED
                        apiModelDelta.matchingAPIModel = matchingModel;
                        apiModelDelta.IsSelected       = true;
                    }
                }
                else
                {
                    apiModelDelta.comparisonStatus = DeltaAPIModel.eComparisonOutput.New;                   // NEW API
                    apiModelDelta.IsSelected       = true;
                }

                deltaAPIModelsList.Add(apiModelDelta);
            }

            return(deltaAPIModelsList);
        }
コード例 #19
0
        public void ResetActionList()
        {
            a1.Acts.Clear();

            ActWebAPISoap actWebAPISoap = new ActWebAPISoap();

            actWebAPISoap.ItemName = "Action1";
            actWebAPISoap.ActInputValues.Add(new Amdocs.Ginger.Repository.ActInputValue()
            {
                Param = ActWebAPIBase.Fields.EndPointURL, Value = "bla bli bla VTFInsideList bla bla bla"
            });
            actWebAPISoap.ActReturnValues.Add(new Amdocs.Ginger.Repository.ActReturnValue()
            {
                Param = "ReturnValue1", Expected = "I expect you to VTFInsideList behave"
            });
            actWebAPISoap.Active = true;
            a1.Acts.Add(actWebAPISoap);

            ActClearAllVariables actClearAllVariables = new ActClearAllVariables();

            actClearAllVariables.ItemName     = "Action2";
            actClearAllVariables.VariableName = "My Variable is VTFStringField";
            a1.Acts.Add(actClearAllVariables);

            ActScript actScript = new ActScript();

            actScript.ItemName      = "Action3";
            actScript.ScriptCommand = ActScript.eScriptAct.FreeCommand;
            actScript.Wait          = 13132424;
            a1.Acts.Add(actScript);

            mApplicationAPIModels.Clear();

            ApplicationAPIModel applicationAPIModel = new ApplicationAPIModel();

            applicationAPIModel.APIType     = ApplicationAPIUtils.eWebApiType.SOAP;
            applicationAPIModel.EndpointURL = "VTF";
            applicationAPIModel.DoNotFailActionOnBadRespose = true;
            applicationAPIModel.AppModelParameters.Add(new AppModelParameter()
            {
                PlaceHolder = "VTF", Path = "VTF/Path/Path/Path", OptionalValuesList = new ObservableList <OptionalValue>()
                {
                    new OptionalValue()
                    {
                        Value = "VTF1"
                    }, new OptionalValue()
                    {
                        Value = "VTF2"
                    }
                }
            });
            applicationAPIModel.HttpHeaders.Add(new APIModelKeyValue()
            {
                Param = "Content-Type", Value = "Applicaiton/VTF"
            });
            mApplicationAPIModels.Add(applicationAPIModel);
        }
コード例 #20
0
 private void viewApplicationModel(ApplicationModelBase applicationModelToView)
 {
     if (applicationModelToView is ApplicationAPIModel)
     {
         ApplicationAPIModel applicationAPIModel = applicationModelToView as ApplicationAPIModel;
         APIModelPage        w = new APIModelPage(applicationAPIModel);
         w.ShowAsWindow(eWindowShowStyle.Free, true, APIModelPage.eEditMode.FindAndReplace);
     }
 }
コード例 #21
0
        private void GenerateResponse(SwaggerOperation operation, ApplicationAPIModel basicModal)
        {
            if (operation.Responses.Count > 0 && operation.Responses.Keys.Where(x => x.StartsWith("2")).Count() > 0)
            {
                //handling only the first sucess response code need to be improved
                //as discussed, for now handling response for only success
                string          sucesskey = operation.Responses.Keys.Where(x => x.StartsWith("2")).ElementAt(0);
                SwaggerResponse response  = null;
                operation.Responses.TryGetValue(sucesskey, out response);

                if (response != null && response.Schema == null)
                {
                    if (response.Reference != null && response.Reference is SwaggerResponse)
                    {
                        response = response.Reference;
                    }
                }

                if (response.Schema != null)
                {
                    var schemaObj = response.Schema;
                    if (response.Schema.HasReference && response.Schema.Reference != null)
                    {
                        schemaObj = response.Schema.Reference;
                    }
                    if (basicModal.ContentType == ApplicationAPIUtils.eContentType.XML)
                    {
                        ApplicationAPIModel JsonResponseModel = new ApplicationAPIModel();
                        var i = GenerateXMLBody(JsonResponseModel, schemaObj);

                        foreach (AppModelParameter currModel in GenerateJsonBody(JsonResponseModel, schemaObj))
                        {
                            ActReturnValue arv = new ActReturnValue();
                            arv.ItemName            = currModel.ItemName;
                            arv.Path                = currModel.XPath;
                            arv.DoNotConsiderAsTemp = true;
                            basicModal.ReturnValues.Add(arv);
                        }
                    }
                    else if (basicModal.ContentType == ApplicationAPIUtils.eContentType.JSon)
                    {
                        ApplicationAPIModel JsonResponseModel = new ApplicationAPIModel();
                        var i = GenerateJsonBody(JsonResponseModel, schemaObj);

                        foreach (AppModelParameter currModel in GenerateJsonBody(JsonResponseModel, schemaObj))
                        {
                            ActReturnValue arv = new ActReturnValue();
                            arv.ItemName            = currModel.ItemName;
                            arv.Path                = currModel.XPath;
                            arv.DoNotConsiderAsTemp = true;
                            basicModal.ReturnValues.Add(arv);
                        }
                    }
                }
            }
        }
コード例 #22
0
        public void ApplicationAPIModelMultipleSoapAndRestSaveAndLoad()
        {
            // Arrange
            RepositoryFolder <ApplicationAPIModel> RFRoot    = SR.GetRepositoryItemRootFolder <ApplicationAPIModel>();
            RepositoryFolder <ApplicationAPIModel> subFolder = (RepositoryFolder <ApplicationAPIModel>)RFRoot.AddSubFolder("SecondFolder");

            //Act
            //add items to root folder
            ApplicationAPIModel AAMS1 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation1"
            };

            SR.AddRepositoryItem(AAMS1);
            ApplicationAPIModel AAMS2 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation2"
            };

            SR.AddRepositoryItem(AAMS2);
            ApplicationAPIModel AAMS3 = new ApplicationAPIModel()
            {
                Name = "Group1_Operation3"
            };

            SR.AddRepositoryItem(AAMS3);
            //add items to sub folder items
            ApplicationAPIModel AAMR1 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation1"
            };

            subFolder.AddRepositoryItem(AAMR1);
            ApplicationAPIModel AAMR2 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation2"
            };

            subFolder.AddRepositoryItem(AAMR2);
            ApplicationAPIModel AAMR3 = new ApplicationAPIModel()
            {
                Name = "Group2_Operation3"
            };

            subFolder.AddRepositoryItem(AAMR3);

            ObservableList <ApplicationAPIModel>   AAMBList          = SR.GetAllRepositoryItems <ApplicationAPIModel>();
            RepositoryFolder <ApplicationAPIModel> SecondFolder      = RFRoot.GetSubFolder("SecondFolder");
            ObservableList <ApplicationAPIModel>   AAMBListSubFolder = SecondFolder.GetFolderItems();


            //Assert
            // Assert.AreEqual(AAMBList.Count, 6, "All appllication models including sub folders"); - cannot compare since we run several tests in parallel
            Assert.AreEqual(AAMBListSubFolder.Count, 3, "Second Folder should have 3 files");
        }
コード例 #23
0
        public AddOptionalValuesModelSelectTypePage(ApplicationAPIModel AAMB)
        {
            InitializeComponent();
            mAAMB = AAMB;
            importOptionalValues.ParameterType = ImportOptionalValuesForParameters.eParameterType.Local;
            ControlsBinding.FillComboFromEnumType(xSourceTypeComboBox, typeof(eSourceType), null);

            xSourceTypeComboBox.Style = this.FindResource("$FlatInputComboBoxStyle") as Style;
            SetFieldsGrid(); //XML & JSON
            SetDefaultPresentation();
        }
コード例 #24
0
 private void AddSingleAPIModel(ApplicationAPIUtils.eWebApiType type)
 {
     string apiName = string.Empty; ;
     if (InputBoxWindow.GetInputWithValidation(string.Format("Add {0} API",type.ToString()), "API Name:", ref apiName, System.IO.Path.GetInvalidPathChars()))
     {
         ApplicationAPIModel newApi = new ApplicationAPIModel();
         newApi.APIType = type;
         newApi.Name = apiName;
         newApi.ContainingFolder = mAPIModelFolder.FolderFullPath;              
         mAPIModelFolder.AddRepositoryItem(newApi);                            
     }
 }
コード例 #25
0
        /// <summary>
        /// This method will create the new api model action
        /// </summary>
        /// <param name="applicationModel"></param>
        /// <param name="act"></param>
        /// <returns></returns>
        private ActWebAPIModel GetNewAPIModelAction(ApplicationAPIModel applicationModel, Act act, Dictionary <System.Tuple <string, string>, List <string> > optionalValuesPulledFromConvertedAction)
        {
            AutoMapper.MapperConfiguration mapConfigUIElement = new AutoMapper.MapperConfiguration(cfg => { cfg.CreateMap <Act, ActWebAPIModel>(); });
            ActWebAPIModel newActModel = mapConfigUIElement.CreateMapper().Map <Act, ActWebAPIModel>(act);

            newActModel.APImodelGUID = applicationModel.Guid;
            newActModel.Active       = true;
            newActModel.Reset();
            newActModel.APIModelParamsValue = GetAPIActionParams(applicationModel.AppModelParameters, optionalValuesPulledFromConvertedAction);
            //newActModel.ReturnValues = GetAPIModelActionReturnValues(applicationModel.ReturnValues); //For now we want to keep original validations on action
            return(newActModel);
        }
コード例 #26
0
        /// <summary>
        /// Update optional values only for selected Local parameters according to DB\Excel file
        /// </summary>
        /// <param name="AAM"></param>
        /// <param name="SelectedParametersGridList"></param>
        public void PopulateExcelDBOptionalValuesForAPIParametersExcelDB(ApplicationAPIModel AAM, List <AppModelParameter> SelectedParametersGridList, Dictionary <string, List <string> > ParameterValuesByNameDic)
        {
            int  UpdatedParameters = 0;
            bool IsUpdate;
            List <AppModelParameter> RelevantParameterList = new List <AppModelParameter>();

            foreach (AppModelParameter prm in SelectedParametersGridList)
            {
                AppModelParameter pOriginal = AAM.AppModelParameters.FirstOrDefault(p => p.ItemName == prm.ItemName);
                if (pOriginal != null)
                {
                    RelevantParameterList.Add(pOriginal);
                }
            }
            foreach (var tuple in SelectedParametersGridList.Zip(RelevantParameterList, (x, y) => (x, y)))
            {
                IsUpdate = false;
                if (tuple.x.RequiredAsInput)//selected
                {
                    if (ParameterValuesByNameDic.ContainsKey(tuple.y.ItemName))
                    {
                        string[]      paramExistingvalues = tuple.y.OptionalValuesString.Split(',');;
                        OptionalValue defaultValue        = tuple.y.OptionalValuesList.FirstOrDefault(x => x.IsDefault);
                        foreach (string val in ParameterValuesByNameDic[tuple.y.ItemName])
                        {
                            bool ValueAlreadyExists = paramExistingvalues.Any(x => x == val);
                            if ((paramExistingvalues != null && !ValueAlreadyExists) && (defaultValue == null || defaultValue.Value != val))
                            {
                                OptionalValue OptionalValue = new OptionalValue()
                                {
                                    Value = val
                                };
                                if (tuple.y.OptionalValuesList.Count == 0)
                                {
                                    OptionalValue.IsDefault = true;
                                }
                                tuple.y.OptionalValuesList.Add(OptionalValue);
                                IsUpdate = true;
                            }
                        }
                    }
                }
                if (IsUpdate)
                {
                    UpdatedParameters++;
                }
            }
            if (ShowMessage)
            {
                Reporter.ToUser(eUserMsgKeys.ParameterOptionalValues, UpdatedParameters);
            }
        }
コード例 #27
0
        public void VerifyApplicationAPIModelFileExtension()
        {
            // Need to verify ext is coming from ApplicationAPIModel and file name will not have ApplicationAPIModel

            // Arrange
            ApplicationAPIModel AAMS1 = new ApplicationAPIModel();

            // Act
            string ext = AAMS1.ObjFileExt;

            //Assert
            Assert.AreEqual(ext, "Ginger.ApplicationAPIModel");
        }
コード例 #28
0
        public ModelParamsPage(ApplicationAPIModel AAMB)
        {
            InitializeComponent();
            mAAMB              = AAMB;
            ParamsList         = AAMB.AppModelParameters;
            APIGlobalParamList = AAMB.GlobalAppModelParameters;
            InitModelParametersGrid();
            InitGlobalModelParametersGrid();

            mAAMB.AppModelParameters.CollectionChanged += LocalParameters_CollectionChanged;
            UpdateLocalParametersGridHeader();
            mAAMB.GlobalAppModelParameters.CollectionChanged += GloablParameters_CollectionChanged;
            UpdateGlobalParametersGridHeader();
        }
コード例 #29
0
 /// <summary>
 /// Update optional values only for selected parameters
 /// </summary>
 /// <param name="AAM"></param>
 /// <param name="OptionalValuesPerParameterDict"></param>
 /// <param name="SelectedParametersGridList"></param>
 public void PopulateOptionalValuesForAPIParameters(ApplicationAPIModel AAM, Dictionary <Tuple <string, string>, List <string> > OptionalValuesPerParameterDict, List <AppModelParameter> SelectedParametersGridList)
 {
     if (currentParser != null)
     {
         if (currentParser.GetType() == typeof(XMLTemplateParser))
         {
             PopulateXMLOptionalValuesForAPIParameters(AAM, OptionalValuesPerParameterDict, SelectedParametersGridList);
         }
         else if (currentParser.GetType() == typeof(JSONTemplateParser))
         {
             PopulateJSONOptionalValuesForAPIParameters(AAM, OptionalValuesPerParameterDict, SelectedParametersGridList);
         }
     }
 }
コード例 #30
0
 public void GetAllOptionalValuesFromExamplesFiles(ApplicationAPIModel AAM, Dictionary <Tuple <string, string>, List <string> > OptionalValuesPerParameterDict)
 {
     foreach (TemplateFile TF in AAM.OptionalValuesTemplates)
     {
         CreateParser(TF.FilePath);
         if (currentParser.GetType() == typeof(XMLTemplateParser))
         {
             GetXMLAllOptionalValuesFromExamplesFile(TF, OptionalValuesPerParameterDict);
         }
         else if (currentParser.GetType() == typeof(JSONTemplateParser))
         {
             GetJSONAllOptionalValuesFromExamplesFile(TF, OptionalValuesPerParameterDict);
         }
     }
 }