-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(seeding): move company and address to overwrite dir (#1067)
* make company and address overwriteable to provide the option to seed the bpn without changing the code it's moved into a directory where it can be overwritten Co-authored-by: Norbert Truchsess <[email protected]> Reviewed-by: Norbert Truchsess <[email protected]> Reviewed-By: Evelyn Gurschler <[email protected]> Refs: eclipse-tractusx/portal#449
- Loading branch information
1 parent
58e0659
commit f4a371b
Showing
13 changed files
with
99 additions
and
40 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
src/portalbackend/PortalBackend.Migrations/Extensions/SeedingExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; | ||
|
||
namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.Migrations.Extensions; | ||
|
||
public static class SeedingExtensions | ||
{ | ||
#region Company | ||
|
||
public static bool UpdateCompanyNeeded(this (Company dataEntity, Company dbEntity) data) => | ||
(data.dbEntity.SelfDescriptionDocumentId == null && | ||
data.dataEntity.SelfDescriptionDocumentId != null) || | ||
data.dbEntity.BusinessPartnerNumber != data.dataEntity.BusinessPartnerNumber || | ||
data.dbEntity.Shortname != data.dataEntity.Shortname || | ||
data.dbEntity.Name != data.dataEntity.Name; | ||
|
||
public static void UpdateCompany(this Company dbEntry, Company entry) | ||
{ | ||
if (dbEntry.SelfDescriptionDocumentId == null && | ||
entry.SelfDescriptionDocumentId != null) | ||
{ | ||
dbEntry.SelfDescriptionDocumentId = entry.SelfDescriptionDocumentId; | ||
} | ||
|
||
dbEntry.BusinessPartnerNumber = entry.BusinessPartnerNumber; | ||
dbEntry.Shortname = entry.Shortname; | ||
dbEntry.Name = entry.Name; | ||
} | ||
|
||
#endregion | ||
|
||
#region Address | ||
|
||
public static bool UpdateAddressNeeded(this (Address dataEntity, Address dbEntity) data) => | ||
data.dataEntity.City != data.dbEntity.City || | ||
data.dbEntity.Region != data.dataEntity.Region || | ||
data.dbEntity.Streetadditional != data.dataEntity.Streetadditional || | ||
data.dbEntity.Streetname != data.dataEntity.Streetname || | ||
data.dbEntity.Streetnumber != data.dataEntity.Streetnumber || | ||
data.dbEntity.Zipcode != data.dataEntity.Zipcode || | ||
data.dbEntity.CountryAlpha2Code != data.dataEntity.CountryAlpha2Code; | ||
|
||
public static void UpdateAddress(this Address dbEntry, Address entry) | ||
{ | ||
dbEntry.City = entry.City; | ||
dbEntry.Region = entry.Region; | ||
dbEntry.Streetadditional = entry.Streetadditional; | ||
dbEntry.Streetname = entry.Streetname; | ||
dbEntry.Streetnumber = entry.Streetnumber; | ||
dbEntry.Zipcode = entry.Zipcode; | ||
dbEntry.CountryAlpha2Code = entry.CountryAlpha2Code; | ||
} | ||
|
||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -450,14 +450,14 @@ public async Task GetCompanyDetailsAsync_ReturnsExpected() | |
result.Should().NotBeNull(); | ||
|
||
result!.CompanyId.Should().Be(new Guid("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87")); | ||
result.Name.Should().Be("Catena-X"); | ||
result.ShortName.Should().Be("Catena-X"); | ||
result.Name.Should().Be("CX-Operator"); | ||
result.ShortName.Should().Be("CX-Operator"); | ||
result.BusinessPartnerNumber.Should().Be("BPNL00000003CRHK"); | ||
result.CountryAlpha2Code.Should().Be("DE"); | ||
result.City.Should().Be("Munich"); | ||
result.StreetName.Should().Be("Street"); | ||
result.StreetNumber.Should().Be("1"); | ||
result.ZipCode.Should().Be("00001"); | ||
result.City.Should().Be("tbd"); | ||
result.StreetName.Should().Be("tbd"); | ||
result.StreetNumber.Should().Be(""); | ||
result.ZipCode.Should().Be(""); | ||
result.CompanyRole.Should().Contain(CompanyRoleId.ACTIVE_PARTICIPANT); | ||
} | ||
|
||
|
@@ -706,7 +706,7 @@ public async Task GetOwnCompanAndCompanyUseryIdWithCompanyNameAndUserEmailAsync_ | |
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result!.OrganizationName.Should().Be("Catena-X"); | ||
result!.OrganizationName.Should().Be("CX-Operator"); | ||
result.CompanyUserEmail.Should().Be("[email protected]"); | ||
} | ||
|
||
|
@@ -739,7 +739,7 @@ public async Task GetOperatorBpns_ReturnsExpectedResult() | |
// Assert | ||
result.Should().ContainSingle() | ||
.Which.Should().BeOfType<OperatorBpnData>() | ||
.And.Match<OperatorBpnData>(x => x.Bpn == "BPNL00000003CRHK" && x.OperatorName == "Catena-X"); | ||
.And.Match<OperatorBpnData>(x => x.Bpn == "BPNL00000003CRHK" && x.OperatorName == "CX-Operator"); | ||
} | ||
|
||
#endregion | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,7 +182,7 @@ public async Task GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync_W | |
var (sut, _) = await CreateSut(); | ||
|
||
// Act | ||
var results = await sut.GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync(_userCompanyId, OfferTypeId.SERVICE, SubscriptionStatusSorting.CompanyNameAsc, new[] { OfferSubscriptionStatusId.ACTIVE, OfferSubscriptionStatusId.PENDING }, null, "catena")(0, 15); | ||
var results = await sut.GetOwnCompanyProvidedOfferSubscriptionStatusesUntrackedAsync(_userCompanyId, OfferTypeId.SERVICE, SubscriptionStatusSorting.CompanyNameAsc, new[] { OfferSubscriptionStatusId.ACTIVE, OfferSubscriptionStatusId.PENDING }, null, "operator")(0, 15); | ||
|
||
// Assert | ||
results.Should().NotBeNull(); | ||
|
@@ -210,7 +210,7 @@ public async Task GetOfferDetailsAndCheckUser_WithValidUserAndSubscriptionId_Ret | |
result!.OfferId.Should().Be(new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007")); | ||
result.Status.Should().Be(OfferSubscriptionStatusId.ACTIVE); | ||
result.CompanyId.Should().Be(new Guid("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87")); | ||
result.CompanyName.Should().Be("Catena-X"); | ||
result.CompanyName.Should().Be("CX-Operator"); | ||
result.IsProviderCompany.Should().BeTrue(); | ||
result.Bpn.Should().Be("BPNL00000003CRHK"); | ||
result.OfferName.Should().Be("Trace-X"); | ||
|
@@ -233,7 +233,7 @@ public async Task GetOfferDetailsAndCheckUser_WithSubscriptionForOfferWithoutApp | |
result!.OfferId.Should().Be(new Guid("a16e73b9-5277-4b69-9f8d-3b227495dfae")); | ||
result.Status.Should().Be(OfferSubscriptionStatusId.ACTIVE); | ||
result.CompanyId.Should().Be(new Guid("2dc4249f-b5ca-4d42-bef1-7a7a950a4f87")); | ||
result.CompanyName.Should().Be("Catena-X"); | ||
result.CompanyName.Should().Be("CX-Operator"); | ||
result.IsProviderCompany.Should().BeTrue(); | ||
result.Bpn.Should().Be("BPNL00000003CRHK"); | ||
result.OfferName.Should().Be("Service Test 123"); | ||
|
@@ -259,7 +259,7 @@ public async Task GetSubscriptionDetailForProviderAsync_ReturnsExpected() | |
result.IsUserOfCompany.Should().BeTrue(); | ||
result.Details.Should().NotBeNull().And.Match<ProviderSubscriptionDetailData>(x => | ||
x.Name == "SDE with EDC" && | ||
x.Customer == "Catena-X" && | ||
x.Customer == "CX-Operator" && | ||
x.Contact.SequenceEqual(new[] { "[email protected]" }) && | ||
x.OfferSubscriptionStatus == OfferSubscriptionStatusId.ACTIVE | ||
&& x.TechnicalUserData.All(x => x.Id == new Guid("d0c8ae19-d4f3-49cc-9cb4-6c766d4680f2") && x.Name == "sa-x-4")); | ||
|
@@ -313,7 +313,7 @@ public async Task GetAppSubscriptionDetailForProviderAsync_ReturnsExpected() | |
result.IsUserOfCompany.Should().BeTrue(); | ||
result.Details.Should().NotBeNull().And.Match<AppProviderSubscriptionDetail>(x => | ||
x.Name == "SDE with EDC" && | ||
x.Customer == "Catena-X" && | ||
x.Customer == "CX-Operator" && | ||
x.Contact.SequenceEqual(new[] { "[email protected]" }) && | ||
x.OfferSubscriptionStatus == OfferSubscriptionStatusId.ACTIVE && | ||
x.TenantUrl == "https://ec-qas.d13fe27.kyma.ondemand.com" && | ||
|
@@ -869,13 +869,13 @@ public async Task GetOwnCompanySubscribedOfferSubscriptionStatusAsync_ReturnsExp | |
x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && | ||
x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.ACTIVE && | ||
x.OfferName == "Trace-X" && | ||
x.Provider == "Catena-X" && | ||
x.Provider == "CX-Operator" && | ||
x.OfferSubscriptionId == new Guid("ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba") && | ||
x.DocumentId == new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1"), | ||
x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && | ||
x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.PENDING && | ||
x.OfferName == "Trace-X" && | ||
x.Provider == "Catena-X" && | ||
x.Provider == "CX-Operator" && | ||
x.OfferSubscriptionId == new Guid("e8886159-9258-44a5-88d8-f5735a197a09") && | ||
x.DocumentId == new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1") | ||
); | ||
|
@@ -920,7 +920,7 @@ public async Task GetOwnCompanySubscribedOfferSubscriptionStatusAsync_WithStatus | |
x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && | ||
x.OfferSubscriptionStatusId == OfferSubscriptionStatusId.ACTIVE && | ||
x.OfferName == "Trace-X" && | ||
x.Provider == "Catena-X" && | ||
x.Provider == "CX-Operator" && | ||
x.OfferSubscriptionId == new Guid("ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba") && | ||
x.DocumentId == new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1") | ||
); | ||
|
@@ -1070,7 +1070,7 @@ public async Task GetOwnCompanyActiveSubscribedOfferSubscriptionStatusesUntracke | |
result.Should().HaveCount(1).And.Satisfy( | ||
x => x.OfferId == new Guid("ac1cf001-7fbc-1f2f-817f-bce0572c0007") && | ||
x.OfferName == "Trace-X" && | ||
x.Provider == "Catena-X" && | ||
x.Provider == "CX-Operator" && | ||
x.DocumentId == new Guid("e020787d-1e04-4c0b-9c06-bd1cd44724b1") && | ||
x.OfferSubscriptionId == new Guid("ed4de48d-fd4b-4384-a72f-ecae3c6cc5ba")); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters