From b40f6cea88ef26f045401548640d4f0001f987eb Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 08:35:54 +0100 Subject: [PATCH 1/9] Rename monotor tests --- ...Scenario.cs => MonitorOrchestrationUsingClientScenario.cs} | 4 ++-- ...Scenario.cs => MonitorOrchestrationUsingClientScenario.cs} | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/{MonitorExampleUsingClientScenario.cs => MonitorOrchestrationUsingClientScenario.cs} (98%) rename source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/{MonitorNoInputExampleUsingClientScenario.cs => MonitorOrchestrationUsingClientScenario.cs} (97%) diff --git a/source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorExampleUsingClientScenario.cs b/source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs similarity index 98% rename from source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorExampleUsingClientScenario.cs rename to source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs index 3ddabe07..fb44a30c 100644 --- a/source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorExampleUsingClientScenario.cs +++ b/source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs @@ -33,9 +33,9 @@ namespace Energinet.DataHub.ProcessManager.Client.Tests.Integration.BRS_X01.Inpu /// example orchestration (with input parameter) and monitor its status during its lifetime. /// [Collection(nameof(ProcessManagerClientCollection))] -public class MonitorExampleUsingClientScenario : IAsyncLifetime +public class MonitorOrchestrationUsingClientScenario : IAsyncLifetime { - public MonitorExampleUsingClientScenario( + public MonitorOrchestrationUsingClientScenario( ProcessManagerClientFixture fixture, ITestOutputHelper testOutputHelper) { diff --git a/source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorNoInputExampleUsingClientScenario.cs b/source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs similarity index 97% rename from source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorNoInputExampleUsingClientScenario.cs rename to source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs index 8d0de220..64b1e308 100644 --- a/source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorNoInputExampleUsingClientScenario.cs +++ b/source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs @@ -31,9 +31,9 @@ namespace Energinet.DataHub.ProcessManager.Client.Tests.Integration.BRS_X01.NoIn /// example orchestration (with no input parameter) and monitor its status during its lifetime. /// [Collection(nameof(ProcessManagerClientCollection))] -public class MonitorNoInputExampleUsingClientScenario : IAsyncLifetime +public class MonitorOrchestrationUsingClientScenario : IAsyncLifetime { - public MonitorNoInputExampleUsingClientScenario( + public MonitorOrchestrationUsingClientScenario( ProcessManagerClientFixture fixture, ITestOutputHelper testOutputHelper) { From 1ae31bddffdc9c85177153697a9329f43297e8bd Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 08:58:38 +0100 Subject: [PATCH 2/9] Moved api test to api solution --- ...anager.Example.Orchestrations.Tests.csproj | 4 ++ .../Fixtures/ProcessManagerAppFixture.cs | 52 +++++++++++++++++-- .../MonitorOrchestrationUsingApiScenario.cs} | 14 ++--- .../MonitorOrchestrationUsingApiScenario.cs} | 14 ++--- .../ProcessManager.Tests.csproj | 2 + 5 files changed, 69 insertions(+), 17 deletions(-) rename source/{ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorInputExampleUsingApiScenario.cs => ProcessManager.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorOrchestrationUsingApiScenario.cs} (90%) rename source/{ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorNoInputExampleUsingApiScenario.cs => ProcessManager.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingApiScenario.cs} (90%) diff --git a/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj b/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj index 840d3ee0..366fdcd5 100644 --- a/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj +++ b/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj @@ -42,4 +42,8 @@ + + + + diff --git a/source/ProcessManager.Tests/Fixtures/ProcessManagerAppFixture.cs b/source/ProcessManager.Tests/Fixtures/ProcessManagerAppFixture.cs index 04bd39e9..d4874cd1 100644 --- a/source/ProcessManager.Tests/Fixtures/ProcessManagerAppFixture.cs +++ b/source/ProcessManager.Tests/Fixtures/ProcessManagerAppFixture.cs @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +using Energinet.DataHub.Core.FunctionApp.TestCommon.Azurite; +using Energinet.DataHub.Core.FunctionApp.TestCommon.Configuration; +using Energinet.DataHub.ProcessManager.Core.Tests.Fixtures; +using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; using Xunit.Abstractions; namespace Energinet.DataHub.ProcessManager.Tests.Fixtures; @@ -19,28 +23,70 @@ namespace Energinet.DataHub.ProcessManager.Tests.Fixtures; /// /// Support testing Process Manager Orchestrations app using default fixture configuration. /// -public class ProcessManagerAppFixture - : IAsyncLifetime +public class ProcessManagerAppFixture : IAsyncLifetime { + private const string TaskHubName = "ApiOrchestrationsAppTest01"; + public ProcessManagerAppFixture() { - ProcessManagerAppManager = new ProcessManagerAppManager(); + DatabaseManager = new ProcessManagerDatabaseManager("ApiOrchestrationsAppTests"); + AzuriteManager = new AzuriteManager(useOAuth: true); + + IntegrationTestConfiguration = new IntegrationTestConfiguration(); + + ExampleOrchestrationsAppManager = new ExampleOrchestrationsAppManager( + DatabaseManager, + IntegrationTestConfiguration, + AzuriteManager, + taskHubName: TaskHubName, + appPort: 8201, + manageDatabase: false, + manageAzurite: false); + + ProcessManagerAppManager = new ProcessManagerAppManager( + DatabaseManager, + IntegrationTestConfiguration, + AzuriteManager, + taskHubName: TaskHubName, + appPort: 8202, + manageDatabase: false, + manageAzurite: false); } + public IntegrationTestConfiguration IntegrationTestConfiguration { get; } + + public ExampleOrchestrationsAppManager ExampleOrchestrationsAppManager { get; } + public ProcessManagerAppManager ProcessManagerAppManager { get; } + private ProcessManagerDatabaseManager DatabaseManager { get; } + + private AzuriteManager AzuriteManager { get; } + public async Task InitializeAsync() { + AzuriteManager.CleanupAzuriteStorage(); + AzuriteManager.StartAzurite(); + + await DatabaseManager.CreateDatabaseAsync(); + + await ExampleOrchestrationsAppManager.StartAsync(); await ProcessManagerAppManager.StartAsync(); } public async Task DisposeAsync() { + await ExampleOrchestrationsAppManager.DisposeAsync(); await ProcessManagerAppManager.DisposeAsync(); + + await DatabaseManager.DeleteDatabaseAsync(); + + AzuriteManager.Dispose(); } public void SetTestOutputHelper(ITestOutputHelper? testOutputHelper) { + ExampleOrchestrationsAppManager.SetTestOutputHelper(testOutputHelper); ProcessManagerAppManager.SetTestOutputHelper(testOutputHelper); } } diff --git a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorInputExampleUsingApiScenario.cs b/source/ProcessManager.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorOrchestrationUsingApiScenario.cs similarity index 90% rename from source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorInputExampleUsingApiScenario.cs rename to source/ProcessManager.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorOrchestrationUsingApiScenario.cs index 23fed5f2..f6875ed7 100644 --- a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorInputExampleUsingApiScenario.cs +++ b/source/ProcessManager.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorOrchestrationUsingApiScenario.cs @@ -19,29 +19,29 @@ using Energinet.DataHub.ProcessManager.Abstractions.Api.Model; using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance; using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.InputExample.V1.Model; -using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; +using Energinet.DataHub.ProcessManager.Tests.Fixtures; using FluentAssertions; using Xunit.Abstractions; -namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.InputExample.V1; +namespace Energinet.DataHub.ProcessManager.Tests.Integration.Processes.BRS_X01.InputExample.V1; /// /// Test case where we verify the ProcessManager.Example.Orchestrations and Process Manager Api /// can be used to start an example orchestration (with input parameter) and /// monitor its status during its lifetime. /// -[Collection(nameof(ExampleOrchestrationsAppCollection))] -public class MonitorInputExampleUsingApiScenario : IAsyncLifetime +[Collection(nameof(ProcessManagerAppCollection))] +public class MonitorOrchestrationUsingApiScenario : IAsyncLifetime { - public MonitorInputExampleUsingApiScenario( - ExampleOrchestrationsAppFixture fixture, + public MonitorOrchestrationUsingApiScenario( + ProcessManagerAppFixture fixture, ITestOutputHelper testOutputHelper) { Fixture = fixture; Fixture.SetTestOutputHelper(testOutputHelper); } - private ExampleOrchestrationsAppFixture Fixture { get; } + private ProcessManagerAppFixture Fixture { get; } public Task InitializeAsync() { diff --git a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorNoInputExampleUsingApiScenario.cs b/source/ProcessManager.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingApiScenario.cs similarity index 90% rename from source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorNoInputExampleUsingApiScenario.cs rename to source/ProcessManager.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingApiScenario.cs index aa04bf67..640df006 100644 --- a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorNoInputExampleUsingApiScenario.cs +++ b/source/ProcessManager.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingApiScenario.cs @@ -19,29 +19,29 @@ using Energinet.DataHub.ProcessManager.Abstractions.Api.Model; using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance; using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.NoInputExample.V1.Model; -using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; +using Energinet.DataHub.ProcessManager.Tests.Fixtures; using FluentAssertions; using Xunit.Abstractions; -namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.NoInputExample.V1; +namespace Energinet.DataHub.ProcessManager.Tests.Integration.Processes.BRS_X01.NoInputExample.V1; /// /// Test case where we verify the ProcessManager.Example.Orchestrations and Process Manager Api /// can be used to start an example orchestration (with no-input parameter) and /// monitor its status during its lifetime. /// -[Collection(nameof(ExampleOrchestrationsAppCollection))] -public class MonitorNoInputExampleUsingApiScenario : IAsyncLifetime +[Collection(nameof(ProcessManagerAppCollection))] +public class MonitorOrchestrationUsingApiScenario : IAsyncLifetime { - public MonitorNoInputExampleUsingApiScenario( - ExampleOrchestrationsAppFixture fixture, + public MonitorOrchestrationUsingApiScenario( + ProcessManagerAppFixture fixture, ITestOutputHelper testOutputHelper) { Fixture = fixture; Fixture.SetTestOutputHelper(testOutputHelper); } - private ExampleOrchestrationsAppFixture Fixture { get; } + private ProcessManagerAppFixture Fixture { get; } public Task InitializeAsync() { diff --git a/source/ProcessManager.Tests/ProcessManager.Tests.csproj b/source/ProcessManager.Tests/ProcessManager.Tests.csproj index 420237bf..209997ee 100644 --- a/source/ProcessManager.Tests/ProcessManager.Tests.csproj +++ b/source/ProcessManager.Tests/ProcessManager.Tests.csproj @@ -9,6 +9,7 @@ + @@ -24,6 +25,7 @@ + From fac9275b4ca698e7032845231e8648674cb58a21 Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 11:37:32 +0100 Subject: [PATCH 3/9] Move monitor test from client to orchestration --- .../Extensions/ServiceCollectionExtensions.cs | 2 +- .../V1/MonitorOrchestrationUsingClientScenario.cs | 13 +++++++------ .../V1/MonitorOrchestrationUsingClientScenario.cs | 13 +++++++------ ...ocessManager.Example.Orchestrations.Tests.csproj | 5 +---- 4 files changed, 16 insertions(+), 17 deletions(-) rename source/{ProcessManager.Client.Tests => ProcessManager.Example.Orchestrations.Tests}/Fixtures/Extensions/ServiceCollectionExtensions.cs (92%) rename source/{ProcessManager.Client.Tests/Integration => ProcessManager.Example.Orchestrations.Tests/Integration/Processes}/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs (95%) rename source/{ProcessManager.Client.Tests/Integration => ProcessManager.Example.Orchestrations.Tests/Integration/Processes}/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs (91%) diff --git a/source/ProcessManager.Client.Tests/Fixtures/Extensions/ServiceCollectionExtensions.cs b/source/ProcessManager.Example.Orchestrations.Tests/Fixtures/Extensions/ServiceCollectionExtensions.cs similarity index 92% rename from source/ProcessManager.Client.Tests/Fixtures/Extensions/ServiceCollectionExtensions.cs rename to source/ProcessManager.Example.Orchestrations.Tests/Fixtures/Extensions/ServiceCollectionExtensions.cs index 762701fc..ed9b44cc 100644 --- a/source/ProcessManager.Client.Tests/Fixtures/Extensions/ServiceCollectionExtensions.cs +++ b/source/ProcessManager.Example.Orchestrations.Tests/Fixtures/Extensions/ServiceCollectionExtensions.cs @@ -15,7 +15,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -namespace Energinet.DataHub.ProcessManager.Client.Tests.Fixtures.Extensions; +namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures.Extensions; public static class ServiceCollectionExtensions { diff --git a/source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs b/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs similarity index 95% rename from source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs rename to source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs index fb44a30c..bdf182fa 100644 --- a/source/ProcessManager.Client.Tests/Integration/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs +++ b/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/MonitorOrchestrationUsingClientScenario.cs @@ -16,27 +16,28 @@ using Energinet.DataHub.Core.TestCommon; using Energinet.DataHub.ProcessManager.Abstractions.Api.Model; using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance; +using Energinet.DataHub.ProcessManager.Client; using Energinet.DataHub.ProcessManager.Client.Extensions.DependencyInjection; using Energinet.DataHub.ProcessManager.Client.Extensions.Options; -using Energinet.DataHub.ProcessManager.Client.Tests.Fixtures; -using Energinet.DataHub.ProcessManager.Client.Tests.Fixtures.Extensions; using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.InputExample.V1; using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.InputExample.V1.Model; +using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; +using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures.Extensions; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Xunit.Abstractions; -namespace Energinet.DataHub.ProcessManager.Client.Tests.Integration.BRS_X01.InputExample.V1; +namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.InputExample.V1; /// /// Test case where we verify the Process Manager clients can be used to start an /// example orchestration (with input parameter) and monitor its status during its lifetime. /// -[Collection(nameof(ProcessManagerClientCollection))] +[Collection(nameof(ExampleOrchestrationsAppCollection))] public class MonitorOrchestrationUsingClientScenario : IAsyncLifetime { public MonitorOrchestrationUsingClientScenario( - ProcessManagerClientFixture fixture, + ExampleOrchestrationsAppFixture fixture, ITestOutputHelper testOutputHelper) { Fixture = fixture; @@ -54,7 +55,7 @@ public MonitorOrchestrationUsingClientScenario( ServiceProvider = services.BuildServiceProvider(); } - private ProcessManagerClientFixture Fixture { get; } + private ExampleOrchestrationsAppFixture Fixture { get; } private ServiceProvider ServiceProvider { get; } diff --git a/source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs b/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs similarity index 91% rename from source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs rename to source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs index 64b1e308..5c036a2b 100644 --- a/source/ProcessManager.Client.Tests/Integration/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs +++ b/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/NoInputExample/V1/MonitorOrchestrationUsingClientScenario.cs @@ -15,26 +15,27 @@ using Energinet.DataHub.Core.TestCommon; using Energinet.DataHub.ProcessManager.Abstractions.Api.Model; using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance; +using Energinet.DataHub.ProcessManager.Client; using Energinet.DataHub.ProcessManager.Client.Extensions.DependencyInjection; using Energinet.DataHub.ProcessManager.Client.Extensions.Options; -using Energinet.DataHub.ProcessManager.Client.Tests.Fixtures; -using Energinet.DataHub.ProcessManager.Client.Tests.Fixtures.Extensions; using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.NoInputExample.V1.Model; +using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; +using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures.Extensions; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Xunit.Abstractions; -namespace Energinet.DataHub.ProcessManager.Client.Tests.Integration.BRS_X01.NoInputExample.V1; +namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.NoInputExample.V1; /// /// Test case where we verify the Process Manager clients can be used to start an /// example orchestration (with no input parameter) and monitor its status during its lifetime. /// -[Collection(nameof(ProcessManagerClientCollection))] +[Collection(nameof(ExampleOrchestrationsAppCollection))] public class MonitorOrchestrationUsingClientScenario : IAsyncLifetime { public MonitorOrchestrationUsingClientScenario( - ProcessManagerClientFixture fixture, + ExampleOrchestrationsAppFixture fixture, ITestOutputHelper testOutputHelper) { Fixture = fixture; @@ -52,7 +53,7 @@ public MonitorOrchestrationUsingClientScenario( ServiceProvider = services.BuildServiceProvider(); } - private ProcessManagerClientFixture Fixture { get; } + private ExampleOrchestrationsAppFixture Fixture { get; } private ServiceProvider ServiceProvider { get; } diff --git a/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj b/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj index 366fdcd5..155d4953 100644 --- a/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj +++ b/source/ProcessManager.Example.Orchestrations.Tests/ProcessManager.Example.Orchestrations.Tests.csproj @@ -25,6 +25,7 @@ + @@ -42,8 +43,4 @@ - - - - From e9577f6ec31f27d7102e744c47289de7a2dbccb3 Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 11:58:07 +0100 Subject: [PATCH 4/9] Renames activities for example processes --- ...ializeActivity_Brs_X01_InputExample_V1.cs} | 4 +- ...minateActivity_Brs_X01_InputExample_V1.cs} | 4 +- ...epStartActivity_Brs_X01_InputExample_V1.cs | 48 ------------------- ...tepStopActivity_Brs_X01_InputExample_V1.cs | 48 ------------------- ...unningActivity_Brs_X01_InputExample_V1.cs} | 9 ++-- ...inatedActivity_Brs_X01_InputExample_V1.cs} | 9 ++-- .../Orchestration_Brs_X01_InputExample_V1.cs | 36 +++++++------- ...StartActivity_Brs_X01_NoInputExample_V1.cs | 48 ------------------- ...pStopActivity_Brs_X01_NoInputExample_V1.cs | 48 ------------------- ...ningActivity_Brs_X01_NoInputExample_V1.cs} | 9 ++-- ...atedActivity_Brs_X01_NoInputExample_V1.cs} | 9 ++-- ...Orchestration_Brs_X01_NoInputExample_V1.cs | 28 ++++++----- 12 files changed, 60 insertions(+), 240 deletions(-) rename source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/{InitializeOrchestrationActivity_Brs_X01_InputExample_V1.cs => OrchestrationInitializeActivity_Brs_X01_InputExample_V1.cs} (94%) rename source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/{TerminateOrchestrationActivity_Brs_X01_InputExample_V1.cs => OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs} (92%) delete mode 100644 source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStartActivity_Brs_X01_InputExample_V1.cs delete mode 100644 source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStopActivity_Brs_X01_InputExample_V1.cs rename source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/{FirstStepStartActivity_Brs_X01_InputExample_V1.cs => TransitionStepToRunningActivity_Brs_X01_InputExample_V1.cs} (85%) rename source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/{FirstStepStopActivity_Brs_X01_InputExample_V1.cs => TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs} (86%) delete mode 100644 source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStartActivity_Brs_X01_NoInputExample_V1.cs delete mode 100644 source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStopActivity_Brs_X01_NoInputExample_V1.cs rename source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/{FirstStepStartActivity_Brs_X01_NoInputExample_V1.cs => TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1.cs} (85%) rename source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/{FirstStepStopActivity_Brs_X01_NoInputExample_V1.cs => TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs} (85%) diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/InitializeOrchestrationActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationInitializeActivity_Brs_X01_InputExample_V1.cs similarity index 94% rename from source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/InitializeOrchestrationActivity_Brs_X01_InputExample_V1.cs rename to source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationInitializeActivity_Brs_X01_InputExample_V1.cs index adb34986..92d0054a 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/InitializeOrchestrationActivity_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationInitializeActivity_Brs_X01_InputExample_V1.cs @@ -20,14 +20,14 @@ namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.InputExample.V1.Activities; -internal class InitializeOrchestrationActivity_Brs_X01_InputExample_V1( +internal class OrchestrationInitializeActivity_Brs_X01_InputExample_V1( IClock clock, IOrchestrationInstanceProgressRepository progressRepository) : ProgressActivityBase( clock, progressRepository) { - [Function(nameof(InitializeOrchestrationActivity_Brs_X01_InputExample_V1))] + [Function(nameof(OrchestrationInitializeActivity_Brs_X01_InputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) { diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TerminateOrchestrationActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs similarity index 92% rename from source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TerminateOrchestrationActivity_Brs_X01_InputExample_V1.cs rename to source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs index 28510a7d..8a386d55 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TerminateOrchestrationActivity_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs @@ -19,14 +19,14 @@ namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.InputExample.V1.Activities; -internal class TerminateOrchestrationActivity_Brs_X01_InputExample_V1( +internal class OrchestrationTerminateActivity_Brs_X01_InputExample_V1( IClock clock, IOrchestrationInstanceProgressRepository progressRepository) : ProgressActivityBase( clock, progressRepository) { - [Function(nameof(TerminateOrchestrationActivity_Brs_X01_InputExample_V1))] + [Function(nameof(OrchestrationTerminateActivity_Brs_X01_InputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) { diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStartActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStartActivity_Brs_X01_InputExample_V1.cs deleted file mode 100644 index 70bc71b4..00000000 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStartActivity_Brs_X01_InputExample_V1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 Energinet DataHub A/S -// -// Licensed under the Apache License, Version 2.0 (the "License2"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Energinet.DataHub.ProcessManagement.Core.Application.Orchestration; -using Energinet.DataHub.ProcessManagement.Core.Domain.OrchestrationInstance; -using Microsoft.Azure.Functions.Worker; -using NodaTime; - -namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.InputExample.V1.Activities; - -internal class SecondStepStartActivity_Brs_X01_InputExample_V1( - IClock clock, - IOrchestrationInstanceProgressRepository progressRepository) - : ProgressActivityBase( - clock, - progressRepository) -{ - [Function(nameof(SecondStepStartActivity_Brs_X01_InputExample_V1))] - public async Task Run( - [ActivityTrigger] ActivityInput input) - { - var orchestrationInstance = await ProgressRepository - .GetAsync(input.OrchestrationInstanceId) - .ConfigureAwait(false); - - var step = orchestrationInstance.Steps - .Single(step => step.Sequence == Orchestration_Brs_X01_InputExample_V1.SkippableStepSequence); - - step.Lifecycle.TransitionToRunning(Clock); - await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); - - await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); - } - - public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); -} diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStopActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStopActivity_Brs_X01_InputExample_V1.cs deleted file mode 100644 index c8736c64..00000000 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/SecondStepStopActivity_Brs_X01_InputExample_V1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 Energinet DataHub A/S -// -// Licensed under the Apache License, Version 2.0 (the "License2"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Energinet.DataHub.ProcessManagement.Core.Application.Orchestration; -using Energinet.DataHub.ProcessManagement.Core.Domain.OrchestrationInstance; -using Microsoft.Azure.Functions.Worker; -using NodaTime; - -namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.InputExample.V1.Activities; - -internal class SecondStepStopActivity_Brs_X01_InputExample_V1( - IClock clock, - IOrchestrationInstanceProgressRepository progressRepository) - : ProgressActivityBase( - clock, - progressRepository) -{ - [Function(nameof(SecondStepStopActivity_Brs_X01_InputExample_V1))] - public async Task Run( - [ActivityTrigger] ActivityInput input) - { - var orchestrationInstance = await ProgressRepository - .GetAsync(input.OrchestrationInstanceId) - .ConfigureAwait(false); - - var step = orchestrationInstance.Steps - .Single(step => step.Sequence == Orchestration_Brs_X01_InputExample_V1.SkippableStepSequence); - - step.Lifecycle.TransitionToTerminated(Clock, OrchestrationStepTerminationStates.Succeeded); - await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); - - await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); - } - - public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); -} diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/FirstStepStartActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToRunningActivity_Brs_X01_InputExample_V1.cs similarity index 85% rename from source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/FirstStepStartActivity_Brs_X01_InputExample_V1.cs rename to source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToRunningActivity_Brs_X01_InputExample_V1.cs index fd8da8f6..ba2cbc82 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/FirstStepStartActivity_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToRunningActivity_Brs_X01_InputExample_V1.cs @@ -19,14 +19,14 @@ namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.InputExample.V1.Activities; -internal class FirstStepStartActivity_Brs_X01_InputExample_V1( +internal class TransitionStepToRunningActivity_Brs_X01_InputExample_V1( IClock clock, IOrchestrationInstanceProgressRepository progressRepository) : ProgressActivityBase( clock, progressRepository) { - [Function(nameof(FirstStepStartActivity_Brs_X01_InputExample_V1))] + [Function(nameof(TransitionStepToRunningActivity_Brs_X01_InputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) { @@ -34,7 +34,7 @@ public async Task Run( .GetAsync(input.OrchestrationInstanceId) .ConfigureAwait(false); - var step = orchestrationInstance.Steps.Single(x => x.Sequence == Orchestration_Brs_X01_InputExample_V1.FirstStepSequence); + var step = orchestrationInstance.Steps.Single(x => x.Sequence == input.StepSequence); step.Lifecycle.TransitionToRunning(Clock); await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); @@ -42,5 +42,6 @@ public async Task Run( } public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); + OrchestrationInstanceId OrchestrationInstanceId, + int StepSequence); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/FirstStepStopActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs similarity index 86% rename from source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/FirstStepStopActivity_Brs_X01_InputExample_V1.cs rename to source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs index d8cb6b5e..7ec0be3c 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/FirstStepStopActivity_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs @@ -19,14 +19,14 @@ namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.InputExample.V1.Activities; -internal class FirstStepStopActivity_Brs_X01_InputExample_V1( +internal class TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1( IClock clock, IOrchestrationInstanceProgressRepository progressRepository) : ProgressActivityBase( clock, progressRepository) { - [Function(nameof(FirstStepStopActivity_Brs_X01_InputExample_V1))] + [Function(nameof(TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) { @@ -34,7 +34,7 @@ public async Task Run( .GetAsync(input.OrchestrationInstanceId) .ConfigureAwait(false); - var step = orchestrationInstance.Steps.Single(x => x.Sequence == Orchestration_Brs_X01_InputExample_V1.FirstStepSequence); + var step = orchestrationInstance.Steps.Single(x => x.Sequence == input.StepSequence); step.Lifecycle.TransitionToTerminated(Clock, OrchestrationStepTerminationStates.Succeeded); await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); @@ -42,5 +42,6 @@ public async Task Run( } public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); + OrchestrationInstanceId OrchestrationInstanceId, + int StepSequence); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs index c30aaedc..564b2c2b 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs @@ -48,42 +48,46 @@ public async Task Run( // Initialize var executionPlan = await context.CallActivityAsync( - nameof(InitializeOrchestrationActivity_Brs_X01_InputExample_V1), - new InitializeOrchestrationActivity_Brs_X01_InputExample_V1.ActivityInput( + nameof(OrchestrationInitializeActivity_Brs_X01_InputExample_V1), + new OrchestrationInitializeActivity_Brs_X01_InputExample_V1.ActivityInput( instanceId), _defaultRetryOptions); // First Step await context.CallActivityAsync( - nameof(FirstStepStartActivity_Brs_X01_InputExample_V1), - new FirstStepStartActivity_Brs_X01_InputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToRunningActivity_Brs_X01_InputExample_V1), + new TransitionStepToRunningActivity_Brs_X01_InputExample_V1.ActivityInput( + instanceId, + FirstStepSequence), _defaultRetryOptions); await context.CallActivityAsync( - nameof(FirstStepStopActivity_Brs_X01_InputExample_V1), - new FirstStepStopActivity_Brs_X01_InputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1), + new TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.ActivityInput( + instanceId, + FirstStepSequence), _defaultRetryOptions); // Skippable step if (!executionPlan.SkippedStepsBySequence.Contains(SkippableStepSequence)) { await context.CallActivityAsync( - nameof(SecondStepStartActivity_Brs_X01_InputExample_V1), - new SecondStepStartActivity_Brs_X01_InputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToRunningActivity_Brs_X01_InputExample_V1), + new TransitionStepToRunningActivity_Brs_X01_InputExample_V1.ActivityInput( + instanceId, + SkippableStepSequence), _defaultRetryOptions); await context.CallActivityAsync( - nameof(SecondStepStopActivity_Brs_X01_InputExample_V1), - new SecondStepStopActivity_Brs_X01_InputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1), + new TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.ActivityInput( + instanceId, + SkippableStepSequence), _defaultRetryOptions); } // Terminate await context.CallActivityAsync( - nameof(TerminateOrchestrationActivity_Brs_X01_InputExample_V1), - new TerminateOrchestrationActivity_Brs_X01_InputExample_V1.ActivityInput( + nameof(OrchestrationTerminateActivity_Brs_X01_InputExample_V1), + new OrchestrationTerminateActivity_Brs_X01_InputExample_V1.ActivityInput( instanceId), _defaultRetryOptions); diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStartActivity_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStartActivity_Brs_X01_NoInputExample_V1.cs deleted file mode 100644 index d3004cea..00000000 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStartActivity_Brs_X01_NoInputExample_V1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 Energinet DataHub A/S -// -// Licensed under the Apache License, Version 2.0 (the "License2"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Energinet.DataHub.ProcessManagement.Core.Application.Orchestration; -using Energinet.DataHub.ProcessManagement.Core.Domain.OrchestrationInstance; -using Microsoft.Azure.Functions.Worker; -using NodaTime; - -namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.NoInputExample.V1.Activities; - -internal class SecondStepStartActivity_Brs_X01_NoInputExample_V1( - IClock clock, - IOrchestrationInstanceProgressRepository progressRepository) - : ProgressActivityBase( - clock, - progressRepository) -{ - [Function(nameof(SecondStepStartActivity_Brs_X01_NoInputExample_V1))] - public async Task Run( - [ActivityTrigger] ActivityInput input) - { - var orchestrationInstance = await ProgressRepository - .GetAsync(input.OrchestrationInstanceId) - .ConfigureAwait(false); - - var step = orchestrationInstance.Steps - .Single(step => step.Sequence == Orchestration_Brs_X01_NoInputExample_V1.SkippableStepSequence); - - step.Lifecycle.TransitionToRunning(Clock); - await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); - - await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); - } - - public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); -} diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStopActivity_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStopActivity_Brs_X01_NoInputExample_V1.cs deleted file mode 100644 index f3d96248..00000000 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/SecondStepStopActivity_Brs_X01_NoInputExample_V1.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 Energinet DataHub A/S -// -// Licensed under the Apache License, Version 2.0 (the "License2"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Energinet.DataHub.ProcessManagement.Core.Application.Orchestration; -using Energinet.DataHub.ProcessManagement.Core.Domain.OrchestrationInstance; -using Microsoft.Azure.Functions.Worker; -using NodaTime; - -namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.NoInputExample.V1.Activities; - -internal class SecondStepStopActivity_Brs_X01_NoInputExample_V1( - IClock clock, - IOrchestrationInstanceProgressRepository progressRepository) - : ProgressActivityBase( - clock, - progressRepository) -{ - [Function(nameof(SecondStepStopActivity_Brs_X01_NoInputExample_V1))] - public async Task Run( - [ActivityTrigger] ActivityInput input) - { - var orchestrationInstance = await ProgressRepository - .GetAsync(input.OrchestrationInstanceId) - .ConfigureAwait(false); - - var step = orchestrationInstance.Steps - .Single(step => step.Sequence == Orchestration_Brs_X01_NoInputExample_V1.SkippableStepSequence); - - step.Lifecycle.TransitionToTerminated(Clock, OrchestrationStepTerminationStates.Succeeded); - await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); - - await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); - } - - public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); -} diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/FirstStepStartActivity_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1.cs similarity index 85% rename from source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/FirstStepStartActivity_Brs_X01_NoInputExample_V1.cs rename to source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1.cs index 49f38cad..107a7808 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/FirstStepStartActivity_Brs_X01_NoInputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1.cs @@ -19,14 +19,14 @@ namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.NoInputExample.V1.Activities; -internal class FirstStepStartActivity_Brs_X01_NoInputExample_V1( +internal class TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1( IClock clock, IOrchestrationInstanceProgressRepository progressRepository) : ProgressActivityBase( clock, progressRepository) { - [Function(nameof(FirstStepStartActivity_Brs_X01_NoInputExample_V1))] + [Function(nameof(TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) { @@ -34,7 +34,7 @@ public async Task Run( .GetAsync(input.OrchestrationInstanceId) .ConfigureAwait(false); - var step = orchestrationInstance.Steps.Single(x => x.Sequence == Orchestration_Brs_X01_NoInputExample_V1.FirstStepSequence); + var step = orchestrationInstance.Steps.Single(x => x.Sequence == input.StepSequence); step.Lifecycle.TransitionToRunning(Clock); await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); @@ -42,5 +42,6 @@ public async Task Run( } public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); + OrchestrationInstanceId OrchestrationInstanceId, + int StepSequence); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/FirstStepStopActivity_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs similarity index 85% rename from source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/FirstStepStopActivity_Brs_X01_NoInputExample_V1.cs rename to source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs index ae5286ea..fbffed4b 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/FirstStepStopActivity_Brs_X01_NoInputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs @@ -19,14 +19,14 @@ namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.NoInputExample.V1.Activities; -internal class FirstStepStopActivity_Brs_X01_NoInputExample_V1( +internal class TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1( IClock clock, IOrchestrationInstanceProgressRepository progressRepository) : ProgressActivityBase( clock, progressRepository) { - [Function(nameof(FirstStepStopActivity_Brs_X01_NoInputExample_V1))] + [Function(nameof(TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) { @@ -34,7 +34,7 @@ public async Task Run( .GetAsync(input.OrchestrationInstanceId) .ConfigureAwait(false); - var step = orchestrationInstance.Steps.Single(x => x.Sequence == Orchestration_Brs_X01_NoInputExample_V1.FirstStepSequence); + var step = orchestrationInstance.Steps.Single(x => x.Sequence == input.StepSequence); step.Lifecycle.TransitionToTerminated(Clock, OrchestrationStepTerminationStates.Succeeded); await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); @@ -42,5 +42,6 @@ public async Task Run( } public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); + OrchestrationInstanceId OrchestrationInstanceId, + int StepSequence); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs index e406eefc..24e9f986 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs @@ -48,28 +48,32 @@ public async Task Run( // First Step await context.CallActivityAsync( - nameof(FirstStepStartActivity_Brs_X01_NoInputExample_V1), - new FirstStepStartActivity_Brs_X01_NoInputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1), + new TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1.ActivityInput( + instanceId, + FirstStepSequence), _defaultRetryOptions); await context.CallActivityAsync( - nameof(FirstStepStopActivity_Brs_X01_NoInputExample_V1), - new FirstStepStopActivity_Brs_X01_NoInputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1), + new TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.ActivityInput( + instanceId, + FirstStepSequence), _defaultRetryOptions); // Skippable step if (!executionPlan.SkippedStepsBySequence.Contains(SkippableStepSequence)) { await context.CallActivityAsync( - nameof(SecondStepStartActivity_Brs_X01_NoInputExample_V1), - new SecondStepStartActivity_Brs_X01_NoInputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1), + new TransitionStepToRunningActivity_Brs_X01_NoInputExample_V1.ActivityInput( + instanceId, + SkippableStepSequence), _defaultRetryOptions); await context.CallActivityAsync( - nameof(SecondStepStopActivity_Brs_X01_NoInputExample_V1), - new SecondStepStopActivity_Brs_X01_NoInputExample_V1.ActivityInput( - instanceId), + nameof(TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1), + new TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.ActivityInput( + instanceId, + SkippableStepSequence), _defaultRetryOptions); } From 6a4fb374a489bc722e37f88b83da012e3381c33e Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 12:01:37 +0100 Subject: [PATCH 5/9] Remove deprecated tests --- .../V1/OrchestrationsCompletionsTests.cs | 141 ---------------- .../V1/OrchestrationsSearchTests.cs | 158 ------------------ 2 files changed, 299 deletions(-) delete mode 100644 source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsCompletionsTests.cs delete mode 100644 source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsSearchTests.cs diff --git a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsCompletionsTests.cs b/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsCompletionsTests.cs deleted file mode 100644 index 2e785f9a..00000000 --- a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsCompletionsTests.cs +++ /dev/null @@ -1,141 +0,0 @@ -// // Copyright 2020 Energinet DataHub A/S -// // -// // Licensed under the Apache License, Version 2.0 (the "License2"); -// // you may not use this file except in compliance with the License. -// // You may obtain a copy of the License at -// // -// // http://www.apache.org/licenses/LICENSE-2.0 -// // -// // Unless required by applicable law or agreed to in writing, software -// // distributed under the License is distributed on an "AS IS" BASIS, -// // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// // See the License for the specific language governing permissions and -// // limitations under the License. -// -// using System.Text; -// using System.Text.Json; -// using Energinet.DataHub.Core.DurableFunctionApp.TestCommon.DurableTask; -// using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.Example.V1.Model; -// using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; -// using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Models; -// using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance; -// using FluentAssertions; -// using Xunit.Abstractions; -// -// namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.Examples.V1; -// -// /// -// /// Tests that verify that we can start and finish a "BRS_X01" orchestration. -// /// -// [Collection(nameof(ExampleOrchestrationsAppCollection))] -// public class OrchestrationsCompletionsTests : IAsyncLifetime -// { -// public OrchestrationsCompletionsTests(ExampleOrchestrationsAppFixture fixture, ITestOutputHelper testOutputHelper) -// { -// Fixture = fixture; -// Fixture.SetTestOutputHelper(testOutputHelper); -// } -// -// private ExampleOrchestrationsAppFixture Fixture { get; } -// -// public Task InitializeAsync() -// { -// Fixture.ExampleOrchestrationsAppManager.AppHostManager.ClearHostLog(); -// -// return Task.CompletedTask; -// } -// -// public Task DisposeAsync() -// { -// Fixture.SetTestOutputHelper(null!); -// -// return Task.CompletedTask; -// } -// -// [Fact] -// public async Task ExampleOrchestration_WhenOrchestrationIsStarted_ThenItCompletesAndHaveHistoryCount8() -// { -// // Arrange -// var input = new InputV1(false); -// -// // Act -// var orchestrationId = await StartOrchestrationAsync(input); -// -// // Assert -// // => Wait for orchestration to complete -// var completedOrchestrationStatus = await Fixture.ExampleOrchestrationsAppManager.DurableClient.WaitForOrchestrationCompletedAsync( -// orchestrationId, -// TimeSpan.FromSeconds(60)); -// completedOrchestrationStatus.Should().NotBeNull(); -// -// var activities = completedOrchestrationStatus.History -// .OrderBy(item => item["Timestamp"]) -// .Select(item => item.ToObject()) -// .ToList(); -// -// activities.Should() -// .NotBeNull() -// .And.Equal( -// [ -// new OrchestrationHistoryItem( -// EventType: "ExecutionStarted", -// Name: null, -// FunctionName: "Orchestration_Brs_X01_Example_V1"), -// new OrchestrationHistoryItem( -// EventType: "TaskCompleted", -// Name: null, -// FunctionName: "InitializeOrchestrationActivity_Brs_X01_Example_V1"), -// new OrchestrationHistoryItem( -// EventType: "TaskCompleted", -// Name: null, -// FunctionName: "FirstStepStartActivity_Brs_X01_Example_V1"), -// new OrchestrationHistoryItem( -// EventType: "TaskCompleted", -// Name: null, -// FunctionName: "FirstStepStopActivity_Brs_X01_Example_V1"), -// new OrchestrationHistoryItem( -// EventType: "TaskCompleted", -// Name: null, -// FunctionName: "SecondStepStartActivity_Brs_X01_Example_V1"), -// new OrchestrationHistoryItem( -// EventType: "TaskCompleted", -// Name: null, -// FunctionName: "SecondStepStopActivity_Brs_X01_Example_V1"), -// new OrchestrationHistoryItem( -// EventType: "TaskCompleted", -// Name: null, -// FunctionName: "TerminateOrchestrationActivity_Brs_X01_Example_V1"), -// new OrchestrationHistoryItem( -// "ExecutionCompleted", -// null, -// null), -// ]); -// } -// -// private async Task StartOrchestrationAsync(InputV1 input) -// { -// var command = new StartExampleCommandV1( -// operatingIdentity: new UserIdentityDto( -// Guid.NewGuid(), -// Guid.NewGuid()), -// input); -// -// var json = JsonSerializer.Serialize(command, command.GetType()); -// -// using var request = new HttpRequestMessage( -// HttpMethod.Post, -// $"/api/orchestrationinstance/command/start/custom/{command.OrchestrationDescriptionUniqueName.Name}/{command.OrchestrationDescriptionUniqueName.Version}"); -// -// request.Content = new StringContent( -// json, -// Encoding.UTF8, -// "application/json"); -// -// var id = await (await Fixture.ExampleOrchestrationsAppManager.AppHostManager.HttpClient -// .SendAsync(request)) -// .Content.ReadAsStringAsync(); -// -// // id is a string containing a start and end quote :( -// return id.Substring(1, id.Length - 2); -// } -// } diff --git a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsSearchTests.cs b/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsSearchTests.cs deleted file mode 100644 index 0b2b09ef..00000000 --- a/source/ProcessManager.Example.Orchestrations.Tests/Integration/Processes/BRS_X01/InputExample/V1/OrchestrationsSearchTests.cs +++ /dev/null @@ -1,158 +0,0 @@ -// // Copyright 2020 Energinet DataHub A/S -// // -// // Licensed under the Apache License, Version 2.0 (the "License2"); -// // you may not use this file except in compliance with the License. -// // You may obtain a copy of the License at -// // -// // http://www.apache.org/licenses/LICENSE-2.0 -// // -// // Unless required by applicable law or agreed to in writing, software -// // distributed under the License is distributed on an "AS IS" BASIS, -// // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// // See the License for the specific language governing permissions and -// // limitations under the License. -// -// using System.Collections.ObjectModel; -// using System.Text; -// using System.Text.Json; -// using Energinet.DataHub.Core.DurableFunctionApp.TestCommon.DurableTask; -// using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.Example.V1; -// using Energinet.DataHub.ProcessManager.Example.Orchestrations.Abstractions.Processes.BRS_X01.Example.V1.Model; -// using Energinet.DataHub.ProcessManager.Example.Orchestrations.Processes.BRS_X01.Example.V1; -// using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; -// using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance; -// using FluentAssertions; -// using NodaTime; -// using Xunit.Abstractions; -// -// namespace Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Integration.Processes.BRS_X01.Examples.V1; -// -// /// -// /// Tests that verify that we can search in "BRS_X01" orchestrations. -// /// -// [Collection(nameof(ExampleOrchestrationsAppCollection))] -// public class OrchestrationsSearchTests : IAsyncLifetime -// { -// public OrchestrationsSearchTests(ExampleOrchestrationsAppFixture fixture, ITestOutputHelper testOutputHelper) -// { -// Fixture = fixture; -// Fixture.SetTestOutputHelper(testOutputHelper); -// } -// -// private ExampleOrchestrationsAppFixture Fixture { get; } -// -// public Task InitializeAsync() -// { -// Fixture.ExampleOrchestrationsAppManager.AppHostManager.ClearHostLog(); -// -// return Task.CompletedTask; -// } -// -// public Task DisposeAsync() -// { -// Fixture.SetTestOutputHelper(null!); -// -// return Task.CompletedTask; -// } -// -// [Fact] -// public async Task ExampleOrchestration_WhenOrchestrationIsStarted_ThenItsSearchable() -// { -// // Arrange -// var skipStepTwo = false; -// await StartAndEnsureRunningAsync(skipStepTwo); -// -// var searchQuery = new ExampleQuery( -// operatingIdentity: new UserIdentityDto( -// Guid.NewGuid(), -// Guid.NewGuid()), -// SkippedStepTwo: skipStepTwo); -// -// var searchJson = JsonSerializer.Serialize(searchQuery, searchQuery.GetType()); -// -// // Act -// var actual = await SendSearchRequestAsync(searchJson); -// -// // Assert -// actual.Should().NotBeNull().And.NotBeEmpty(); -// } -// -// [Fact] -// public async Task ExampleOrchestration_WhenUsingCustomSearchCriteria_ThenItsSearchable() -// { -// // Arrange -// var skipStepTwo = false; -// await StartAndEnsureRunningAsync(skipStepTwo); -// await StartAndEnsureRunningAsync(!skipStepTwo); -// -// var searchQuery = new ExampleQuery( -// operatingIdentity: new UserIdentityDto( -// Guid.NewGuid(), -// Guid.NewGuid()), -// SkippedStepTwo: skipStepTwo); -// -// var searchJson = JsonSerializer.Serialize(searchQuery, searchQuery.GetType()); -// -// // Act -// var actual = await SendSearchRequestAsync(searchJson); -// -// // Assert -// // TODO: Should be 2, but the search is not working as of right now -// actual.Should().NotBeNull().And.HaveCount(2); -// } -// -// private async Task?> SendSearchRequestAsync(string search) -// { -// using var request = new HttpRequestMessage( -// HttpMethod.Post, -// $"/api/orchestrationinstance/query/custom/brs_x01_example"); -// -// request.Content = new StringContent( -// search, -// Encoding.UTF8, -// "application/json"); -// var response = await Fixture.ExampleOrchestrationsAppManager.AppHostManager.HttpClient -// .SendAsync(request); -// -// response.EnsureSuccessStatusCode(); -// -// var content = await response.Content.ReadAsStringAsync(); -// -// var result = JsonSerializer.Deserialize>(content); -// return result; -// } -// -// private async Task StartAndEnsureRunningAsync(bool skipStepTwo) -// { -// var command = new StartCommandV1( -// operatingIdentity: new UserIdentityDto( -// Guid.NewGuid(), -// Guid.NewGuid()), -// new InputV1(skipStepTwo)); -// -// var json = JsonSerializer.Serialize(command, command.GetType()); -// -// using var request = new HttpRequestMessage( -// HttpMethod.Post, -// $"/api/orchestrationinstance/command/start/custom/{command.OrchestrationDescriptionUniqueName.Name}/{command.OrchestrationDescriptionUniqueName.Version}"); -// -// request.Content = new StringContent( -// json, -// Encoding.UTF8, -// "application/json"); -// -// var beforeCreationOfOrchestration = SystemClock.Instance.GetCurrentInstant(); -// -// var id = await (await Fixture.ExampleOrchestrationsAppManager.AppHostManager.HttpClient -// .SendAsync(request)) -// .Content.ReadAsStringAsync(); -// -// var startedOrchestrationStatus = await Fixture.ExampleOrchestrationsAppManager.DurableClient.WaitForOrchestationStartedAsync( -// createdTimeFrom: beforeCreationOfOrchestration.ToDateTimeUtc(), -// name: nameof(Orchestration_Brs_X01_Example_V1)); -// startedOrchestrationStatus.Should().NotBeNull("The orchestration should have been started"); -// -// // id is a string containing a start and end quote :( -// return id.Substring(1, id.Length - 2); -// } -// } From 00b951a4c48c27edcdd930c0b631a66963374a9b Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 12:04:31 +0100 Subject: [PATCH 6/9] Clean up --- .../ProcessManagerClientCollection.cs | 27 ------ .../Fixtures/ProcessManagerClientFixture.cs | 94 ------------------- .../ProcessManager.Client.Tests.csproj | 13 --- 3 files changed, 134 deletions(-) delete mode 100644 source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientCollection.cs delete mode 100644 source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientFixture.cs diff --git a/source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientCollection.cs b/source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientCollection.cs deleted file mode 100644 index cf60b7d1..00000000 --- a/source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientCollection.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2020 Energinet DataHub A/S -// -// Licensed under the Apache License, Version 2.0 (the "License2"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -namespace Energinet.DataHub.ProcessManager.Client.Tests.Fixtures; - -/// -/// A xUnit collection fixture for ensuring tests don't run in parallel. -/// -/// xUnit documentation of collection fixtures: -/// * https://xunit.net/docs/shared-context#collection-fixture -/// -[CollectionDefinition(nameof(ProcessManagerClientCollection))] -public class ProcessManagerClientCollection : - ICollectionFixture -{ -} diff --git a/source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientFixture.cs b/source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientFixture.cs deleted file mode 100644 index c27baf92..00000000 --- a/source/ProcessManager.Client.Tests/Fixtures/ProcessManagerClientFixture.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2020 Energinet DataHub A/S -// -// Licensed under the Apache License, Version 2.0 (the "License2"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using Energinet.DataHub.Core.FunctionApp.TestCommon.Azurite; -using Energinet.DataHub.Core.FunctionApp.TestCommon.Configuration; -using Energinet.DataHub.ProcessManager.Core.Tests.Fixtures; -using Energinet.DataHub.ProcessManager.Example.Orchestrations.Tests.Fixtures; -using Energinet.DataHub.ProcessManager.Tests.Fixtures; -using Xunit.Abstractions; - -namespace Energinet.DataHub.ProcessManager.Client.Tests.Fixtures; - -/// -/// Support testing the Process Manager Clients by coordinating the startup -/// of the dependent applications ProcessManager.Example.Orchestrations and ProcessManager (Api). -/// -public class ProcessManagerClientFixture : IAsyncLifetime -{ - private const string TaskHubName = "ClientTest01"; - - public ProcessManagerClientFixture() - { - DatabaseManager = new ProcessManagerDatabaseManager("ProcessManagerClientTests"); - AzuriteManager = new AzuriteManager(useOAuth: true); - - IntegrationTestConfiguration = new IntegrationTestConfiguration(); - - ExampleOrchestrationsAppManager = new ExampleOrchestrationsAppManager( - DatabaseManager, - IntegrationTestConfiguration, - AzuriteManager, - taskHubName: TaskHubName, - appPort: 8201, - manageDatabase: false, - manageAzurite: false); - - ProcessManagerAppManager = new ProcessManagerAppManager( - DatabaseManager, - IntegrationTestConfiguration, - AzuriteManager, - taskHubName: TaskHubName, - appPort: 8202, - manageDatabase: false, - manageAzurite: false); - } - - public IntegrationTestConfiguration IntegrationTestConfiguration { get; } - - public ExampleOrchestrationsAppManager ExampleOrchestrationsAppManager { get; } - - public ProcessManagerAppManager ProcessManagerAppManager { get; } - - private ProcessManagerDatabaseManager DatabaseManager { get; } - - private AzuriteManager AzuriteManager { get; } - - public async Task InitializeAsync() - { - AzuriteManager.CleanupAzuriteStorage(); - AzuriteManager.StartAzurite(); - - await DatabaseManager.CreateDatabaseAsync(); - - await ExampleOrchestrationsAppManager.StartAsync(); - await ProcessManagerAppManager.StartAsync(); - } - - public async Task DisposeAsync() - { - await ExampleOrchestrationsAppManager.DisposeAsync(); - await ProcessManagerAppManager.DisposeAsync(); - - await DatabaseManager.DeleteDatabaseAsync(); - - AzuriteManager.Dispose(); - } - - public void SetTestOutputHelper(ITestOutputHelper? testOutputHelper) - { - ExampleOrchestrationsAppManager.SetTestOutputHelper(testOutputHelper); - ProcessManagerAppManager.SetTestOutputHelper(testOutputHelper); - } -} diff --git a/source/ProcessManager.Client.Tests/ProcessManager.Client.Tests.csproj b/source/ProcessManager.Client.Tests/ProcessManager.Client.Tests.csproj index 28e376d4..5d1d8e7c 100644 --- a/source/ProcessManager.Client.Tests/ProcessManager.Client.Tests.csproj +++ b/source/ProcessManager.Client.Tests/ProcessManager.Client.Tests.csproj @@ -7,19 +7,6 @@ true - - - - Fixtures\ExampleOrchestrationsAppManager.cs - - - Fixtures\OrchestrationsAppManager.cs - - - Fixtures\ProcessManagerAppManager.cs - - - all From ccb214b1cd73d8252e50705347493cdfca155f8c Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 15:01:26 +0100 Subject: [PATCH 7/9] Set Termination state dependent of input --- .../ProcessManager.Abstractions.csproj | 2 +- ...rminateActivity_Brs_X01_InputExample_V1.cs | 24 ++++++++++++++++--- .../Orchestration_Brs_X01_InputExample_V1.cs | 3 ++- ...inateActivity_Brs_X01_NoInputExample_V1.cs | 24 ++++++++++++++++--- ...Orchestration_Brs_X01_NoInputExample_V1.cs | 3 ++- 5 files changed, 47 insertions(+), 9 deletions(-) diff --git a/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj b/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj index cbd8931b..5c2e2587 100644 --- a/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj +++ b/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj @@ -53,7 +53,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs index 8a386d55..23f5c1ba 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_InputExample_V1.cs @@ -26,6 +26,9 @@ internal class OrchestrationTerminateActivity_Brs_X01_InputExample_V1( clock, progressRepository) { + private readonly IClock _clock = clock; + private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; + [Function(nameof(OrchestrationTerminateActivity_Brs_X01_InputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) @@ -34,12 +37,27 @@ public async Task Run( .GetAsync(input.OrchestrationInstanceId) .ConfigureAwait(false); - orchestrationInstance.Lifecycle.TransitionToSucceeded(Clock); - await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); + switch (input.TerminationState) + { + case OrchestrationInstanceTerminationStates.Succeeded: + orchestrationInstance.Lifecycle.TransitionToSucceeded(_clock); + break; + + case OrchestrationInstanceTerminationStates.Failed: + orchestrationInstance.Lifecycle.TransitionToFailed(_clock); + break; + + case OrchestrationInstanceTerminationStates.UserCanceled: + default: + throw new ArgumentOutOfRangeException(nameof(input.TerminationState), input.TerminationState, "Invalid termination state"); + } + + await _progressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); } public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); + OrchestrationInstanceId OrchestrationInstanceId, + OrchestrationInstanceTerminationStates TerminationState); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs index 564b2c2b..09b7e05a 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs @@ -88,7 +88,8 @@ await context.CallActivityAsync( await context.CallActivityAsync( nameof(OrchestrationTerminateActivity_Brs_X01_InputExample_V1), new OrchestrationTerminateActivity_Brs_X01_InputExample_V1.ActivityInput( - instanceId), + instanceId, + OrchestrationInstanceTerminationStates.Succeeded), _defaultRetryOptions); return "Success"; diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1.cs index c8185f36..88c8f667 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1.cs @@ -26,6 +26,9 @@ internal class OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1( clock, progressRepository) { + private readonly IClock _clock = clock; + private readonly IOrchestrationInstanceProgressRepository _progressRepository = progressRepository; + [Function(nameof(OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1))] public async Task Run( [ActivityTrigger] ActivityInput input) @@ -34,12 +37,27 @@ public async Task Run( .GetAsync(input.OrchestrationInstanceId) .ConfigureAwait(false); - orchestrationInstance.Lifecycle.TransitionToSucceeded(Clock); - await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); + switch (input.TerminationState) + { + case OrchestrationInstanceTerminationStates.Succeeded: + orchestrationInstance.Lifecycle.TransitionToSucceeded(_clock); + break; + + case OrchestrationInstanceTerminationStates.Failed: + orchestrationInstance.Lifecycle.TransitionToFailed(_clock); + break; + + case OrchestrationInstanceTerminationStates.UserCanceled: + default: + throw new ArgumentOutOfRangeException(nameof(input.TerminationState), input.TerminationState, "Invalid termination state"); + } + + await _progressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); } public record ActivityInput( - OrchestrationInstanceId OrchestrationInstanceId); + OrchestrationInstanceId OrchestrationInstanceId, + OrchestrationInstanceTerminationStates TerminationState); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs index 24e9f986..f6e2edd4 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs @@ -81,7 +81,8 @@ await context.CallActivityAsync( await context.CallActivityAsync( nameof(OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1), new OrchestrationTerminateActivity_Brs_X01_NoInputExample_V1.ActivityInput( - instanceId), + instanceId, + OrchestrationInstanceTerminationStates.Succeeded), _defaultRetryOptions); return "Success"; From e23191ea7eddf956416f180da6086245a9be3a1b Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 15:02:05 +0100 Subject: [PATCH 8/9] Update ProcessManager.Abstractions.csproj --- .../ProcessManager.Abstractions.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj b/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj index 5c2e2587..cbd8931b 100644 --- a/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj +++ b/source/ProcessManager.Abstractions/ProcessManager.Abstractions.csproj @@ -53,7 +53,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 1518414b918fa710aa02ec3b6b406c41fd8abe35 Mon Sep 17 00:00:00 2001 From: RasmusGraabaek Date: Fri, 20 Dec 2024 15:24:38 +0100 Subject: [PATCH 9/9] TerminatedSted takes state as input --- ...itionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs | 5 +++-- .../V1/Orchestration_Brs_X01_InputExample_V1.cs | 6 ++++-- ...ionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs | 5 +++-- .../V1/Orchestration_Brs_X01_NoInputExample_V1.cs | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs index 7ec0be3c..7fe92057 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.cs @@ -35,7 +35,7 @@ public async Task Run( .ConfigureAwait(false); var step = orchestrationInstance.Steps.Single(x => x.Sequence == input.StepSequence); - step.Lifecycle.TransitionToTerminated(Clock, OrchestrationStepTerminationStates.Succeeded); + step.Lifecycle.TransitionToTerminated(Clock, input.TerminationState); await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); @@ -43,5 +43,6 @@ public async Task Run( public record ActivityInput( OrchestrationInstanceId OrchestrationInstanceId, - int StepSequence); + int StepSequence, + OrchestrationStepTerminationStates TerminationState); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs index 09b7e05a..bb5af5f5 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/InputExample/V1/Orchestration_Brs_X01_InputExample_V1.cs @@ -64,7 +64,8 @@ await context.CallActivityAsync( nameof(TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1), new TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.ActivityInput( instanceId, - FirstStepSequence), + FirstStepSequence, + OrchestrationStepTerminationStates.Succeeded), _defaultRetryOptions); // Skippable step @@ -80,7 +81,8 @@ await context.CallActivityAsync( nameof(TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1), new TransitionStepToTerminatedActivity_Brs_X01_InputExample_V1.ActivityInput( instanceId, - SkippableStepSequence), + SkippableStepSequence, + OrchestrationStepTerminationStates.Succeeded), _defaultRetryOptions); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs index fbffed4b..4154d1ef 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Activities/TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.cs @@ -35,7 +35,7 @@ public async Task Run( .ConfigureAwait(false); var step = orchestrationInstance.Steps.Single(x => x.Sequence == input.StepSequence); - step.Lifecycle.TransitionToTerminated(Clock, OrchestrationStepTerminationStates.Succeeded); + step.Lifecycle.TransitionToTerminated(Clock, input.TerminationState); await ProgressRepository.UnitOfWork.CommitAsync().ConfigureAwait(false); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false); @@ -43,5 +43,6 @@ public async Task Run( public record ActivityInput( OrchestrationInstanceId OrchestrationInstanceId, - int StepSequence); + int StepSequence, + OrchestrationStepTerminationStates TerminationState); } diff --git a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs index f6e2edd4..2b8f919a 100644 --- a/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs +++ b/source/ProcessManager.Example.Orchestrations/Processes/BRS_X01/NoInputExample/V1/Orchestration_Brs_X01_NoInputExample_V1.cs @@ -57,7 +57,8 @@ await context.CallActivityAsync( nameof(TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1), new TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.ActivityInput( instanceId, - FirstStepSequence), + FirstStepSequence, + OrchestrationStepTerminationStates.Succeeded), _defaultRetryOptions); // Skippable step @@ -73,7 +74,8 @@ await context.CallActivityAsync( nameof(TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1), new TransitionStepToTerminatedActivity_Brs_X01_NoInputExample_V1.ActivityInput( instanceId, - SkippableStepSequence), + SkippableStepSequence, + OrchestrationStepTerminationStates.Succeeded), _defaultRetryOptions); }