From 870a4ec6876545998f7baff9dfa36cc3699dcaeb Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Fri, 29 Mar 2024 08:53:31 +0100 Subject: [PATCH] chore: fix formatting and unit tests --- .../DimProcessTypeExecutor.cs | 8 ++++---- .../DimProcess.Library/DimProcessHandler.cs | 2 +- .../DimProcessHandlerTests.cs | 18 ++---------------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs b/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs index 4159e70..8d22159 100644 --- a/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs +++ b/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs @@ -52,7 +52,7 @@ public class DimProcessTypeExecutor : IProcessTypeExecutor ProcessStepTypeId.SEND_CALLBACK); private Guid _tenantId; - private string _tenantName; + private string? _tenantName; public DimProcessTypeExecutor( IDimRepositories dimRepositories, @@ -82,7 +82,7 @@ public DimProcessTypeExecutor( public async ValueTask ExecuteProcessStep(ProcessStepTypeId processStepTypeId, IEnumerable processStepTypeIds, CancellationToken cancellationToken) { - if (_tenantId == Guid.Empty || _tenantName == default) + if (_tenantId == Guid.Empty || _tenantName is null) { throw new UnexpectedConditionException("tenantId and tenantName should never be empty here"); } @@ -135,14 +135,14 @@ public DimProcessTypeExecutor( } catch (Exception ex) when (ex is not SystemException) { - (stepStatusId, processMessage, nextStepTypeIds) = ProcessError(ex, processStepTypeId); + (stepStatusId, processMessage, nextStepTypeIds) = ProcessError(ex); modified = true; } return new IProcessTypeExecutor.StepExecutionResult(modified, stepStatusId, nextStepTypeIds, null, processMessage); } - private static (ProcessStepStatusId StatusId, string? ProcessMessage, IEnumerable? nextSteps) ProcessError(Exception ex, ProcessStepTypeId processStepTypeId) + private static (ProcessStepStatusId StatusId, string? ProcessMessage, IEnumerable? nextSteps) ProcessError(Exception ex) { return ex switch { diff --git a/src/processes/DimProcess.Library/DimProcessHandler.cs b/src/processes/DimProcess.Library/DimProcessHandler.cs index 63720dd..5e00ac6 100644 --- a/src/processes/DimProcess.Library/DimProcessHandler.cs +++ b/src/processes/DimProcess.Library/DimProcessHandler.cs @@ -353,7 +353,7 @@ await _provisioningClient.CreateCloudFoundryEnvironment(saBinding.Url, bindingRe { throw new ConflictException("SpaceId must not be null."); } - + await _cfClient.CreateServiceInstanceBindings(tenantName, spaceId.Value, cancellationToken).ConfigureAwait(false); return new ValueTuple?, ProcessStepStatusId, bool, string?>( diff --git a/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs b/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs index 5f8f58e..03074d8 100644 --- a/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs +++ b/tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs @@ -33,6 +33,7 @@ using DimProcess.Library.DependencyInjection; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; +using System.Runtime.CompilerServices; using System.Text.Json; namespace DimProcess.Library.Tests; @@ -571,28 +572,13 @@ public async Task AddSpaceDeveloperRole_WithValidData_ReturnsExpected() #region CreateDimServiceInstance - [Fact] - public async Task CreateDimServiceInstance_WithNotExisting_ReturnsExpected() - { - // Arrange - A.CallTo(() => _tenantRepositories.GetSpaceId(_tenantId)) - .Returns((Guid?)null); - async Task Act() => await _sut.CreateDimServiceInstance(_tenantName, _tenantId, CancellationToken.None).ConfigureAwait(false); - - // Act - var ex = await Assert.ThrowsAsync(Act); - - // Assert - ex.Message.Should().Be("SpaceId must not be null."); - } - [Fact] public async Task CreateDimServiceInstance_WithValidData_ReturnsExpected() { // Arrange var spaceId = Guid.NewGuid(); var servicePlanId = Guid.NewGuid(); - A.CallTo(() => _tenantRepositories.GetSpaceId(_tenantId)) + A.CallTo(() => _cfClient.GetSpace(_tenantName, A._)) .Returns(spaceId); A.CallTo(() => _cfClient.GetServicePlan("decentralized-identity-management", "standard", A._)) .Returns(servicePlanId);