Skip to content

Commit

Permalink
Merge branch 'main' into update-log4j
Browse files Browse the repository at this point in the history
  • Loading branch information
smirnoal authored Dec 1, 2023
2 parents db542bb + 3d8dfb6 commit e6ea6ec
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class SqsHandler implements RequestHandler<SQSEvent, String> {
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.3</version>
<version>3.11.4</version>
</dependency>
```

Expand Down Expand Up @@ -154,7 +154,7 @@ This package defines the Lambda serialization logic using in the `aws-lambda-jav
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-serialization</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion aws-lambda-java-events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.3</version>
<version>3.11.4</version>
</dependency>
...
</dependencies>
Expand Down
5 changes: 5 additions & 0 deletions aws-lambda-java-events/RELEASE.CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### December 1, 2023
`3.11.4`:
- Improve `toString` in Cognito events by calling `super`
- Added missing `version` field to ScheduledEvent from CloudWatch

### September 1, 2023
`3.11.3`:
- Update challengeAnswer field format in CognitoUserPoolEvent
Expand Down
2 changes: 1 addition & 1 deletion aws-lambda-java-events/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.3</version>
<version>3.11.4</version>
<packaging>jar</packaging>

<name>AWS Lambda Java Events Library</name>
Expand Down
4 changes: 4 additions & 0 deletions aws-lambda-java-serialization/RELEASE.CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### December 1, 2023
`1.1.5`:
- Add support for DynamodbEvent.DynamodbStreamRecord serialization

### October 19, 2023
`1.1.4`:
- Update org.json version to 20231013
Expand Down
2 changes: 1 addition & 1 deletion aws-lambda-java-serialization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-serialization</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
<packaging>jar</packaging>

<name>AWS Lambda Java Runtime Serialization</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public class LambdaEventSerializers {
* If mixins are required for inner classes of an event, then those nested classes must be specified here.
*/
@SuppressWarnings("rawtypes")
private static final Map<String, List<NestedClass>> NESTED_CLASS_MAP = Stream.of(
private static final Map<String, List<? extends NestedClass>> NESTED_CLASS_MAP = Stream.of(
new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.CodeCommitEvent",
Arrays.asList(
new NestedClass("com.amazonaws.services.lambda.runtime.events.CodeCommitEvent$Record"))),
Expand All @@ -180,6 +180,14 @@ public class LambdaEventSerializers {
"com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord",
"com.amazonaws.services.dynamodbv2.model.StreamRecord"),
new NestedClass("com.amazonaws.services.lambda.runtime.events.DynamodbEvent$DynamodbStreamRecord"))),
new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.DynamodbEvent$DynamodbStreamRecord",
Arrays.asList(
new AlternateNestedClass(
"com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue",
"com.amazonaws.services.dynamodbv2.model.AttributeValue"),
new AlternateNestedClass(
"com.amazonaws.services.lambda.runtime.events.models.dynamodb.StreamRecord",
"com.amazonaws.services.dynamodbv2.model.StreamRecord"))),
new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.DynamodbTimeWindowEvent",
Arrays.asList(
new AlternateNestedClass(
Expand Down Expand Up @@ -236,7 +244,7 @@ public static <T> PojoSerializer<T> serializerFor(Class<T> eventClass, ClassLoad
}
// if event model has nested classes then load those classes and check if mixins apply
if (NESTED_CLASS_MAP.containsKey(eventClass.getName())) {
List<NestedClass> nestedClasses = NESTED_CLASS_MAP.get(eventClass.getName());
List<? extends NestedClass> nestedClasses = NESTED_CLASS_MAP.get(eventClass.getName());
for (NestedClass nestedClass: nestedClasses) {
// if mixin exists for nested class then apply
if (MIXIN_MAP.containsKey(nestedClass.className)) {
Expand Down
4 changes: 2 additions & 2 deletions aws-lambda-java-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-serialization</artifactId>
<version>1.1.4</version>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.3</version>
<version>3.11.4</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public static DynamodbEvent loadDynamoDbEvent(String filename) {
return loadEvent(filename, DynamodbEvent.class);
}

public static DynamodbEvent.DynamodbStreamRecord loadDynamoDbStreamRecord(String filename) {
return loadEvent(filename, DynamodbEvent.DynamodbStreamRecord.class);
}

public static KafkaEvent loadKafkaEvent(String filename) {
return loadEvent(filename, KafkaEvent.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,43 @@ public void testLoadSNSEvent() {

@Test
public void testLoadDynamoEvent() {
DynamodbEvent event = EventLoader.loadDynamoDbEvent("dynamo_event.json");
DynamodbEvent event = EventLoader.loadDynamoDbEvent("ddb/dynamo_event.json");
assertThat(event).isNotNull();
assertThat(event.getRecords()).hasSize(3);
assertDynamoDbStreamRecord(event.getRecords().get(1));
}

DynamodbEvent.DynamodbStreamRecord record = event.getRecords().get(0);
@Test
public void testLoadDynamoDbStreamRecord() {
assertDynamoDbStreamRecord(EventLoader.loadDynamoDbStreamRecord("ddb/dynamo_ddb_stream_record.json"));
}

private static void assertDynamoDbStreamRecord(final DynamodbEvent.DynamodbStreamRecord record) {
assertThat(record)
.isNotNull()
.returns("arn:aws:dynamodb:eu-central-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", from(DynamodbEvent.DynamodbStreamRecord::getEventSourceARN))
.returns("INSERT", from(Record::getEventName));
.returns("MODIFY", from(Record::getEventName));

StreamRecord streamRecord = record.getDynamodb();
assertThat(streamRecord)
.returns("4421584500000000017450439091", StreamRecord::getSequenceNumber)
.returns(26L, StreamRecord::getSizeBytes)
.returns("4421584500000000017450439092", StreamRecord::getSequenceNumber)
.returns(59L, StreamRecord::getSizeBytes)
.returns("NEW_AND_OLD_IMAGES", StreamRecord::getStreamViewType)
.returns(Date.from(ofEpochSecond(1428537600)), StreamRecord::getApproximateCreationDateTime);

assertThat(streamRecord.getKeys()).contains(entry("Id", new AttributeValue().withN("101")));
assertThat(streamRecord.getNewImage()).containsAnyOf(
entry("Message", new AttributeValue("New item!")),
entry("Id", new AttributeValue().withN("101"))
);
.returns(Date.from(ofEpochSecond(1635734407).plusNanos(123456789)), StreamRecord::getApproximateCreationDateTime);

assertThat(streamRecord.getKeys())
.isNotNull()
.contains(entry("Id", new AttributeValue().withN("101")));
assertThat(streamRecord.getNewImage())
.isNotNull()
.containsAnyOf(
entry("Message", new AttributeValue("This item has changed")),
entry("Id", new AttributeValue().withN("101")));
assertThat(streamRecord.getOldImage())
.isNotNull()
.containsAnyOf(
entry("Message", new AttributeValue("New item!")),
entry("Id", new AttributeValue().withN("101")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"eventID": "c81e728d9d4c2f636f067f89cc14862c",
"eventName": "MODIFY",
"eventVersion": "1.1",
"eventSource": "aws:dynamodb",
"awsRegion": "eu-central-1",
"dynamodb": {
"Keys": {
"Id": {
"N": "101"
}
},
"NewImage": {
"Message": {
"S": "This item has changed"
},
"Id": {
"N": "101"
}
},
"OldImage": {
"Message": {
"S": "New item!"
},
"Id": {
"N": "101"
}
},
"ApproximateCreationDateTime": 1.635734407123456789E9,
"SequenceNumber": "4421584500000000017450439092",
"SizeBytes": 59,
"StreamViewType": "NEW_AND_OLD_IMAGES"
},
"eventSourceARN": "arn:aws:dynamodb:eu-central-1:123456789012:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899"
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"N": "101"
}
},
"ApproximateCreationDateTime": 1428537600,
"ApproximateCreationDateTime": 1.635734407123456789E9,
"SequenceNumber": "4421584500000000017450439092",
"SizeBytes": 59,
"StreamViewType": "NEW_AND_OLD_IMAGES"
Expand Down
2 changes: 1 addition & 1 deletion samples/kinesis-firehose-event-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.11.3</version>
<version>3.11.4</version>
</dependency>

<dependency>
Expand Down

0 comments on commit e6ea6ec

Please sign in to comment.