diff --git a/src/IIIFPresentation/API.Tests/Converters/ManifestConverterTests.cs b/src/IIIFPresentation/API.Tests/Converters/ManifestConverterTests.cs index c3285fd5..7f854433 100644 --- a/src/IIIFPresentation/API.Tests/Converters/ManifestConverterTests.cs +++ b/src/IIIFPresentation/API.Tests/Converters/ManifestConverterTests.cs @@ -107,7 +107,7 @@ public void SetGeneratedFields_SetsParentAndSlug_FromSingleHierarchyByDefault() // Assert result.Slug.Should().Be("hierarchy-slug"); - result.Parent.Should().Be("hierarchy-parent"); + result.Parent.Should().Be("/0/collections/hierarchy-parent", "Always use FlatId"); } [Fact] @@ -137,6 +137,6 @@ public void SetGeneratedFields_SetsParentAndSlug_FromHierarchyUsingFactory() // Assert result.Slug.Should().Be("other-slug"); - result.Parent.Should().Be("other-parent"); + result.Parent.Should().Be("/0/collections/other-parent", "Always use FlatId"); } } \ No newline at end of file diff --git a/src/IIIFPresentation/API.Tests/Helpers/CollectionHelperXTests.cs b/src/IIIFPresentation/API.Tests/Helpers/CollectionHelperXTests.cs index 7e4784d4..884807f3 100644 --- a/src/IIIFPresentation/API.Tests/Helpers/CollectionHelperXTests.cs +++ b/src/IIIFPresentation/API.Tests/Helpers/CollectionHelperXTests.cs @@ -139,7 +139,8 @@ public void GenerateFlatId_Correct_Manifest() [Theory] [InlineData(ResourceType.StorageCollection)] [InlineData(ResourceType.IIIFCollection)] - public void GenerateFlatParentId_Correct_Collection(ResourceType resourceType) + [InlineData(ResourceType.IIIFManifest)] + public void GenerateFlatParentId_Correct(ResourceType resourceType) { // Arrange var hierarchy = new Hierarchy @@ -156,24 +157,6 @@ public void GenerateFlatParentId_Correct_Collection(ResourceType resourceType) id.Should().Be("http://base/0/collections/parent"); } - [Fact] - public void GenerateFlatParentId_Correct_Manifest() - { - // Arrange - var hierarchy = new Hierarchy - { - Slug = "slug", - Parent = "parent", - Type = ResourceType.IIIFManifest - }; - - // Act - var id = hierarchy.GenerateFlatParentId(urlRoots); - - // Assert - id.Should().Be("http://base/0/manifests/parent"); - } - [Fact] public void GenerateFlatCollectionViewId_CreatesViewId() { diff --git a/src/IIIFPresentation/API.Tests/Integration/ModifyManifestTests.cs b/src/IIIFPresentation/API.Tests/Integration/ModifyManifestTests.cs index b565108c..cf784c88 100644 --- a/src/IIIFPresentation/API.Tests/Integration/ModifyManifestTests.cs +++ b/src/IIIFPresentation/API.Tests/Integration/ModifyManifestTests.cs @@ -313,7 +313,7 @@ public async Task CreateManifest_CreatesManifest_ParentIsValidHierarchicalUrl() responseManifest.Modified.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(2)); responseManifest.CreatedBy.Should().Be("Admin"); responseManifest.Slug.Should().Be(slug); - responseManifest.Parent.Should().Be(RootCollection.Id); + responseManifest.Parent.Should().Be($"http://localhost/1/collections/{RootCollection.Id}"); } [Fact] @@ -343,7 +343,7 @@ public async Task CreateManifest_ReturnsManifest() responseManifest.Modified.Should().BeCloseTo(DateTime.UtcNow, TimeSpan.FromSeconds(2)); responseManifest.CreatedBy.Should().Be("Admin"); responseManifest.Slug.Should().Be(slug); - responseManifest.Parent.Should().Be(RootCollection.Id); + responseManifest.Parent.Should().Be($"http://localhost/1/collections/{RootCollection.Id}"); } [Fact] diff --git a/src/IIIFPresentation/API/Converters/ManifestConverter.cs b/src/IIIFPresentation/API/Converters/ManifestConverter.cs index 0061f03c..08156c28 100644 --- a/src/IIIFPresentation/API/Converters/ManifestConverter.cs +++ b/src/IIIFPresentation/API/Converters/ManifestConverter.cs @@ -33,7 +33,7 @@ public static PresentationManifest SetGeneratedFields(this PresentationManifest iiifManifest.Modified = dbManifest.Modified.Floor(DateTimeX.Precision.Second); iiifManifest.CreatedBy = dbManifest.CreatedBy; iiifManifest.ModifiedBy = dbManifest.ModifiedBy; - iiifManifest.Parent = hierarchy.Parent; + iiifManifest.Parent = hierarchy.GenerateFlatParentId(urlRoots); iiifManifest.Slug = hierarchy.Slug; iiifManifest.EnsurePresentation3Context(); iiifManifest.EnsureContext(PresentationJsonLdContext.Context); diff --git a/src/IIIFPresentation/API/Helpers/CollectionHelperX.cs b/src/IIIFPresentation/API/Helpers/CollectionHelperX.cs index 76ba8d6a..d5f710c8 100644 --- a/src/IIIFPresentation/API/Helpers/CollectionHelperX.cs +++ b/src/IIIFPresentation/API/Helpers/CollectionHelperX.cs @@ -35,10 +35,10 @@ public static string GenerateFlatId(this Hierarchy hierarchy, UrlRoots urlRoots) $"{urlRoots.BaseUrl}/{hierarchy.CustomerId}/{hierarchy.Type.GetSlug()}/{hierarchy.ResourceId}"; /// - /// Get flat id for hierarchy parent + /// Get flat id for parent of /// public static string GenerateFlatParentId(this Hierarchy hierarchy, UrlRoots urlRoots) => - $"{urlRoots.BaseUrl}/{hierarchy.CustomerId}/{hierarchy.Type.GetSlug()}/{hierarchy.Parent}"; + $"{urlRoots.BaseUrl}/{hierarchy.CustomerId}/{CollectionsSlug}/{hierarchy.Parent}"; public static string GenerateFlatCollectionViewId(this Collection collection, UrlRoots urlRoots, int currentPage, int pageSize, string? orderQueryParam) =>