Skip to content

Commit

Permalink
fix(serviceTypeId): rename Consultance_Service (#235)
Browse files Browse the repository at this point in the history
Reviewed-By: Phil Schneider <[email protected]>
Refs: CPLP-2745
  • Loading branch information
qxz2mqe authored Aug 25, 2023
1 parent 0e5ade6 commit d564882
Show file tree
Hide file tree
Showing 9 changed files with 7,326 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/marketplace/Offers.Library/Service/OfferService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,9 +765,9 @@ public async Task UpdateTechnicalUserProfiles(Guid offerId, OfferTypeId offerTyp
throw new ForbiddenException($"Company {companyId} is not the providing company");
}

if (offerProfileData.ServiceTypeIds?.All(x => x == ServiceTypeId.CONSULTANCE_SERVICE) ?? false)
if (offerProfileData.ServiceTypeIds?.All(x => x == ServiceTypeId.CONSULTANCY_SERVICE) ?? false)
{
throw new ConflictException("Technical User Profiles can't be set for CONSULTANCE_SERVICE");
throw new ConflictException("Technical User Profiles can't be set for CONSULTANCY_SERVICE");
}

var notExistingRoles = data.SelectMany(ur => ur.UserRoleIds).Except(roles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public async Task UpdateServiceAsync(Guid serviceId, ServiceUpdateRequestData da
newServiceTypes,
serviceTypeIdsToRemove,
offerRepository);
if (data.ServiceTypeIds.All(x => x == ServiceTypeId.CONSULTANCE_SERVICE))
if (data.ServiceTypeIds.All(x => x == ServiceTypeId.CONSULTANCY_SERVICE))
{
_portalRepositories.GetInstance<ITechnicalUserProfileRepository>()
.RemoveTechnicalUserProfilesForOffer(serviceId);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/********************************************************************************
* 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
* 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
{
public partial class CPLP2745RenameServiceTypeIdEnum : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
schema: "portal",
table: "service_types",
keyColumn: "id",
keyValue: 2,
column: "label",
value: "CONSULTANCY_SERVICE");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
schema: "portal",
table: "service_types",
keyColumn: "id",
keyValue: 2,
column: "label",
value: "CONSULTANCE_SERVICE");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
Expand Down Expand Up @@ -4808,7 +4807,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
new
{
Id = 2,
Label = "CONSULTANCE_SERVICE"
Label = "CONSULTANCY_SERVICE"
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums
public enum ServiceTypeId
{
DATASPACE_SERVICE = 1,
CONSULTANCE_SERVICE = 2
CONSULTANCY_SERVICE = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,7 @@ public async Task UpdateTechnicalUserProfiles_ForConsultancyService_ThrowsExcept
}),
};
A.CallTo(() => _technicalUserProfileRepository.GetOfferProfileData(offerId, offerTypeId, _identity.CompanyId))
.Returns(new OfferProfileData(true, new[] { ServiceTypeId.CONSULTANCE_SERVICE }, Enumerable.Empty<(Guid TechnicalUserProfileId, IEnumerable<Guid> UserRoleIds)>()));
.Returns(new OfferProfileData(true, new[] { ServiceTypeId.CONSULTANCY_SERVICE }, Enumerable.Empty<(Guid TechnicalUserProfileId, IEnumerable<Guid> UserRoleIds)>()));
A.CallTo(() => _userRolesRepository.GetRolesForClient("cl1"))
.Returns(new Guid[] { userRole1Id, userRole2Id }.ToAsyncEnumerable());

Expand All @@ -1979,7 +1979,7 @@ public async Task UpdateTechnicalUserProfiles_ForConsultancyService_ThrowsExcept

// Assert
var ex = await Assert.ThrowsAsync<ConflictException>(Act);
ex.Message.Should().Be("Technical User Profiles can't be set for CONSULTANCE_SERVICE");
ex.Message.Should().Be("Technical User Profiles can't be set for CONSULTANCY_SERVICE");
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public async Task GetServiceTypeData_ReturnExpectedResult()
// Arrange
var data = _fixture.Build<ServiceTypeData>()
.With(x => x.ServiceTypeId, 1)
.With(x => x.Name, ServiceTypeId.CONSULTANCE_SERVICE.ToString())
.With(x => x.Name, ServiceTypeId.CONSULTANCY_SERVICE.ToString())
.CreateMany()
.ToAsyncEnumerable();

Expand All @@ -215,7 +215,7 @@ public async Task GetServiceTypeData_ReturnExpectedResult()
.MustHaveHappenedOnceExactly();
result.Should().BeOfType<List<ServiceTypeData>>();
result.FirstOrDefault()!.ServiceTypeId.Should().Be(1);
result.FirstOrDefault()!.Name.Should().Be(ServiceTypeId.CONSULTANCE_SERVICE.ToString());
result.FirstOrDefault()!.Name.Should().Be(ServiceTypeId.CONSULTANCY_SERVICE.ToString());
}

[Fact]
Expand Down Expand Up @@ -249,7 +249,7 @@ public async Task GetServiceTypeDataAsync_ReturnsExpected()
.With(x => x.Title, "test title")
.With(x => x.ContactEmail, "[email protected]")
.With(x => x.UseCase, (IEnumerable<AppUseCaseData>?)null)
.With(x => x.ServiceTypeIds, new[] { ServiceTypeId.DATASPACE_SERVICE, ServiceTypeId.CONSULTANCE_SERVICE })
.With(x => x.ServiceTypeIds, new[] { ServiceTypeId.DATASPACE_SERVICE, ServiceTypeId.CONSULTANCY_SERVICE })
.Create();

A.CallTo(() => _offerService.GetProviderOfferDetailsForStatusAsync(serviceId, _identity.CompanyId, OfferTypeId.SERVICE))
Expand Down Expand Up @@ -444,7 +444,7 @@ public async Task UpdateServiceAsync_WithValidData_ReturnsExpected()
},
new List<ServiceTypeId>
{
ServiceTypeId.CONSULTANCE_SERVICE
ServiceTypeId.CONSULTANCY_SERVICE
},
"43",
"[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ public async Task RemoveServiceAssignedServiceTypes_WithExisting_RemovesServiceA
var (sut, dbContext) = await CreateSutWithContext().ConfigureAwait(false);

// Act
sut.RemoveServiceAssignedServiceTypes(new[] { (new Guid("99C5FD12-8085-4DE2-ABFD-215E1EE4BAA5"), ServiceTypeId.CONSULTANCE_SERVICE) });
sut.RemoveServiceAssignedServiceTypes(new[] { (new Guid("99C5FD12-8085-4DE2-ABFD-215E1EE4BAA5"), ServiceTypeId.CONSULTANCY_SERVICE) });

// Assert
var changeTracker = dbContext.ChangeTracker;
Expand Down Expand Up @@ -412,7 +412,7 @@ public async Task GetActiveServices_ReturnsExpectedResult(ServiceOverviewSorting
}

[Theory]
[InlineData(ServiceTypeId.CONSULTANCE_SERVICE, 0, 2, 1, 1)]
[InlineData(ServiceTypeId.CONSULTANCY_SERVICE, 0, 2, 1, 1)]
[InlineData(ServiceTypeId.DATASPACE_SERVICE, 0, 2, 2, 2)]
[InlineData(null, 0, 2, 4, 2)]
[InlineData(null, 1, 1, 4, 1)]
Expand Down

0 comments on commit d564882

Please sign in to comment.