Exemplo n.º 1
0
        /// <summary>
        /// Parse WSE XTestStep to get data.
        /// </summary>
        /// <param name="xTestStep">WSE XTestStep</param>
        /// <param name="payloadParser">XML or Json Payload Parser.
        /// The request payload is extracted from XTestStep.
        /// The response paylod is extracted from Module.
        /// </param>
        public void Parse(XTestStep xTestStep, IPayloadParser payloadParser)
        {
            try {
                var methodParser = new MethodParser();
                Method = methodParser.Parse(xTestStep);

                var addressParser = new AddressParser();
                AddressParserResult addressParserResult = addressParser.Parse(xTestStep);
                Endpoint    = addressParserResult.Endpoint;
                Resource    = addressParserResult.Resource;
                QueryParams = addressParserResult.QueryParams;

                var headerParser = new HeaderParser();
                Headers         = headerParser.Parse(xTestStep, AddOnConstants.TestStepRequestHeadersTql);
                Headers         = CommonUtilities.ModifyContentTypeToEmpty(Headers);
                ResponseHeaders = headerParser.Parse(xTestStep, AddOnConstants.TestStepResponseHeadersTql);

                var statusCodeParser = new StatusCodeParser();
                ResponseStatus = statusCodeParser.ParseResponseStatus(xTestStep);

                RequestPayload = payloadParser.Parse(xTestStep,
                                                     "=>SUBPARTS:XTestStepValue[Name==\"Request\"]->SUBPARTS:XTestStepValue");
                ResponsePayload = payloadParser.Parse(xTestStep.Module, AddOnConstants.ResponsePayloadTql);
                HashCode        = GetHashCode(xTestStep);
            }
            catch (Exception e) {
                FileLogger.Instance.Error(e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles Web service response data in XML/JSON embedded 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)
        {
            if (wseTestStep.TestStepValues == null)
            {
                return;
            }

            if (SpecializationHelper.IsResponseIsUsingEmbeddedModule(wseTestStep,
                                                                     out XModule responseSpecializationModule))
            {
                var responsePayload =
                    payloadParser.Parse(responseSpecializationModule, AddOnConstants.TestStepXmlPayloadTql);
                var apiModule = (apiTestStep.Module as ApiModule);
                apiModule?.APISetMessagePayload(responsePayload);
            }
            else
            {
                successor?.HandleSpecialization(wseTestStep, apiTestStep, payloadParser, payloadSetterFactory);
            }
        }
 /// <summary>
 /// Handles Web service request data in XML/JSON embedded 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)
 {
     if (wseTestStep.TestStepValues == null)
     {
         return;
     }
     if (SpecializationHelper.IsRequestIsUsingEmbeddedModule(wseTestStep,
                                                             out XModule requestSpecializationModule))
     {
         var requestPayload =
             payloadParser.Parse(wseTestStep,
                                 "=>SUBPARTS:XTestStepValue[Name==\"Request\"]->SUBPARTS:XTestStepValue");
         var apiModule = (apiTestStep.Module as ApiModule);
         apiModule?.APISetMessagePayload(requestPayload);
     }
     else
     {
         successor?.HandleSpecialization(wseTestStep, apiTestStep, payloadParser, payloadSetterFactory);
     }
 }