mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Adds metadata aggregation to the media library enrichment job
This commit is contained in:
1 parent
c82fadc7a2
commit
66871ccf62
168 files changed
+3503
-1062
No files matched your search
+45
-42
@@ -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
|
||||
|
||||
+30
-77
@@ -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();
|
||||
|
||||
+4
-5
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+11
-2
@@ -1,6 +1,7 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Mapping.UsersManagement.Users;
|
||||
using Lumina.Application.Core.UsersManagement.Settings.Commands.UpdateUserSettings;
|
||||
using Lumina.Contracts.Fixtures.Core.Requests.UsersManagement.Settings;
|
||||
using Lumina.Contracts.Requests.UsersManagement.Settings;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
@@ -13,11 +14,19 @@ namespace Lumina.Application.UnitTests.Common.Mapping.UsersManagement.Users;
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateUserSettingsRequestMappingTests
|
||||
{
|
||||
private readonly UpdateUserSettingsRequestFixture _requestFixture = new();
|
||||
|
||||
[Fact]
|
||||
public void ToCommand_WhenMappingValidRequest_ShouldMapCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
UpdateUserSettingsRequest request = new(IsPaginationEnabled: true, ItemsPerPage: 48, IgnoreThePrefixForAlphaPicker: false, IsThemeCachingEnabled: true);
|
||||
UpdateUserSettingsRequest request = _requestFixture.Create(
|
||||
isPaginationEnabled: true,
|
||||
itemsPerPage: 48,
|
||||
shouldIgnoreThePrefixForAlphaPicker: false,
|
||||
isThemeCachingEnabled: true,
|
||||
shouldAggregateMetadataWhenMissing: false
|
||||
);
|
||||
|
||||
// Act
|
||||
UpdateUserSettingsCommand result = request.ToCommand();
|
||||
@@ -26,7 +35,7 @@ public class UpdateUserSettingsRequestMappingTests
|
||||
Assert.NotNull(result);
|
||||
Assert.Equal(request.IsPaginationEnabled, result.IsPaginationEnabled);
|
||||
Assert.Equal(request.ItemsPerPage, result.ItemsPerPage);
|
||||
Assert.Equal(request.IgnoreThePrefixForAlphaPicker, result.IgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(request.ShouldIgnoreThePrefixForAlphaPicker, result.ShouldIgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(request.IsThemeCachingEnabled, result.IsThemeCachingEnabled);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -33,7 +33,7 @@ public class UserSettingsEntityMappingTests
|
||||
Assert.Equal(entity.UserId, result.Value.UserId.Value);
|
||||
Assert.Equal(entity.IsPaginationEnabled, result.Value.IsPaginationEnabled);
|
||||
Assert.Equal(entity.ItemsPerPage, result.Value.ItemsPerPage);
|
||||
Assert.Equal(entity.IgnoreThePrefixForAlphaPicker, result.Value.IgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(entity.ShouldIgnoreThePrefixForAlphaPicker, result.Value.ShouldIgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(entity.IsThemeCachingEnabled, result.Value.IsThemeCachingEnabled);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class UserSettingsEntityMappingTests
|
||||
Assert.Equal(entity.UserId, result.UserId);
|
||||
Assert.Equal(entity.IsPaginationEnabled, result.IsPaginationEnabled);
|
||||
Assert.Equal(entity.ItemsPerPage, result.ItemsPerPage);
|
||||
Assert.Equal(entity.IgnoreThePrefixForAlphaPicker, result.IgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(entity.ShouldIgnoreThePrefixForAlphaPicker, result.ShouldIgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(entity.IsThemeCachingEnabled, result.IsThemeCachingEnabled);
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -34,7 +34,7 @@ public class UserSettingsMappingTests
|
||||
Assert.Equal(userId, result.UserId);
|
||||
Assert.Equal(domainEntity.IsPaginationEnabled, result.IsPaginationEnabled);
|
||||
Assert.Equal(domainEntity.ItemsPerPage, result.ItemsPerPage);
|
||||
Assert.Equal(domainEntity.IgnoreThePrefixForAlphaPicker, result.IgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(domainEntity.ShouldIgnoreThePrefixForAlphaPicker, result.ShouldIgnoreThePrefixForAlphaPicker);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -52,6 +52,6 @@ public class UserSettingsMappingTests
|
||||
Assert.Equal(userId, result.UserId);
|
||||
Assert.Equal(domainEntity.IsPaginationEnabled, result.IsPaginationEnabled);
|
||||
Assert.Equal(domainEntity.ItemsPerPage, result.ItemsPerPage);
|
||||
Assert.Equal(domainEntity.IgnoreThePrefixForAlphaPicker, result.IgnoreThePrefixForAlphaPicker);
|
||||
Assert.Equal(domainEntity.ShouldIgnoreThePrefixForAlphaPicker, result.ShouldIgnoreThePrefixForAlphaPicker);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user