diff --git a/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs b/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs
index 309ff33162..6b99bc11e4 100644
--- a/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs
+++ b/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs
@@ -93,16 +93,21 @@ private async Task RegisterSelfDescriptionInternalAsync(
throw new ConflictException($"CompanyApplication {applicationId} is not in status SUBMITTED");
}
- var (companyId, businessPartnerNumber, countryCode, uniqueIdentifiers) = result;
+ var (companyId, legalName, businessPartnerNumber, countryCode, region, uniqueIdentifiers) = result;
if (string.IsNullOrWhiteSpace(businessPartnerNumber))
{
throw new ConflictException(
$"BusinessPartnerNumber (bpn) for CompanyApplications {applicationId} company {companyId} is empty");
}
+ if (string.IsNullOrWhiteSpace(countryCode) || string.IsNullOrWhiteSpace(region))
+ {
+ throw new ConflictException(
+ $"CountryCode or Region for CompanyApplications {applicationId} and Company {companyId} is empty. Expected value: DE-NW and Current value: {countryCode}-{region}");
+ }
await sdFactoryService
- .RegisterSelfDescriptionAsync(applicationId, uniqueIdentifiers, countryCode, businessPartnerNumber, cancellationToken)
+ .RegisterSelfDescriptionAsync(applicationId, legalName, uniqueIdentifiers, countryCode, region, businessPartnerNumber, cancellationToken)
.ConfigureAwait(ConfigureAwaitOptions.None);
}
diff --git a/src/externalsystems/SdFactory.Library/ISdFactoryService.cs b/src/externalsystems/SdFactory.Library/ISdFactoryService.cs
index 12ab2a73bc..604bd22d32 100644
--- a/src/externalsystems/SdFactory.Library/ISdFactoryService.cs
+++ b/src/externalsystems/SdFactory.Library/ISdFactoryService.cs
@@ -38,5 +38,5 @@ public interface ISdFactoryService
/// throws an exception if the service call wasn't successfully
Task RegisterConnectorAsync(Guid connectorId, string selfDescriptionDocumentUrl, string businessPartnerNumber, CancellationToken cancellationToken);
- Task RegisterSelfDescriptionAsync(Guid externalId, IEnumerable<(UniqueIdentifierId Id, string Value)> uniqueIdentifiers, string countryCode, string businessPartnerNumber, CancellationToken cancellationToken);
+ Task RegisterSelfDescriptionAsync(Guid externalId, string legalName, IEnumerable<(UniqueIdentifierId Id, string Value)> uniqueIdentifiers, string countryCode, string region, string businessPartnerNumber, CancellationToken cancellationToken);
}
diff --git a/src/externalsystems/SdFactory.Library/Models/SdFactoryRequestModel.cs b/src/externalsystems/SdFactory.Library/Models/SdFactoryRequestModel.cs
index f06233116a..2911d43b46 100644
--- a/src/externalsystems/SdFactory.Library/Models/SdFactoryRequestModel.cs
+++ b/src/externalsystems/SdFactory.Library/Models/SdFactoryRequestModel.cs
@@ -1,5 +1,4 @@
/********************************************************************************
- * Copyright (c) 2022 BMW Group AG
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
@@ -28,13 +27,12 @@ namespace Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models;
///
public record SdFactoryRequestModel(
[property: JsonPropertyName("externalId")] string ExternalId,
+ [property: JsonPropertyName("name")] string LegalName,
[property: JsonPropertyName("registrationNumber")] IEnumerable RegistrationNumber,
- [property: JsonPropertyName("headquarterAddress.country")] string HeadquarterCountry,
- [property: JsonPropertyName("legalAddress.country")] string LegalCountry,
+ [property: JsonPropertyName("headquarterAddress.countrySubdivisionCode")] string HeadquarterCountrySubdivisionCode,
+ [property: JsonPropertyName("legalAddress.countrySubdivisionCode")] string LegalCountrySubdivisionCode,
[property: JsonPropertyName("type"), JsonConverter(typeof(JsonStringEnumConverter))] SdFactoryRequestModelSdType Type,
- [property: JsonPropertyName("bpn")] string Bpn,
- [property: JsonPropertyName("holder")] string Holder,
- [property: JsonPropertyName("issuer")] string Issuer);
+ [property: JsonPropertyName("holder")] string Holder);
public record RegistrationNumber(
[property: JsonPropertyName("type")] string Type,
diff --git a/src/externalsystems/SdFactory.Library/SdFactoryService.cs b/src/externalsystems/SdFactory.Library/SdFactoryService.cs
index 5d1add1b3a..513da9baf9 100644
--- a/src/externalsystems/SdFactory.Library/SdFactoryService.cs
+++ b/src/externalsystems/SdFactory.Library/SdFactoryService.cs
@@ -54,19 +54,19 @@ await httpClient.PostAsJsonAsync(default(string?), requestModel, cancellationTok
}
///
- public async Task RegisterSelfDescriptionAsync(Guid externalId, IEnumerable<(UniqueIdentifierId Id, string Value)> uniqueIdentifiers, string countryCode, string businessPartnerNumber, CancellationToken cancellationToken)
+ public async Task RegisterSelfDescriptionAsync(Guid externalId, string legalName, IEnumerable<(UniqueIdentifierId Id, string Value)> uniqueIdentifiers, string countryCode, string region, string businessPartnerNumber, CancellationToken cancellationToken)
{
var httpClient = await tokenService.GetAuthorizedClient(_settings, cancellationToken)
.ConfigureAwait(ConfigureAwaitOptions.None);
+ var countrySubdivisionCode = string.Format("{0}-{1}", countryCode, region);
var requestModel = new SdFactoryRequestModel(
externalId.ToString(),
+ legalName,
uniqueIdentifiers.Select(x => new RegistrationNumber(x.Id.GetSdUniqueIdentifierValue(), x.Value)),
- countryCode,
- countryCode,
+ countrySubdivisionCode,
+ countrySubdivisionCode,
SdFactoryRequestModelSdType.LegalParticipant,
- businessPartnerNumber,
- businessPartnerNumber,
- _settings.SdFactoryIssuerBpn);
+ businessPartnerNumber);
await httpClient.PostAsJsonAsync(default(string?), requestModel, cancellationToken)
.CatchingIntoServiceExceptionFor("sd-factory-selfdescription-post", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false);
diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ApplicationRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ApplicationRepository.cs
index 03061d4066..9a7eadc5fd 100644
--- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ApplicationRepository.cs
+++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ApplicationRepository.cs
@@ -227,14 +227,16 @@ public IQueryable GetExternalCompanyApplicationsFilteredQuer
.SingleOrDefaultAsync();
///
- public Task<(Guid CompanyId, string? BusinessPartnerNumber, string Alpha2Code, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers)> GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(Guid applicationId) =>
+ public Task<(Guid CompanyId, string legalName, string? BusinessPartnerNumber, string? Alpha2Code, string? Region, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers)> GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(Guid applicationId) =>
portalDbContext.CompanyApplications.Where(companyApplication =>
companyApplication.Id == applicationId &&
companyApplication.ApplicationStatusId == CompanyApplicationStatusId.SUBMITTED)
- .Select(ca => new ValueTuple>(
+ .Select(ca => new ValueTuple>(
ca.CompanyId,
+ ca.Company!.Name,
ca.Company!.BusinessPartnerNumber,
ca.Company.Address!.Country!.Alpha2Code,
+ ca.Company.Address!.Region,
ca.Company.CompanyIdentifiers.Select(x => new ValueTuple(x.UniqueIdentifierId, x.Value))))
.SingleOrDefaultAsync();
diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs
index 7e64ce75d3..7e70103560 100644
--- a/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs
+++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/CompanyRepository.cs
@@ -455,14 +455,16 @@ public IAsyncEnumerable GetCompanyIdsWithMissingSelfDescription() =>
.Select(c => c.Id)
.ToAsyncEnumerable();
- public Task<(Guid Id, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers, string? BusinessPartnerNumber, string CountryCode)> GetCompanyByProcessId(Guid processId) =>
+ public Task<(Guid Id, string LegalName, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers, string? BusinessPartnerNumber, string? CountryCode, string? Region)> GetCompanyByProcessId(Guid processId) =>
context.Companies
.Where(c => c.SdCreationProcessId == processId)
- .Select(c => new ValueTuple, string?, string>(
+ .Select(c => new ValueTuple, string?, string?, string?>(
c.Id,
+ c.Name,
c.CompanyIdentifiers.Select(ci => new ValueTuple(ci.UniqueIdentifierId, ci.Value)),
c.BusinessPartnerNumber,
- c.Address!.Country!.Alpha2Code
+ c.Address!.Country!.Alpha2Code,
+ c.Address!.Region
))
.SingleOrDefaultAsync();
diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IApplicationRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IApplicationRepository.cs
index c931e14e1f..cf14fad8ed 100644
--- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IApplicationRepository.cs
+++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IApplicationRepository.cs
@@ -48,7 +48,7 @@ public interface IApplicationRepository
Task<(bool IsValidApplicationId, bool IsValidCompany, RegistrationData? Data)> GetRegistrationDataUntrackedAsync(Guid applicationId, Guid userCompanyId, IEnumerable documentTypes);
Task<(string? Bpn, IEnumerable ExistingChecklistEntryTypeIds)> GetBpnAndChecklistCheckForApplicationIdAsync(Guid applicationId);
- Task<(Guid CompanyId, string? BusinessPartnerNumber, string Alpha2Code, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers)> GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(Guid applicationId);
+ Task<(Guid CompanyId, string legalName, string? BusinessPartnerNumber, string? Alpha2Code, string? Region, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers)> GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(Guid applicationId);
///
/// Gets the application status and the status of the application checklist entry of the given type
diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs
index 59cdbaebe6..306f31eb5b 100644
--- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs
+++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ICompanyRepository.cs
@@ -181,7 +181,7 @@ public interface ICompanyRepository
void RemoveProviderCompanyDetails(Guid providerCompanyDetailId);
Func?>> GetCompaniesWithMissingSdDocument();
IAsyncEnumerable GetCompanyIdsWithMissingSelfDescription();
- Task<(Guid Id, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers, string? BusinessPartnerNumber, string CountryCode)> GetCompanyByProcessId(Guid processId);
+ Task<(Guid Id, string LegalName, IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers, string? BusinessPartnerNumber, string? CountryCode, string? Region)> GetCompanyByProcessId(Guid processId);
Task IsExistingCompany(Guid companyId);
Task<(bool Exists, Guid CompanyId, IEnumerable SubmittedCompanyApplicationId)> GetCompanyIdByBpn(string bpn);
Task?> GetProcessDataForCompanyIdId(Guid companyId);
diff --git a/src/processes/SelfDescriptionCreation.Executor/SdCreationProcessTypeExecutor.cs b/src/processes/SelfDescriptionCreation.Executor/SdCreationProcessTypeExecutor.cs
index d04b507d0c..ede43f3ee1 100644
--- a/src/processes/SelfDescriptionCreation.Executor/SdCreationProcessTypeExecutor.cs
+++ b/src/processes/SelfDescriptionCreation.Executor/SdCreationProcessTypeExecutor.cs
@@ -80,13 +80,18 @@ public class SdCreationProcessTypeExecutor(IPortalRepositories portalRepositorie
}
var companyRepository = portalRepositories.GetInstance();
- var (id, uniqueIdentifiers, businessPartnerNumber, countryCode) = await companyRepository.GetCompanyByProcessId(_processId.Value);
+ var (id, legalName, uniqueIdentifiers, businessPartnerNumber, countryCode, region) = await companyRepository.GetCompanyByProcessId(_processId.Value);
if (string.IsNullOrWhiteSpace(businessPartnerNumber))
{
throw new ConflictException("BusinessPartnerNumber should never be null here.");
}
+ if (string.IsNullOrWhiteSpace(countryCode) || string.IsNullOrWhiteSpace(region))
+ {
+ throw new ConflictException(
+ $"CountryCode or Region is empty here. Expected value: DE-NW and Current value: {countryCode}-{region}");
+ }
- await sdFactoryService.RegisterSelfDescriptionAsync(id, uniqueIdentifiers, countryCode, businessPartnerNumber, cancellationToken)
+ await sdFactoryService.RegisterSelfDescriptionAsync(id, legalName, uniqueIdentifiers, countryCode, region, businessPartnerNumber, cancellationToken)
.ConfigureAwait(ConfigureAwaitOptions.None);
return ([ProcessStepTypeId.RETRIGGER_AWAIT_SELF_DESCRIPTION_COMPANY_RESPONSE], ProcessStepStatusId.DONE, true, null);
diff --git a/tests/endtoend/InterfacePartnerHealthCheck/SdFactoryEndPointTests.cs b/tests/endtoend/InterfacePartnerHealthCheck/SdFactoryEndPointTests.cs
index 1e1d4887fa..504d519070 100644
--- a/tests/endtoend/InterfacePartnerHealthCheck/SdFactoryEndPointTests.cs
+++ b/tests/endtoend/InterfacePartnerHealthCheck/SdFactoryEndPointTests.cs
@@ -52,13 +52,12 @@ public void InterfaceHealthCheck_SdDocCreation()
var body = DataHandleHelper.SerializeData(
new SdFactoryRequestModel(
"TestAutomation",
+ "Legal Participant Company Name",
new List { new("local", "o12345678") },
- "DE",
- "DE",
+ "DE-NW",
+ "DE-NW",
SdFactoryRequestModelSdType.LegalParticipant,
- "BPNL000000000000",
- "BPNL000000000000",
- "CAXSDUMMYCATENAZZ"
+ "BPNL000000000000"
)
);
diff --git a/tests/externalsystems/SdFactory.Library.Tests/SdFactoryBusinessLogicTests.cs b/tests/externalsystems/SdFactory.Library.Tests/SdFactoryBusinessLogicTests.cs
index dc8b8e928c..98821e9c28 100644
--- a/tests/externalsystems/SdFactory.Library.Tests/SdFactoryBusinessLogicTests.cs
+++ b/tests/externalsystems/SdFactory.Library.Tests/SdFactoryBusinessLogicTests.cs
@@ -42,6 +42,8 @@ public class SdFactoryBusinessLogicTests
#region Initialization
private const string CountryCode = "DE";
+ private const string Region = "NW";
+ private const string LegalName = "Legal Participant Company Name";
private const string Bpn = "BPNL000000000009";
private static readonly Guid ApplicationId = new("ac1cf001-7fbc-1f2f-817f-bce058020001");
private readonly Process _process;
@@ -126,17 +128,16 @@ public async Task RegisterConnectorAsync_ExpectedServiceCallIsMade()
public async Task StartSelfDescriptionRegistration_WithValidData_CompanyIsUpdated(bool clearinghouseConnectDisabled)
{
// Arrange
- var checklist = new Dictionary
- {
- { ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE },
- }
- .ToImmutableDictionary();
+ var checklist = ImmutableDictionary.CreateRange(
+ [
+ new(ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE)
+ ]);
var context = new IApplicationChecklistService.WorkerChecklistProcessStepData(ApplicationId, default, checklist, Enumerable.Empty());
var entry = new ApplicationChecklistEntry(Guid.NewGuid(), ApplicationChecklistEntryTypeId.SELF_DESCRIPTION_LP, ApplicationChecklistEntryStatusId.TO_DO, DateTimeOffset.UtcNow);
A.CallTo(() => _applicationRepository.GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(ApplicationId))
- .Returns((CompanyId, Bpn, CountryCode, UniqueIdentifiers));
+ .Returns((CompanyId, LegalName, Bpn, CountryCode, Region, UniqueIdentifiers));
var sut = new SdFactoryBusinessLogic(_service, _portalRepositories, _checklistService, Options.Create(new SdFactorySettings
{
SdFactoryUrl = "https://www.api.sdfactory.com",
@@ -148,7 +149,7 @@ public async Task StartSelfDescriptionRegistration_WithValidData_CompanyIsUpdate
var result = await sut.StartSelfDescriptionRegistration(context, CancellationToken.None);
// Assert
- A.CallTo(() => _service.RegisterSelfDescriptionAsync(ApplicationId, UniqueIdentifiers, CountryCode, Bpn, A._))
+ A.CallTo(() => _service.RegisterSelfDescriptionAsync(ApplicationId, LegalName, UniqueIdentifiers, CountryCode, Region, Bpn, A._))
.MustHaveHappened(clearinghouseConnectDisabled ? 0 : 1, Times.Exactly);
result.Should().NotBeNull();
result.ModifyChecklistEntry.Should().NotBeNull();
@@ -165,16 +166,15 @@ public async Task StartSelfDescriptionRegistration_WithValidData_CompanyIsUpdate
public async Task StartSelfDescriptionRegistration_WithNoApplication_ThrowsConflictException()
{
// Arrange
- var checklist = new Dictionary
- {
- { ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE },
- }
- .ToImmutableDictionary();
+ var checklist = ImmutableDictionary.CreateRange(
+ [
+ new(ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE)
+ ]);
var context = new IApplicationChecklistService.WorkerChecklistProcessStepData(ApplicationId, default, checklist, Enumerable.Empty());
A.CallTo(() => _applicationRepository.GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(ApplicationId))
- .Returns<(Guid, string?, string, IEnumerable<(UniqueIdentifierId, string)>)>(default);
+ .Returns<(Guid, string, string?, string?, string?, IEnumerable<(UniqueIdentifierId, string)>)>(default);
// Act
async Task Act() => await _sut.StartSelfDescriptionRegistration(context, CancellationToken.None);
@@ -182,7 +182,7 @@ public async Task StartSelfDescriptionRegistration_WithNoApplication_ThrowsConfl
// Assert
var ex = await Assert.ThrowsAsync(Act);
ex.Message.Should().Be($"CompanyApplication {ApplicationId} is not in status SUBMITTED");
- A.CallTo(() => _service.RegisterSelfDescriptionAsync(ApplicationId, UniqueIdentifiers, CountryCode, Bpn, A._))
+ A.CallTo(() => _service.RegisterSelfDescriptionAsync(ApplicationId, LegalName, UniqueIdentifiers, CountryCode, Region, Bpn, A._))
.MustNotHaveHappened();
}
@@ -190,16 +190,15 @@ public async Task StartSelfDescriptionRegistration_WithNoApplication_ThrowsConfl
public async Task StartSelfDescriptionRegistration_WithBpnNotSet_ThrowsConflictException()
{
// Arrange
- var checklist = new Dictionary
- {
- { ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE },
- }
- .ToImmutableDictionary();
+ var checklist = ImmutableDictionary.CreateRange(
+ [
+ new(ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE)
+ ]);
var context = new IApplicationChecklistService.WorkerChecklistProcessStepData(ApplicationId, default, checklist, Enumerable.Empty());
A.CallTo(() => _applicationRepository.GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(ApplicationId))
- .Returns((CompanyId, null, CountryCode, Enumerable.Empty<(UniqueIdentifierId Id, string Value)>()));
+ .Returns((CompanyId, LegalName, null, CountryCode, Region, Enumerable.Empty<(UniqueIdentifierId Id, string Value)>()));
// Act
async Task Act() => await _sut.StartSelfDescriptionRegistration(context, CancellationToken.None);
@@ -207,7 +206,34 @@ public async Task StartSelfDescriptionRegistration_WithBpnNotSet_ThrowsConflictE
// Assert
var ex = await Assert.ThrowsAsync(Act);
ex.Message.Should().Be($"BusinessPartnerNumber (bpn) for CompanyApplications {ApplicationId} company {CompanyId} is empty");
- A.CallTo(() => _service.RegisterSelfDescriptionAsync(ApplicationId, UniqueIdentifiers, CountryCode, Bpn, A._))
+ A.CallTo(() => _service.RegisterSelfDescriptionAsync(ApplicationId, LegalName, UniqueIdentifiers, CountryCode, Region, Bpn, A._))
+ .MustNotHaveHappened();
+ }
+
+ [Theory]
+ [InlineData(CountryCode, null)]
+ [InlineData(null, Region)]
+ [InlineData(null, null)]
+ public async Task StartSelfDescriptionRegistration_WithCountryOrRegionNotSet_ThrowsConflictException(string? countryCode, string? region)
+ {
+ // Arrange
+ var checklist = ImmutableDictionary.CreateRange(
+ [
+ new(ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE),
+ ]);
+ var context = new IApplicationChecklistService.WorkerChecklistProcessStepData(ApplicationId, default, checklist, Enumerable.Empty());
+ A.CallTo(() => _applicationRepository.GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(ApplicationId))
+ .Returns((CompanyId, LegalName, Bpn, countryCode, region, Enumerable.Empty<(UniqueIdentifierId Id, string Value)>()));
+
+ // Act
+ async Task Act() => await _sut.StartSelfDescriptionRegistration(context, CancellationToken.None);
+
+ // Assert
+ var ex = await Assert.ThrowsAsync(Act);
+ ex.Message.Should().Be($"CountryCode or Region for CompanyApplications {ApplicationId} and Company {CompanyId} is empty. Expected value: DE-NW and Current value: {countryCode}-{region}");
+ A.CallTo(() => _service.RegisterSelfDescriptionAsync(ApplicationId, LegalName, UniqueIdentifiers, CountryCode, Region, Bpn, A._))
.MustNotHaveHappened();
}
@@ -307,16 +333,15 @@ public async Task ProcessFinishSelfDescriptionLp_FailedWithoutMessage_ThrowsConf
public async Task RegisterSelfDescriptionAsync_WithNoApplication_ThrowsConflictException()
{
// Arrange
- var checklist = new Dictionary
- {
- { ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE },
- }
- .ToImmutableDictionary();
+ var checklist = ImmutableDictionary.CreateRange(
+ [
+ new(ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE)
+ ]);
var context = new IApplicationChecklistService.WorkerChecklistProcessStepData(ApplicationId, default, checklist, Enumerable.Empty());
A.CallTo(() => _applicationRepository.GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(ApplicationId))
- .Returns<(Guid, string?, string, IEnumerable<(UniqueIdentifierId, string)>)>(default);
+ .Returns<(Guid, string, string?, string?, string?, IEnumerable<(UniqueIdentifierId, string)>)>(default);
// Act
async Task Act() => await _sut.StartSelfDescriptionRegistration(context, CancellationToken.None);
@@ -330,16 +355,15 @@ public async Task RegisterSelfDescriptionAsync_WithNoApplication_ThrowsConflictE
public async Task RegisterSelfDescriptionAsync_WithBpnNotSet_ThrowsConflictException()
{
// Arrange
- var checklist = new Dictionary
- {
- { ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE },
- { ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE },
- }
- .ToImmutableDictionary();
+ var checklist = ImmutableDictionary.CreateRange(
+ [
+ new(ApplicationChecklistEntryTypeId.REGISTRATION_VERIFICATION, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.BUSINESS_PARTNER_NUMBER, ApplicationChecklistEntryStatusId.DONE),
+ new(ApplicationChecklistEntryTypeId.IDENTITY_WALLET, ApplicationChecklistEntryStatusId.DONE)
+ ]);
var context = new IApplicationChecklistService.WorkerChecklistProcessStepData(ApplicationId, default, checklist, Enumerable.Empty());
A.CallTo(() => _applicationRepository.GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync(ApplicationId))
- .Returns((CompanyId, null, CountryCode, Enumerable.Empty<(UniqueIdentifierId Id, string Value)>()));
+ .Returns((CompanyId, LegalName, null, CountryCode, Region, Enumerable.Empty<(UniqueIdentifierId Id, string Value)>()));
// Act
async Task Act() => await _sut.StartSelfDescriptionRegistration(context, CancellationToken.None);
diff --git a/tests/externalsystems/SdFactory.Library.Tests/SdFactoryServiceTests.cs b/tests/externalsystems/SdFactory.Library.Tests/SdFactoryServiceTests.cs
index bba6fe7018..739342109a 100644
--- a/tests/externalsystems/SdFactory.Library.Tests/SdFactoryServiceTests.cs
+++ b/tests/externalsystems/SdFactory.Library.Tests/SdFactoryServiceTests.cs
@@ -33,6 +33,10 @@ public class SdFactoryServiceTests
{
#region Initialization
+ private const string CountryCode = "DE";
+ private const string Region = "NW";
+ private const string LegalName = "Legal Participant Company Name";
+ private const string Bpn = "BPNL000000000009";
private static readonly IEnumerable<(UniqueIdentifierId Id, string Value)> UniqueIdentifiers = new List<(UniqueIdentifierId Id, string Value)>
{
new(UniqueIdentifierId.VAT_ID, "JUSTATEST")
@@ -73,13 +77,12 @@ public SdFactoryServiceTests()
public async Task RegisterConnectorAsync_WithValidData_CreatesDocumentInDatabase()
{
// Arrange
- const string bpn = "BPNL000000000009";
var id = Guid.NewGuid();
var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.OK);
using var httpClient = CreateHttpClient(httpMessageHandlerMock);
// Act
- await _service.RegisterConnectorAsync(id, "https://connect-tor.com", bpn, CancellationToken.None);
+ await _service.RegisterConnectorAsync(id, "https://connect-tor.com", Bpn, CancellationToken.None);
// Assert
_documents.Should().BeEmpty();
@@ -90,12 +93,11 @@ public async Task RegisterConnectorAsync_WithInvalidData_ThrowsException()
{
// Arrange
var id = Guid.NewGuid();
- const string bpn = "BPNL000000000009";
var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.BadRequest);
using var httpClient = CreateHttpClient(httpMessageHandlerMock);
// Act
- async Task Action() => await _service.RegisterConnectorAsync(id, "https://connect-tor.com", bpn, CancellationToken.None);
+ async Task Action() => await _service.RegisterConnectorAsync(id, "https://connect-tor.com", Bpn, CancellationToken.None);
// Assert
var exception = await Assert.ThrowsAsync(Action);
@@ -111,13 +113,12 @@ public async Task RegisterConnectorAsync_WithInvalidData_ThrowsException()
public async Task RegisterSelfDescriptionAsync_WithValidData_CreatesDocumentInDatabase()
{
// Arrange
- const string bpn = "BPNL000000000009";
var applicationId = Guid.NewGuid();
var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.OK);
using var httpClient = CreateHttpClient(httpMessageHandlerMock);
// Act
- await _service.RegisterSelfDescriptionAsync(applicationId, UniqueIdentifiers, "de", bpn, CancellationToken.None);
+ await _service.RegisterSelfDescriptionAsync(applicationId, LegalName, UniqueIdentifiers, CountryCode, Region, Bpn, CancellationToken.None);
// Assert
_documents.Should().BeEmpty();
@@ -128,12 +129,11 @@ public async Task RegisterSelfDescriptionAsync_WithInvalidData_ThrowsException()
{
// Arrange
var applicationId = Guid.NewGuid();
- const string bpn = "BPNL000000000009";
var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.BadRequest);
using var httpClient = CreateHttpClient(httpMessageHandlerMock);
// Act
- async Task Action() => await _service.RegisterSelfDescriptionAsync(applicationId, UniqueIdentifiers, "de", bpn, CancellationToken.None);
+ async Task Action() => await _service.RegisterSelfDescriptionAsync(applicationId, LegalName, UniqueIdentifiers, CountryCode, Region, Bpn, CancellationToken.None);
// Assert
var exception = await Assert.ThrowsAsync(Action);
diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationRepositoryTests.cs
index c9ed18cc08..7c3462b618 100644
--- a/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationRepositoryTests.cs
+++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/ApplicationRepositoryTests.cs
@@ -326,8 +326,10 @@ public async Task GetCompanyAndApplicationDetailsWithUniqueIdentifiersAsync_With
// Assert
data.CompanyId.Should().Be(CompanyId);
+ data.legalName.Should().Be("CX-Test-Access");
data.BusinessPartnerNumber.Should().NotBeNullOrEmpty().And.Be("BPNL00000003CRHL");
data.Alpha2Code.Should().Be("DE");
+ data.Region.Should().Be("BY");
data.UniqueIdentifiers.Should().HaveCount(1);
}
diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/addresses.unittest.json b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/addresses.unittest.json
index c653e3e9ed..ccf5cc7565 100644
--- a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/addresses.unittest.json
+++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/addresses.unittest.json
@@ -40,7 +40,7 @@
"date_created": "2022-03-24 18:01:33.306000 +00:00",
"date_last_changed": "2022-03-24 18:01:33.306000 +00:00",
"city": "Munich",
- "region": null,
+ "region": "BY",
"streetadditional": null,
"streetname": "Street",
"streetnumber": "1",
diff --git a/tests/processes/SelfDescriptionCreation.Executor.Tests/SdCreationProcessTypeExecutorTests.cs b/tests/processes/SelfDescriptionCreation.Executor.Tests/SdCreationProcessTypeExecutorTests.cs
index ea1da9ed7b..acc08b9c11 100644
--- a/tests/processes/SelfDescriptionCreation.Executor.Tests/SdCreationProcessTypeExecutorTests.cs
+++ b/tests/processes/SelfDescriptionCreation.Executor.Tests/SdCreationProcessTypeExecutorTests.cs
@@ -30,6 +30,10 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Processes.SelfDescriptionCreation.
public class SdCreationProcessTypeExecutorTests
{
+ private const string CountryCode = "DE";
+ private const string Region = "NW";
+ private const string LegalName = "Legal Participant Company Name";
+ private const string Bpn = "BPNL000000001TEST";
private readonly ICompanyRepository _companyRepository;
private readonly IConnectorsRepository _connectorsRepository;
private readonly SdCreationProcessTypeExecutor _executor;
@@ -98,11 +102,13 @@ public async Task ExecuteProcessStep_ForCompanies_ReturnsExpected()
initializationResult.ScheduleStepTypeIds.Should().BeNull();
// Arrange
- var company = new ValueTuple, string?, string>(
+ var company = new ValueTuple, string?, string?, string?>(
Guid.NewGuid(),
+ LegalName,
new List<(UniqueIdentifierId Id, string Value)> { new(UniqueIdentifierId.VAT_ID, "test") },
- "BPNL000000001TEST",
- "DE");
+ Bpn,
+ CountryCode,
+ Region);
A.CallTo(() => _companyRepository.GetCompanyByProcessId(processId))
.Returns(company);
@@ -115,7 +121,7 @@ public async Task ExecuteProcessStep_ForCompanies_ReturnsExpected()
x => x == ProcessStepTypeId.RETRIGGER_AWAIT_SELF_DESCRIPTION_COMPANY_RESPONSE);
result.ProcessStepStatusId.Should().Be(ProcessStepStatusId.DONE);
- A.CallTo(() => _sdFactoryService.RegisterSelfDescriptionAsync(company.Item1, A>._, A._, A._, A._))
+ A.CallTo(() => _sdFactoryService.RegisterSelfDescriptionAsync(company.Item1, A._, A>._, A._, A._, A._, A._))
.MustHaveHappenedOnceExactly();
}
@@ -134,7 +140,7 @@ public async Task ExecuteProcessStep_ForConnectors_ReturnsExpected()
// Arrange
var connector = new ValueTuple(
Guid.NewGuid(),
- "BPNL000000001TEST",
+ Bpn,
Guid.NewGuid());
A.CallTo(() => _connectorsRepository.GetConnectorForProcessId(processId))
.Returns(connector);
@@ -148,7 +154,7 @@ public async Task ExecuteProcessStep_ForConnectors_ReturnsExpected()
x => x == ProcessStepTypeId.RETRIGGER_AWAIT_SELF_DESCRIPTION_CONNECTOR_RESPONSE);
result.ProcessStepStatusId.Should().Be(ProcessStepStatusId.DONE);
- A.CallTo(() => _sdFactoryService.RegisterConnectorAsync(connector.Item1, A._, "BPNL000000001TEST", A._))
+ A.CallTo(() => _sdFactoryService.RegisterConnectorAsync(connector.Item1, A._, Bpn, A._))
.MustHaveHappenedOnceExactly();
}
@@ -167,16 +173,18 @@ public async Task ExecuteProcessStep_ThrowingTestException_ReturnsExpected()
initializationResult.ScheduleStepTypeIds.Should().BeNull();
// Arrange execute
- var company = new ValueTuple, string?, string>(
+ var company = new ValueTuple, string?, string?, string?>(
Guid.NewGuid(),
+ LegalName,
new List<(UniqueIdentifierId Id, string Value)> { new(UniqueIdentifierId.VAT_ID, "test") },
- "BPNL000000001TEST",
- "DE");
+ Bpn,
+ CountryCode,
+ Region);
A.CallTo(() => _companyRepository.GetCompanyByProcessId(processId))
.Returns(company);
var error = _fixture.Create();
- A.CallTo(() => _sdFactoryService.RegisterSelfDescriptionAsync(A._, A>._, A._, A._, A._))
+ A.CallTo(() => _sdFactoryService.RegisterSelfDescriptionAsync(A._, A._, A>._, A._, A._, A._, A._))
.Throws(error);
// Act execute
@@ -205,16 +213,18 @@ public async Task ExecuteProcessStep_ThrowingSystemException_Throws()
initializationResult.ScheduleStepTypeIds.Should().BeNull();
// Arrange execute
- var company = new ValueTuple, string?, string>(
+ var company = new ValueTuple, string?, string?, string?>(
Guid.NewGuid(),
+ LegalName,
new List<(UniqueIdentifierId Id, string Value)> { new(UniqueIdentifierId.VAT_ID, "test") },
- "BPNL000000001TEST",
- "DE");
+ Bpn,
+ CountryCode,
+ Region);
A.CallTo(() => _companyRepository.GetCompanyByProcessId(processId))
.Returns(company);
var error = new SystemException(_fixture.Create());
- A.CallTo(() => _sdFactoryService.RegisterSelfDescriptionAsync(A._, A>._, A._, A._, A._))
+ A.CallTo(() => _sdFactoryService.RegisterSelfDescriptionAsync(A._, A._, A>._, A._, A._, A._, A._))
.Throws(error);
// Act execute