Skip to content

Commit

Permalink
Add test for S3BatchEventV2
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerfort committed Jul 22, 2024
1 parent 16533b0 commit d9964f2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public static S3Event loadS3Event(String filename) {
return loadEvent(filename, S3Event.class);
}

public static S3BatchEventV2 loadS3BatchEventV2(String filename) {
return loadEvent(filename, S3BatchEventV2.class);
}

public static SecretsManagerRotationEvent loadSecretsManagerRotationEvent(String filename) {
return loadEvent(filename, SecretsManagerRotationEvent.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.amazonaws.services.lambda.runtime.tests;

import com.amazonaws.services.lambda.runtime.events.S3BatchEventV2;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.*;

public class S3BatchEventV2Test {

@Test
public void testS3BatchEventV2() {
S3BatchEventV2 event = EventLoader.loadS3BatchEventV2("s3_batch_event_v2.json");
assertThat(event).isNotNull();
assertThat(event.getInvocationId()).isEqualTo("Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy");
assertThat(event.getJob()).isNotNull();
assertThat(event.getJob().getUserArguments().get("MyDestinationBucket")).isEqualTo("destination-directory-bucket-name");
assertThat(event.getTasks()).hasSize(1);
assertThat(event.getTasks().get(0).getS3Key()).isEqualTo("s3objectkey");
}
}
21 changes: 21 additions & 0 deletions aws-lambda-java-tests/src/test/resources/s3_batch_event_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"invocationSchemaVersion": "2.0",
"invocationId": "Jr3s8KZqYWRmaiBhc2RmdW9hZHNmZGpmaGFzbGtkaGZzatx7Ruy",
"job": {
"id": "ry77cd60-61f6-4a2b-8a21-d07600c874gf",
"userArguments": {
"MyDestinationBucket": "destination-directory-bucket-name",
"MyDestinationBucketRegion": "us-east-1",
"MyDestinationPrefix": "copied/",
"MyDestinationObjectKeySuffix": "_new_suffix"
}
},
"tasks": [
{
"taskId": "y5R3a2lkZ29lc2hlurcS",
"s3Key": "s3objectkey",
"s3VersionId": null,
"s3Bucket": "source-directory-bucket-name"
}
]
}

0 comments on commit d9964f2

Please sign in to comment.