コード例 #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);
            }
        }
        /// <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);
            }
        }
コード例 #3
0
        public MessageBuilder(IMessageParser parser, IPayloadParser position, IPayloadParser veloctiy, IPayloadParser identification)
        {
            this.parser = parser;

            builderMethods.Add(ADSBMessagetype.Position, BuildPositionMessage);
            builderMethods.Add(ADSBMessagetype.Velocity, BuildVelocityMessage);
            builderMethods.Add(ADSBMessagetype.Identification, BuildIdentificationMessage);

            payloadParserPosition       = position;
            payloadParserVelocity       = veloctiy;
            payloadParserIdentification = identification;
        }
コード例 #4
0
        public MessageViewModel()
        {
            messageRepository = ServiceFactory.CreateWebRepository("http://flugmon-it.hs-esslingen.de/subscribe/ads.sentence");
            messageService    = ServiceFactory.CreateMessageService(messageRepository);

            messageParser        = ServiceFactory.CreateMessageParserService();
            positionParser       = ServiceFactory.CreatePayloadParserPosition();
            velocityParser       = ServiceFactory.CreatePayloadParserVelocity();
            identificationParser = ServiceFactory.CreatePayloadParserIdentification();

            messageBuilder = ServiceFactory.CreateMessageBuilderService(messageParser, positionParser, velocityParser, identificationParser);

            Planes = new PlaneContainer();
        }
コード例 #5
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);
            }
        }
コード例 #6
0
        /// <summary>
        /// Handles Web service request/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)
            {
                var wseTestStepValue = (XTestStepValue)wseTestStep.Search(TqlToGetWseTestStepValue)?.FirstOrDefault();
                BodyParamHandler.CreateBodyParameterForRequestAndResponse(
                    apiTestStep,
                    new List <XTestStepValue>()
                {
                    wseTestStepValue
                });
            }
            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);
     }
 }
コード例 #8
0
        /// <summary>
        /// Migrates WSE XTestStep to API XTestStep.(Also Applies any transformation which are performed on Request or Response.Currently a limited list
        /// of transformation is supported.)
        /// </summary>
        /// <param name="rootComponentFolder">Folder on which the migration is performed</param>
        /// <param name="requestApiModule">Request API Module</param>
        /// <param name="responseApiModule">Response API Module</param>
        /// <param name="payloadParser">Instance of XML or JSON parser depending upon Module Type</param>
        /// <param name="payloadSetterFactory">Instance of XML or JSON Setter depending upon Module Type</param>
        /// <param name="wseTestStep">WSE XTestStep to be migrated</param>
        public void Migrate(TCObject rootComponentFolder,
                            ApiModule requestApiModule,
                            ApiModule responseApiModule,
                            IPayloadParser payloadParser,
                            IPayloadSetterFactory payloadSetterFactory,
                            XTestStep wseTestStep)
        {
            try {
                FileLogger.Instance.Info(
                    $"Migrating XTestStep:{wseTestStep.Name} -- NodePath:{wseTestStep.NodePath}");
                bool isWseStepDisabled = wseTestStep.Disabled;
                //disable wse teststep
                wseTestStep.Disabled = true;

                //Get Parent of wse teststep
                var parent = wseTestStep.ParentFolder ?? (dynamic)wseTestStep.TestCase;

                //Create API Request TestStep
                XTestStep requestTestStep = (XTestStep)parent.CreateXTestStepFromXModule(requestApiModule);
                requestTestStep.Name = wseTestStep.Name;

                AbstractSpecializationHandler requestSpecializationHandler =
                    SpecializationFactory.GetRequestSpecializationHandler();
                requestSpecializationHandler.HandleSpecialization(wseTestStep,
                                                                  requestTestStep,
                                                                  payloadParser,
                                                                  payloadSetterFactory);

                RequestValueSetters.ForEach(setter => setter.Execute(requestTestStep, wseTestStep));
                wseTestStep.Reorder(requestTestStep, "Yes");

                //Create API Response TestStep
                XTestStep responseTestStep = (XTestStep)parent.CreateXTestStepFromXModule(responseApiModule);
                responseTestStep.Name = wseTestStep.Name + " Response";

                ResponseValueSetters.ForEach(setter => setter.Execute(responseTestStep, wseTestStep));
                requestTestStep.Reorder(responseTestStep, "Yes");

                AbstractSpecializationHandler responseSpecializationHandler =
                    SpecializationFactory.GetResponseSpecializationHandler();
                responseSpecializationHandler.HandleSpecialization(wseTestStep,
                                                                   responseTestStep,
                                                                   payloadParser,
                                                                   payloadSetterFactory);

                //For Payload
                payloadSetterFactory.GetRequestPayloadSetter().Execute(requestTestStep, wseTestStep);
                payloadSetterFactory.GetResponsePayloadSetter().Execute(responseTestStep, wseTestStep);

                CommonParserMethods.FillTransformRequest(requestTestStep, wseTestStep);
                CommonParserMethods.FillTransformResponse(responseTestStep, wseTestStep);

                if (isWseStepDisabled)
                {
                    requestTestStep.Disable(wseTestStep.DisabledDescription);
                    responseTestStep.Disable(wseTestStep.DisabledDescription);
                    requestTestStep.Disabled  = true;
                    responseTestStep.Disabled = true;
                }

                if (!string.IsNullOrEmpty(wseTestStep.Condition))
                {
                    requestTestStep.Condition  = wseTestStep.Condition;
                    responseTestStep.Condition = wseTestStep.Condition;
                }

                if (!string.IsNullOrEmpty(wseTestStep.Path))
                {
                    requestTestStep.Path  = wseTestStep.Path;
                    responseTestStep.Path = wseTestStep.Path;
                }

                MoveBodyAttributeAtLast(requestTestStep);
                MoveBodyAttributeAtLast(responseTestStep);
            }
            catch (Exception e) {
                FileLogger.Instance.Error(e);
            }
        }
コード例 #9
0
 /// <summary>
 /// Handles all types of Specialization for WSE TestStep
 /// </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 abstract void HandleSpecialization(XTestStep wseTestStep,
                                           XTestStep apiTestStep,
                                           IPayloadParser payloadParser,
                                           IPayloadSetterFactory payloadSetterFactory);
コード例 #10
0
 public static IMessageBuilder CreateMessageBuilderService(IMessageParser messageParser, IPayloadParser position, IPayloadParser velocity, IPayloadParser identification)
 {
     return(new MessageBuilder(messageParser, position, velocity, identification));
 }