diff --git a/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj b/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj index 582c69e..719daaa 100644 --- a/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj +++ b/TransactionProcessorACL.BusinessLogic.Tests/TransactionProcessorACL.BusinessLogic.Tests.csproj @@ -1,21 +1,21 @@  - net5.0 + net6.0 Full false - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj b/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj index b778af0..3938dc5 100644 --- a/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj +++ b/TransactionProcessorACL.BusinessLogic/TransactionProcessorACL.BusinessLogic.csproj @@ -1,14 +1,14 @@  - net5.0 + net6.0 - - - - + + + + diff --git a/TransactionProcessorACL.DataTransferObjects/TransactionProcessorACL.DataTransferObjects.csproj b/TransactionProcessorACL.DataTransferObjects/TransactionProcessorACL.DataTransferObjects.csproj index c4982e4..d0d6086 100644 --- a/TransactionProcessorACL.DataTransferObjects/TransactionProcessorACL.DataTransferObjects.csproj +++ b/TransactionProcessorACL.DataTransferObjects/TransactionProcessorACL.DataTransferObjects.csproj @@ -1,7 +1,7 @@  - net5.0;netstandard2.0 + net6.0;netstandard2.0 @@ -9,7 +9,7 @@ - + diff --git a/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs b/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs index 9cbec70..d2b14aa 100644 --- a/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs +++ b/TransactionProcessorACL.IntegrationTests/Common/DockerHelper.cs @@ -268,79 +268,16 @@ public override async Task StartContainersForScenarioRun(String scenarioName) this.HttpClient = new HttpClient(); this.HttpClient.BaseAddress = new Uri(TransactionProcessorAclBaseAddressResolver(string.Empty)); - await this.LoadEventStoreProjections().ConfigureAwait(false); - } - - private static EventStoreClientSettings ConfigureEventStoreSettings(Int32 eventStoreHttpPort) - { - String connectionString = $"http://127.0.0.1:{eventStoreHttpPort}"; - - EventStoreClientSettings settings = new EventStoreClientSettings(); - settings.CreateHttpMessageHandler = () => new SocketsHttpHandler - { - SslOptions = - { - RemoteCertificateValidationCallback = (sender, - certificate, - chain, - errors) => true, - } - }; - settings.ConnectionName = "Specflow"; - settings.ConnectivitySettings = new EventStoreClientConnectivitySettings - { - Insecure = true, - Address = new Uri(connectionString), - }; - - settings.DefaultCredentials = new UserCredentials("admin", "changeit"); - return settings; - } - - private async Task LoadEventStoreProjections() - { - //Start our Continous Projections - we might decide to do this at a different stage, but now lets try here - String projectionsFolder = "../../../projections/continuous"; - IPAddress[] ipAddresses = Dns.GetHostAddresses("127.0.0.1"); - - if (!String.IsNullOrWhiteSpace(projectionsFolder)) - { - DirectoryInfo di = new DirectoryInfo(projectionsFolder); - - if (di.Exists) - { - FileInfo[] files = di.GetFiles(); - - EventStoreProjectionManagementClient projectionClient = new EventStoreProjectionManagementClient(ConfigureEventStoreSettings(this.EventStoreHttpPort)); - - foreach (FileInfo file in files) - { - String projection = File.ReadAllText(file.FullName); - String projectionName = file.Name.Replace(".js", String.Empty); - - try - { - Logger.LogInformation($"Creating projection [{projectionName}]"); - await projectionClient.CreateContinuousAsync(projectionName, projection, trackEmittedStreams:true).ConfigureAwait(false); - } - catch (Exception e) - { - Logger.LogError(new Exception($"Projection [{projectionName}] error", e)); - } - } - } - } - - Logger.LogInformation("Loaded projections"); + await this.LoadEventStoreProjections(this.EventStoreHttpPort).ConfigureAwait(false); } public async Task PopulateSubscriptionServiceConfiguration(String estateName) { - EventStorePersistentSubscriptionsClient client = new EventStorePersistentSubscriptionsClient(ConfigureEventStoreSettings(this.EventStoreHttpPort)); - - PersistentSubscriptionSettings settings = new PersistentSubscriptionSettings(resolveLinkTos: true, StreamPosition.Start); - await client.CreateAsync(estateName.Replace(" ", ""), "Reporting", settings); - await client.CreateAsync($"EstateManagementSubscriptionStream_{estateName.Replace(" ", "")}", "Estate Management", settings); + List<(String streamName, String groupName, Int32 maxRetries)> subscriptions = new List<(String streamName, String groupName, Int32 maxRetries)>(); + subscriptions.Add((estateName.Replace(" ", ""), "Reporting", 5)); + subscriptions.Add(($"EstateManagementSubscriptionStream_{estateName.Replace(" ", "")}", "Estate Management", 0)); + subscriptions.Add(($"TransactionProcessorSubscriptionStream_{estateName.Replace(" ", "")}", "Transaction Processor", 0)); + await this.PopulateSubscriptionServiceConfiguration(this.EventStoreHttpPort, subscriptions); } private async Task RemoveEstateReadModel() diff --git a/TransactionProcessorACL.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs b/TransactionProcessorACL.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs index 132024e..162d63a 100644 --- a/TransactionProcessorACL.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs +++ b/TransactionProcessorACL.IntegrationTests/LogonTransaction/LogonTransaction.feature.cs @@ -1,8 +1,8 @@ // ------------------------------------------------------------------------------ // // This code was generated by SpecFlow (https://www.specflow.org/). -// SpecFlow Version:3.5.0.0 -// SpecFlow Generator Version:3.5.0.0 +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -17,7 +17,7 @@ namespace TransactionProcessorACL.IntegrationTests.LogonTransaction using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [Xunit.TraitAttribute("Category", "base")] [Xunit.TraitAttribute("Category", "shared")] @@ -26,7 +26,7 @@ public partial class LogonTransactionFeature : object, Xunit.IClassFixture(_testOutputHelper); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -302,26 +300,16 @@ void System.IDisposable.Dispose() [Xunit.TraitAttribute("FeatureTitle", "LogonTransaction")] [Xunit.TraitAttribute("Description", "Logon Transaction")] [Xunit.TraitAttribute("Category", "PRTest")] - public virtual void LogonTransaction() + public void LogonTransaction() { string[] tagsOfScenario = new string[] { "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction", null, tagsOfScenario, argumentsOfScenario); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Logon Transaction", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 60 this.ScenarioInitialize(scenarioInfo); #line hidden - bool isScenarioIgnored = default(bool); - bool isFeatureIgnored = default(bool); - if ((tagsOfScenario != null)) - { - isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); - } - if ((this._featureTags != null)) - { - isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); - } - if ((isScenarioIgnored || isFeatureIgnored)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -432,7 +420,7 @@ public virtual void LogonTransaction() this.ScenarioCleanup(); } - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class FixtureData : System.IDisposable { diff --git a/TransactionProcessorACL.IntegrationTests/Reconciliation/Reconciliation.feature.cs b/TransactionProcessorACL.IntegrationTests/Reconciliation/Reconciliation.feature.cs index b9a27e9..5340d62 100644 --- a/TransactionProcessorACL.IntegrationTests/Reconciliation/Reconciliation.feature.cs +++ b/TransactionProcessorACL.IntegrationTests/Reconciliation/Reconciliation.feature.cs @@ -1,8 +1,8 @@ // ------------------------------------------------------------------------------ // // This code was generated by SpecFlow (https://www.specflow.org/). -// SpecFlow Version:3.5.0.0 -// SpecFlow Generator Version:3.5.0.0 +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -17,7 +17,7 @@ namespace TransactionProcessorACL.IntegrationTests.Reconciliation using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [Xunit.TraitAttribute("Category", "base")] [Xunit.TraitAttribute("Category", "shared")] @@ -26,7 +26,7 @@ public partial class ReconciliationFeature : object, Xunit.IClassFixture(_testOutputHelper); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -414,26 +412,16 @@ void System.IDisposable.Dispose() [Xunit.TraitAttribute("FeatureTitle", "Reconciliation")] [Xunit.TraitAttribute("Description", "Reconciliation Transaction")] [Xunit.TraitAttribute("Category", "PRTest")] - public virtual void ReconciliationTransaction() + public void ReconciliationTransaction() { string[] tagsOfScenario = new string[] { "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Reconciliation Transaction", null, tagsOfScenario, argumentsOfScenario); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Reconciliation Transaction", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 87 this.ScenarioInitialize(scenarioInfo); #line hidden - bool isScenarioIgnored = default(bool); - bool isFeatureIgnored = default(bool); - if ((tagsOfScenario != null)) - { - isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); - } - if ((this._featureTags != null)) - { - isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); - } - if ((isScenarioIgnored || isFeatureIgnored)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -536,7 +524,7 @@ public virtual void ReconciliationTransaction() this.ScenarioCleanup(); } - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class FixtureData : System.IDisposable { diff --git a/TransactionProcessorACL.IntegrationTests/SaleTransaction/SalesTransaction.feature.cs b/TransactionProcessorACL.IntegrationTests/SaleTransaction/SalesTransaction.feature.cs index ca340fc..c4f433c 100644 --- a/TransactionProcessorACL.IntegrationTests/SaleTransaction/SalesTransaction.feature.cs +++ b/TransactionProcessorACL.IntegrationTests/SaleTransaction/SalesTransaction.feature.cs @@ -1,8 +1,8 @@ // ------------------------------------------------------------------------------ // // This code was generated by SpecFlow (https://www.specflow.org/). -// SpecFlow Version:3.5.0.0 -// SpecFlow Generator Version:3.5.0.0 +// SpecFlow Version:3.9.0.0 +// SpecFlow Generator Version:3.9.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -17,7 +17,7 @@ namespace TransactionProcessorACL.IntegrationTests.SaleTransaction using System.Linq; - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [Xunit.TraitAttribute("Category", "base")] [Xunit.TraitAttribute("Category", "shared")] @@ -26,7 +26,7 @@ public partial class SalesTransactionFeature : object, Xunit.IClassFixture(_testOutputHelper); } - public virtual void ScenarioStart() + public void ScenarioStart() { testRunner.OnScenarioStart(); } - public virtual void ScenarioCleanup() + public void ScenarioCleanup() { testRunner.CollectScenarioErrors(); } @@ -474,26 +472,16 @@ void System.IDisposable.Dispose() [Xunit.TraitAttribute("FeatureTitle", "SalesTransaction")] [Xunit.TraitAttribute("Description", "Sale Transaction")] [Xunit.TraitAttribute("Category", "PRTest")] - public virtual void SaleTransaction() + public void SaleTransaction() { string[] tagsOfScenario = new string[] { "PRTest"}; System.Collections.Specialized.OrderedDictionary argumentsOfScenario = new System.Collections.Specialized.OrderedDictionary(); - TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction", null, tagsOfScenario, argumentsOfScenario); + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Sale Transaction", null, tagsOfScenario, argumentsOfScenario, featureTags); #line 98 this.ScenarioInitialize(scenarioInfo); #line hidden - bool isScenarioIgnored = default(bool); - bool isFeatureIgnored = default(bool); - if ((tagsOfScenario != null)) - { - isScenarioIgnored = tagsOfScenario.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); - } - if ((this._featureTags != null)) - { - isFeatureIgnored = this._featureTags.Where(__entry => __entry != null).Where(__entry => String.Equals(__entry, "ignore", StringComparison.CurrentCultureIgnoreCase)).Any(); - } - if ((isScenarioIgnored || isFeatureIgnored)) + if ((TagHelper.ContainsIgnoreTag(tagsOfScenario) || TagHelper.ContainsIgnoreTag(featureTags))) { testRunner.SkipScenario(); } @@ -740,7 +728,7 @@ public virtual void SaleTransaction() this.ScenarioCleanup(); } - [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.5.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "3.9.0.0")] [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] public class FixtureData : System.IDisposable { diff --git a/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj b/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj index 16053a1..ccf5bc2 100644 --- a/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj +++ b/TransactionProcessorACL.IntegrationTests/TransactionProcessorACL.IntegrationTests.csproj @@ -1,34 +1,34 @@  - net5.0 + net6.0 Full false - - - - - - - - - - - + + + + + + + + + + + - - - - + + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -44,6 +44,33 @@ + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + SpecFlowSingleFileGenerator diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/CallbackHandlerEnricher.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/CallbackHandlerEnricher.js index 39e6807..30acab3 100644 --- a/TransactionProcessorACL.IntegrationTests/projections/continuous/CallbackHandlerEnricher.js +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/CallbackHandlerEnricher.js @@ -1,9 +1,12 @@ -//var fromStreams = fromStreams || require('../../node_modules/esprojection-testing-framework').scope.fromStreams; -//var emit = emit || require('../../node_modules/esprojection-testing-framework').scope.emit; +//starttestsetup +var fromStreams = fromStreams || require('../../node_modules/@transactionprocessing/esprojection-testing-framework').scope.fromStreams; +var emit = emit || require('../../node_modules/@transactionprocessing/esprojection-testing-framework').scope.emit; +//endtestsetup fromStreams("$ce-EstateAggregate", "$et-CallbackReceivedEvent") .when({ - $init: function (s, e) { + $init: function (s, e) + { return { estates: [], debug: [] diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/EstateAggregator.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/EstateAggregator.js index 773d786..3a910e1 100644 --- a/TransactionProcessorACL.IntegrationTests/projections/continuous/EstateAggregator.js +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/EstateAggregator.js @@ -1,5 +1,7 @@ -//var fromAll = fromAll || require("../../node_modules/esprojection-testing-framework").scope.fromAll; -//var linkTo = linkTo || require("../../node_modules/esprojection-testing-framework").scope.linkTo; +//starttestsetup +var fromAll = fromAll || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.fromAll; +var linkTo = linkTo || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.linkTo; +//endtestsetup isEstateEvent = (e) => { return (e.data && e.data.estateId); } isAnEstateCreatedEvent = (e) => { return compareEventTypeSafely(e.eventType, 'EstateCreatedEvent') }; @@ -23,6 +25,8 @@ isTruncated = function (metadata) { return false; }; +getStringWithNoSpaces = function(inputString) { return inputString.replace(/-/gi, "").replace(/ /g, ""); } + fromAll() .when({ $init: function (s, e) { @@ -36,7 +40,7 @@ fromAll() if (isAnEstateCreatedEvent(e)) { s.estates[e.data.estateId] = { - name: e.data.estateName.replace(/-/gi, "").replace(/ /g, "") + name: getStringWithNoSpaces(e.data.estateName) }; } diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/EstateManagementSubscriptionStreamBuilder.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/EstateManagementSubscriptionStreamBuilder.js new file mode 100644 index 0000000..7b69f57 --- /dev/null +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/EstateManagementSubscriptionStreamBuilder.js @@ -0,0 +1,68 @@ +//starttestsetup +var fromAll = fromAll || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.fromAll; +var linkTo = linkTo || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.linkTo; +//endtestsetup + +isEstateEvent = (e) => { return (e.data && e.data.estateId); } +isAnEstateCreatedEvent = (e) => { return compareEventTypeSafely(e.eventType, 'EstateCreatedEvent') }; +compareEventTypeSafely = (sourceEventType, targetEventType) => { return (sourceEventType.toUpperCase() === targetEventType.toUpperCase()); } +isInvalidEvent = (e) => (e === null || e === undefined || e.data === undefined); + +getSupportedEventTypes = function () { + var eventTypes = []; + + eventTypes.push('TransactionHasBeenCompletedEvent'); + eventTypes.push('MerchantFeeSettledEvent'); + eventTypes.push('StatementGeneratedEvent'); + + return eventTypes; +} + +isARequiredEvent = (e) => { + var supportedEvents = getSupportedEventTypes(); + + var index = supportedEvents.indexOf(e.eventType); + + return index !== -1; +}; + +isTruncated = function (metadata) { + if (metadata && metadata['$v']) { + var parts = metadata['$v'].split(":"); + var projectionEpoch = parts[1]; + + return (projectionEpoch < 0); + } + return false; +}; + +getStreamName = function (estateName) { + return 'EstateManagementSubscriptionStream_' + estateName; +} + +getStringWithNoSpaces = function (inputString) { return inputString.replace(/-/gi, "").replace(/ /g, ""); } + +fromAll() + .when({ + $init: function (s, e) { + return { estates: {} } + }, + $any: function (s, e) { + if (isTruncated(e)) return; + + if (isEstateEvent(e)) { + + if (isAnEstateCreatedEvent(e)) { + s.estates[e.data.estateId] = { + filteredName: e.data.estateName.replace(/-/gi, ""), + name: getStringWithNoSpaces(e.data.estateName) + }; + } + + if (isARequiredEvent(e) === false) return; + + linkTo(getStreamName(s.estates[e.data.estateId].name), e); + } + } + } + ); \ No newline at end of file diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/FileProcessorSubscriptionStreamBuilder.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/FileProcessorSubscriptionStreamBuilder.js index 94ab83d..5cc7d29 100644 --- a/TransactionProcessorACL.IntegrationTests/projections/continuous/FileProcessorSubscriptionStreamBuilder.js +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/FileProcessorSubscriptionStreamBuilder.js @@ -1,5 +1,7 @@ -//var fromAll = fromAll || require("../../node_modules/esprojection-testing-framework").scope.fromAll; -//var linkTo = linkTo || require("../../node_modules/esprojection-testing-framework").scope.linkTo; +//starttestsetup +var fromAll = fromAll || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.fromAll; +var linkTo = linkTo || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.linkTo; +//endtestsetup isEstateEvent = (e) => { return (e.data && e.data.estateId); } isAnEstateCreatedEvent = (e) => { return compareEventTypeSafely(e.eventType, 'EstateCreatedEvent') }; @@ -42,6 +44,8 @@ getStreamName = function (estateName) { return 'FileProcessorSubscriptionStream_' + estateName; } +getStringWithNoSpaces = function (inputString) { return inputString.replace(/-/gi, "").replace(/ /g, ""); } + fromAll() .when({ $init: function (s, e) { @@ -55,7 +59,7 @@ fromAll() if (isAnEstateCreatedEvent(e)) { s.estates[e.data.estateId] = { filteredName: e.data.estateName.replace(/-/gi, ""), - name: e.data.estateName.replace(/-/gi, "").replace(" ", "") + name: getStringWithNoSpaces(e.data.estateName) }; } @@ -65,4 +69,4 @@ fromAll() } } } - ); \ No newline at end of file +); \ No newline at end of file diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantAggregator.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantAggregator.js index f8d67be..8174f30 100644 --- a/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantAggregator.js +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantAggregator.js @@ -1,5 +1,7 @@ -//var fromAll = fromAll || require("../../node_modules/esprojection-testing-framework").scope.fromAll; -//var linkTo = linkTo || require("../../node_modules/esprojection-testing-framework").scope.linkTo; +//starttestsetup +var fromAll = fromAll || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.fromAll; +var linkTo = linkTo || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.linkTo; +//endtestsetup isValidEvent = function (e) { @@ -29,9 +31,7 @@ fromAll() if (isValidEvent(e)) { var merchantId = getMerchantId(e); if (merchantId !== null) { - s.merchantId = merchantId; var streamName = "MerchantArchive-" + merchantId.replace(/-/gi, ""); - s.streamName = streamName; linkTo(streamName, e); } } diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantBalanceCalculator.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantBalanceCalculator.js index 6d1d31d..35a14f1 100644 --- a/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantBalanceCalculator.js +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/MerchantBalanceCalculator.js @@ -1,6 +1,8 @@ -//var fromCategory = fromCategory || require('../../node_modules/esprojection-testing-framework').scope.fromCategory; -//var partitionBy = partitionBy !== null ? partitionBy : require('../../node_modules/esprojection-testing-framework').scope.partitionBy; -//var emit = emit || require('../../node_modules/esprojection-testing-framework').scope.emit; +//starttestsetup +var fromCategory = fromCategory || require('../../node_modules/@transactionprocessing/esprojection-testing-framework').scope.fromCategory; +var partitionBy = partitionBy !== null ? partitionBy : require('../../node_modules/@transactionprocessing/esprojection-testing-framework').scope.partitionBy; +var emit = emit || require('../../node_modules/@transactionprocessing/esprojection-testing-framework').scope.emit; +//endtestsetup fromCategory('MerchantArchive') .foreachStream() @@ -18,10 +20,11 @@ fromCategory('MerchantArchive') totalAuthorisedSales: 0, totalDeclinedSales: 0, totalFees: 0, - emittedEvents: 1 + emittedEvents:1 } }, - $any: function (s, e) { + $any: function (s, e) + { if (e === null || e.data === null || e.data.IsJson === false) return; @@ -42,6 +45,11 @@ var eventbus = { return; } + if (e.eventType === 'AutomaticDepositMadeEvent') { + depositMadeEventHandler(s, e); + return; + } + if (e.eventType === 'TransactionHasStartedEvent') { transactionHasStartedEventHandler(s, e); return; @@ -129,7 +137,7 @@ var merchantCreatedEventHandler = function (s, e) { var emitBalanceChangedEvent = function (aggregateId, eventId, s, changeAmount, dateTime, reference) { if (s.initialised === true) { - + // Emit an opening balance event var openingBalanceEvent = { $type: getEventTypeName(), @@ -178,7 +186,7 @@ var depositMadeEventHandler = function (s, e) { incrementBalanceFromDeposit(s, e.data.amount, e.data.depositDateTime); // emit an balance changed event here - s = emitBalanceChangedEvent(e.data.merchantId, e.eventId, s, e.data.amount, e.data.depositDateTime, "Merchant Deposit"); + emitBalanceChangedEvent(e.data.merchantId, e.eventId, s, e.data.amount, e.data.depositDateTime, "Merchant Deposit"); }; var transactionHasStartedEventHandler = function (s, e) { @@ -241,7 +249,7 @@ var merchantFeeAddedToTransactionEventHandler = function (s, e) { // increment the balance now incrementBalanceFromMerchantFee(s, e.data.calculatedValue, e.data.feeCalculatedDateTime); - + // emit an balance changed event here s = emitBalanceChangedEvent(e.data.transactionId, e.eventId, s, e.data.calculatedValue, e.data.feeCalculatedDateTime, "Transaction Fee Processed"); } \ No newline at end of file diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionEnricher.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionEnricher.js index 91d6a52..271dead 100644 --- a/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionEnricher.js +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionEnricher.js @@ -1,7 +1,8 @@ -//var fromCategory = fromCategory || require('../../node_modules/esprojection-testing-framework').scope.fromCategory; -//var partitionBy = partitionBy !== null ? partitionBy : require('../../node_modules/event-store-projection-testing').scope.partitionBy; -//var emit = emit || require('../../node_modules/esprojection-testing-framework').scope.emit; -//var linkTo = linkTo || require("../../node_modules/esprojection-testing-framework").scope.linkTo; +//starttestsetup +var fromCategory = fromCategory || require('../../node_modules/@transactionprocessing/esprojection-testing-framework').scope.fromCategory; +var emit = emit || require('../../node_modules/@transactionprocessing/esprojection-testing-framework').scope.emit; +var linkTo = linkTo || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.linkTo; +//endtestsetup fromCategory('TransactionAggregate') .foreachStream() @@ -46,7 +47,7 @@ function merchantFeeAddedToTransactionEventHandler(s, e) { feeCalculationType: e.data.feeCalculationType, eventId: e.eventId } - emit(getStreamName(s), "MerchantFeeAddedToTransactionEnrichedEvent", newEvent, {}); + emit(getStreamName(s), "MerchantFeeAddedToTransactionEnrichedEvent", newEvent, null); } function serviceProviderFeeAddedToTransactionEventHandler(s, e) { @@ -61,7 +62,7 @@ function serviceProviderFeeAddedToTransactionEventHandler(s, e) { feeCalculationType: e.data.feeCalculationType, eventId: e.eventId } - emit(getStreamName(s), "ServiceProviderFeeAddedToTransactionEnrichedEvent", newEvent, {}); + emit(getStreamName(s), "ServiceProviderFeeAddedToTransactionEnrichedEvent", newEvent, null); } function getStreamName(s) { diff --git a/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js b/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js index 099a6c9..3a0b08b 100644 --- a/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js +++ b/TransactionProcessorACL.IntegrationTests/projections/continuous/TransactionProcessorSubscriptionStreamBuilder.js @@ -1,5 +1,7 @@ -//var fromAll = fromAll || require("../../node_modules/esprojection-testing-framework").scope.fromAll; -//var linkTo = linkTo || require("../../node_modules/esprojection-testing-framework").scope.linkTo; +//starttestsetup +var fromAll = fromAll || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.fromAll; +var linkTo = linkTo || require("../../node_modules/@transactionprocessing/esprojection-testing-framework").scope.linkTo; +//endtestsetup isEstateEvent = (e) => { return (e.data && e.data.estateId); } isAnEstateCreatedEvent = (e) => { return compareEventTypeSafely(e.eventType, 'EstateCreatedEvent') }; @@ -37,6 +39,8 @@ getStreamName = function (estateName) { return 'TransactionProcessorSubscriptionStream_' + estateName; } +getStringWithNoSpaces = function (inputString) { return inputString.replace(/-/gi, "").replace(/ /g, ""); } + fromAll() .when({ $init: function (s, e) { @@ -50,7 +54,7 @@ fromAll() if (isAnEstateCreatedEvent(e)) { s.estates[e.data.estateId] = { filteredName: e.data.estateName.replace(/-/gi, ""), - name: e.data.estateName.replace(/-/gi, "").replace(" ", "") + name: getStringWithNoSpaces(e.data.estateName) }; } @@ -60,4 +64,4 @@ fromAll() } } } - ); \ No newline at end of file +); \ No newline at end of file diff --git a/TransactionProcessorACL.Models/TransactionProcessorACL.Models.csproj b/TransactionProcessorACL.Models/TransactionProcessorACL.Models.csproj index 0bf14e1..efc79fa 100644 --- a/TransactionProcessorACL.Models/TransactionProcessorACL.Models.csproj +++ b/TransactionProcessorACL.Models/TransactionProcessorACL.Models.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 diff --git a/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj b/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj index bde20af..7574c29 100644 --- a/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj +++ b/TransactionProcessorACL.Testing/TransactionProcessorACL.Testing.csproj @@ -1,12 +1,12 @@  - net5.0 + net6.0 None - + diff --git a/TransactionProcessorACL.Tests/General/BootstrapperTests.cs b/TransactionProcessorACL.Tests/General/BootstrapperTests.cs index 4013c8d..74f4a62 100644 --- a/TransactionProcessorACL.Tests/General/BootstrapperTests.cs +++ b/TransactionProcessorACL.Tests/General/BootstrapperTests.cs @@ -11,6 +11,7 @@ namespace TransactionProcessorACL.Tests.General using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.Hosting; using Moq; using Shared.General; using Xunit; @@ -68,6 +69,7 @@ private void AddTestRegistrations(ServiceRegistry services, services.AddSingleton(diagnosticSource); services.AddSingleton(diagnosticSource); services.AddSingleton(hostingEnvironment); + services.AddSingleton(hostingEnvironment); } #endregion diff --git a/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj b/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj index 6e24220..9815dc2 100644 --- a/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj +++ b/TransactionProcessorACL.Tests/TransactionProcessorACL.Tests.csproj @@ -1,22 +1,22 @@  - net5.0 + net6.0 None false - - - + + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/TransactionProcessorACL/Dockerfile b/TransactionProcessorACL/Dockerfile index c271535..743b97c 100644 --- a/TransactionProcessorACL/Dockerfile +++ b/TransactionProcessorACL/Dockerfile @@ -1,7 +1,7 @@ FROM stuartferguson/txnprocbase:latest AS base WORKDIR /app -FROM mcr.microsoft.com/dotnet/sdk:5.0.102-ca-patch-buster-slim AS build +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["TransactionProcessorACL/NuGet.Config", "."] COPY ["TransactionProcessorACL/TransactionProcessorACL.csproj", "TransactionProcessorACL/"] diff --git a/TransactionProcessorACL/TransactionProcessorACL.csproj b/TransactionProcessorACL/TransactionProcessorACL.csproj index a5bcf6d..784da96 100644 --- a/TransactionProcessorACL/TransactionProcessorACL.csproj +++ b/TransactionProcessorACL/TransactionProcessorACL.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 Linux @@ -10,26 +10,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +