예제 #1
0
        public void SetUp()
        {
            theInitializer = new DefaultChannelInitializer <FakeTopic>();
            theWriter      = new RecordingServerEventWriter();

            theCache = MockRepository.GenerateMock <ITopicChannelCache>();
            ITopicChannel <FakeTopic> channel = new TopicChannel <FakeTopic>(new EventQueue <FakeTopic>());

            theChannel = channel.Channel;
            theTopic   = new FakeTopic();

            theCache.Stub(x => x.TryGetChannelFor(theTopic, out channel)).Return(true).OutRef(channel);

            theChannelWriter = new ChannelWriter <FakeTopic>(theWriter, theWriter, theCache, theInitializer);

            e1 = new ServerEvent("1", "data-1");
            e2 = new ServerEvent("2", "data-2");
            e3 = new ServerEvent("3", "data-3");
            e4 = new ServerEvent("4", "data-4");
            e5 = new ServerEvent("5", "data-5");

            ie1 = new ServerEvent("random1", "initialization data-1");
            ie2 = new ServerEvent("random2", "initialization data-2");
            ie3 = new ServerEvent("3", "initialization data-3");
        }
예제 #2
0
        public void failure_to_acquire_channel_terminates_without_errors()
        {
            theWriter = new RecordingServerEventWriter();

            var cache = MockRepository.GenerateMock <ITopicChannelCache>();
            ITopicChannel <FakeTopic> channel = new TopicChannel <FakeTopic>(new EventQueue <FakeTopic>());

            theChannel = channel.Channel;
            theTopic   = new FakeTopic();

            cache.Stub(x => x.TryGetChannelFor(theTopic, out channel)).Return(false);

            theChannelWriter = new ChannelWriter <FakeTopic>(theWriter, theWriter, cache, theInitializer);
            var task = theChannelWriter.Write(theTopic);

            task.Wait(150).ShouldBeTrue();
        }
예제 #3
0
        public void publish_against_a_different_interface()
        {
            var oddQueue = MockFor <IOddQueue>();
            var @event   = new ServerEvent("1", "some text");
            var topic    = new FakeTopic
            {
                Name = "something"
            };

            var theChannel = new TopicChannel <FakeTopic>(oddQueue);

            MockFor <ITopicChannelCache>().Stub(x => x.ChannelFor(topic)).Return(theChannel);

            ClassUnderTest.WriteTo <FakeTopic, IOddQueue>(topic, x =>
            {
                x.WriteOddly(@event);
            });

            oddQueue.AssertWasCalled(x => x.WriteOddly(@event));
        }
        public void RenderTemplateAsyncWithMissingMessagingObjectWithWarning(ITemplateRenderer renderer, AzureIntegrationServicesModel model, MessagingObject messagingObject, string templateContent, string renderedContent, Exception e)
        {
            "Given a template renderer"
            .x(() => renderer = new LiquidTemplateRenderer(_mockLogger.Object));

            "And a model"
            .x(() => model = _model);

            "And a missing messaging object"
            .x(() => messagingObject = new TopicChannel("MissingChannel")
            {
                Key = "MessageBus:MissingApp:MissingChannel"
            });

            "And a template content"
            .x(() => templateContent = _templateChannelContent);

            "When rendering the template"
            .x(async() => e = await Record.ExceptionAsync(async() => renderedContent = await renderer.RenderTemplateAsync(templateContent, model, messagingObject)));

            "Then the render should succeed"
            .x(() => e.Should().BeNull());

            "And the rendered content should not have expected values from the model"
            .x(() =>
            {
                renderedContent.Should().NotBeNull().And.Be("").And.NotContainAny("{{").And.NotContainAny("}}");

                // Verify warning was raised
                _mockLogger.Verify(l => l.Log(
                                       It.Is <LogLevel>(l => l == LogLevel.Warning),
                                       It.IsAny <EventId>(),
                                       It.Is <It.IsAnyType>((v, t) => v.ToString().Contains("does not appear in the target model", StringComparison.CurrentCultureIgnoreCase)),
                                       It.IsAny <Exception>(),
                                       It.Is <Func <It.IsAnyType, Exception, string> >((v, t) => true)), Times.Once);
            });
        }
