diff --git a/Libraries/src/Amazon.Lambda.KafkaEvents/Amazon.Lambda.KafkaEvents.csproj b/Libraries/src/Amazon.Lambda.KafkaEvents/Amazon.Lambda.KafkaEvents.csproj index 7f7b62f66..3ac237348 100644 --- a/Libraries/src/Amazon.Lambda.KafkaEvents/Amazon.Lambda.KafkaEvents.csproj +++ b/Libraries/src/Amazon.Lambda.KafkaEvents/Amazon.Lambda.KafkaEvents.csproj @@ -6,7 +6,7 @@ netstandard2.0 Amazon Lambda .NET Core support - KafkaEvents package. Amazon.Lambda.KafkaEvents - 1.0.1 + 2.0.0 Amazon.Lambda.KafkaEvents Amazon.Lambda.KafkaEvents AWS;Amazon;Lambda;Kafka diff --git a/Libraries/src/Amazon.Lambda.KafkaEvents/KafkaEvent.cs b/Libraries/src/Amazon.Lambda.KafkaEvents/KafkaEvent.cs index 03700af34..2ccc06fe8 100644 --- a/Libraries/src/Amazon.Lambda.KafkaEvents/KafkaEvent.cs +++ b/Libraries/src/Amazon.Lambda.KafkaEvents/KafkaEvent.cs @@ -73,7 +73,7 @@ public class KafkaEventRecord /// /// The Kafka event record headers. /// - public IList> Headers { get; set; } + public IList> Headers { get; set; } } } } diff --git a/Libraries/test/EventsTests.Shared/EventTests.cs b/Libraries/test/EventsTests.Shared/EventTests.cs index 9fad4f09e..ecc2ac7b7 100644 --- a/Libraries/test/EventsTests.Shared/EventTests.cs +++ b/Libraries/test/EventsTests.Shared/EventTests.cs @@ -2729,20 +2729,25 @@ public void KafkaEventTest(Type serializerType) var eventRecord = record.Value.FirstOrDefault(); Assert.Equal(eventRecord.Topic, "mytopic"); Assert.Equal(eventRecord.Partition, 12); - Assert.Equal(eventRecord.Offset, 15); + Assert.Equal(eventRecord.Offset, 3043205); Assert.Equal(eventRecord.Timestamp, 1545084650987); Assert.Equal(eventRecord.TimestampType, "CREATE_TIME"); Assert.Equal(new StreamReader(eventRecord.Value).ReadToEnd(), "Hello, this is a test."); - Assert.Equal(eventRecord.Headers.Count, 1); + Assert.Equal(eventRecord.Headers.Count, 8); var eventRecordHeader = eventRecord.Headers.FirstOrDefault(); Assert.NotNull(eventRecordHeader); Assert.Equal(eventRecordHeader.Count, 1); var eventRecordHeaderValue = eventRecordHeader.FirstOrDefault(); Assert.NotNull(eventRecordHeaderValue); Assert.Equal(eventRecordHeaderValue.Key, "headerKey"); - Assert.Equal(Encoding.UTF8.GetString(eventRecordHeaderValue.Value), "headerValue"); + + // Convert sbyte[] to byte[] array. + var tempHeaderValueByteArray = new byte[eventRecordHeaderValue.Value.Length]; + Buffer.BlockCopy(eventRecordHeaderValue.Value, 0, tempHeaderValueByteArray, 0, tempHeaderValueByteArray.Length); + + Assert.Equal(Encoding.UTF8.GetString(tempHeaderValueByteArray), "headerValue"); Handle(kafkaEvent); } diff --git a/Libraries/test/EventsTests.Shared/kafka-event.json b/Libraries/test/EventsTests.Shared/kafka-event.json index 17fa6fac6..a06e604ab 100644 --- a/Libraries/test/EventsTests.Shared/kafka-event.json +++ b/Libraries/test/EventsTests.Shared/kafka-event.json @@ -7,9 +7,10 @@ { "topic": "mytopic", "partition": 12, - "offset": 15, + "offset": 3043205, "timestamp": 1545084650987, "timestampType": "CREATE_TIME", + "key": "MzM4NjQ2Njcy", "value": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==", "headers": [ { @@ -26,6 +27,173 @@ 117, 101 ] + }, + { + "Id": [ + 55, + 48, + 57, + 101, + 52, + 57, + 98, + 54, + 45, + 57, + 57, + 56, + 100, + 45, + 52, + 99, + 48, + 99, + 45, + 56, + 101, + 102, + 55, + 45, + 98, + 57, + 56, + 99, + 102, + 97, + 102, + 101, + 100, + 48, + 56, + 98 + ] + }, + { + "ModelType": [ + 82, + 101, + 115, + 105, + 100, + 101, + 110, + 116, + 105, + 97, + 108, + 80, + 114, + 111, + 100, + 117, + 99, + 116, + 95, + 65, + 103, + 101, + 110, + 116, + 68, + 101, + 116, + 97, + 105, + 108 + ] + }, + { + "Version": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 3 + ] + }, + { + "IsFullBuild": [ + 1 + ] + }, + { + "IsLowPriority": [ + 1 + ] + }, + { + "OriginationTimestamp": [ + 0, + 0, + 1, + -123, + -11, + -81, + -50, + -2 + ] + }, + { + "traceparent": [ + 48, + 48, + 45, + 54, + 57, + 49, + 99, + 99, + 101, + 55, + 50, + 102, + 50, + 55, + 52, + 97, + 54, + 100, + 54, + 56, + 97, + 102, + 54, + 54, + 56, + 102, + 54, + 51, + 97, + 98, + 52, + 97, + 57, + 99, + 49, + 45, + 53, + 97, + 97, + 50, + 57, + 98, + 54, + 99, + 97, + 51, + 97, + 49, + 101, + 57, + 50, + 102, + 45, + 48, + 48 + ] } ] }