Adds metadata aggregation to the media library enrichment job

This commit is contained in:
BinaryAlley committed 2026-08-24 14:18:40 -07:00
1 parent c82fadc7a2
commit 66871ccf62
168 files changed
+3503 -1062

No files matched your search

@@ -1,6 +1,7 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Core.MediaLibrary.Management.Commands.AddLibrary;
using Lumina.Contracts.Fixtures.Core.Requests.MediaLibrary.Management;
using Lumina.Contracts.Requests.MediaLibrary.Management;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using System.Diagnostics.CodeAnalysis;
@@ -14,20 +15,22 @@ namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
[ExcludeFromCodeCoverage]
public class AddMediaLibraryRequestMappingTests
{
private readonly AddLibraryRequestFixture _addLibraryRequestFixture = new();
[Fact]
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
{
// Arrange
AddLibraryRequest request = new(
"My Library",
"Book",
["C:/Books", "D:/Media/Books"],
"D:/poster.jpg",
true,
false,
true,
false,
false
AddLibraryRequest request = _addLibraryRequestFixture.Create(
title: "My Library",
libraryType: "Book",
contentLocations: ["C:/Books", "D:/Media/Books"],
coverImage: "D:/poster.jpg",
isEnabled: true,
isLocked: false,
canDownloadMetadataFromWeb: true,
shouldSaveMetadataInMediaDirectories: false,
shouldSkipUnchangedDirectoriesDuringScan: false
);
// Act
@@ -41,7 +44,7 @@ public class AddMediaLibraryRequestMappingTests
Assert.Equal(request.CoverImage, result.CoverImage);
Assert.Equal(request.IsEnabled, result.IsEnabled);
Assert.Equal(request.IsLocked, result.IsLocked);
Assert.Equal(request.DownloadMetadataFromWeb, result.DownloadMetadataFromWeb);
Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb);
Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories);
}
@@ -53,16 +56,16 @@ public class AddMediaLibraryRequestMappingTests
public void ToCommand_WhenMappingDifferentLibraryTypes_ShouldMapCorrectly(LibraryType libraryType)
{
// Arrange
AddLibraryRequest request = new(
"My Library",
libraryType.ToString(),
["C:/Media"],
"D:/poster.jpg",
true,
false,
true,
false,
false
AddLibraryRequest request = _addLibraryRequestFixture.Create(
title: "My Library",
libraryType: libraryType.ToString(),
contentLocations: ["C:/Media"],
coverImage: "D:/poster.jpg",
isEnabled: true,
isLocked: false,
canDownloadMetadataFromWeb: true,
shouldSaveMetadataInMediaDirectories: false,
shouldSkipUnchangedDirectoriesDuringScan: false
);
// Act
@@ -76,7 +79,7 @@ public class AddMediaLibraryRequestMappingTests
Assert.Equal(request.CoverImage, result.CoverImage);
Assert.Equal(request.IsEnabled, result.IsEnabled);
Assert.Equal(request.IsLocked, result.IsLocked);
Assert.Equal(request.DownloadMetadataFromWeb, result.DownloadMetadataFromWeb);
Assert.Equal(request.CanDownloadMetadataFromWeb, result.CanDownloadMetadataFromWeb);
Assert.Equal(request.ShouldSaveMetadataInMediaDirectories, result.ShouldSaveMetadataInMediaDirectories);
}
@@ -92,16 +95,16 @@ public class AddMediaLibraryRequestMappingTests
"F:/Reading Material"
];
AddLibraryRequest request = new(
"My Library",
"Book",
contentLocations,
"D:/poster.jpg",
true,
false,
true,
false,
false
AddLibraryRequest request = _addLibraryRequestFixture.Create(
title: "My Library",
libraryType: "Book",
contentLocations: contentLocations,
coverImage: "D:/poster.jpg",
isEnabled: true,
isLocked: false,
canDownloadMetadataFromWeb: true,
shouldSaveMetadataInMediaDirectories: false,
shouldSkipUnchangedDirectoriesDuringScan: false
);
// Act
@@ -122,16 +125,16 @@ public class AddMediaLibraryRequestMappingTests
"D:/Books"
];
AddLibraryRequest request = new(
"My Library",
"Book",
contentLocations,
null,
true,
false,
true,
false,
false
AddLibraryRequest request = _addLibraryRequestFixture.Create(
title: "My Library",
libraryType: "Book",
contentLocations: contentLocations,
coverImage: null,
isEnabled: true,
isLocked: false,
canDownloadMetadataFromWeb: true,
shouldSaveMetadataInMediaDirectories: false,
shouldSkipUnchangedDirectoriesDuringScan: false
);
// Act
@@ -1,9 +1,9 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Fixtures.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Contracts.Responses.MediaLibrary.Management;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.ValueObjects;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -17,28 +17,17 @@ namespace Lumina.Application.UnitTests.Common.Mapping.MediaLibrary.Management;
[ExcludeFromCodeCoverage]
public class LibraryEntityMappingTests
{
private readonly LibraryEntityFixture _libraryEntityFixture = new();
[Fact]
public void ToResponse_WhenMappingValidLibraryEntity_ShouldMapCorrectly()
{
// Arrange
LibraryEntity entity = new()
{
Id = Guid.NewGuid(),
UserId = Guid.NewGuid(),
Title = "My Library",
LibraryType = LibraryType.Book,
ContentLocations =
[
new() { Path = "C:/Books" },
new() { Path = "D:/Media/Books" }
],
CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = null,
UpdatedBy = null,
LibraryScans = []
};
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books", "D:/Media/Books"],
coverImage: "D:/myPoster.jpg");
// Act
LibraryResponse result = entity.ToResponse();
@@ -63,19 +52,11 @@ public class LibraryEntityMappingTests
public void ToResponse_WhenMappingDifferentLibraryTypes_ShouldMapCorrectly(LibraryType libraryType)
{
// Arrange
LibraryEntity entity = new()
{
Id = Guid.NewGuid(),
UserId = Guid.NewGuid(),
Title = "My Library",
LibraryType = libraryType,
ContentLocations = [new() { Path = "C:/Media" }],
CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = null,
UpdatedBy = null
};
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: libraryType,
contentLocations: ["C:/Media"],
coverImage: "D:/myPoster.jpg");
// Act
LibraryResponse result = entity.ToResponse();
@@ -89,25 +70,11 @@ public class LibraryEntityMappingTests
public void ToResponse_WhenMappingMultipleContentLocations_ShouldMapAllCorrectly()
{
// Arrange
LibraryEntity entity = new()
{
Id = Guid.NewGuid(),
UserId = Guid.NewGuid(),
Title = "My Library",
LibraryType = LibraryType.Book,
ContentLocations =
[
new() { Path = "C:/Media/Books" },
new() { Path = "D:/Books" },
new() { Path = "E:/Digital Library/Books" },
new() { Path = "F:/Reading Material" }
],
CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = null,
UpdatedBy = null
};
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Media/Books", "D:/Books", "E:/Digital Library/Books", "F:/Reading Material"],
coverImage: "D:/myPoster.jpg");
// Act
LibraryResponse result = entity.ToResponse();
@@ -122,19 +89,12 @@ public class LibraryEntityMappingTests
{
// Arrange
DateTime updated = DateTime.UtcNow.AddDays(-1);
LibraryEntity entity = new()
{
Id = Guid.NewGuid(),
UserId = Guid.NewGuid(),
Title = "My Library",
LibraryType = LibraryType.Book,
ContentLocations = [new() { Path = "C:/Books" }],
CoverImage = "D:/myPoster.jpg",
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = updated,
UpdatedBy = Guid.NewGuid()
};
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"],
coverImage: "D:/myPoster.jpg");
entity.UpdatedOnUtc = updated;
// Act
LibraryResponse result = entity.ToResponse();
@@ -149,19 +109,12 @@ public class LibraryEntityMappingTests
{
// Arrange
DateTime updated = DateTime.UtcNow.AddDays(-1);
LibraryEntity entity = new()
{
Id = Guid.NewGuid(),
UserId = Guid.NewGuid(),
Title = "My Library",
LibraryType = LibraryType.Book,
ContentLocations = [new() { Path = "C:/Books" }],
CoverImage = null,
CreatedOnUtc = DateTime.UtcNow,
CreatedBy = Guid.NewGuid(),
UpdatedOnUtc = updated,
UpdatedBy = Guid.NewGuid()
};
LibraryEntity entity = _libraryEntityFixture.Create(
title: "My Library",
libraryType: LibraryType.Book,
contentLocations: ["C:/Books"]);
entity.CoverImage = null;
entity.UpdatedOnUtc = updated;
// Act
LibraryResponse result = entity.ToResponse();
@@ -3,7 +3,6 @@ using Lumina.Application.Common.DataAccess.Entities.MediaLibrary.Management;
using Lumina.Application.Common.Mapping.Common.Metadata;
using Lumina.Application.Common.Mapping.MediaLibrary.Management;
using Lumina.Application.Common.Mapping.MediaLibrary.WrittenContentLibrary.BookLibrary.Common;
using Lumina.Domain.Common.Primitives;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.Fixtures.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryAggregate;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -34,7 +33,7 @@ public class LibraryMappingTests
coverImage: "D:/myPoster.jpg",
isEnabled: true,
isLocked: false,
downloadMetadataFromWeb: true,
canDownloadMetadataFromWeb: true,
shouldSaveMetadataInMediaDirectories: false,
shouldSkipUnchangedDirectoriesDuringScan: false,
scanIds: [Guid.NewGuid()]);
@@ -54,7 +53,7 @@ public class LibraryMappingTests
Assert.Equal(library.UpdatedOnUtc, result.UpdatedOnUtc);
Assert.True(result.IsEnabled);
Assert.False(result.IsLocked);
Assert.True(result.DownloadMetadataFromWeb);
Assert.True(result.CanDownloadMetadataFromWeb);
Assert.False(result.ShouldSaveMetadataInMediaDirectories);
Assert.Equal(library.ScanIds.Select(scanId => scanId.Value), result.LibraryScans.Select(libraryScan => libraryScan.Id));
}
@@ -93,7 +92,7 @@ public class LibraryMappingTests
coverImage: "D:/myPoster.jpg",
isEnabled: true,
isLocked: false,
downloadMetadataFromWeb: true,
canDownloadMetadataFromWeb: true,
shouldSaveMetadataInMediaDirectories: false);
// Act
@@ -105,7 +104,7 @@ public class LibraryMappingTests
Assert.Equal(library.CoverImage, result.CoverImage);
Assert.True(result.IsEnabled);
Assert.False(result.IsLocked);
Assert.True(result.DownloadMetadataFromWeb);
Assert.True(result.CanDownloadMetadataFromWeb);
Assert.False(result.ShouldSaveMetadataInMediaDirectories);
}