diff --git a/src/ScoopSearch.Indexer.Tests/Helpers/Faker.cs b/src/ScoopSearch.Indexer.Tests/Helpers/Faker.cs index f52e146..3087cfc 100644 --- a/src/ScoopSearch.Indexer.Tests/Helpers/Faker.cs +++ b/src/ScoopSearch.Indexer.Tests/Helpers/Faker.cs @@ -19,6 +19,7 @@ public static Faker CreateManifestInfo(Action _.NamePartial, (f, o) => o.Name) .RuleFor(_ => _.NameSuffix, (f, o) => o.Name) .RuleFor(_ => _.Description, f => f.Lorem.Sentences()) + .RuleFor(_ => _.Notes, f => f.Lorem.Sentences()) .RuleFor(_ => _.Homepage, f => f.Internet.Url()) .RuleFor(_ => _.License, f => f.PickRandomParam("MIT", "BSD", "GPL", "Custom")) .RuleFor(_ => _.Version, f => f.System.Semver()) diff --git a/src/ScoopSearch.Indexer.Tests/Manifest/ManifestInfoDeserializationTests.cs b/src/ScoopSearch.Indexer.Tests/Manifest/ManifestInfoDeserializationTests.cs index 34c53fb..c04fb41 100644 --- a/src/ScoopSearch.Indexer.Tests/Manifest/ManifestInfoDeserializationTests.cs +++ b/src/ScoopSearch.Indexer.Tests/Manifest/ManifestInfoDeserializationTests.cs @@ -99,6 +99,26 @@ public void Deserialize_Description_Succeeds(string jsonContent, string? expecte result!.Description.Should().Be(expectedResult?.Replace("\n", Environment.NewLine)); } + [Theory] + [InlineData("", null)] + [InlineData(@"""notes"": """"", "")] + [InlineData(@"""notes"": ""foo""", "foo")] + [InlineData(@"""notes"": [ ""foo"" ]", "foo")] + [InlineData(@"""notes"": [ ""foo"", ""bar"" ]", "foo bar")] + [InlineData(@"""notes"": [ ""foo"", """", ""bar"" ]", "foo \n bar")] + public void Deserialize_Notes_Succeeds(string jsonContent, string? expectedResult) + { + // Arrange + jsonContent = $"{{ {jsonContent} }}"; + + // Act + var result = ManifestInfo.Deserialize(jsonContent, "foo", new ManifestMetadata()); + + // Assert + result.Should().NotBeNull(); + result!.Notes.Should().Be(expectedResult?.Replace("\n", Environment.NewLine)); + } + [Theory] [InlineData("", null)] [InlineData(@"""version"": """"", "")] diff --git a/src/ScoopSearch.Indexer/Data/JsonConverter/DescriptionConverter.cs b/src/ScoopSearch.Indexer/Data/JsonConverter/MultiLineStringConverter.cs similarity index 93% rename from src/ScoopSearch.Indexer/Data/JsonConverter/DescriptionConverter.cs rename to src/ScoopSearch.Indexer/Data/JsonConverter/MultiLineStringConverter.cs index 963f52b..66f2a68 100644 --- a/src/ScoopSearch.Indexer/Data/JsonConverter/DescriptionConverter.cs +++ b/src/ScoopSearch.Indexer/Data/JsonConverter/MultiLineStringConverter.cs @@ -3,7 +3,7 @@ namespace ScoopSearch.Indexer.Data.JsonConverter; -internal class DescriptionConverter : JsonConverter +internal class MultiLineStringConverter : JsonConverter { public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { diff --git a/src/ScoopSearch.Indexer/Data/ManifestInfo.cs b/src/ScoopSearch.Indexer/Data/ManifestInfo.cs index f96a838..6f6efd3 100644 --- a/src/ScoopSearch.Indexer/Data/ManifestInfo.cs +++ b/src/ScoopSearch.Indexer/Data/ManifestInfo.cs @@ -42,10 +42,15 @@ public class ManifestInfo public string? NameSuffix { get; private set; } [SearchableField(AnalyzerName = LexicalAnalyzerName.Values.EnLucene)] - [JsonConverter(typeof(DescriptionConverter))] + [JsonConverter(typeof(MultiLineStringConverter))] [JsonInclude] public string? Description { get; private set; } + [SearchableField(AnalyzerName = LexicalAnalyzerName.Values.EnLucene)] + [JsonConverter(typeof(MultiLineStringConverter))] + [JsonInclude] + public string? Notes { get; private set; } + [SearchableField(IsFilterable = true, IsSortable = true, IsFacetable = true, AnalyzerName = AzureSearchIndex.UrlAnalyzer)] [JsonInclude] public string? Homepage { get; private set; }