예제 #5
0
        /// <summary>
        /// Builds a target model.
        /// </summary>
        /// <param name="model">The model.</param>
        private static void BuildTargetModel(AzureIntegrationServicesModel model)
        {
            model.MigrationTarget.TargetEnvironment     = AzureIntegrationServicesTargetEnvironment.Consumption;
            model.MigrationTarget.DeploymentEnvironment = "dev";
            model.MigrationTarget.AzurePrimaryRegion    = "UK South";
            model.MigrationTarget.AzureSecondaryRegion  = "West US";
            model.MigrationTarget.UniqueDeploymentId    = "unit-test";
            model.MigrationTarget.MessageBus            = new MessageBus()
            {
                Name           = "Message Bus",
                Key            = "MessageBus",
                Type           = MessagingObjectType.MessageBus,
                Description    = "Azure Integration Services Message Bus",
                ResourceMapKey = "messageBus",
                Rating         = ConversionRating.NotSupported
            };

            // Message Bus resources
            var resource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "deployResources",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "deploy-resources",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = ""
            };

            resource1.ResourceTemplateFiles.Add("Deploy-All.ps1.liquid");
            resource1.ResourceTemplateFiles.Add("TearDown-All.ps1.liquid");
            model.MigrationTarget.MessageBus.Resources.Add(resource1);

            var resource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "messageBusAzureResourceGroup",
                TemplateType = "microsoft.template.arm",
                ResourceName = "arrg-aimmsgbus-dev-uksouth",
                ResourceType = "microsoft.groups.azureresourcegroup",
                OutputPath   = "messagebus/messagebusgroup",
            };

            resource2.Tags.Add("ApplicationName", "AIM-MessageBus");
            resource2.Tags.Add("Env", "dev");
            resource2.Parameters.Add("azure_primary_region", "UK South");
            resource2.Parameters.Add("azure_secondary_region", "West US");
            resource2.Parameters.Add("azure_subscription_id", "");
            resource2.ResourceTemplateFiles.Add("messagebus/messagebusgroup/messagebusgroup.dev.parameters.json.liquid");
            resource2.ResourceTemplateFiles.Add("messagebus/messagebusgroup/messagebusgroup.json.liquid");
            model.MigrationTarget.MessageBus.Resources.Add(resource2);

            var resource3 = new TargetResourceTemplate()
            {
                TemplateKey  = "deployMessageBusGroup",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "arrg-aimmsgbus-dev-uksouth",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "messagebus/messagebusgroup",
            };

            resource3.Parameters.Add("azure_primary_region", "UK South");
            resource3.Parameters.Add("azure_secondary_region", "West US");
            resource3.Parameters.Add("azure_subscription_id", "");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/Deploy-10-MessageBusGroup.ps1.liquid");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/New-MessageBusGroup.ps1.liquid");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/TearDown-10-MessageBusGroup.ps1.liquid");
            resource3.ResourceTemplateFiles.Add("messagebus/messagebusgroup/Remove-MessageBusGroup.ps1.liquid");
            model.MigrationTarget.MessageBus.Resources.Add(resource3);

            var resource4 = new TargetResourceTemplate()
            {
                TemplateKey  = "messageBusServiceAzureRole",
                TemplateType = "microsoft.template.json",
                ResourceName = "arapim-aimmsgbussvc-dev",
                ResourceType = "microsoft.security.azurerole",
                OutputPath   = "messagebus/messagebusservice"
            };

            resource4.ResourceTemplateFiles.Add("messagebus/messagebusservice/messagebusservice.logicappsrole.json");
            model.MigrationTarget.MessageBus.Resources.Add(resource4);

            // Applications
            var application1 = new Application()
            {
                Name           = "BTS2010FlatFilePipelineSample",
                Key            = "MessageBus:BTS2010FlatFilePipelineSample",
                Type           = MessagingObjectType.Application,
                Description    = "Azure Integration Application",
                ResourceMapKey = "applicationBTS2010FlatFilePipelineSample",
                Rating         = ConversionRating.NoRating,
            };

            model.MigrationTarget.MessageBus.Applications.Add(application1);

            var appresource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "applicationAzureResourceGroupBTS2010FlatFilePipelineSample",
                TemplateType = "microsoft.template.arm",
                ResourceName = "arrg-aimapp-bts2010flatfilepipelinesample-dev-uksouth",
                ResourceType = "microsoft.groups.azureresourcegroup",
                OutputPath   = "applications/bts2010flatfilepipelinesample/bts2010flatfilepipelinesamplegroup",
            };

            appresource1.Tags.Add("ApplicationName", "BTS2010FlatFilePipelineSample");
            appresource1.Tags.Add("Env", "dev");
            appresource1.Parameters.Add("azure_primary_region", "UK South");
            appresource1.Parameters.Add("azure_secondary_region", "West US");
            appresource1.Parameters.Add("azure_subscription_id", "");
            appresource1.ResourceTemplateFiles.Add("application/applicationgroup/applicationgroup.json.liquid");
            appresource1.ResourceTemplateFiles.Add("application/applicationgroup/applicationgroup.dev.parameters.json.liquid");
            application1.Resources.Add(appresource1);

            var appresource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "deployApplicationGroupBTS2010FlatFilePipelineSample",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "arrg-aimapp-bts2010flatfilepipelinesample-dev-uksouth",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "applications/bts2010flatfilepipelinesample/bts2010flatfilepipelinesamplegroup",
            };

            appresource2.Parameters.Add("azure_primary_region", "UK South");
            appresource2.Parameters.Add("azure_secondary_region", "West US");
            appresource2.Parameters.Add("azure_subscription_id", "");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/Deploy-10-ApplicationGroup.ps1.liquid");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/New-ApplicationGroup.ps1.liquid");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/TearDown-10-ApplicationGroup.ps1.liquid");
            appresource2.ResourceTemplateFiles.Add("application/applicationgroup/Remove-ApplicationGroup.ps1.liquid");
            application1.Resources.Add(appresource2);

            // Messages in the application
            var documentmessage1 = new DocumentMessage()
            {
                MessageType   = MessageType.Document,
                ContentType   = MessageContentType.Xml,
                MessageSchema = new MessageSchema()
                {
                    Name           = "NewOrder",
                    ResourceKeyRef = "BTS2010FlatFilePipelineSample:ITEM~0:BTS2010FlatFilePipelineSample:NewOrder:schema:Order"
                },
                Name           = "NewOrder",
                Key            = "MessageBus:BTS2010FlatFilePipelineSample:NewOrder",
                Type           = MessagingObjectType.Message,
                Description    = "Azure Integration Application Schema",
                ResourceMapKey = "applicationMessageBTS2010FlatFilePipelineSampleNewOrder",
                Rating         = ConversionRating.NoRating
            };

            application1.Messages.Add(documentmessage1);

            var messageresource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "deploySchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            messageresource1.Parameters.Add("azure_primary_region", "UK South");
            messageresource1.Parameters.Add("azure_secondary_region", "West US");
            messageresource1.Parameters.Add("azure_subscription_id", "");
            messageresource1.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            messageresource1.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            messageresource1.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/Deploy-100-Schema.ps1.liquid");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/New-Schema.ps1.liquid");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/Remove-Schema.ps1.liquid");
            messageresource1.ResourceTemplateFiles.Add("messages/schemas/TearDown-100-Schema.ps1.liquid");
            documentmessage1.Resources.Add(messageresource1);

            var messageresource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "messagesAzureIntegrationAccountSchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.json",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.schemas.xml",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            messageresource2.Tags.Add("Application", "BTS2010FlatFilePipelineSample");
            messageresource2.Tags.Add("Env", "dev");
            messageresource2.Parameters.Add("azure_primary_region", "UK South");
            messageresource2.Parameters.Add("azure_secondary_region", "West US");
            messageresource2.Parameters.Add("azure_subscription_id", "");
            messageresource2.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            messageresource2.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            messageresource2.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            messageresource2.ResourceTemplateFiles.Add("messages/schemas/requestbody.dev.json.liquid");
            documentmessage1.Resources.Add(messageresource2);

            // Endpoints
            var ftpadapter1 = new AdapterEndpoint()
            {
                Type                     = MessagingObjectType.Endpoint,
                AdapterProtocol          = "FTP",
                MessageExchangePattern   = MessageExchangePattern.Receive,
                Name                     = "FTP Receive",
                Description              = "FTP Receive Adapter",
                EndpointType             = EndpointType.Adapter,
                MessageDeliveryGuarantee = MessageDeliveryGuarantee.AtLeastOnce,
                Activator                = true,
            };

            ftpadapter1.MessageKeyRefs.Add("MessageBus:BTS2010FlatFilePipelineSample:NewOrder");
            ftpadapter1.OutputChannelKeyRef = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter";
            ftpadapter1.Properties.Add("scenario", "Aim.BizTalk.FTPPassthru.RcvFile.RcvFile.FTP");
            ftpadapter1.Properties.Add("scenarioStep", "ftpReceiveAdapter");
            ftpadapter1.Properties.Add("configuration", new Dictionary <string, object>
            {
                { "btsReceivePortName", "RcvFile" }
            });
            ftpadapter1.ReportMessages.Add(new ReportMessage()
            {
                Severity = MessageSeverity.Error, Message = ModelResources.ExampleErrorMessage
            });
            ftpadapter1.ReportMessages.Add(new ReportMessage()
            {
                Severity = MessageSeverity.Warning, Message = ModelResources.ExampleWarningMessage
            });
            ftpadapter1.ReportMessages.Add(new ReportMessage()
            {
                Severity = MessageSeverity.Information, Message = ModelResources.ExampleInformationMessage
            });
            application1.Endpoints.Add(ftpadapter1);

            var adapterresource1 = new TargetResourceTemplate()
            {
                TemplateKey  = "deploySchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.powershell",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.scripts.powershell",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            adapterresource1.Parameters.Add("azure_primary_region", "UK South");
            adapterresource1.Parameters.Add("azure_secondary_region", "West US");
            adapterresource1.Parameters.Add("azure_subscription_id", "");
            adapterresource1.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            adapterresource1.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            adapterresource1.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/Deploy-100-Schema.ps1.liquid");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/New-Schema.ps1.liquid");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/Remove-Schema.ps1.liquid");
            adapterresource1.ResourceTemplateFiles.Add("messages/schemas/TearDown-100-Schema.ps1.liquid");
            ftpadapter1.Resources.Add(adapterresource1);

            var adapterresource2 = new TargetResourceTemplate()
            {
                TemplateKey  = "messagesAzureIntegrationAccountSchemaBTS2010FlatFilePipelineSampleNewOrder",
                TemplateType = "microsoft.template.json",
                ResourceName = "NewOrder",
                ResourceType = "microsoft.schemas.xml",
                OutputPath   = "applications/BTS2010FlatFilePipelineSample/messages/neworder",
            };

            adapterresource2.Tags.Add("Application", "BTS2010FlatFilePipelineSample");
            adapterresource2.Tags.Add("Env", "dev");
            adapterresource2.Parameters.Add("azure_primary_region", "UK South");
            adapterresource2.Parameters.Add("azure_secondary_region", "West US");
            adapterresource2.Parameters.Add("azure_subscription_id", "");
            adapterresource2.Parameters.Add("azure_resource_group_name", "arrg-aimmsgbus-dev-uksouth");
            adapterresource2.Parameters.Add("azure_integration_account_name", "arintacc-aimartifactstore-dev-uksouth");
            adapterresource2.Parameters.Add("azure_message_schema_name", "BTS2010FlatFilePipelineSample.NewOrder");
            adapterresource2.ResourceTemplateFiles.Add("messages/schemas/requestbody.dev.json.liquid");
            ftpadapter1.Resources.Add(adapterresource2);

            // Create the channel for the FTP adapter
            var channel1 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.RoutingSlipRouter intermediary.",
            };

            application1.Channels.Add(channel1);

            var routingSlipRouter = new RoutingSlipRouter()
            {
                Type              = MessagingObjectType.Intermediary,
                IntermediaryType  = IntermediaryType.MessageRouter,
                MessageRouterType = MessageRouterType.ContentBasedRouter,
                Name              = "Routing Slip Router",
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:RoutingSlipRouter:RcvFile.FTP-ContentPromoter",
                Description = "The routing slip router calls the next step in the route which is Content Promoter.",
            };

            routingSlipRouter.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RcvFile.FTP-RoutingSlipRouter");
            routingSlipRouter.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            application1.Intermediaries.Add(routingSlipRouter);

            var channel2 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.",
                TriggerUrl  = "/routingManager/route/contentPromoter"
            };

            application1.Channels.Add(channel2);

            var contentPromoter = new ContentPromoter()
            {
                Type                 = MessagingObjectType.Intermediary,
                IntermediaryType     = IntermediaryType.MessageProcessor,
                MessageProcessorType = MessageProcessorType.ContentPromoter,
            };

            contentPromoter.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            contentPromoter.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:ContentPromoter-RoutingSlipRouter");
            application1.Intermediaries.Add(contentPromoter);

            var channel3 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:ContentPromoter-RoutingSlipRouter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.RoutingSlipRouter intermediary.",
            };

            application1.Channels.Add(channel3);

            var routingSlipRouter2 = new RoutingSlipRouter()
            {
                Type              = MessagingObjectType.Intermediary,
                IntermediaryType  = IntermediaryType.MessageRouter,
                MessageRouterType = MessageRouterType.ContentBasedRouter,
                Name              = "Routing Slip Router",
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:ContentPromoter",
                Description = "The routing slip router calls the next step in the route which is Content Promoter.",
            };

            routingSlipRouter2.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            routingSlipRouter2.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            application1.Intermediaries.Add(routingSlipRouter2);

            var channel4 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.",
                TriggerUrl  = "/routingManager/route/contentPromoter"
            };

            application1.Channels.Add(channel4);

            var contentPromoter2 = new ContentPromoter()
            {
                Type                 = MessagingObjectType.Intermediary,
                IntermediaryType     = IntermediaryType.MessageProcessor,
                MessageProcessorType = MessageProcessorType.ContentPromoter,
                Name                 = "Content Promoter",
                Key = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:ContentPromoter",
            };

            contentPromoter2.InputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            contentPromoter2.OutputChannelKeyRefs.Add("MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter");
            application1.Intermediaries.Add(contentPromoter2);

            var channel5 = new TriggerChannel()
            {
                Type        = MessagingObjectType.Channel,
                ChannelType = ChannelType.PointToPoint,
                Key         = "MessageBus:Aim.BizTalk.FTPPassthru:RcvFile:RcvFile.FTP:TriggerChannel:RoutingSlipRouter-ContentPromoter",
                Name        = "Trigger Channel",
                Description = "The trigger channel sends a message to a URL endpoint which triggers the Microsoft.AzureIntegrationMigration.ApplicationModel.Target.Intermediaries.ContentPromoter intermediary.",
                TriggerUrl  = "/routingManager/route/contentPromoter"
            };

            application1.Channels.Add(channel5);

            // System application
            var systemapp = new Application()
            {
                Name           = "System Application",
                Key            = "MessageBus:SystemApplication",
                Type           = MessagingObjectType.Application,
                Description    = "Azure Integration System Application",
                ResourceMapKey = "applicationSystemApplication",
                Rating         = ConversionRating.NoRating,
            };

            model.MigrationTarget.MessageBus.Applications.Add(systemapp);

            // Channels in the system application
            var topicchannel1 = new TopicChannel()
            {
                ChannelType    = ChannelType.PublishSubscribe,
                Name           = "Message Box",
                Key            = "MessageBus:SystemApplication:MessageBox",
                Type           = MessagingObjectType.Channel,
                Description    = "Azure Integration Message Box",
                ResourceMapKey = "messageBox",
                Rating         = ConversionRating.NotSupported
            };

            systemapp.Channels.Add(topicchannel1);
        }
