Skip to content

Commit

Permalink
fix(registration): missing identifier #606 (#612)
Browse files Browse the repository at this point in the history
* Company Registration: Display UniqueIdentifier
Revert accidental change introduced from 1.6 -> 1.7. Use identifier.Value
instead of repeating its type. Resolves issue with displaying identifier
in /applicationrequests
Closes #606
* Add tests for company identifiers with theory case for each identifier type.
---------
Co-authored-by: Dr. Hans Beck <[email protected]>
Co-authored-by: Karsten Thiems <[email protected]>
  • Loading branch information
ntruchsess authored Apr 9, 2024
1 parent 56ca24f commit e83de4d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
using Org.Eclipse.TractusX.Portal.Backend.Processes.ApplicationChecklist.Library;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Mailing.Library;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library;
using Org.Eclipse.TractusX.Portal.Backend.Registration.Common;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;
using System.Collections.Immutable;
Expand Down Expand Up @@ -128,7 +129,7 @@ private async Task<CompanyWithAddressData> GetCompanyWithAddressAsyncInternal(Gu
x.FirstName ?? "",
x.LastName ?? "",
x.Email ?? "")),
companyWithAddress.CompanyIdentifiers.Select(identifier => new UniqueIdentifierData((int)identifier.UniqueIdentifierId, identifier.UniqueIdentifierId))
companyWithAddress.CompanyIdentifiers.Select(identifier => new CompanyUniqueIdData(identifier.UniqueIdentifierId, identifier.Value))
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/********************************************************************************
* Copyright (c) 2021, 2023 BMW Group AG
* Copyright (c) 2021, 2023 Contributors to the CatenaX (ng) GitHub Organisation.
*
* See the NOTICE file(s) distributed with this work for additional
Expand All @@ -18,8 +17,8 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models;
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Registration.Common;
using System.Text.Json.Serialization;

namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models;
Expand Down Expand Up @@ -57,7 +56,7 @@ public record CompanyWithAddressData(
string ZipCode,
[property: JsonPropertyName("companyRoles")] IEnumerable<AgreementsRoleData> AgreementsRoleData,
[property: JsonPropertyName("companyUser")] IEnumerable<InvitedUserData> InvitedUserData,
IEnumerable<UniqueIdentifierData> UniqueIds
IEnumerable<CompanyUniqueIdData> UniqueIds
);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/********************************************************************************
* Copyright (c) 2021, 2023 BMW Group AG
* Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using Org.Eclipse.TractusX.Portal.Backend.Processes.ApplicationChecklist.Library;
using Org.Eclipse.TractusX.Portal.Backend.Processes.Mailing.Library;
using Org.Eclipse.TractusX.Portal.Backend.Provisioning.Library;
using Org.Eclipse.TractusX.Portal.Backend.Registration.Common;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.BusinessLogic;
using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;
using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared;
Expand Down Expand Up @@ -173,13 +174,19 @@ public async Task GetCompanyApplicationDetailsAsync_WithClosedRequest_GetsExpect

#region GetCompanyWithAddressAsync

[Fact]
public async Task GetCompanyWithAddressAsync_WithDefaultRequest_GetsExpectedResult()
[Theory]
[InlineData(UniqueIdentifierId.VAT_ID, "DE124356789")]
[InlineData(UniqueIdentifierId.LEI_CODE, "54930084UKLVMY22DS16")]
[InlineData(UniqueIdentifierId.EORI, "DE123456789012345")]
[InlineData(UniqueIdentifierId.COMMERCIAL_REG_NUMBER, "HRB123456")]
[InlineData(UniqueIdentifierId.VIES, "ATU99999999")]
public async Task GetCompanyWithAddressAsync_WithDefaultRequest_GetsExpectedResult(UniqueIdentifierId identifierIdType, string companyUniqueIds)
{
// Arrange
var applicationId = _fixture.Create<Guid>();
var data = _fixture.Build<CompanyUserRoleWithAddress>()
.With(x => x.AgreementsData, _fixture.CreateMany<AgreementsData>(20))
.With(x => x.CompanyIdentifiers, Enumerable.Repeat(new ValueTuple<UniqueIdentifierId, string>(identifierIdType, companyUniqueIds), 1))
.Create();
A.CallTo(() => _applicationRepository.GetCompanyUserRoleWithAddressUntrackedAsync(applicationId))
.Returns(data);
Expand All @@ -206,6 +213,7 @@ public async Task GetCompanyWithAddressAsync_WithDefaultRequest_GetsExpectedResu
result.AgreementsRoleData.Should().HaveSameCount(data.AgreementsData.DistinctBy(ad => ad.CompanyRoleId));
result.InvitedUserData.Should().HaveSameCount(data.InvitedCompanyUserData);
result.UniqueIds.Should().HaveSameCount(data.CompanyIdentifiers);
result.UniqueIds.Should().AllSatisfy(u => u.Should().Match<CompanyUniqueIdData>(u => u.UniqueIdentifierId == identifierIdType && u.Value == companyUniqueIds));
}

[Fact]
Expand Down

0 comments on commit e83de4d

Please sign in to comment.