-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Psp 9512 jobs for upload, polling, retries (#4529)
* psp-9500 scheduler microservice. * psp-9512 tests and jobs for polling, uploads, and retries. * Account for possible NPEs. * mapping/model corrections. * enhance logging/error reporting. * additional logging, log corrections. * change order of when processing flag set. * add skip extension check, to force process all documents. * ensure that mayan error max length is not exceeded. * remove mappings for document content. * Add additional call to ensure that all updates are made against most recent copy of documentQueue -> since polling may trigger updates. * update appsettings, truncation logic. * document queue repository updates. * update truncation logic, error handling. * move disable filter annotation to interface. * Allow for max size filter to limit returned documents. * add repository method to allow for file lengths to be retreived. * additional logging. * reduce number of calls to db for file sizes during processing. * updates from testing psp-9513. * Add ability to configure retry job separately. * psp-9512 - corrections from testing. * fix for document template uploads. * snapshot updates. --------- Co-authored-by: Smith <[email protected]>
- Loading branch information
1 parent
26d1ff5
commit dfc2b6a
Showing
73 changed files
with
4,137 additions
and
1,823 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
source/backend/Pims.Scheduler.Test/Pims.Scheduler.Test.csproj
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,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentAssertions" Version="6.10.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" /> | ||
<PackageReference Include="Moq" Version="4.20.70" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\scheduler\Pims.Scheduler.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
105 changes: 105 additions & 0 deletions
105
source/backend/Pims.Scheduler.Test/Repositories/PimsDocumentQueueRepositoryTests.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,105 @@ | ||
using FluentAssertions; | ||
using Moq; | ||
using Pims.Api.Models.CodeTypes; | ||
using Pims.Api.Models.Concepts.Document; | ||
using Pims.Api.Models.Requests.Http; | ||
using Pims.Dal.Entities.Models; | ||
using Pims.Scheduler.Repositories; | ||
using Xunit; | ||
|
||
namespace Pims.Scheduler.Test.Repositories | ||
{ | ||
public class PimsDocumentQueueRepositoryTest | ||
{ | ||
[Fact] | ||
public async Task PollQueuedDocument_ValidDocument_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var document = new DocumentQueueModel { Id = 1 }; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.PollQueuedDocument(document)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.PollQueuedDocument(document); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.PollQueuedDocument(document), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task UploadQueuedDocument_ValidDocument_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var document = new DocumentQueueModel { Id = 1 }; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.UploadQueuedDocument(document)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.UploadQueuedDocument(document); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.UploadQueuedDocument(document), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task UpdateQueuedDocument_ValidDocument_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var documentQueueId = 1; | ||
var document = new DocumentQueueModel { Id = documentQueueId }; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.UpdateQueuedDocument(documentQueueId, document)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.UpdateQueuedDocument(documentQueueId, document); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.UpdateQueuedDocument(documentQueueId, document), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task SearchQueuedDocumentsAsync_ValidFilter_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var filter = new DocumentQueueFilter(); | ||
var expectedResponse = new ExternalResponse<List<DocumentQueueModel>> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.SearchQueuedDocumentsAsync(filter)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.SearchQueuedDocumentsAsync(filter); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.SearchQueuedDocumentsAsync(filter), Times.Once); | ||
} | ||
|
||
[Fact] | ||
public async Task GetById_ValidDocumentQueueId_ReturnsExternalResponse() | ||
{ | ||
// Arrange | ||
var documentQueueId = 1; | ||
var expectedResponse = new ExternalResponse<DocumentQueueModel> { Status = ExternalResponseStatus.Success }; | ||
var repositoryMock = new Mock<IPimsDocumentQueueRepository>(); | ||
repositoryMock.Setup(x => x.GetById(documentQueueId)).ReturnsAsync(expectedResponse); | ||
|
||
// Act | ||
var result = await repositoryMock.Object.GetById(documentQueueId); | ||
|
||
// Assert | ||
result.Should().NotBeNull(); | ||
result.Status.Should().Be(ExternalResponseStatus.Success); | ||
repositoryMock.Verify(x => x.GetById(documentQueueId), Times.Once); | ||
} | ||
} | ||
} |
Oops, something went wrong.