|
| 1 | +// Licensed to Elasticsearch B.V under one or more agreements. |
| 2 | +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. |
| 3 | +// See the LICENSE file in the project root for more information. |
| 4 | + |
| 5 | +using System.Linq; |
| 6 | +using Elastic.Clients.Elasticsearch.IndexManagement; |
| 7 | +using Tests.Serialization; |
| 8 | + |
| 9 | +namespace Tests.IndexManagement.DataStreamManagement; |
| 10 | + |
| 11 | +public class GetDataStreamSerializationTests : SerializerTestBase |
| 12 | +{ |
| 13 | + [U] |
| 14 | + public void GetIndexResponse_IsDeserializedCorrectly() |
| 15 | + { |
| 16 | + const string json = @"{ |
| 17 | + ""data_streams"": [ |
| 18 | + { |
| 19 | + ""name"": ""logs-dev"", |
| 20 | + ""timestamp_field"": { |
| 21 | + ""name"": ""@timestamp"" |
| 22 | + }, |
| 23 | + ""indices"": [ |
| 24 | + { |
| 25 | + ""index_name"": "".ds-logs-dev-2023.02.16-000001"", |
| 26 | + ""index_uuid"": ""xyWXN5T1Rm6_sOCayv7GDA"" |
| 27 | + } |
| 28 | + ], |
| 29 | + ""generation"": 1, |
| 30 | + ""_meta"": { |
| 31 | + ""description"": ""default logs template installed by x-pack"", |
| 32 | + ""managed"": true |
| 33 | + }, |
| 34 | + ""status"": ""GREEN"", |
| 35 | + ""template"": ""logs"", |
| 36 | + ""ilm_policy"": ""logs"", |
| 37 | + ""hidden"": false, |
| 38 | + ""system"": false, |
| 39 | + ""allow_custom_routing"": false, |
| 40 | + ""replicated"": false |
| 41 | + } |
| 42 | + ] |
| 43 | +}"; |
| 44 | + |
| 45 | + var response = DeserializeJsonString<GetDataStreamResponse>(json); |
| 46 | + |
| 47 | + response.DataStreams.Count.Should().Be(1); |
| 48 | + |
| 49 | + var dataStream = response.DataStreams.First(); |
| 50 | + |
| 51 | + dataStream.Name.Should().Be("logs-dev"); |
| 52 | + dataStream.TimestampField.Name.Should().Be("@timestamp"); |
| 53 | + |
| 54 | + dataStream.Indices.Count.Should().Be(1); |
| 55 | + var indices = dataStream.Indices.First(); |
| 56 | + indices.IndexName.Should().Be(".ds-logs-dev-2023.02.16-000001"); |
| 57 | + indices.IndexUuid.Should().Be("xyWXN5T1Rm6_sOCayv7GDA"); |
| 58 | + |
| 59 | + dataStream.Generation.Should().Be(1); |
| 60 | + dataStream.Meta["description"].Should().Be("default logs template installed by x-pack"); |
| 61 | + dataStream.Meta["managed"].Should().Be(true); |
| 62 | + dataStream.Status.Should().Be(HealthStatus.Green); |
| 63 | + dataStream.Template.Should().Be("logs"); |
| 64 | + dataStream.IlmPolicy.Should().Be("logs"); |
| 65 | + dataStream.Hidden.Should().Be(false); |
| 66 | + dataStream.System.Should().Be(false); |
| 67 | + dataStream.AllowCustomRouting.Should().Be(false); |
| 68 | + dataStream.Replicated.Should().Be(false); |
| 69 | + } |
| 70 | +} |
| 71 | + |
0 commit comments