Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(status): change document status as locked while uploading certificate #551

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private async Task HandleCompanyCertificateCreationAsync(CompanyCertificateTypeI
hash, mediaTypeId, DocumentTypeId.COMPANY_CERTIFICATE, x =>
{
x.CompanyUserId = _identityData.IdentityId;
x.DocumentStatusId = DocumentStatusId.PENDING;
x.DocumentStatusId = DocumentStatusId.LOCKED;
});

companyCertificateRepository.CreateCompanyCertificate(_identityData.CompanyId, companyCertificateTypeId, doc.Id,
Expand Down Expand Up @@ -639,7 +639,7 @@ public async Task<int> DeleteCompanyCertificateAsync(Guid documentId)
{
companyCertificateRepository.AttachAndModifyCompanyCertificateDetails(details.CompanyCertificateId.SingleOrDefault(), null, c =>
{
c.CompanyCertificateStatusId = CompanyCertificateStatusId.INACTVIE;
c.CompanyCertificateStatusId = CompanyCertificateStatusId.INACTIVE;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public IAsyncEnumerable<CompanyCertificateBpnData> GetCompanyCertificateData(Gui
.Select(document => new ValueTuple<Guid, DocumentStatusId, IEnumerable<Guid>, bool>(
document.Id,
document.DocumentStatusId,
document.CompanyCertificates.Where(x => x.CompanyCertificateStatusId != CompanyCertificateStatusId.INACTVIE).Select(x => x.Id),
document.CompanyCertificates.Where(x => x.CompanyCertificateStatusId != CompanyCertificateStatusId.INACTIVE).Select(x => x.Id),
document.CompanyUser!.Identity!.CompanyId == companyId))
.SingleOrDefaultAsync();

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/********************************************************************************
* Copyright (c) 2021, 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 companycertificateupdate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
schema: "portal",
table: "company_certificate_statuses",
keyColumn: "id",
keyValue: 2,
column: "label",
value: "INACTIVE");

migrationBuilder.UpdateData(
schema: "portal",
table: "company_certificate_type_statuses",
keyColumn: "id",
keyValue: 2,
column: "label",
value: "INACTIVE");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
schema: "portal",
table: "company_certificate_statuses",
keyColumn: "id",
keyValue: 2,
column: "label",
value: "INACTVIE");

migrationBuilder.UpdateData(
schema: "portal",
table: "company_certificate_type_statuses",
keyColumn: "id",
keyValue: 2,
column: "label",
value: "INACTVIE");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/********************************************************************************
/********************************************************************************
* Copyright (c) 2021, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
Expand Down Expand Up @@ -2213,7 +2213,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
new
{
Id = 2,
Label = "INACTVIE"
Label = "INACTIVE"
});
});

Expand Down Expand Up @@ -2367,7 +2367,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
new
{
Id = 2,
Label = "INACTVIE"
Label = "INACTIVE"
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums
public enum CompanyCertificateStatusId
{
ACTIVE = 1,
INACTVIE = 2
INACTIVE = 2
}
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 CompanyCertificateTypeStatusId
{
ACTIVE = 1,
INACTVIE = 2
INACTIVE = 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ public async Task CheckCompanyCertificate_WithValidCall_CreatesExpected()
A.CallTo(() => _documentRepository.CreateDocument(A<string>._, A<byte[]>._, A<byte[]>._, MediaTypeId.PDF, DocumentTypeId.COMPANY_CERTIFICATE, A<Action<Document>>._))
.Invokes((string documentName, byte[] documentContent, byte[] hash, MediaTypeId mediaTypeId, DocumentTypeId documentTypeId, Action<Document>? setupOptionalFields) =>
{
var document = new Document(documentId, documentContent, hash, documentName, mediaTypeId, DateTimeOffset.UtcNow, DocumentStatusId.PENDING, documentTypeId);
var document = new Document(documentId, documentContent, hash, documentName, mediaTypeId, DateTimeOffset.UtcNow, DocumentStatusId.LOCKED, documentTypeId);
setupOptionalFields?.Invoke(document);
documents.Add(document);
})
Expand All @@ -1041,7 +1041,7 @@ public async Task CheckCompanyCertificate_WithValidCall_CreatesExpected()
documents.Should().ContainSingle();
var document = documents.Single();
document.DocumentTypeId.Should().Be(DocumentTypeId.COMPANY_CERTIFICATE);
document.DocumentStatusId.Should().Be(DocumentStatusId.PENDING);
document.DocumentStatusId.Should().Be(DocumentStatusId.LOCKED);
A.CallTo(() => _companyCertificateRepository.CreateCompanyCertificate(_identity.CompanyId, CompanyCertificateTypeId.IATF, document.Id, A<Action<CompanyCertificate>>._))
.MustHaveHappenedOnceExactly();
companyCertificates.Should().ContainSingle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public async Task GetAllCertificates_ReturnsExpectedResult(CertificateSorting so
[Theory]
[InlineData(CompanyCertificateStatusId.ACTIVE, CompanyCertificateTypeId.AEO_CTPAT_Security_Declaration, 0, 2, 1, 1)]
[InlineData(CompanyCertificateStatusId.ACTIVE, CompanyCertificateTypeId.ISO_9001, 0, 2, 1, 1)]
[InlineData(CompanyCertificateStatusId.INACTVIE, CompanyCertificateTypeId.IATF, 0, 2, 0, 0)]
[InlineData(CompanyCertificateStatusId.INACTIVE, CompanyCertificateTypeId.IATF, 0, 2, 0, 0)]
public async Task GetAllCertificates_WithExistingCompanyCertificateAndCertificateType_ReturnsExpectedResult(CompanyCertificateStatusId companyCertificateStatusId, CompanyCertificateTypeId companyCertificateTypeId, int page, int size, int count, int numData)
{
// Arrange
Expand Down Expand Up @@ -256,7 +256,7 @@ public async Task CompanyCertificateDetailsModify_WithValidData_ReturnsExpected(
// Act
sut.AttachAndModifyCompanyCertificateDetails(new("9f5b9934-4014-4099-91e9-7b1aee696c12"), null, x =>
{
x.CompanyCertificateStatusId = CompanyCertificateStatusId.INACTVIE;
x.CompanyCertificateStatusId = CompanyCertificateStatusId.INACTIVE;
});

// Assert
Expand All @@ -265,7 +265,7 @@ public async Task CompanyCertificateDetailsModify_WithValidData_ReturnsExpected(
changeTracker.HasChanges().Should().BeTrue();
changedEntries.Should().ContainSingle()
.Which.Entity.Should().BeOfType<CompanyCertificate>()
.And.Match<CompanyCertificate>(x => x.CompanyCertificateStatusId == CompanyCertificateStatusId.INACTVIE);
.And.Match<CompanyCertificate>(x => x.CompanyCertificateStatusId == CompanyCertificateStatusId.INACTIVE);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public async Task GetCertificateTypes_WithInactiveCertificateType_ReturnsExpecte
// Arrange
var (context, sut) = await CreateSutWithContext().ConfigureAwait(false);
var active = new CompanyCertificateTypeAssignedStatus(CompanyCertificateTypeId.ISO_15504_SPICE, CompanyCertificateTypeStatusId.ACTIVE);
var inactive = new CompanyCertificateTypeAssignedStatus(CompanyCertificateTypeId.ISO_15504_SPICE, CompanyCertificateTypeStatusId.INACTVIE);
var inactive = new CompanyCertificateTypeAssignedStatus(CompanyCertificateTypeId.ISO_15504_SPICE, CompanyCertificateTypeStatusId.INACTIVE);
context.Remove(active);
context.Add(inactive);
await context.SaveChangesAsync().ConfigureAwait(false);
Expand Down
Loading