예제 #6
0
        /// <summary>
        /// Gets a populated model to use for the tests.
        /// </summary>
        /// <returns>A model instance.</returns>
        public static AzureIntegrationServicesModel GetModel()
        {
            var model = new AzureIntegrationServicesModel();

            model.MigrationTarget.TargetEnvironment     = AzureIntegrationServicesTargetEnvironment.Consumption;
            model.MigrationTarget.DeploymentEnvironment = "dev";
            model.MigrationTarget.AzureSubscriptionId   = "azure-subs-id";
            model.MigrationTarget.AzurePrimaryRegion    = "UK South";
            model.MigrationTarget.AzureSecondaryRegion  = "UK West";

            // Add a message bus
            model.MigrationTarget.MessageBus = new MessageBus()
            {
                Name           = "ContosoMessageBus",
                Key            = "ContosoMessageBus",
                ResourceMapKey = "messageBus"
            };

            // Add an application
            var systemApp = new Application()
            {
                Name = "System",
                Key  = "ContosoMessageBus:System"
            };

            model.MigrationTarget.MessageBus.Applications.Add(systemApp);

            var app = new Application()
            {
                Name           = "AppA",
                Key            = "ContosoMessageBus:AppA",
                ResourceMapKey = "application"
            };

            model.MigrationTarget.MessageBus.Applications.Add(app);

            // Add an application message
            var appMessage = new DocumentMessage()
            {
                Name           = "PurchaseOrderFlatFile",
                Key            = "ContosoMessageBus:AppA:PurchaseOrderFlatFile",
                ContentType    = MessageContentType.Xml,
                ResourceMapKey = "applicationMessage"
            };

            app.Messages.Add(appMessage);

            // Add a message box
            var messageBox = new TopicChannel()
            {
                Name           = "MessageBox",
                Key            = "ContosoMessageBus:System:MessageBox",
                ResourceMapKey = "messageBox"
            };

            systemApp.Channels.Add(messageBox);

            // Add a message agent
            var messageAgent = new ContentBasedRouter()
            {
                Name           = "MessageAgent",
                Key            = "ContosoMessageBus:System:MessageAgent",
                ResourceMapKey = "messageAgent"
            };

            systemApp.Intermediaries.Add(messageAgent);

            // Add a process manager
            var processManager = new ProcessManager()
            {
                Name           = "FtpTransformWorkflow",
                Key            = "ContosoMessageBus:AppA:FtpTransformWorkflow",
                ResourceMapKey = "processManager"
            };

            processManager.WorkflowModel = GetWorkflowModel();
            app.Intermediaries.Add(processManager);

            // Add workflow model to process manager
            // Add an FTP endpoint
            var ftpReceive = new AdapterEndpoint()
            {
                Name           = "FtpReceive",
                Key            = "ContosoMessageBus:System:FtpReceive",
                ResourceMapKey = "ftpReceive"
            };

            systemApp.Endpoints.Add(ftpReceive);

            return(model);
        }
