/// <summary> /// Creates a default object model for parsing and building a report. /// </summary> /// <returns></returns> public static AzureIntegrationServicesModel CreateDefaultModelForParsing() { var aisModel = 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" }; aisModel.MigrationSource.ResourceContainers.Add(resourceContainer); var appResourceDefinition1 = new ResourceDefinition() { Name = "App 1 Resource Definition", Key = $"{resourceContainer.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 = $"{appResourceDefinition1.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 = $"{resourceContainer.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 = $"{appResourceDefinition2.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 = $"{resourceContainer.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 = $"{appResourceDefinition3.Key}:pp-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 = $"{resourceContainer.Key}:document-schema-1" }; resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition1); var schemaResource1 = new ResourceItem() { Name = "DocumentSchema1", Description = "This is document schema 1.", Type = ModelConstants.ResourceDocumentSchema, Key = $"{schemaResourceDefinition1.Key}:document-schema-1:schema" }; schemaResourceDefinition1.Resources.Add(schemaResource1); var schemaResourceDefinition2 = new ResourceDefinition() { Name = "DocumentSchema2", Description = "This is document schema 2.", Type = ModelConstants.ResourceDefinitionSchema, Key = $"{resourceContainer.Key}:document-schema-2" }; resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition2); var schemaResource2 = new ResourceItem() { Name = "DocumentSchema2", Description = "This is document schema 2.", Type = ModelConstants.ResourceDocumentSchema, Key = $"{schemaResourceDefinition2.Key}:document-schema-2:schema" }; schemaResourceDefinition2.Resources.Add(schemaResource2); var schemaResourceDefinition3 = new ResourceDefinition() { Name = "PropertySchema1", Description = "This is property schema 1.", Type = ModelConstants.ResourceDefinitionSchema, Key = $"{resourceContainer.Key}:property-schema-1" }; resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition3); var schemaResource3 = new ResourceItem() { Name = "PropertySchema1", Description = "This is property schema 2.", Type = ModelConstants.ResourceDocumentSchema, Key = $"{schemaResourceDefinition3.Key}:property-schema-1:schema" }; schemaResourceDefinition3.Resources.Add(schemaResource3); var schemaResource3Property1 = new ResourceItem() { Name = "Property1", Description = "This is property 2", Type = ModelConstants.ResourcePropertySchema, Key = $"{schemaResourceDefinition3.Key}:property-schema-1:schema:Property1" }; schemaResourceDefinition3.Resources.Add(schemaResource3Property1); var schemaResource3Property2 = new ResourceItem() { Name = "Property2", Description = "This is property 2", Type = ModelConstants.ResourcePropertySchema, Key = $"{schemaResourceDefinition3.Key}:property-schema-1:schema:Property2" }; schemaResourceDefinition3.Resources.Add(schemaResource3Property2); var transformResourceDefinition1 = new ResourceDefinition() { Name = "Transform1", Description = "This is transform 1.", Type = ModelConstants.ResourceDefinitionMap, Key = $"{resourceContainer.Key}:transform-1" }; resourceContainer.ResourceDefinitions.Add(transformResourceDefinition1); var transformResource1 = new ResourceItem() { Name = "Transform1", Description = "This is the transform 1, resource", Type = ModelConstants.ResourceMap, Key = $"{transformResourceDefinition1.Key}:transform-1-resource" }; transformResourceDefinition1.Resources.Add(transformResource1); var bindingResourceDefinition1 = new ResourceDefinition() { Name = "Binding1", Description = "This is binding 1.", Type = ModelConstants.ResourceDefinitionBindings, Key = $"{resourceContainer.Key}:binding-1" }; resourceContainer.ResourceDefinitions.Add(bindingResourceDefinition1); var sendPortResource1 = new ResourceItem() { Name = "SendPort1", Description = "This is sendport 1.", Type = ModelConstants.ResourceSendPort, Key = $"{bindingResourceDefinition1.Key}:sendport-1" }; bindingResourceDefinition1.Resources.Add(sendPortResource1); var sendPortFilterResource1 = new ResourceItem() { Name = "SendPort1-Filter", Description = "This is sendport 1, filter expression", Type = ModelConstants.ResourceFilterExpression, Key = $"{sendPortResource1.Key}:sendport-1-filter" }; sendPortResource1.Resources.Add(sendPortFilterResource1); var receivePortResource1 = new ResourceItem() { Name = "ReceivePort1", Description = "This is receive port 1.", Type = ModelConstants.ResourceReceivePort, Key = $"{bindingResourceDefinition1.Key}:receiveport-1" }; bindingResourceDefinition1.Resources.Add(receivePortResource1); var receiveLocation1 = new ResourceItem() { Name = "ReceiveLocation1", Description = "This is receive location 1.", Type = ModelConstants.ResourceReceiveLocation, Key = $"{receivePortResource1.Key}:receivelocation-1" }; receivePortResource1.Resources.Add(receiveLocation1); var distributionListResource1 = new ResourceItem { Name = "DistributionList1", Description = "This is distributionlist 1.", Type = ModelConstants.ResourceDistributionList, Key = $"{bindingResourceDefinition1.Key}:distributionlist-1" }; bindingResourceDefinition1.Resources.Add(distributionListResource1); var distributionListFilterResource1 = new ResourceItem { Name = "DistributionListFilter1", Description = "This is distribution list filer 1.", Type = ModelConstants.ResourceFilterExpression, Key = $"{distributionListResource1.Key}:distributionlistfilter-1" }; distributionListResource1.Resources.Add(distributionListFilterResource1); // Create a parsed BizTalk Application Group var applicationGroup = new ParsedBizTalkApplicationGroup(); aisModel.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() }; var container = new ResourceContainer(); container.ResourceDefinitions.Add(new ResourceDefinition()); container.ResourceDefinitions[0].Resources.Add(new ResourceItem { Key = appResource1.Key }); aisModel.MigrationSource.ResourceContainers.Add(container); // 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", ResourceContainerKey = "app-1-assembly-resource-key", 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", ResourceContainerKey = "app-1-assembly-resource-key", 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 } } }; var app1Msi = new ResourceContainer() { Name = "App 1 MSI", Description = "App 1 MSI Description", Key = "app-1-msi-resource-key", Type = ModelConstants.ResourceContainerMsi }; aisModel.MigrationSource.ResourceContainers.Add(app1Msi); var app1Cab = new ResourceContainer() { Name = "App 1 CAB", Description = "App 1 CAB Description", Key = $"{app1Msi.Key}:app-1-cab-resource-key", Type = ModelConstants.ResourceContainerCab }; app1Msi.ResourceContainers.Add(app1Cab); var app1Assembly = new ResourceContainer() { Name = "App 1 Assembly", Description = "App 1 Assembly Description", Key = $"{app1Cab.Key}:app-1-assembly-resource-key", Type = ModelConstants.ResourceContainerAssembly }; app1Cab.ResourceContainers.Add(app1Assembly); var app1Schema = new ResourceDefinition() { Name = "Document Schema 1", Description = "Document Schema 1 Description", Key = $"{app1Assembly.Key}:document-schema-1", Type = ModelConstants.ResourceDefinitionSchema }; app1Assembly.ResourceDefinitions.Add(app1Schema); var app1DocumentSchema = new ResourceItem() { Name = "DocumentSchema1", Description = "DocumentSchema1Description", Key = $"{app1Schema.Key}:app-1-schema-resource-key" }; app1Schema.Resources.Add(app1DocumentSchema); var app1Schema2 = new ResourceDefinition() { Name = "Document Schema 2", Description = "Document Schema 2 Description", Key = $"{app1Assembly.Key}:document-schema-2", Type = ModelConstants.ResourceDefinitionSchema }; app1Assembly.ResourceDefinitions.Add(app1Schema2); var app1DocumentSchema2 = new ResourceItem() { Name = "DocumentSchema2", Description = "DocumentSchema2Description", Key = $"{app1Schema.Key}:app-1-schema-2-resource-key" }; app1Schema.Resources.Add(app1DocumentSchema2); return(aisModel); }
public void ParseFailsWhenTransformDefinitionIsMissing(TransformParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e) { var missingResourceDefinitionKey = "missingResourceDefinitionKey"; "Given a model with a transform and missing its definition" .x(() => { model = new AzureIntegrationServicesModel(); group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; var msiContainer = new ResourceContainer() { Key = "TestMsi.Key", Name = "TestMsi", Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi" }; model.MigrationSource.ResourceContainers.Add(msiContainer); var cabContainer = new ResourceContainer() { Key = "TestCab.Key", Name = "TestCab", Type = ModelConstants.ResourceContainerCab, ContainerLocation = @"C:\Test\Test.CAB" }; msiContainer.ResourceContainers.Add(cabContainer); var asmContainer = new ResourceContainer() { Key = "TestAssembly.Key", Name = "TestAssembly", Type = ModelConstants.ResourceContainerAssembly, ContainerLocation = @"C:\Test\Test.dll" }; cabContainer.ResourceContainers.Add(asmContainer); var transformResourceDefinition = new ResourceDefinition() { Key = "transformDefinitionKey", Name = "transformName", Type = ModelConstants.ResourceDefinitionMap }; asmContainer.ResourceDefinitions.Add(transformResourceDefinition); var application = new BizTalkApplication() { Name = "ApplicationOne" }; var transform = new Types.Entities.Transform { Name = "transformName", ResourceContainerKey = asmContainer.Key, ResourceDefinitionKey = missingResourceDefinitionKey }; application.Transforms.Add(transform); group.Applications.Add( new ParsedBizTalkApplication { Application = application }); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new TransformParser(model, context, logger)); "When parsing" .x(() => e = Record.Exception(() => parser.Parse())); "Then the code should not throw an exception" .x(() => e.Should().BeNull()); "And there should be an error logged" .x(() => { context.Errors.Should().NotBeNull(); context.Errors.Should().HaveCount(1); context.Errors[0].Message.Should().Contain(missingResourceDefinitionKey); context.Errors[0].Message.Should().Contain(ModelConstants.ResourceDefinitionMap); }); }
/// <summary> /// Creates a default object model for analyzing and building a report. /// </summary> /// <returns></returns> public static AzureIntegrationServicesModel CreateDefaultModelForAnalyzing() { var aisModel = 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" }; aisModel.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" }; 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 schema 1.", Type = ModelConstants.ResourceMessageType, Key = "document-schema-1:schema:Root", 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" }; resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition2); var schemaResource2 = new ResourceItem() { Name = "DocumentSchema2", Description = "This is document schema 2.", Type = ModelConstants.ResourceDocumentSchema, Key = "document-schema-2:schema", ParentRefId = schemaResourceDefinition2.RefId }; schemaResourceDefinition2.Resources.Add(schemaResource2); var messageResource2 = new ResourceItem() { Name = "Message2", Description = "This is message schema 2.", Type = ModelConstants.ResourceMessageType, Key = "document-schema-2:schema:Root", 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" }; resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition3); var schemaResource3 = new ResourceItem() { Name = "PropertySchema1", Description = "This is property schema 1 resource.", 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 schema 3.", Type = ModelConstants.ResourceMessageType, Key = "document-schema-3:schema:Root", ParentRefId = schemaResource3.RefId }; schemaResource3.Resources.Add(messageResource3); var schemaResourceDefinition4 = new ResourceDefinition() { Name = "EnvelopeSchema1", Description = "This is envelope schema 1.", Type = ModelConstants.ResourceDefinitionSchema, Key = "envelope-schema-1" }; resourceContainer.ResourceDefinitions.Add(schemaResourceDefinition4); var schemaResource4 = new ResourceItem() { Name = "EnvelopeSchema1", Description = "This is envelope schema 1.", Type = ModelConstants.ResourceDocumentSchema, Key = "envelope-schema-1:schema", ParentRefId = schemaResourceDefinition1.RefId }; schemaResourceDefinition4.Resources.Add(schemaResource4); var messageResource4 = new ResourceItem() { Name = "Envelope1", Description = "This is envelope schema 1.", Type = ModelConstants.ResourceMessageType, Key = "envelope-schema-1:schema:Envelope", ParentRefId = schemaResource4.RefId }; schemaResource4.Resources.Add(messageResource4); var contextProperty1 = new ResourceItem() { Name = "Property1", Description = "This is property 2", Key = "property-schema-1:schema:Property1", Type = ModelConstants.ResourcePropertySchema }; schemaResource3.Resources.Add(contextProperty1); var contextProperty2 = new ResourceItem() { Name = "Property2", Description = "This is property 2", Key = "property-schema-1:schema:Property2", Type = ModelConstants.ResourcePropertySchema }; schemaResource3.Resources.Add(contextProperty2); var transformResourceDefinition1 = new ResourceDefinition() { Name = "Transform1", Description = "This is transform 1.", Type = ModelConstants.ResourceDefinitionMap, Key = "transform-1" }; resourceContainer.ResourceDefinitions.Add(transformResourceDefinition1); var transformResourceDefinition2 = new ResourceDefinition() { Name = "Transform2", Description = "This is transform 2.", Type = ModelConstants.ResourceDefinitionMap, Key = "transform-2" }; resourceContainer.ResourceDefinitions.Add(transformResourceDefinition2); var transformResource1 = new ResourceItem() { Name = "Transform1", Description = "This is the transform 1, resource", Type = ModelConstants.ResourceMap, Key = "transform-1-resource" }; transformResourceDefinition1.Resources.Add(transformResource1); schemaResource1.ResourceRelationships.Add(new ResourceRelationship { ResourceRelationshipType = ResourceRelationshipType.ReferencedBy, ResourceRefId = transformResource1.RefId, }); var transformResource2 = new ResourceItem() { Name = "Transform2", Description = "This is the transform 2, resource", Type = ModelConstants.ResourceMap, Key = "transform-2-resource" }; transformResourceDefinition2.Resources.Add(transformResource2); var bindingResourceDefinition1 = new ResourceDefinition() { Name = "Binding1", Description = "This is binding 1.", Type = ModelConstants.ResourceDefinitionBindings, Key = "binding-1" }; resourceContainer.ResourceDefinitions.Add(bindingResourceDefinition1); var sendPortResource1 = new ResourceItem() { Name = "Test.SendPorts.SendPort1", Description = "This is sendport 1.", Type = ModelConstants.ResourceSendPort, Key = "sendport-1" }; 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" }; sendPortResource1.Resources.Add(sendPortFilterResource1); var receivePortResource1 = new ResourceItem() { Name = "ReceivePort1", Description = "This is receive port 1.", Type = ModelConstants.ResourceReceivePort, Key = "receiveport-1" }; bindingResourceDefinition1.Resources.Add(receivePortResource1); var receiveLocation1 = new ResourceItem() { Name = "ReceiveLocation1", Description = "This is receive location 1.", Type = ModelConstants.ResourceReceiveLocation, Key = "receivelocation-1" }; receivePortResource1.Resources.Add(receiveLocation1); var distributionListResource1 = new ResourceItem { Name = "DistributionList1", Description = "This is distributionlist 1.", Type = ModelConstants.ResourceDistributionList, Key = "distributionlist-1" }; bindingResourceDefinition1.Resources.Add(distributionListResource1); var distributionListFilterResource1 = new ResourceItem { Name = "DistributionListFilter1", Description = "This is distribution list filer 1.", Type = ModelConstants.ResourceFilterExpression, Key = "distributionlistfilter-1" }; distributionListResource1.Resources.Add(distributionListFilterResource1); // Create a parsed BizTalk Application Group var applicationGroup = new ParsedBizTalkApplicationGroup(); aisModel.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, Resource = appResource1, 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, Resource = appResource2, 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, Resource = appResource3, 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, Resource = schemaResource1, SchemaType = BizTalkSchemaType.Document }; var messageDefinition1 = new MessageDefinition(documentSchema1.RootNodeName, documentSchema1.XmlNamespace, "Test.Schemas.DocumentSchema1", "DocumentSchema1", messageResource1.Key); messageResource1.SourceObject = messageDefinition1; documentSchema1.MessageDefinitions.Add(messageDefinition1); documentSchema1.PromotedProperties.Add(new PromotedProperty() { PropertyType = "Test.Schemas.PropertySchema1.Property1", XPath = "some xpath 1" }); messageDefinition1.PromotedProperties.Add(new PromotedProperty() { PropertyType = "Test.Schemas.PropertySchema1.Property1", XPath = "some xpath 1" }); 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, Resource = schemaResource2, SchemaType = BizTalkSchemaType.Document }; var messageDefinition2 = new MessageDefinition(documentSchema2.RootNodeName, documentSchema2.XmlNamespace, "Test.Schemas.DocumentSchema2", "DocumentSchema2", messageResource2.Key); messageResource2.SourceObject = messageDefinition2; documentSchema2.MessageDefinitions.Add(messageDefinition2); 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, Resource = schemaResource3, SchemaType = BizTalkSchemaType.Property }; propertySchema.ContextProperties.Add(new ContextProperty() { DataType = "xs:string", FullyQualifiedName = "Test.Schemas.PropertySchema1.Property1", PropertyName = contextProperty1.Name, Namespace = "Test.Schemas.PropertySchema1", ResourceKey = contextProperty1.Key, Resource = contextProperty1 }); propertySchema.ContextProperties.Add(new ContextProperty() { DataType = "xs:int", FullyQualifiedName = "Test.Schemas.PropertySchema1.Property2", PropertyName = contextProperty2.Name, Namespace = "Test.Schemas.PropertySchema1", ResourceKey = contextProperty2.Key, Resource = contextProperty2 }); application1.Application.Schemas.Add(propertySchema); var envelopeSchema1 = new Types.Entities.Schema() { Name = "EnvelopeSchema1", Namespace = "Test.Schemas", FullName = "Test.Schemas.EnvelopeSchema1", XmlNamespace = "http://schemas.test.com/EnvelopeSchema1", RootNodeName = "Envelope", IsEnvelope = true, BodyXPath = "/*[local-name()='Envelope' and namespace-uri()='http://schemas.test.com/EnvelopeSchema1']/*[local-name()='Body' and namespace-uri()='http://schemas.test.com/EnvelopeSchema1']", ResourceDefinitionKey = schemaResourceDefinition4.Key, ResourceKey = schemaResource4.Key, Resource = schemaResource4, SchemaType = BizTalkSchemaType.Document }; var messageDefinition3 = new MessageDefinition(envelopeSchema1.RootNodeName, envelopeSchema1.XmlNamespace, "Test.Schemas.EnvelopeSchema1", "EnvelopeSchema1", messageResource4.Key); messageResource4.SourceObject = messageDefinition3; envelopeSchema1.MessageDefinitions.Add(messageDefinition2); application1.Application.Schemas.Add(envelopeSchema1); // Create transforms var map1 = 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, ResourceKey = transformResource1.Key, Resource = transformResource1 }; map1.SourceSchemaTypeNames.Add("Test.Schemas.DocumentSchema1"); map1.TargetSchemaTypeNames.Add("Test.Schemas.DocumentSchema2"); transformResource1.SourceObject = map1; application1.Application.Transforms.Add(map1); var map2 = new Types.Entities.Transform() { Name = "Transform2", FullName = "Test.Maps.Transform2", ModuleName = "Test.Maps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", Namespace = "Test.Maps", ResourceContainerKey = resourceContainer.Key, ResourceDefinitionKey = transformResourceDefinition1.Key, ResourceKey = transformResource2.Key, Resource = transformResource2 }; map2.SourceSchemaTypeNames.Add("Test.Schemas.DocumentSchema2"); map2.TargetSchemaTypeNames.Add("Test.Schemas.DocumentSchema1"); transformResource2.SourceObject = map2; application1.Application.Transforms.Add(map2); // Create send ports. var sendPort = new SendPort { ResourceKey = sendPortResource1.Key, Resource = sendPortResource1, Description = "This is a send port description.", Name = "Test.SendPorts.SendPort1", PrimaryTransport = new TransportInfo { TransportType = new ProtocolType { Name = "FTP" }, TransportTypeData = "<CustomProps><AdapterConfig vt=\"8\"><Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><uri>ftp://127.0.0.1:22/%MessageID%.xml</uri><serverAddress>127.0.0.1</serverAddress><serverPort>22</serverPort><ftpServerType>Detect</ftpServerType><targetFolder /><targetFileName>%MessageID%.xml</targetFileName><representationType>binary</representationType><allocateStorage>False</allocateStorage><appendIfExists>False</appendIfExists><connectionLimit>0</connectionLimit><passiveMode>False</passiveMode><firewallType>NoFirewall</firewallType><firewallPort>22</firewallPort><useSsl>False</useSsl><useDataProtection>True</useDataProtection><ftpsConnMode>Explicit</ftpsConnMode></Config></AdapterConfig></CustomProps>", }, 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() } } } }, Transforms = new Types.Entities.Bindings.Transform[1] { new Types.Entities.Bindings.Transform() { FullName = map2.FullName, AssemblyQualifiedName = $"{map2.Name}, {map2.ModuleName}" } }, InboundTransforms = new Types.Entities.Bindings.Transform[1] { new Types.Entities.Bindings.Transform() { FullName = map1.FullName, AssemblyQualifiedName = $"{map1.Name}, {map1.ModuleName}" } } }; sendPortResource1.SourceObject = sendPort; /// Create receive ports. var receivePort = new ReceivePort { ResourceKey = receivePortResource1.Key, Resource = receivePortResource1, Description = receivePortResource1.Description, Name = receivePortResource1.Name, ReceiveLocations = new ReceiveLocation[] { new ReceiveLocation { ResourceKey = receiveLocation1.Key, Name = receiveLocation1.Name, Description = receiveLocation1.Name, ReceiveLocationTransportType = new ProtocolType { Name = "FTP", }, ReceiveLocationTransportTypeData = "<CustomProps><AdapterConfig vt=\"8\"><Config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><uri>ftp://127.0.0.1:21/*.*</uri><serverAddress>127.0.0.1</serverAddress><serverPort>21</serverPort><userName>btsuser</userName><password>******</password><ftpServerType>Detect</ftpServerType><fileMask>*.*</fileMask><targetFolder /><representationType>binary</representationType><receiveDataTimeout>90000</receiveDataTimeout><maximumBatchSize>0</maximumBatchSize><maximumNumberOfFiles>0</maximumNumberOfFiles><passiveMode>False</passiveMode><useNLST>False</useNLST><firewallType>NoFirewall</firewallType><firewallPort>21</firewallPort><pollingUnitOfMeasure>Seconds</pollingUnitOfMeasure><pollingInterval>60</pollingInterval><redownloadInterval>-1</redownloadInterval><errorThreshold>10</errorThreshold><maxFileSize>100</maxFileSize><useSsl>False</useSsl><useDataProtection>True</useDataProtection><ftpsConnMode>Explicit</ftpsConnMode><deleteAfterDownload>True</deleteAfterDownload><enableTimeComparison>False</enableTimeComparison></Config></AdapterConfig></CustomProps>" } }, Transforms = new Types.Entities.Bindings.Transform[1] { new Types.Entities.Bindings.Transform() { FullName = map1.FullName, AssemblyQualifiedName = $"{map1.Name}, {map1.ModuleName}" } }, OutboundTransforms = new Types.Entities.Bindings.Transform[1] { new Types.Entities.Bindings.Transform() { FullName = map2.FullName, AssemblyQualifiedName = $"{map2.Name}, {map2.ModuleName}" } } }; // Create distribution lists. var distributionList = new DistributionList { ResourceKey = distributionListResource1.Key, Resource = distributionListResource1, 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() } }, SendPorts = new SendPortRef[] { new SendPortRef() { Name = sendPort.Name } } }; distributionListResource1.SourceObject = distributionList; application1.Application.Bindings = new BindingFile { BindingInfo = new BindingInfo { SendPortCollection = new SendPort[] { sendPort }, ReceivePortCollection = new ReceivePort[] { receivePort }, DistributionListCollection = new DistributionList[] { distributionList } } }; return(aisModel); }
public void ParseTransformWithSuccess(TransformParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, ParsedBizTalkApplicationGroup group, Exception e) { "Given a model with a transform" .x(() => { model = new AzureIntegrationServicesModel(); group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; var msiContainer = new ResourceContainer() { Key = "TestMsi.Key", Name = "TestMsi", Type = ModelConstants.ResourceContainerMsi, ContainerLocation = @"C:\Test\Test.msi" }; model.MigrationSource.ResourceContainers.Add(msiContainer); var cabContainer = new ResourceContainer() { Key = "TestCab.Key", Name = "TestCab", Type = ModelConstants.ResourceContainerCab, ContainerLocation = @"C:\Test\Test.CAB" }; msiContainer.ResourceContainers.Add(cabContainer); var asmContainer = new ResourceContainer() { Key = "TestAssembly.Key", Name = "TestAssembly", Type = ModelConstants.ResourceContainerAssembly, ContainerLocation = @"C:\Test\Test.dll" }; cabContainer.ResourceContainers.Add(asmContainer); var transformResourceDefinition = new ResourceDefinition() { Key = "transformDefinitionKey", Name = "transformName", Type = ModelConstants.ResourceDefinitionMap }; asmContainer.ResourceDefinitions.Add(transformResourceDefinition); var application = new BizTalkApplication() { Name = "ApplicationOne" }; var transform = new Types.Entities.Transform { Name = "transformName", ResourceContainerKey = asmContainer.Key, ResourceDefinitionKey = transformResourceDefinition.Key }; application.Transforms.Add(transform); group.Applications.Add( new ParsedBizTalkApplication { Application = application }); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new TransformParser(model, context, logger)); "When parsing" .x(() => e = Record.Exception(() => parser.Parse())); "Then the code should not throw an exception" .x(() => e.Should().BeNull()); "And the resources should be set." .x(() => { var appModel = (AzureIntegrationServicesModel)model; // Check the transform resource has been created. appModel.MigrationSource.ResourceContainers[0].ResourceContainers[0].ResourceContainers[0].ResourceDefinitions[0].Resources.Should().NotBeNullOrEmpty(); appModel.MigrationSource.ResourceContainers[0].ResourceContainers[0].ResourceContainers[0].ResourceDefinitions[0].Resources.Should().HaveCount(1); var transformResourceDefinition = appModel.MigrationSource.ResourceContainers[0].ResourceContainers[0].ResourceContainers[0].ResourceDefinitions[0]; var transformResource = transformResourceDefinition.Resources[0]; // Get the transform. var transform = group.Applications[0].Application.Transforms[0]; // Validate the transform resource. transformResource.Should().NotBeNull(); transformResource.Key.Should().Be(transformResourceDefinition.Key + ":map"); transformResource.Name.Should().Be(transform.Name); transformResource.Type.Should().Be(ModelConstants.ResourceMap); transformResource.Description.Should().Be(transform.FullName); transform.Resource.Should().Be(transformResource); // The pointer to the resource should be set. transformResource.ParentRefId.Should().Be(transformResourceDefinition.RefId); // The parent ref ID should be set. transformResource.SourceObject.Should().Be(transform); // The resource should have a pointer to the source object. }); }
/// <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); }