Skip to content

Commit

Permalink
feat(clearinghouse): add comments to process step and application che…
Browse files Browse the repository at this point in the history
…cklist

enhance application checklist with a comment of the skipped self description step

Refs: #837
  • Loading branch information
Phil91 committed Aug 6, 2024
1 parent 7a931b9 commit c173961
Show file tree
Hide file tree
Showing 8 changed files with 9,644 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ public Task RegisterConnectorAsync(
{
return new IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult(
ProcessStepStatusId.SKIPPED,
entry => entry.ApplicationChecklistEntryStatusId = ApplicationChecklistEntryStatusId.DONE,
entry =>
{
entry.ApplicationChecklistEntryStatusId = ApplicationChecklistEntryStatusId.SKIPPED;
entry.Comment = "Self description was skipped due to clearinghouse trigger is disabled";
},
new[] { ProcessStepTypeId.ACTIVATE_APPLICATION },
null,
true,
null
"Self description was skipped due to clearinghouse trigger is disabled"
);
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.Migrations.Migrations
{
/// <inheritdoc />
public partial class _837AddSkippedStateForChecklist : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.InsertData(
schema: "portal",
table: "application_checklist_statuses",
columns: new[] { "id", "label" },
values: new object[] { 5, "SKIPPED" });
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
schema: "portal",
table: "application_checklist_statuses",
keyColumn: "id",
keyValue: 5);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
********************************************************************************/

// <auto-generated />
using System;
using System.Text.Json;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities;
using System.Text.Json;

#nullable disable

Expand Down Expand Up @@ -2580,6 +2583,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
Id = 4,
Label = "FAILED"
},
new
{
Id = 5,
Label = "SKIPPED"
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ public enum ApplicationChecklistEntryStatusId
TO_DO = 1,
IN_PROGRESS = 2,
DONE = 3,
FAILED = 4
FAILED = 4,
SKIPPED = 5
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ public ApplicationActivationService(
{
return Task.FromResult(new IApplicationChecklistService.WorkerChecklistProcessStepExecutionResult(ProcessStepStatusId.TODO, null, null, null, false, null));
}

var prerequisiteEntries = context.Checklist.Where(entry => entry.Key != ApplicationChecklistEntryTypeId.APPLICATION_ACTIVATION);
if (prerequisiteEntries.Any(entry => entry.Value != ApplicationChecklistEntryStatusId.DONE))
if (!(prerequisiteEntries.All(entry => entry.Value == ApplicationChecklistEntryStatusId.DONE) || prerequisiteEntries.All(entry => entry is { Key: ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP, Value: ApplicationChecklistEntryStatusId.SKIPPED } || (entry.Key != ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP && entry.Value == ApplicationChecklistEntryStatusId.DONE))))
{
throw new ConflictException($"cannot activate application {context.ApplicationId}. Checklist entries that are not in status DONE: {string.Join(",", prerequisiteEntries)}");
}

return HandleApplicationActivationInternal(context, cancellationToken);
}

Expand All @@ -87,8 +89,8 @@ public ApplicationActivationService(
{
throw new ConflictException($"CompanyApplication {context.ApplicationId} is not in status SUBMITTED");
}
var (companyId, companyName, businessPartnerNumber, iamIdpAliasse, applicationTypeId, networkRegistrationProcessId) = result;

var (companyId, companyName, businessPartnerNumber, iamIdpAliasse, applicationTypeId, networkRegistrationProcessId) = result;
if (string.IsNullOrWhiteSpace(businessPartnerNumber))
{
throw new ConflictException($"BusinessPartnerNumber (bpn) for CompanyApplications {context.ApplicationId} company {companyId} is empty");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ public async Task StartSelfDescriptionRegistration_WithValidData_CompanyIsUpdate
result.Should().NotBeNull();
result.ModifyChecklistEntry.Should().NotBeNull();
result.ModifyChecklistEntry!.Invoke(entry);
entry.ApplicationChecklistEntryStatusId.Should().Be(clearinghouseConnectDisabled ? ApplicationChecklistEntryStatusId.DONE : ApplicationChecklistEntryStatusId.IN_PROGRESS);
result.ProcessMessage.Should().Be(clearinghouseConnectDisabled ? "Self description was skipped due to clearinghouse trigger is disabled" : null);
entry.ApplicationChecklistEntryStatusId.Should().Be(clearinghouseConnectDisabled ? ApplicationChecklistEntryStatusId.SKIPPED : ApplicationChecklistEntryStatusId.IN_PROGRESS);
result.ScheduleStepTypeIds.Should().ContainSingle().And.Match(x => clearinghouseConnectDisabled ? x.Single() == ProcessStepTypeId.ACTIVATE_APPLICATION : x.Single() == ProcessStepTypeId.FINISH_SELF_DESCRIPTION_LP);
result.SkipStepTypeIds.Should().BeNull();
result.Modified.Should().BeTrue();
result.StepStatusId.Should().Be(clearinghouseConnectDisabled ? ProcessStepStatusId.SKIPPED : ProcessStepStatusId.DONE);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ public async Task HandleApplicationActivation_WithMidnightRun_ApprovesRequestAnd
result.Modified.Should().BeTrue();
}

[Fact]
public async Task HandleApplicationActivation_WithCompanyAdminUser_ApprovesRequestAndCreatesNotifications()
[Theory]
[InlineData(ApplicationChecklistEntryStatusId.DONE)]
[InlineData(ApplicationChecklistEntryStatusId.SKIPPED)]
public async Task HandleApplicationActivation_WithCompanyAdminUser_ApprovesRequestAndCreatesNotifications(ApplicationChecklistEntryStatusId sdFactoryStatusId)
{
//Arrange
var roles = new[] { "Company Admin" };
Expand Down Expand Up @@ -318,7 +320,7 @@ public async Task HandleApplicationActivation_WithCompanyAdminUser_ApprovesReque
{ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE},
{ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE},
{ApplicationChecklistEntryTypeId.CLEARING_HOUSE, ApplicationChecklistEntryStatusId.DONE},
{ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP, ApplicationChecklistEntryStatusId.DONE},
{ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP, sdFactoryStatusId},
{ApplicationChecklistEntryTypeId.APPLICATION_ACTIVATION, ApplicationChecklistEntryStatusId.TO_DO}
}.ToImmutableDictionary(),
Enumerable.Empty<ProcessStepTypeId>());
Expand Down

0 comments on commit c173961

Please sign in to comment.