예제 #7
0
        /// <summary>
        /// Creates the message box channels.
        /// </summary>
        /// <param name="systemApplication">The application in the target.</param>
        private void CreateMessageBoxChannels(Application systemApplication)
        {
            _logger.LogDebug(TraceMessages.CreatingTopicChannel, RuleName, MigrationTargetResources.MessageBoxName);

            // Create a topic channel representing the normal queue in the message box
            var topicChannel = new TopicChannel(MigrationTargetResources.MessageBoxName)
            {
                Description    = MigrationTargetResources.MessageBoxDescription,
                Key            = $"{systemApplication.Key}:{ModelConstants.MessageBoxLeafKey}",
                Rating         = ConversionRating.FullConversion,
                ResourceMapKey = "messageBox",
                TopicName      = "messagebox"
            };

            // Add to target application
            systemApplication.Channels.Add(topicChannel);

            // Create a topic channel representing the response queue in the message box
            var topicResponseChannel = new TopicChannel(MigrationTargetResources.MessageBoxResponseName)
            {
                Description    = MigrationTargetResources.MessageBoxResponseDescription,
                Key            = $"{systemApplication.Key}:{ModelConstants.MessageBoxResponseLeafKey}",
                Rating         = ConversionRating.FullConversion,
                ResourceMapKey = "messageBoxResponse",
                TopicName      = "messageboxresponse"
            };

            // Add to target application
            systemApplication.Channels.Add(topicResponseChannel);

            _logger.LogDebug(TraceMessages.CreatingQueueChannel, RuleName, MigrationTargetResources.SuspendQueueName);

            // Create a topic channel representing the suspend queue in the message box
            var suspendTopicChannel = new TopicChannel(MigrationTargetResources.SuspendQueueName)
            {
                Description    = MigrationTargetResources.SuspendQueueDescription,
                Key            = $"{systemApplication.Key}:{ModelConstants.SuspendQueueLeafKey}",
                ChannelType    = ChannelType.InvalidMessage,
                Rating         = ConversionRating.FullConversion,
                ResourceMapKey = "suspendQueue",
                TopicName      = "suspendqueue"
            };

            // Add to target application
            systemApplication.Channels.Add(suspendTopicChannel);

            _logger.LogDebug(TraceMessages.CreatingQueueChannel, RuleName, MigrationTargetResources.InterchangeQueueName);

            // Create a correlating channel representing an interchange queue for aggregating interchanges for
            // recoverable interchange processing.
            var interchangeQueueChannel = new CorrelatingQueueChannel(MigrationTargetResources.InterchangeQueueName)
            {
                Description = MigrationTargetResources.InterchangeQueueDescription,
                Key         = $"{systemApplication.Key}:{ModelConstants.InterchangeQueueLeafKey}",
                Rating      = ConversionRating.NoAutomaticConversion,
                QueueName   = "interchangeQueue"
            };

            // Add to target application
            systemApplication.Channels.Add(interchangeQueueChannel);
        }
