<commit_before>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GenerateJsonHelperTest.cs" company="Naos">
//   Copyright 2015 Naos
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Naos.Deployment.Core.Test
{
    using System;
    using System.Collections.Generic;

    using Naos.Deployment.Domain;
    using Naos.Deployment.MessageBus.Contract;
    using Naos.Deployment.MessageBus.Handler;
    using Naos.Deployment.Persistence;
    using Naos.Deployment.Tracking;
    using Naos.MessageBus.Domain;

    using Spritely.ReadModel.Mongo;
    using Spritely.Recipes;

    using Xunit;

    using MessageBusCredentials = Naos.MessageBus.Domain.Credentials;
    using Serializer = Naos.Deployment.Domain.Serializer;
    using SpritelyCredentials = Spritely.ReadModel.Credentials;

    public class GenerateJsonHelperTest
    {
        [Fact]
        public static void CreateDeploymentHandlerDeploymentJson()
        {
            var deploymentDatabaseDns = "Deployment.database.development.com";
            var deploymentDatabaseUser = "user";
            var deploymentDatabasePassword = "<PASSWORD>";

            var region = "sa-east-1";
            var availabilityZone = "sa-east-1a";
            var startStopAccessKey = "<KEY>";
            var startStopSecretKey = "<KEY>";
            var environment = "Development";

            // ----------- CHANGE ABOVE THIS LINE TO YOUR STUFF -----------------
            var packages = new List<PackageDescriptionWithOverrides>();

            var deploymentHandlerPackageId = "Naos.Deployment.MessageBus.Handler";
            var channelNameOne = "aws";
            var channelNameTwo = "cloud";
            var infrastructureTrackerConfig = new InfrastructureTrackerConfigurationDatabase
            {
                Database = new DeploymentDatabase
                {
                    ConnectionSettings = new MongoConnectionSettings
                    {
                        Database = environment,
                        Port = 27017,
                        Server = deploymentDatabaseDns,
                        Credentials = new SpritelyCredentials
                        {
                            User = deploymentDatabaseUser,
                            Password = <PASSWORD>.ToSecureString()
                        }
                    }
                }
            };

            var deploymentMessageHandlerSettings = new DeploymentMessageHandlerSettings
            {
                AccessKey = startStopAccessKey,
                SecretKey = startStopSecretKey,
                Environment = environment,
                SystemLocation = region,
                ContainerSystemLocation = availabilityZone,
                InfrastructureTrackerConfiguration = infrastructureTrackerConfig,
                InstanceNameLookupSource = InstanceNameLookupSource.Arcology
            };

            var deploymentHandler = new PackageDescriptionWithOverrides
            {
                Id = deploymentHandlerPackageId,
                InitializationStrategies =
                                                new InitializationStrategyBase[]
                                                    {
                                                        new InitializationStrategyMessageBusHandler
                                                            {
                                                                ChannelsToMonitor = new[]
                                                                    {
                                                                        new Channel(channelNameOne),
                                                                        new Channel(channelNameTwo)
                                                                    }
                                                            }
                                                    },
                ItsConfigOverrides = new[]
                                                                     {
                                                                         new ItsConfigOverride
                                                                             {
                                                                                 FileNameWithoutExtension = "DeploymentMessageHandlerSettings",
                                                                                 FileContentsJson = Serializer.Serialize(deploymentMessageHandlerSettings, true)
                                                                             }
                                                                     }
            };

            packages.Add(deploymentHandler);
            var output = Serializer.Serialize(packages, true);
            Assert.NotNull(output);
        }

        [Fact]
        public static void CreateHangfireServerDeploymentJson()
        {
            var hangfireDns = "hangfire.development.com";
            var sslCertName = "RootSslCertName";
            var databaseServerPassword = "<PASSWORD>...";

            // ----------- CHANGE ABOVE THIS LINE TO YOUR STUFF -----------------
            var hangfireDatabasePackageId = "Naos.MessageBus.Hangfire.Database";
            var hangfireHarnessPackageId = "Naos.MessageBus.Hangfire.Harness";<commit_msg>Benign commit to trigger the build.<commit_after>﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GenerateJsonHelperTest.cs" company="Naos">
//   Copyright 2015 Naos
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Naos.Deployment.Core.Test
{
    using System;
    using System.Collections.Generic;

    using Naos.Deployment.Domain;
    using Naos.Deployment.MessageBus.Contract;
    using Naos.Deployment.MessageBus.Handler;
    using Naos.Deployment.Persistence;
    using Naos.Deployment.Tracking;
    using Naos.MessageBus.Domain;

    using Spritely.ReadModel.Mongo;
    using Spritely.Recipes;

    using Xunit;

    using MessageBusCredentials = Naos.MessageBus.Domain.Credentials;
    using Serializer = Naos.Deployment.Domain.Serializer;
    using SpritelyCredentials = Spritely.ReadModel.Credentials;

    public class GenerateJsonHelperTest
    {
        [Fact]
        public static void CreateDeploymentHandlerDeploymentJson()
        {
            var deploymentDatabaseDns = "Deployment.database.development.com";
            var deploymentDatabaseUser = "user";
            var deploymentDatabasePassword = "<PASSWORD>";

            var region = "sa-east-1";
            var availabilityZone = "sa-east-1a";
            var startStopAccessKey = "<KEY>";
            var startStopSecretKey = "<KEY>";
            var environment = "Development";

            // ----------- CHANGE ABOVE THIS LINE TO YOUR STUFF ----------------
            var packages = new List<PackageDescriptionWithOverrides>();

            var deploymentHandlerPackageId = "Naos.Deployment.MessageBus.Handler";
            var channelNameOne = "aws";
            var channelNameTwo = "cloud";
            var infrastructureTrackerConfig = new InfrastructureTrackerConfigurationDatabase
            {
                Database = new DeploymentDatabase
                {
                    ConnectionSettings = new MongoConnectionSettings
                    {
                        Database = environment,
                        Port = 27017,
                        Server = deploymentDatabaseDns,
                        Credentials = new SpritelyCredentials
                        {
                            User = deploymentDatabaseUser,
                            Password = <PASSWORD>.ToSecureString()
                        }
                    }
                }
            };

            var deploymentMessageHandlerSettings = new DeploymentMessageHandlerSettings
            {
                AccessKey = startStopAccessKey,
                SecretKey = startStopSecretKey,
                Environment = environment,
                SystemLocation = region,
                ContainerSystemLocation = availabilityZone,
                InfrastructureTrackerConfiguration = infrastructureTrackerConfig,
                InstanceNameLookupSource = InstanceNameLookupSource.Arcology
            };

            var deploymentHandler = new PackageDescriptionWithOverrides
            {
                Id = deploymentHandlerPackageId,
                InitializationStrategies =
                                                new InitializationStrategyBase[]
                                                    {
                                                        new InitializationStrategyMessageBusHandler
                                                            {
                                                                ChannelsToMonitor = new[]
                                                                    {
                                                                        new Channel(channelNameOne),
                                                                        new Channel(channelNameTwo)
                                                                    }
                                                            }
                                                    },
                ItsConfigOverrides = new[]
                                                                     {
                                                                         new ItsConfigOverride
                                                                             {
                                                                                 FileNameWithoutExtension = "DeploymentMessageHandlerSettings",
                                                                                 FileContentsJson = Serializer.Serialize(deploymentMessageHandlerSettings, true)
                                                                             }
                                                                     }
            };

            packages.Add(deploymentHandler);
            var output = Serializer.Serialize(packages, true);
            Assert.NotNull(output);
        }

        [Fact]
        public static void CreateHangfireServerDeploymentJson()
        {
            var hangfireDns = "hangfire.development.com";
            var sslCertName = "RootSslCertName";
            var databaseServerPassword = "<PASSWORD>...";

            // ----------- CHANGE ABOVE THIS LINE TO YOUR STUFF ----------------
            var hangfireDatabasePackageId = "Naos.MessageBus.Hangfire.Database";
            var hangfireHarnessPackageId = "Naos.MessageBus.Hangfire.Harness";
{'fraction_non_alphanumeric': 0.10433284989122553, 'fraction_numerical': 0.001994198694706309, 'mean_word_length': 0.9600284242316575, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 88, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4326988', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1860, 'n_words': 390}