public void SetOrchestratorTest() { Mock <IOrchestratorRepository <string> > mockStringRepo = new Mock <IOrchestratorRepository <string> >(); Mock <IOrchestratorRepository <int> > mockIntRepo = new Mock <IOrchestratorRepository <int> >(); IOrchestration orchestration = new Orchestration(); bool stringOrchestratorEnded = false; bool intOrchestratorEnded = false; IOrchestrator <string> stringOrchestrator = new Orchestrator <string>("ByString", mockStringRepo.Object); stringOrchestrator.OrchestratorEnded += delegate(object sender, EventArgs args) { stringOrchestratorEnded = true; }; IOrchestrator <int> intOrchestrator = new Orchestrator <int>("ByInt", mockIntRepo.Object); intOrchestrator.OrchestratorEnded += delegate(object sender, EventArgs args) { intOrchestratorEnded = true; }; orchestration.SetOrchestrator(stringOrchestrator); orchestration.SetOrchestrator(intOrchestrator); orchestration.StopOrchestrator <string>(); orchestration.StopOrchestrator <int>(); Thread.Sleep(1000); Assert.True(stringOrchestratorEnded); Assert.True(intOrchestratorEnded); }
/// <summary> /// Creates orchestration entries for any orchestrations found in the given <see cref="AssemblyDefinition"/> and adds them to the given <see cref="ParsedBizTalkApplication"/>. /// </summary> /// <param name="assembly"><see cref="AssemblyDefinition"/> in which to look for orchestrations.</param> /// <param name="application"><see cref="ParsedBizTalkApplication"/> to add orchestration entities to.</param> /// <param name="container">The resource container for the definitions.</param> private void LoadOrchestrations(AssemblyDefinition assembly, ParsedBizTalkApplication application, ResourceContainer container) { // Check if we have any types that inherit from BTXService in the types defined in the assembly var orchTypes = assembly.MainModule.Types.Where(ty => ty.BaseType != null && ty.BaseType.FullName == "Microsoft.BizTalk.XLANGs.BTXEngine.BTXService").ToList(); foreach (var orchType in orchTypes) { // Get orchestration content var orchContent = orchType.Fields.Where(f => f.Name == "_symODXML").Single().Constant.ToString().Replace("\n", string.Empty); // Add definition to resource container var resourceName = orchType.Name; var resourceKey = string.Concat(container.Name, ":", resourceName); container.ResourceDefinitions.Add(new ResourceDefinition() { Key = resourceKey, Name = resourceName, Type = ModelConstants.ResourceDefinitionOrchestration, ResourceContent = orchContent }); // Add orchestration to model var orch = new Orchestration(container.Key, resourceKey) { FullName = orchType.FullName, ModuleName = assembly.FullName, Name = orchType.Name, Namespace = orchType.Namespace }; application.Application.Orchestrations.Add(orch); _logger.LogDebug(TraceMessages.DiscoveredTheOrchestration, resourceKey); } }
public ActionResult Orchestration(string applicationName, string artifactid, string version) { Manifest manifest = ManifestReader.GetCurrentManifest(version, Request.PhysicalApplicationPath); BizTalkInstallation installation = InstallationReader.GetBizTalkInstallation(manifest); BizTalkApplication application = installation.Applications[applicationName]; Orchestration orchestration = application.Orchestrations[artifactid]; var breadCrumbs = new List <BizTalkBaseObject> { application, orchestration }; return(View(new OrchestrationViewModel( application, ManifestReader.GetAllManifests(Request.PhysicalApplicationPath), manifest, breadCrumbs, installation.Applications.Values, installation.Hosts.Values, orchestration))); }
public IEnumerable <Orchestration> Get() { List <Orchestration> orchestrations = new List <Orchestration>(); try { //Create EnumerationOptions and run wql query EnumerationOptions enumOptions = new EnumerationOptions(); enumOptions.ReturnImmediately = false; //Search for DB servername and trackingDB name ManagementObjectSearcher searchObject = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer", "Select TrackingDBServerName, TrackingDBName from MSBTS_GroupSetting", enumOptions); ManagementObjectCollection searchCollection = searchObject.Get(); ManagementObject obj = searchCollection.OfType <ManagementObject>().FirstOrDefault(); string connectionString = "Server=" + obj["TrackingDBServerName"] + ";Database=" + obj["TrackingDBName"] + ";Integrated Security=True;"; string query = @"select A.nvcName [ApplicationName] " + ", O.[nvcFullName] [OrchestrationName] " + ", O.nOrchestrationStatus [OrchestrationStatus] " + ", MAX(SF.[ServiceInstance/StartTime]) [LastStartDateTime] " + "from BizTalkMgmtDb.dbo.bts_orchestration O " + "left outer join dtav_ServiceFacts SF on SF.[Service/Name] = O.nvcFullName " + "join BizTalkMgmtDb.dbo.bts_item I on I.id = O.nItemID " + "join BizTalkMgmtDb.dbo.bts_assembly ASSY on ASSY.nID = I.AssemblyId " + "join BizTalkMgmtDb.dbo.bts_application A on A.nID = ASSY.nApplicationID " + "group by A.nvcName, O.[nvcFullName], O.nOrchestrationStatus;"; using (SqlConnection connection = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(query, connection); connection.Open(); SqlDataReader reader = command.ExecuteReader(); try { while (reader.Read()) { Orchestration orchestration = new Orchestration(); orchestration.ApplicationName = (string)reader["ApplicationName"]; orchestration.OrchestrationName = (string)reader["OrchestrationName"]; orchestration.OrchestrationStatus = Enum.GetName(typeof(Orchestration.OrchestrationStatusEnum), (int)reader["OrchestrationStatus"]); if (reader["LastStartDateTime"] != DBNull.Value) { orchestration.LastStartDateTime = (DateTime)reader["LastStartDateTime"]; } orchestrations.Add(orchestration); } } finally { // Always call Close when done reading. reader.Close(); } } } catch (Exception ex) { throw new Exception("Exception Occurred in get orchestrations call. " + ex.Message); } return(orchestrations); }
public void OrchestrationProjectSolveTest() { Mock <IOrchestratorRepository <string> > mockStringRepo = new Mock <IOrchestratorRepository <string> >(); Mock <IOrchestratorRepository <int> > mockIntRepo = new Mock <IOrchestratorRepository <int> >(); string byString = "ByString"; string byInt = "ByInt"; bool stringOrchestratorEnded = false; bool intOrchestratorEnded = false; EquationProject project = new EquationProject() { Equations = new List <Equation>() { new Equation() { Expression = "false", Target = byString, UseExpression = "true" }, new Equation() { Expression = "false", Target = byInt, UseExpression = "true" } } }; IOrchestration orchestration = new Orchestration(project); IOrchestrator <string> stringOrchestrator = new Orchestrator <string>(byString, mockStringRepo.Object); stringOrchestrator.OrchestratorEnded += delegate(object sender, EventArgs args) { stringOrchestratorEnded = true; }; IOrchestrator <int> intOrchestrator = new Orchestrator <int>(byInt, mockIntRepo.Object); intOrchestrator.OrchestratorEnded += delegate(object sender, EventArgs args) { intOrchestratorEnded = true; }; orchestration.SetOrchestrator(stringOrchestrator); orchestration.SetOrchestrator(intOrchestrator); orchestration.SolveEquations(); Thread.Sleep(1000); Assert.True(stringOrchestratorEnded); Assert.True(intOrchestratorEnded); }
private void Awake() { if (_instance == null) { _instance = this; } else if (_instance != this) { Destroy(this); } }
public void Test() { var fixture = new Fixture(); var data = fixture.Create <PostData>(); var context = Substitute.For <IDurableOrchestrationContext>(); context.GetInput <PostData>().Returns(data); var function = new Orchestration(); function.Run(context); context.Received().CallActivityAsync <object>(nameof(CreateIssueActivity), data); }
internal static Orchestration TransformModel(Microsoft.BizTalk.ExplorerOM.BtsOrchestration omOrchestration) { var orchestration = new Orchestration(); orchestration.Name = omOrchestration.FullName; orchestration.Description = omOrchestration.Description; foreach (Microsoft.BizTalk.ExplorerOM.OrchestrationPort omPort in omOrchestration.Ports) { orchestration.Ports.Add(OrchestrationPortModelTransformer.TransformModel(omPort)); } return(orchestration); }
public OrchestrationViewer(Orchestration orchestration) { InitializeComponent(); if (orchestration != null) { this.Text = "Orchestration: " + orchestration.Name; Bitmap bmp = orchestration.GetImage(); if (bmp != null) { this.pictureBox1.Image = bmp; this.panel1.AutoScrollMinSize = new Size(bmp.Width, bmp.Height); if (bmp.Width < this.Width) { this.Width = bmp.Width + additionalBorderSize; } else { if (bmp.Width < maxDisplaySize) { this.Width = bmp.Width + additionalBorderSize; } } if (bmp.Height < this.Height) { this.Height = bmp.Height + additionalBorderSize; } else { if (bmp.Height < maxDisplaySize) { this.Height = bmp.Height + additionalBorderSize; } } } } }
/// <summary> /// Parse the port declarations. /// </summary> /// <param name="orchestration">The orchestration containing the port declarations.</param> /// <param name="serviceDeclarationResource">The service declaration to add the parsed resources to.</param> private void ParsePortDeclarations(Orchestration orchestration, ResourceItem serviceDeclarationResource) { foreach (var portDeclaration in orchestration.FindPortDeclarations() ?? Array.Empty <Element>()) { var resourceName = portDeclaration.FindPropertyValue(MetaModelConstants.PropertyKeyName); var resourceKey = string.Concat(serviceDeclarationResource.Key, ":", resourceName); var portDeclarationResource = new ResourceItem { Name = resourceName, Key = resourceKey, Type = ModelConstants.ResourcePortDeclaration, ParentRefId = serviceDeclarationResource.RefId, Rating = ConversionRating.NotSupported }; portDeclaration.Resource = portDeclarationResource; // Maintain pointer to resource. portDeclarationResource.SourceObject = portDeclaration; // Maintain backward pointer. serviceDeclarationResource.Resources.Add(portDeclarationResource); _logger.LogTrace(TraceMessages.ResourceCreated, nameof(OrchestrationServiceDeclarationParser), portDeclarationResource.Key, portDeclarationResource.Name, portDeclarationResource.Type, portDeclarationResource.Key); } }
private static string GetSourceUrl(this Orchestration orchestration, Manifest manifest, bool isThumb) { var versionPrefix = string.Empty; var reuqestPath = HttpContext.Current.Request.ApplicationPath; var action = "/Orchestration/"; if (reuqestPath != "/") { reuqestPath = reuqestPath + "/"; } if (manifest != null && !manifest.IsDefaultLatest) { versionPrefix = manifest.Version + "/"; } if (isThumb) { action = "/OrchestrationThumb/"; } return(string.Concat(reuqestPath, versionPrefix, "Assets", action, orchestration.Name, ".jpeg")); }
/// <summary> /// /// </summary> /// <param name="coll"></param> /// <returns></returns> private BizTalkBaseObjectCollection RetrieveDeployedOrchestrations(AssemblyOrchestrationPairCollection coll, ReportingConfiguration reportingConfiguration) { // darrenj BizTalkInstallation bi = new BizTalkInstallation(); // Ilya - 08/2007: get the Mgmt DB server / name from the Reporting Configuration bi.MgmtDatabaseName = reportingConfiguration.MgmtDatabaseName; bi.Server = reportingConfiguration.MgmtServerName; BizTalkBaseObjectCollection orchestrations = new BizTalkBaseObjectCollection(); string ConnectionStringFormat = "Server={0};Database={1};Integrated Security=SSPI"; BtsCatalogExplorer explorer = new BtsCatalogExplorer(); explorer.ConnectionString = string.Format(ConnectionStringFormat, reportingConfiguration.MgmtServerName, reportingConfiguration.MgmtDatabaseName); foreach (BtsAssembly btsAssembly in explorer.Assemblies) { string asmName = btsAssembly.DisplayName; if (!btsAssembly.IsSystem && coll.ContainsAssembly(asmName)) { foreach (BtsOrchestration btsOrchestration in btsAssembly.Orchestrations) { if (coll.ContainsOrchestration(asmName, btsOrchestration.FullName)) { Orchestration orchestration = bi.GetOrchestration(btsAssembly.DisplayName, btsOrchestration.FullName); orchestration.ParentAssemblyFormattedName = btsAssembly.DisplayName; orchestrations.Add(orchestration); } } } } return(orchestrations); }
internal static void SetReferences(Orchestration orchestration, BizTalkArtifacts artifacts, Microsoft.BizTalk.ExplorerOM.BtsOrchestration omOrchestration) { //As it's possible to exclude application we don't always have all. Only add application we have. if (artifacts.Applications.ContainsKey(omOrchestration.Application.Id())) { orchestration.Application = artifacts.Applications[omOrchestration.Application.Id()]; } //As it's possible to exclude application we don't always have all assemblies. Only add assemblies we have. if (artifacts.Assemblies.ContainsKey(omOrchestration.BtsAssembly.Id())) { orchestration.ParentAssembly = artifacts.Assemblies[omOrchestration.BtsAssembly.Id()]; } if (omOrchestration.Host != null) { orchestration.Host = artifacts.Hosts[omOrchestration.Host.Id()]; } foreach (var port in orchestration.Ports) { OrchestrationPortModelTransformer.SetReferences(port, artifacts, omOrchestration.Ports.Cast <Microsoft.BizTalk.ExplorerOM.OrchestrationPort>().Where(o => o.Name == port.Name).SingleOrDefault()); } }
public OrchestrationViewModel(BizTalkApplication currentApplication, IEnumerable <Manifest> manifests, Manifest currentManifest, IEnumerable <BizTalkBaseObject> breadCrumbs, IEnumerable <BizTalkApplication> applications, IEnumerable <Host> hosts, Orchestration orchestration) : base(currentApplication, manifests, currentManifest, breadCrumbs, applications, hosts) { Orchestration = orchestration; }
public async Task ReturnsUnauthorizedResultIfNotAuthenticated() { // Arrange var request = new DefaultHttpContext().Request; var durableClientMoq = new Mock <IDurableClient>(); var logMoq = new Mock <ILogger>(); // Getting the list of all functions to be validated var functionsToBeCalled = typeof(DfmEndpoint).Assembly.DefinedTypes .Where(t => t.IsClass) .SelectMany(t => t.GetMethods(BindingFlags.Static | BindingFlags.Public)) .Where(m => m.CustomAttributes.Any(a => a.AttributeType == typeof(FunctionNameAttribute))) .Select(m => m.Name) .ToHashSet(); // Only these two methods should be publicly accessible as of today functionsToBeCalled.Remove(nameof(ServeStatics.DfmServeStaticsFunction)); functionsToBeCalled.Remove(nameof(EasyAuthConfig.DfmGetEasyAuthConfigFunction)); // Collecting the list of functions that were actually called by this test var functionsThatWereCalled = new HashSet <string>(); var methodExtractionRegex = new Regex(@"\.(\w+)\(HttpRequest req,"); logMoq.Setup(log => log.Log(It.IsAny <LogLevel>(), It.IsAny <EventId>(), It.IsAny <It.IsAnyType>(), It.IsAny <Exception>(), It.IsAny <Func <It.IsAnyType, Exception, string> >())) .Callback((LogLevel l, EventId i, object s, Exception ex, object o) => { // Ensuring the correct type of exception was raised internally Assert.IsInstanceOfType(ex, typeof(UnauthorizedAccessException)); Assert.AreEqual("No access token provided. Call is rejected.", ex.Message); // Also extracting the function name that was called functionsThatWereCalled.Add(methodExtractionRegex.Match(ex.StackTrace).Groups[1].Value); }); Environment.SetEnvironmentVariable(EnvVariableNames.DFM_HUB_NAME, string.Empty); // Act var results = new List <IActionResult>() { await About.DfmAboutFunction(request, "TestHub", logMoq.Object), await CleanEntityStorage.DfmCleanEntityStorageFunction(request, durableClientMoq.Object, logMoq.Object), await DeleteTaskHub.DfmDeleteTaskHubFunction(request, "TestHub", logMoq.Object), await IdSuggestions.DfmGetIdSuggestionsFunction(request, durableClientMoq.Object, "abc", logMoq.Object), await ManageConnection.DfmManageConnectionFunction(request, "TestHub", new Microsoft.Azure.WebJobs.ExecutionContext(), logMoq.Object), await IdSuggestions.DfmGetIdSuggestionsFunction(request, durableClientMoq.Object, "abc", logMoq.Object), await Orchestration.DfmGetOrchestrationFunction(request, "abc", durableClientMoq.Object, logMoq.Object), await Orchestration.DfmGetOrchestrationHistoryFunction(request, "abc", durableClientMoq.Object, logMoq.Object), await Orchestration.DfmPostOrchestrationFunction(request, "abc", "todo", durableClientMoq.Object, logMoq.Object), await Orchestration.DfmGetOrchestrationTabMarkupFunction(request, "abc", "todo", durableClientMoq.Object, logMoq.Object), await Orchestrations.DfmGetOrchestrationsFunction(request, durableClientMoq.Object, logMoq.Object), await PurgeHistory.DfmPurgeHistoryFunction(request, durableClientMoq.Object, logMoq.Object), await TaskHubNames.DfmGetTaskHubNamesFunction(request, logMoq.Object), }; // Assert results.ForEach(r => Assert.IsInstanceOfType(r, typeof(UnauthorizedResult))); functionsToBeCalled.ExceptWith(functionsThatWereCalled); Assert.IsTrue(functionsToBeCalled.Count == 0, "You forgot to test " + string.Join(", ", functionsToBeCalled)); }
public static string ThumbSourcePath(this Orchestration orchestration, Manifest manifest) { return(GetSourceUrl(orchestration, manifest, true)); }
public void ParsePortTypeWithMissingModule(OrchestrationServiceDeclarationParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { var orchestrationDefinitionName = "orchestrationDefinitionName"; var orchestrationDefinitionKey = "orchestrationDefinitionKey"; var asmContainerKey = "asmContainerKey"; var wrongKey = "wrongKey"; "Given a source model with an orchestration with a missing module" .x(() => { var orchestration = new Orchestration { Name = orchestrationDefinitionName, ResourceContainerKey = asmContainerKey, ResourceDefinitionKey = wrongKey }; var parsedApplication = new ParsedBizTalkApplication { Application = new BizTalkApplication() }; parsedApplication.Application.Orchestrations.Add(orchestration); model = new AzureIntegrationServicesModel(); var group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; group.Applications.Add(parsedApplication); }); "And one orchestration in the source report model" .x(() => { 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 = asmContainerKey, Name = "TestAssembly", Type = ModelConstants.ResourceContainerAssembly, ContainerLocation = @"C:\Test\Test.dll" }; cabContainer.ResourceContainers.Add(asmContainer); var orchestrationDefinition = new ResourceDefinition() { Key = orchestrationDefinitionKey, Name = orchestrationDefinitionName, Type = ModelConstants.ResourceDefinitionOrchestration }; asmContainer.ResourceDefinitions.Add(orchestrationDefinition); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new OrchestrationServiceDeclarationParser(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(wrongKey); context.Errors[0].Message.Should().Contain(ModelConstants.ResourceModule); }); }
public void ParseServiceDeclarationWithAPortDeclarationSuccess(OrchestrationServiceDeclarationParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { var orchestrationDefinitionName = "orchestrationDefinitionName"; var orchestrationDefinitionKey = "orchestrationDefinitionKey"; var serviceDeclarationName = "serviceDeclarationName"; var portDeclarationName = "portDeclarationName"; var asmContainerKey = "asmContainerKey"; "Given a source model with an orchestration and a service declaration, with a port declaration" .x(() => { var odxModel = new MetaModel { Element = new Element[] { new Element { Type = "Module", Element1 = new Element[] { new Element { Type = "ServiceDeclaration", Property = new ElementProperty[] { new ElementProperty { Name = "Name", Value = serviceDeclarationName } }, Element1 = new Element[] { new Element { Type = "PortDeclaration", Property = new ElementProperty[] { new ElementProperty { Name = "Name", Value = portDeclarationName } } } } } } } } }; var orchestration = new Orchestration { Name = orchestrationDefinitionName, ResourceContainerKey = asmContainerKey, ResourceDefinitionKey = orchestrationDefinitionKey, Model = odxModel }; var parsedApplication = new ParsedBizTalkApplication { Application = new BizTalkApplication() }; parsedApplication.Application.Orchestrations.Add(orchestration); model = new AzureIntegrationServicesModel(); var group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; group.Applications.Add(parsedApplication); parsedApplication.Application.ApplicationDefinition = new ApplicationDefinitionFile { ResourceKey = "ResourceKey" }; var container = new ResourceContainer(); container.ResourceDefinitions.Add(new ResourceDefinition()); container.ResourceDefinitions[0].Resources.Add(new ResourceItem { Key = "ResourceKey" }); model.MigrationSource.ResourceContainers.Add(container); }); "And one orchestration in the source report model" .x(() => { 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 = asmContainerKey, Name = "TestAssembly", Type = ModelConstants.ResourceContainerAssembly, ContainerLocation = @"C:\Test\Test.dll" }; cabContainer.ResourceContainers.Add(asmContainer); var orchestrationDefinition = new ResourceDefinition() { Key = orchestrationDefinitionKey, Name = orchestrationDefinitionName, Type = ModelConstants.ResourceDefinitionOrchestration }; asmContainer.ResourceDefinitions.Add(orchestrationDefinition); var metaModel = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Orchestrations[0].Model; var metaModelResource = new ResourceItem() { Key = string.Concat(orchestrationDefinitionKey, ":", MetaModelConstants.MetaModelRootElement), Name = MetaModelConstants.MetaModelRootElement, Type = ModelConstants.ResourceMetaModel }; metaModel.Resource = metaModelResource; metaModelResource.SourceObject = metaModel; orchestrationDefinition.Resources.Add(metaModelResource); var moduleResource = new ResourceItem() { Key = string.Concat(metaModelResource.Key, ":", MetaModelConstants.ElementTypeModule), Name = MetaModelConstants.ElementTypeModule, Type = ModelConstants.ResourceModule }; metaModelResource.Resources.Add(moduleResource); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new OrchestrationServiceDeclarationParser(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 no errors logged" .x(() => context.Errors.Should().BeNullOrEmpty()); "And the resources should be set." .x(() => { // Check the service declaration resource has been created. var moduleResource = model.FindResourcesByType(ModelConstants.ResourceModule).SingleOrDefault(); moduleResource.Should().NotBeNull(); var serviceDeclarationResource = model.FindResourcesByType(ModelConstants.ResourceServiceDeclaration).SingleOrDefault(); serviceDeclarationResource.Should().NotBeNull(); var serviceDeclaration = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Orchestrations[0].FindServiceDeclaration(); // Validate the service declaration resource. serviceDeclarationResource.Should().NotBeNull(); serviceDeclarationResource.Key.Should().Be(string.Concat(moduleResource.Key, ":", serviceDeclarationName)); serviceDeclarationResource.Name.Should().Be(serviceDeclarationName); serviceDeclarationResource.Type.Should().Be(ModelConstants.ResourceServiceDeclaration); // Validate the port declaration resource. var portDeclarationNameResource = serviceDeclarationResource.Resources[0]; portDeclarationNameResource.Name.Should().Be(portDeclarationName); portDeclarationNameResource.Type.Should().Be(ModelConstants.ResourcePortDeclaration); portDeclarationNameResource.Key.Should().StartWith(serviceDeclarationResource.Key); }); }
public void ParseCorrelationTypeWithSuccess(OrchestrationCorrelationTypeParser parser, ILogger logger, MigrationContext context, AzureIntegrationServicesModel model, Exception e) { var orchestrationDefinitionName = "orchestrationDefinitionName"; var orchestrationDefinitionKey = "orchestrationDefinitionKey"; var correlationTypeName = "correlationTypeName"; var asmContainerKey = "asmContainerKey"; "Given a source model with an orchestration and a correlation type" .x(() => { var odxModel = new MetaModel { Element = new Element[] { new Element { Type = "Module", Element1 = new Element[] { new Element { Type = "CorrelationType", Property = new ElementProperty[] { new ElementProperty { Name = "Name", Value = correlationTypeName } } } } } } }; var orchestration = new Orchestration { Name = orchestrationDefinitionName, ResourceContainerKey = asmContainerKey, ResourceDefinitionKey = orchestrationDefinitionKey, Model = odxModel }; var parsedApplication = new ParsedBizTalkApplication { Application = new BizTalkApplication() }; parsedApplication.Application.Orchestrations.Add(orchestration); model = new AzureIntegrationServicesModel(); var group = new ParsedBizTalkApplicationGroup(); model.MigrationSource.MigrationSourceModel = group; group.Applications.Add(parsedApplication); }); "And one orchestration in the source report model" .x(() => { 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 = asmContainerKey, Name = "TestAssembly", Type = ModelConstants.ResourceContainerAssembly, ContainerLocation = @"C:\Test\Test.dll" }; cabContainer.ResourceContainers.Add(asmContainer); var orchestrationDefinition = new ResourceDefinition() { Key = orchestrationDefinitionKey, Name = orchestrationDefinitionName, Type = ModelConstants.ResourceDefinitionOrchestration }; asmContainer.ResourceDefinitions.Add(orchestrationDefinition); var metaModel = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Orchestrations[0].Model; var metaModelResource = new ResourceItem() { Key = string.Concat(orchestrationDefinitionKey, ":", MetaModelConstants.MetaModelRootElement), Name = MetaModelConstants.MetaModelRootElement, Type = ModelConstants.ResourceMetaModel }; metaModel.Resource = metaModelResource; metaModelResource.SourceObject = metaModel; orchestrationDefinition.Resources.Add(metaModelResource); var moduleResource = new ResourceItem() { Key = string.Concat(metaModelResource.Key, ":", MetaModelConstants.ElementTypeModule), Name = MetaModelConstants.ElementTypeModule, Type = ModelConstants.ResourceModule }; metaModelResource.Resources.Add(moduleResource); }); "And a logger" .x(() => logger = new Mock <ILogger>().Object); "And a context" .x(() => context = new MigrationContext()); "And a parser" .x(() => parser = new OrchestrationCorrelationTypeParser(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 no context errors" .x(() => context.Errors.Should().HaveCount(0)); "And the resources should be set." .x(() => { // Check the correlation type resource has been created. var moduleResource = model.FindResourcesByType(ModelConstants.ResourceModule).SingleOrDefault(); moduleResource.Should().NotBeNull(); var correlationTypeResource = model.FindResourcesByType(ModelConstants.ResourceCorrelationType).SingleOrDefault(); correlationTypeResource.Should().NotBeNull(); var correlationType = ((ParsedBizTalkApplicationGroup)model.MigrationSource.MigrationSourceModel).Applications[0].Application.Orchestrations[0].FindCorrelationTypes().Single(); // Validate the correlation type resource. correlationTypeResource.Should().NotBeNull(); correlationTypeResource.Key.Should().Be(string.Concat(moduleResource.Key, ":", correlationTypeName)); correlationTypeResource.Name.Should().Be(correlationTypeName); correlationTypeResource.Type.Should().Be(ModelConstants.ResourceCorrelationType); correlationType.Resource.Should().Be(correlationTypeResource); // The pointer to the resource should be set. correlationTypeResource.ParentRefId.Should().Be(moduleResource.RefId); // The parent ref ID should be set. correlationTypeResource.SourceObject.Should().Be(correlationType); // The resource should have a pointer to the source object. }); }
public static string SourcePath(this Orchestration orchestration, Manifest manifest) { return(GetSourceUrl(orchestration, manifest, false)); }
internal static Orchestration FilterRoutes(this Orchestration orchestration, string key) { orchestration.Routes = orchestration.Routes.Where(y => y.Key.Contains(key.Trim())); return(orchestration); }