예제 #8
0
        /// <summary>
        /// Creates a default object model for converting.
        /// </summary>
        /// <returns></returns>
        public static AzureIntegrationServicesModel CreateDefaultModelForConverting()
        {
            var model = new AzureIntegrationServicesModel();

            // Create a report node with a resource container and resource definitions
            var resourceContainer = new ResourceContainer()
            {
                Name        = "TestApp1.msi",
                Description = "This is the description of the MSI.",
                Type        = ModelConstants.ResourceContainerMsi,
                Key         = "test-app-1-container-key"
            };

            model.MigrationSource.ResourceContainers.Add(resourceContainer);

            var appResourceDefinition1 = new ResourceDefinition()
            {
                Name        = "App 1 Resource Definition",
                Key         = "app-1",
                Description = "App 1 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition1);

            var appResource1 = new ResourceItem
            {
                Name        = "App 1 Resource Definition Application",
                Key         = "app-resource-1",
                Description = "App 1 Resource Description",
                Type        = ModelConstants.ResourceApplication
            };

            appResourceDefinition1.Resources.Add(appResource1);

            var appResourceDefinition2 = new ResourceDefinition()
            {
                Name        = "App 2 Resource Definition",
                Key         = "app-2",
                Description = "App 2 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition2);

            var appResource2 = new ResourceItem
            {
                Name        = "App 2 Resource Definition Application",
                Key         = "app-resource-2",
                Description = "App 1 Resource Description",
                Type        = ModelConstants.ResourceApplication
            };

            appResourceDefinition2.Resources.Add(appResource2);

            var appResourceDefinition3 = new ResourceDefinition()
            {
                Name        = "App 3 Resource Definition",
                Key         = "app-3",
                Description = "App 3 Description",
                Type        = ModelConstants.ResourceDefinitionApplicationDefinition
            };

            resourceContainer.ResourceDefinitions.Add(appResourceDefinition3);

            var appResource3 = new ResourceItem
            {
                Name        = "App 3 Resource Definition Application",
                Key         = "app-resource-3",
                Description = "App 3 Resource Description",
                Type        = ModelConstants.ResourceApplication
            };

            appResourceDefinition3.Resources.Add(appResource3);

            var schemaResourceDefinition1 = new ResourceDefinition()
            {
                Name            = "DocumentSchema1",
                Description     = "This is document schema 1.",
                Type            = ModelConstants.ResourceDefinitionSchema,
                Key             = "document-schema-1",
                ResourceContent = "<some xml>"
            };

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition1);

            var schemaResource1 = new ResourceItem()
            {
                Name        = "DocumentSchema1",
                Description = "This is document schema 1.",
                Type        = ModelConstants.ResourceDocumentSchema,
                Key         = "document-schema-1:schema1",
                ParentRefId = schemaResourceDefinition1.RefId
            };

            schemaResourceDefinition1.Resources.Add(schemaResource1);

            var messageResource1 = new ResourceItem()
            {
                Name        = "Message1",
                Description = "This is message 1.",
                Type        = ModelConstants.ResourceMessageType,
                Key         = "document-schema-1:schema1:message1",
                ParentRefId = schemaResource1.RefId
            };

            schemaResource1.Resources.Add(messageResource1);

            var schemaResourceDefinition2 = new ResourceDefinition()
            {
                Name        = "DocumentSchema2",
                Description = "This is document schema 2.",
                Type        = ModelConstants.ResourceDefinitionSchema,
                Key         = "document-schema-2",
                ParentRefId = resourceContainer.RefId
            };

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition2);

            var schemaResource2 = new ResourceItem()
            {
                Name        = "DocumentSchema2",
                Description = "This is document schema 2.",
                Type        = ModelConstants.ResourceDocumentSchema,
                Key         = "document-schema-2:schema2",
                ParentRefId = schemaResourceDefinition2.RefId
            };

            schemaResourceDefinition2.Resources.Add(schemaResource2);

            var messageResource2 = new ResourceItem()
            {
                Name        = "Message2",
                Description = "This is message 2.",
                Type        = ModelConstants.ResourceMessageType,
                Key         = "document-schema-2:schema2:message2",
                ParentRefId = schemaResource2.RefId
            };

            schemaResource2.Resources.Add(messageResource2);

            var schemaResourceDefinition3 = new ResourceDefinition()
            {
                Name        = "PropertySchema1",
                Description = "This is property schema 1.",
                Type        = ModelConstants.ResourceDefinitionSchema,
                Key         = "property-schema-1",
                ParentRefId = resourceContainer.RefId
            };

            resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition3);

            var schemaResource3 = new ResourceItem()
            {
                Name        = "PropertySchema1",
                Description = "This is property schema 2.",
                Type        = ModelConstants.ResourceDocumentSchema,
                Key         = "property-schema-1:schema",
                ParentRefId = schemaResourceDefinition3.RefId
            };

            schemaResourceDefinition3.Resources.Add(schemaResource3);

            var messageResource3 = new ResourceItem()
            {
                Name        = "Message3",
                Description = "This is message 3.",
                Type        = ModelConstants.ResourceMessageType,
                Key         = "document-schema-3:schema3:message3",
                ParentRefId = schemaResource3.RefId
            };

            schemaResource3.Resources.Add(messageResource3);

            var schemaResource3Property1 = new ResourceItem()
            {
                Name        = "Property1",
                Description = "This is property 2",
                Key         = "property-schema-1:schema:Property1",
                Type        = ModelConstants.ResourcePropertySchema,
                ParentRefId = schemaResourceDefinition3.RefId
            };

            schemaResourceDefinition3.Resources.Add(schemaResource3Property1);

            var schemaResource3Property2 = new ResourceItem()
            {
                Name        = "Property2",
                Description = "This is property 2",
                Key         = "property-schema-1:schema:Property2",
                Type        = ModelConstants.ResourcePropertySchema,
                ParentRefId = schemaResourceDefinition3.RefId
            };

            schemaResourceDefinition3.Resources.Add(schemaResource3Property2);

            var transformResourceDefinition1 = new ResourceDefinition()
            {
                Name            = "Transform1",
                Description     = "This is transform 1.",
                Type            = ModelConstants.ResourceDefinitionMap,
                Key             = "transform-1",
                ParentRefId     = resourceContainer.RefId,
                ResourceContent = "<some xml>"
            };

            resourceContainer.ResourceDefinitions.Add(transformResourceDefinition1);

            var transformResource1 = new ResourceItem()
            {
                Name        = "Transform1",
                Description = "This is the transform 1, resource",
                Type        = ModelConstants.ResourceMap,
                Key         = "transform-1-resource",
                ParentRefId = transformResourceDefinition1.RefId
            };

            transformResourceDefinition1.Resources.Add(transformResource1);

            var bindingResourceDefinition1 = new ResourceDefinition()
            {
                Name        = "Binding1",
                Description = "This is binding 1.",
                Type        = ModelConstants.ResourceDefinitionBindings,
                Key         = "binding-1",
                ParentRefId = resourceContainer.RefId
            };

            resourceContainer.ResourceDefinitions.Add(bindingResourceDefinition1);

            var sendPortResource1 = new ResourceItem()
            {
                Name        = "SendPort1",
                Description = "This is sendport 1.",
                Type        = ModelConstants.ResourceSendPort,
                Key         = "sendport-1",
                ParentRefId = bindingResourceDefinition1.RefId
            };

            bindingResourceDefinition1.Resources.Add(sendPortResource1);

            var sendPortFilterResource1 = new ResourceItem()
            {
                Name        = "SendPort1-Filter",
                Description = "This is sendport 1, filter expression",
                Type        = ModelConstants.ResourceFilterExpression,
                Key         = "sendport-1-filter",
                ParentRefId = sendPortResource1.RefId
            };

            sendPortResource1.Resources.Add(sendPortFilterResource1);

            var receivePortResource1 = new ResourceItem()
            {
                Name        = "ReceivePort1",
                Description = "This is receive port 1.",
                Type        = ModelConstants.ResourceReceivePort,
                Key         = "receiveport-1",
                ParentRefId = bindingResourceDefinition1.RefId
            };

            bindingResourceDefinition1.Resources.Add(receivePortResource1);

            var receiveLocation1 = new ResourceItem()
            {
                Name        = "ReceiveLocation1",
                Description = "This is receive location 1.",
                Type        = ModelConstants.ResourceReceiveLocation,
                Key         = "receivelocation-1",
                ParentRefId = receivePortResource1.RefId
            };

            receivePortResource1.Resources.Add(receiveLocation1);

            var distributionListResource1 = new ResourceItem
            {
                Name        = "DistributionList1",
                Description = "This is distributionlist 1.",
                Type        = ModelConstants.ResourceDistributionList,
                Key         = "distributionlist-1",
                ParentRefId = bindingResourceDefinition1.RefId
            };

            bindingResourceDefinition1.Resources.Add(distributionListResource1);

            var distributionListFilterResource1 = new ResourceItem
            {
                Name        = "DistributionListFilter1",
                Description = "This is distribution list filer 1.",
                Type        = ModelConstants.ResourceFilterExpression,
                Key         = "distributionlistfilter-1",
                ParentRefId = distributionListResource1.RefId
            };

            distributionListResource1.Resources.Add(distributionListFilterResource1);

            // Create a parsed BizTalk Application Group
            var applicationGroup = new ParsedBizTalkApplicationGroup();

            model.MigrationSource.MigrationSourceModel = applicationGroup;

            // Create applications
            var application1 = new ParsedBizTalkApplication();

            application1.Application.Name = "Test App 1";
            applicationGroup.Applications.Add(application1);

            var application2 = new ParsedBizTalkApplication();

            application2.Application.Name     = "Test App 2";
            application2.Application.Bindings = new BindingFile {
                BindingInfo = new BindingInfo()
            };

            applicationGroup.Applications.Add(application2);

            var application3 = new ParsedBizTalkApplication();

            application3.Application.Name = "Test App 3";
            applicationGroup.Applications.Add(application3);
            application3.Application.Bindings = new BindingFile {
                BindingInfo = new BindingInfo()
            };

            // Create application definitions
            application1.Application.ApplicationDefinition = new ApplicationDefinitionFile()
            {
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = appResourceDefinition1.Key,
                ResourceKey           = appResource1.Key,
                ApplicationDefinition = new ApplicationDefinition()
                {
                    Properties = new List <ApplicationDefinitionProperty>()
                    {
                        new ApplicationDefinitionProperty()
                        {
                            Name = "DisplayName", Value = application1.Application.Name
                        },
                        new ApplicationDefinitionProperty()
                        {
                            Name = "ApplicationDescription", Value = application1.Application.Name + " Description"
                        }
                    }.ToArray()
                }
            };

            application2.Application.ApplicationDefinition = new ApplicationDefinitionFile()
            {
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = appResourceDefinition2.Key,
                ResourceKey           = appResource2.Key,
                ApplicationDefinition = new ApplicationDefinition()
                {
                    References = new List <ApplicationDefinitionReference>()
                    {
                        new ApplicationDefinitionReference()
                        {
                            Name = application3.Application.Name
                        }
                    }.ToArray(),
                    Properties = new List <ApplicationDefinitionProperty>()
                    {
                        new ApplicationDefinitionProperty()
                        {
                            Name = "DisplayName", Value = application2.Application.Name
                        },
                        new ApplicationDefinitionProperty()
                        {
                            Name = "ApplicationDescription", Value = application2.Application.Name + " Description"
                        }
                    }.ToArray()
                }
            };

            application3.Application.ApplicationDefinition = new ApplicationDefinitionFile()
            {
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = appResourceDefinition3.Key,
                ResourceKey           = appResource3.Key,
                ApplicationDefinition = new ApplicationDefinition()
                {
                    Properties = new List <ApplicationDefinitionProperty>()
                    {
                        new ApplicationDefinitionProperty()
                        {
                            Name = "DisplayName", Value = application3.Application.Name
                        },
                        new ApplicationDefinitionProperty()
                        {
                            Name = "ApplicationDescription", Value = application3.Application.Name + " Description"
                        }
                    }.ToArray()
                }
            };

            // Create schemas
            var documentSchema1 = new Types.Entities.Schema()
            {
                Name                  = "DocumentSchema1",
                Namespace             = "Test.Schemas",
                FullName              = "Test.Schemas.DocumentSchema1",
                XmlNamespace          = "http://schemas.test.com/DocumentSchema1",
                RootNodeName          = "Root",
                ResourceDefinitionKey = schemaResourceDefinition1.Key,
                ResourceKey           = schemaResource1.Key,
                SchemaType            = BizTalkSchemaType.Document
            };

            documentSchema1.MessageDefinitions.Add(new MessageDefinition(documentSchema1.RootNodeName, documentSchema1.XmlNamespace, "Test.Schemas.DocumentSchema1", "DocumentSchema1", "document-schema-1:schema:Root"));
            documentSchema1.PromotedProperties.Add(new PromotedProperty()
            {
                PropertyType = "Test.Schemas.PropertySchema1.Property1", XPath = "some xpath"
            });
            application1.Application.Schemas.Add(documentSchema1);

            var documentSchema2 = new Types.Entities.Schema()
            {
                Name                  = "DocumentSchema2",
                Namespace             = "Test.Schemas",
                FullName              = "Test.Schemas.DocumentSchema2",
                XmlNamespace          = "http://schemas.test.com/DocumentSchema2",
                RootNodeName          = "Root",
                ResourceDefinitionKey = schemaResourceDefinition2.Key,
                ResourceKey           = schemaResource2.Key,
                SchemaType            = BizTalkSchemaType.Document
            };

            documentSchema2.MessageDefinitions.Add(new MessageDefinition(documentSchema2.RootNodeName, documentSchema2.XmlNamespace, "Test.Schemas.DocumentSchema2", "DocumentSchema2", "document-schema-2:schema:Root"));
            application1.Application.Schemas.Add(documentSchema2);

            var propertySchema = new Types.Entities.Schema()
            {
                Name                  = "PropertySchema1",
                Namespace             = "Test.Schemas",
                FullName              = "Test.Schemas.PropertySchema1",
                XmlNamespace          = "http://schemas.test.com/PropertySchema1",
                RootNodeName          = "Root",
                ResourceDefinitionKey = schemaResourceDefinition3.Key,
                ResourceKey           = schemaResource3.Key,
                SchemaType            = BizTalkSchemaType.Property
            };

            propertySchema.ContextProperties.Add(new ContextProperty()
            {
                DataType = "xs:string", FullyQualifiedName = "Test.Schemas.PropertySchema1.Property1", PropertyName = schemaResource3Property1.Name, Namespace = "Test.Schemas.PropertySchema1", ResourceKey = schemaResource3Property1.Key
            });
            propertySchema.ContextProperties.Add(new ContextProperty()
            {
                DataType = "xs:int", FullyQualifiedName = "Test.Schemas.PropertySchema1.Property2", PropertyName = schemaResource3Property2.Name, Namespace = "Test.Schemas.PropertySchema1", ResourceKey = schemaResource3Property2.Key
            });
            application1.Application.Schemas.Add(propertySchema);

            // Create transforms
            var map = new Types.Entities.Transform()
            {
                Name                  = "Transform1",
                FullName              = "Test.Maps.Transform1",
                ModuleName            = "Test.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
                Namespace             = "Test.Maps",
                ResourceContainerKey  = resourceContainer.Key,
                ResourceDefinitionKey = transformResourceDefinition1.Key
            };

            map.SourceSchemaTypeNames.Add("Test.Schemas.DocumentSchema1");
            map.TargetSchemaTypeNames.Add("Test.Schemas.DocumentSchema2");
            application1.Application.Transforms.Add(map);

            // Create send ports.
            var sendPort = new SendPort
            {
                ResourceKey      = sendPortResource1.Key,
                Description      = "This is a send port description.",
                Name             = "Test.SendPorts.SendPort1",
                FilterExpression = new Types.Entities.Filters.Filter
                {
                    Group = new Types.Entities.Filters.Group[]
                    {
                        new Types.Entities.Filters.Group
                        {
                            Statement = new Types.Entities.Filters.Statement[]
                            {
                                new Types.Entities.Filters.Statement()
                            }
                        }
                    }
                }
            };

            /// Create receive ports.
            var receivePort = new ReceivePort
            {
                ResourceKey      = receivePortResource1.Key,
                Description      = receivePortResource1.Description,
                Name             = receivePortResource1.Name,
                ReceiveLocations = new ReceiveLocation[]
                {
                    new ReceiveLocation
                    {
                        ResourceKey = receiveLocation1.Key,
                        Name        = receiveLocation1.Name,
                        Description = receiveLocation1.Name
                    }
                }
            };

            // Create distribution lists.
            var distributionList = new DistributionList
            {
                ResourceKey      = distributionListResource1.Key,
                Description      = distributionListResource1.Description,
                Name             = distributionListResource1.Name,
                FilterExpression = new Types.Entities.Filters.Filter
                {
                    ResourceKey = distributionListFilterResource1.Key,
                    Group       = new Types.Entities.Filters.Group[]
                    {
                        new Types.Entities.Filters.Group()
                    }
                }
            };

            application1.Application.Bindings = new BindingFile
            {
                BindingInfo = new BindingInfo
                {
                    SendPortCollection         = new SendPort[] { sendPort },
                    ReceivePortCollection      = new ReceivePort[] { receivePort },
                    DistributionListCollection = new DistributionList[] { distributionList }
                }
            };

            // Target model
            model.MigrationTarget.TargetEnvironment     = AzureIntegrationServicesTargetEnvironment.Consumption;
            model.MigrationTarget.DeploymentEnvironment = "dev";
            model.MigrationTarget.AzureSubscriptionId   = "azure-subs-id";
            model.MigrationTarget.AzurePrimaryRegion    = "UK South";
            model.MigrationTarget.AzureSecondaryRegion  = "UK West";

            // Add a message bus
            model.MigrationTarget.MessageBus = new MessageBus()
            {
                Name           = "ContosoMessageBus",
                Key            = "ContosoMessageBus",
                ResourceMapKey = "messageBus",
            };
            var messageBusResourceTemplate = new TargetResourceTemplate()
            {
                OutputPath = "output"
            };

            messageBusResourceTemplate.ResourceTemplateFiles.Add("path/to/file.json.liquid");
            messageBusResourceTemplate.ResourceTemplateFiles.Add("path/to/file2.json");
            model.MigrationTarget.MessageBus.Resources.Add(messageBusResourceTemplate);

            // Add an application
            var systemApp = new Application()
            {
                Name = "System",
                Key  = "ContosoMessageBus:System"
            };

            model.MigrationTarget.MessageBus.Applications.Add(systemApp);

            var app = new Application()
            {
                Name           = "AppA",
                Key            = "ContosoMessageBus:AppA",
                ResourceMapKey = "application"
            };

            model.MigrationTarget.MessageBus.Applications.Add(app);

            // Add an application message
            var appMessage = new DocumentMessage()
            {
                Name          = "PurchaseOrderFlatFile",
                MessageSchema = new MessageSchema
                {
                    ResourceKeyRef = messageResource1.Key,
                    Name           = messageResource2.Name
                },
                Key            = "ContosoMessageBus:AppA:PurchaseOrderFlatFile",
                ContentType    = MessageContentType.Xml,
                ResourceMapKey = "applicationMessage"
            };

            app.Messages.Add(appMessage);

            var appMessageResource1 = new TargetResourceTemplate()
            {
                OutputPath   = "OutputPath",
                ResourceType = ModelConstants.ResourceTypeXml
            };

            appMessage.Resources.Add(appMessageResource1);

            var transform = new MessageTransform
            {
                Name           = "MessageTransform",
                ResourceKeyRef = "transform-1-resource",
            };

            appMessage.MessageTransforms.Add(transform);

            var appMessageResource2 = new TargetResourceTemplate()
            {
                OutputPath   = "OutputPath",
                ResourceType = ModelConstants.ResourceTypeXslt
            };

            appMessage.Resources.Add(appMessageResource2);

            // Add a message box
            var messageBox = new TopicChannel()
            {
                Name           = "MessageBox",
                Key            = "ContosoMessageBus:System:MessageBox",
                ResourceMapKey = "messageBox"
            };

            systemApp.Channels.Add(messageBox);

            // Add a message agent
            var messageAgent = new ContentBasedRouter()
            {
                Name           = "MessageAgent",
                Key            = "ContosoMessageBus:System:MessageAgent",
                ResourceMapKey = "messageAgent"
            };

            systemApp.Intermediaries.Add(messageAgent);

            // Add an FTP endpoint
            var ftpReceive = new AdapterEndpoint()
            {
                Name           = "FtpReceive",
                Key            = "ContosoMessageBus:System:FtpReceive",
                ResourceMapKey = "ftpReceive"
            };

            systemApp.Endpoints.Add(ftpReceive);

            return(model);
        }