/// <summary>
        /// Handles response data in Xml/JSON Resource specialization
        /// </summary>
        /// <param name="wseTestStep">TestStep of WSE Artifacts</param>
        /// <param name="apiTestStep">TestStep of API Engine Artifacts</param>
        /// <param name="payloadParser">Parse xml and json payload from Wse XModules and TestSteps</param>
        /// <param name="payloadSetterFactory">Create module attributes and Set values for payload in for Api artifacts </param>
        public override void HandleSpecialization(XTestStep wseTestStep,
                                                  XTestStep apiTestStep,
                                                  IPayloadParser payloadParser,
                                                  IPayloadSetterFactory payloadSetterFactory)
        {
            XModule specializationModule =
                (XModule)wseTestStep.Search(TqlToGetWseTestStepSpecializationModule)?.FirstOrDefault();

            if (specializationModule != null)
            {
                try {
                    var wseTestStepValue =
                        (XTestStepValue)wseTestStep.Search(TqlToGetWseTestStepValue)?.FirstOrDefault();
                    if (wseTestStepValue != null && !StringExtensions.IsNullOrBlankInTosca(wseTestStepValue.Value))
                    {
                        TestCase testCase = (TestCase)wseTestStep.Search(TqlToSearchTestCase)?.FirstOrDefault();

                        if (testCase != null)
                        {
                            ResourceManagerHandler.AddResourceToResourceId(testCase.Name, wseTestStepValue.Value);
                        }
                    }
                }
                catch (Exception ex) {
                    FileLogger.Instance.Error("Unable to fetch WSE tesstep value ", ex);
                }
            }
            else
            {
                successor?.HandleSpecialization(wseTestStep, apiTestStep, payloadParser, payloadSetterFactory);
            }
        }
Exemple #2
0
        /// <summary>
        /// Replace Resource with LastResponseResource in Existing TestSteps
        /// </summary>
        /// <param name="objectToExecuteOn">TCObject</param>
        public static void ReplaceResourceWithLastResponseResource(TCObject objectToExecuteOn)
        {
            try {
                var getResourceValueTuple =
                    ResourceManagerHandler.GetResourceFromResourceId(ResourceManagerHandler.ResourceId);
                if (getResourceValueTuple.Item1 && getResourceValueTuple.Item2 != null)
                {
                    foreach (var testCaseResource in getResourceValueTuple.Item2.TestCaseResources)
                    {
                        var testcases = objectToExecuteOn.Search(
                            String.Format("=>SUBPARTS: TestCase[Name == \"{0}\"]", testCaseResource.TestCaseName));
                        foreach (var testcase in testcases)
                        {
                            foreach (var resourceName in testCaseResource.ResourceNameList)
                            {
                                var xTestStepValues = testcase.Search(
                                    String.Format(
                                        "=>INTERSECTION(=>UNION(=>SUBPARTS:XTestStepValue[Value==\"{0}\"], =>return SUBPARTS:XTestStepValue[Value==\"{{RES[{0}]}}\"]),=>return UNION(=>SUBPARTS:XTestStepValue[Value==\"{0}\"], =>return SUBPARTS:XTestStepValue[Value==\"{{RES[{0}]}}\"])->ModuleAttribute->Module:XModule[Engine != \"Webservice\"])",
                                        resourceName));
                                foreach (var xTestStepValue in xTestStepValues)
                                {
                                    if (xTestStepValue is XTestStepValue)
                                    {
                                        var x = xTestStepValue as XTestStepValue;
                                        x.Value = x.Value.Replace(x.Value.ExtractStringFromResource(),
                                                                  "LastResponseResource");
                                    }
                                }
                            }
                        }
                    }

                    ResourceManagerHandler.DeleteResource(ResourceManagerHandler.ResourceId);
                }
            }
            catch (Exception ex) {
                FileLogger.Instance.Error("There is an issue in creating resource manager list.", ex);
            }
        }