Skip to content

Commit

Permalink
chore: fix formatting and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil91 committed Mar 29, 2024
1 parent 1c21f65 commit 870a4ec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class DimProcessTypeExecutor : IProcessTypeExecutor
ProcessStepTypeId.SEND_CALLBACK);

private Guid _tenantId;
private string _tenantName;
private string? _tenantName;

public DimProcessTypeExecutor(
IDimRepositories dimRepositories,
Expand Down Expand Up @@ -82,7 +82,7 @@ public DimProcessTypeExecutor(

public async ValueTask<IProcessTypeExecutor.StepExecutionResult> ExecuteProcessStep(ProcessStepTypeId processStepTypeId, IEnumerable<ProcessStepTypeId> 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");
}
Expand Down Expand Up @@ -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<ProcessStepTypeId>? nextSteps) ProcessError(Exception ex, ProcessStepTypeId processStepTypeId)
private static (ProcessStepStatusId StatusId, string? ProcessMessage, IEnumerable<ProcessStepTypeId>? nextSteps) ProcessError(Exception ex)
{
return ex switch
{
Expand Down
2 changes: 1 addition & 1 deletion src/processes/DimProcess.Library/DimProcessHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEnumerable<ProcessStepTypeId>?, ProcessStepStatusId, bool, string?>(
Expand Down
18 changes: 2 additions & 16 deletions tests/processes/DimProcess.Library.Tests/DimProcessHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ConflictException>(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<CancellationToken>._))
.Returns(spaceId);
A.CallTo(() => _cfClient.GetServicePlan("decentralized-identity-management", "standard", A<CancellationToken>._))
.Returns(servicePlanId);
Expand Down

0 comments on commit 870a4ec

Please sign in to comment.