public APIModelBodyNodeSyncPage(ApplicationAPIModel applicationAPIModel, List <AppModelParameter> paramsToDelete)
        {
            InitializeComponent();
            mParamsPendingDelete = paramsToDelete;
            mApplicationAPIModel = applicationAPIModel;

            if (APIConfigurationsDocumentParserBase.IsValidXML(mApplicationAPIModel.RequestBody))
            {
                requestBodyType = ApplicationAPIUtils.eContentType.XML;
                XMLDoc          = new XmlDocument();
                XMLDoc.LoadXml(mApplicationAPIModel.RequestBody);
            }
            else if (APIConfigurationsDocumentParserBase.IsValidJson(mApplicationAPIModel.RequestBody))
            {
                requestBodyType = ApplicationAPIUtils.eContentType.JSon;
                JsonDoc         = new JsonExtended(applicationAPIModel.RequestBody);
            }
            else
            {
                requestBodyType = ApplicationAPIUtils.eContentType.TextPlain;
            }
        }
Exemplo n.º 2
0
        private void TestToOutput(SoapUIUtils soapUIUtils, Act act)
        {
            Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >();

            dict = soapUIUtils.RequestsAndResponds();
            foreach (KeyValuePair <string, List <string> > kpr in dict)
            {
                if (!string.IsNullOrEmpty(kpr.Value[1]))
                {
                    string requestQouteFixed = kpr.Value[1].Replace("\"", "");
                    requestQouteFixed = requestQouteFixed.Replace("\0", "");
                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Request", requestQouteFixed);
                }
                if (!string.IsNullOrEmpty(kpr.Value[2]))
                {
                    string responseQouteFixed = string.Empty;

                    //if response is JSON format then not replace double quotes
                    if (kpr.Value[2].IndexOf("{") > -1)
                    {
                        responseQouteFixed = kpr.Value[2];
                    }
                    else
                    {
                        responseQouteFixed = kpr.Value[2].Replace("\"", "");
                    }


                    responseQouteFixed = responseQouteFixed.Replace("\0", "");

                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Response", responseQouteFixed);
                    if (((ActSoapUI)act).AddXMLResponse_Value)
                    {
                        string fileContent = kpr.Value[2];
                        ObservableList <ActReturnValue> ReturnValues = null;
                        if (APIConfigurationsDocumentParserBase.IsValidJson(fileContent))
                        {
                            ReturnValues = JSONTemplateParser.ParseJSONResponseSampleIntoReturnValues(fileContent);
                            foreach (ActReturnValue ReturnValue in ReturnValues)
                            {
                                act.ReturnValues.Add(ReturnValue);
                            }
                        }
                        else if (APIConfigurationsDocumentParserBase.IsValidXML(fileContent))
                        {
                            XmlDocument xmlDoc1 = new XmlDocument();
                            xmlDoc1.LoadXml(kpr.Value[2]);

                            List <GingerCore.General.XmlNodeItem> outputTagsList1 = new List <GingerCore.General.XmlNodeItem>();
                            outputTagsList1 = General.GetXMLNodesItems(xmlDoc1);
                            foreach (GingerCore.General.XmlNodeItem outputItem in outputTagsList1)
                            {
                                act.AddOrUpdateReturnParamActualWithPath(outputItem.param, outputItem.value, outputItem.path);
                            }
                        }
                    }
                }
                if (!string.IsNullOrEmpty(kpr.Value[4]))
                {
                    string messageQouteFixed = kpr.Value[4].Replace("\"", "");
                    messageQouteFixed = messageQouteFixed.Replace("\0", "");
                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Message", kpr.Value[4]);
                }
                if (!string.IsNullOrEmpty(kpr.Value[5]))
                {
                    string propertiesQouteFixed = kpr.Value[4].Replace("\"", "");
                    propertiesQouteFixed = propertiesQouteFixed.Replace("\0", "");
                    act.AddOrUpdateReturnParamActual(kpr.Value[0] + "-Properties", kpr.Value[5]);
                }
            }

            Dictionary <List <string>, List <string> > dictValues = new Dictionary <List <string>, List <string> >();

            dictValues = soapUIUtils.OutputParamAndValues();
            foreach (KeyValuePair <List <string>, List <string> > Kpr in dictValues)
            {
                int index = 0;
                if (Kpr.Key.Count() != 0 && Kpr.Value.Count() != 0)
                {
                    foreach (string property in Kpr.Key)
                    {
                        act.AddOrUpdateReturnParamActual(Kpr.Key[index], Kpr.Value[index]);
                        index++;
                    }
                }
            }
        }