Skip to content

Commit

Permalink
refactor: Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dscpinheiro committed Jan 10, 2024
1 parent 3818b8d commit 3bd10bc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Libraries/src/Amazon.Lambda.DynamoDBEvents/DynamoDBEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public class AttributeValue
/// <c>"BOOL": true</c>
/// </para>
/// </summary>
public bool BOOL { get; set; }
public bool? BOOL { get; set; }

/// <summary>
/// <para>
Expand Down Expand Up @@ -304,7 +304,7 @@ public class AttributeValue
/// <c>"NULL": true</c>
/// </para>
/// </summary>
public bool NULL { get; set; }
public bool? NULL { get; set; }

/// <summary>
/// <para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AssemblyName>Amazon.Lambda.Serialization.Json</AssemblyName>
<PackageId>Amazon.Lambda.Serialization.Json</PackageId>
<PackageTags>AWS;Amazon;Lambda</PackageTags>
<VersionPrefix>2.1.1</VersionPrefix>
<VersionPrefix>2.2.0</VersionPrefix>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions Libraries/src/Amazon.Lambda.Serialization.Json/AwsResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ protected override IList<JsonProperty> CreateProperties(Type type, MemberSeriali
}
}
}
else if (type.FullName.Equals("Amazon.Lambda.DynamoDBEvents.DynamoDBEvent+StreamRecord", StringComparison.Ordinal))
else if (
type.FullName.Equals("Amazon.Lambda.DynamoDBEvents.DynamoDBEvent+StreamRecord", StringComparison.Ordinal) ||
type.FullName.Equals("Amazon.DynamoDBv2.Model.StreamRecord", StringComparison.Ordinal)
)
{
foreach (JsonProperty property in properties)
{
Expand All @@ -96,7 +99,10 @@ protected override IList<JsonProperty> CreateProperties(Type type, MemberSeriali
}
}
}
else if (type.FullName.Equals("Amazon.Lambda.DynamoDBEvents.DynamoDBEvent+AttributeValue", StringComparison.Ordinal))
else if (
type.FullName.Equals("Amazon.Lambda.DynamoDBEvents.DynamoDBEvent+AttributeValue", StringComparison.Ordinal) ||
type.FullName.Equals("Amazon.DynamoDBv2.Model.AttributeValue", StringComparison.Ordinal)
)
{
foreach (JsonProperty property in properties)
{
Expand Down
18 changes: 18 additions & 0 deletions Libraries/test/EventsTests.Shared/EventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,17 @@ public void DynamoDbUpdateTest(Type serializerType)
Assert.Equal(record.Dynamodb.Keys.Count, 2);
Assert.Equal(record.Dynamodb.Keys["key"].S, "binary");
Assert.Equal(record.Dynamodb.Keys["val"].S, "data");
Assert.Null(record.UserIdentity);
Assert.Null(record.Dynamodb.OldImage);
Assert.Equal(record.Dynamodb.NewImage["val"].S, "data");
Assert.Equal(record.Dynamodb.NewImage["key"].S, "binary");
Assert.Null(record.Dynamodb.NewImage["key"].BOOL);
Assert.Null(record.Dynamodb.NewImage["key"].L);
Assert.Null(record.Dynamodb.NewImage["key"].M);
Assert.Null(record.Dynamodb.NewImage["key"].N);
Assert.Null(record.Dynamodb.NewImage["key"].NS);
Assert.Null(record.Dynamodb.NewImage["key"].NULL);
Assert.Null(record.Dynamodb.NewImage["key"].SS);
Assert.Equal(MemoryStreamToBase64String(record.Dynamodb.NewImage["asdf1"].B), "AAEqQQ==");
Assert.Equal(record.Dynamodb.NewImage["asdf2"].BS.Count, 2);
Assert.Equal(MemoryStreamToBase64String(record.Dynamodb.NewImage["asdf2"].BS[0]), "AAEqQQ==");
Expand Down Expand Up @@ -498,6 +507,15 @@ public void DynamoDbUpdateTest(Type serializerType)
Assert.NotNull(secondRecord.UserIdentity);
Assert.Equal("dynamodb.amazonaws.com", secondRecord.UserIdentity.PrincipalId);
Assert.Equal("Service", secondRecord.UserIdentity.Type);
Assert.Null(secondRecord.Dynamodb.NewImage);
Assert.NotNull(secondRecord.Dynamodb.OldImage["asdf1"].B);
Assert.Null(secondRecord.Dynamodb.OldImage["asdf1"].S);
Assert.Null(secondRecord.Dynamodb.OldImage["asdf1"].L);
Assert.Null(secondRecord.Dynamodb.OldImage["asdf1"].M);
Assert.Null(secondRecord.Dynamodb.OldImage["asdf1"].N);
Assert.Null(secondRecord.Dynamodb.OldImage["asdf1"].NS);
Assert.Null(secondRecord.Dynamodb.OldImage["asdf1"].NULL);
Assert.Null(secondRecord.Dynamodb.OldImage["asdf1"].SS);

Handle(dynamodbEvent);
}
Expand Down

0 comments on commit 3bd10bc

Please sign in to comment.