Skip to content

Commit d9964f2

Browse files
committed
Add test for S3BatchEventV2
1 parent 16533b0 commit d9964f2

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

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

+4
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
}
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"invocationSchemaVersion": "2.0",
3+
"invocationId": "Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy",
4+
"job": {
5+
"id": "ry77cd60-61f6-4a2b-8a21-d07600c874gf",
6+
"userArguments": {
7+
"MyDestinationBucket": "destination-directory-bucket-name",
8+
"MyDestinationBucketRegion": "us-east-1",
9+
"MyDestinationPrefix": "copied/",
10+
"MyDestinationObjectKeySuffix": "_new_suffix"
11+
}
12+
},
13+
"tasks": [
14+
{
15+
"taskId": "y5R3a2lkZ29lc2hlurcS",
16+
"s3Key": "s3objectkey",
17+
"s3VersionId": null,
18+
"s3Bucket": "source-directory-bucket-name"
19+
}
20+
]
21+
}

0 commit comments

Comments
 (0)