Add S3BatchEventV2 (#496) · vip-amzn/aws-lambda-java-libs@aa399f5 · GitHub
Skip to content

Commit aa399f5

Browse files
mmerfortsmirnoal
andauthored
Add S3BatchEventV2 (aws#496)
* Add S3BatchEventV2 class * Add test for S3BatchEventV2 --------- Co-authored-by: Martin Merfort <mmerfort@users.noreply.github.com> Co-authored-by: Alexander Smirnov <75367056+smirnoal@users.noreply.github.com>
1 parent a36e041 commit aa399f5

5 files changed

Lines changed: 102 additions & 1 deletion

File tree

Lines changed: 50 additions & 0 deletions

‎aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/S3BatchResponse.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,10 @@ public static S3BatchResponseBuilder fromS3BatchEvent(S3BatchEvent s3BatchEvent)
6262
.withInvocationId(s3BatchEvent.getInvocationId())
6363
.withInvocationSchemaVersion(s3BatchEvent.getInvocationSchemaVersion());
6464
}
65-
}
65+
66+
public static S3BatchResponseBuilder fromS3BatchEvent(S3BatchEventV2 s3BatchEvent) {
67+
return S3BatchResponse.builder()
68+
.withInvocationId(s3BatchEvent.getInvocationId())
69+
.withInvocationSchemaVersion(s3BatchEvent.getInvocationSchemaVersion());
70+
}
71+
}

‎aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/EventLoader.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public static S3Event loadS3Event(String filename) {
105105
return loadEvent(filename, S3Event.class);
106106
}
107107

108+
public static S3BatchEventV2 loadS3BatchEventV2(String filename) {
109+
return loadEvent(filename, S3BatchEventV2.class);
110+
}
111+
108112
public static SecretsManagerRotationEvent loadSecretsManagerRotationEvent(String filename) {
109113
return loadEvent(filename, SecretsManagerRotationEvent.class);
110114
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.amazonaws.services.lambda.runtime.tests;
2+
3+
import com.amazonaws.services.lambda.runtime.events.S3BatchEventV2;
4+
import org.junit.jupiter.api.Test;
5+
6+
import static org.assertj.core.api.Assertions.*;
7+
8+
public class S3BatchEventV2Test {
9+
10+
@Test
11+
public void testS3BatchEventV2() {
12+
S3BatchEventV2 event = EventLoader.loadS3BatchEventV2("s3_batch_event_v2.json");
13+
assertThat(event).isNotNull();
14+
assertThat(event.getInvocationId()).isEqualTo("Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy");
15+
assertThat(event.getJob()).isNotNull();
16+
assertThat(event.getJob().getUserArguments().get("MyDestinationBucket")).isEqualTo("destination-directory-bucket-name");
17+
assertThat(event.getTasks()).hasSize(1);
18+
assertThat(event.getTasks().get(0).getS3Key()).isEqualTo("s3objectkey");
19+
}
20+
}
Lines changed: 21 additions & 0 deletions

0 commit comments

Comments
 (0)