Skip to content

Commit 730ba44

Browse files
committed
Add test case
1 parent 8c3542d commit 730ba44

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

services-custom/s3-event-notifications/src/test/java/software/amazon/awssdk/eventnotifications/s3/model/S3EventNotificationReaderTest.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,53 @@ void missingField_shouldBeNull() {
442442
assertThat(rec.getResponseElements()).isNull();
443443
}
444444

445+
@Test
446+
void eventTimeIsNullWhenEventNamePresent_shouldSucceed() {
447+
String json = "{\n"
448+
+ " \"Records\" : [ {\n"
449+
+ " \"eventVersion\" : \"2.1\",\n"
450+
+ " \"eventSource\" : \"aws:s3\",\n"
451+
+ " \"awsRegion\" : \"us-west-2\",\n"
452+
// missing eventTime
453+
+ " \"eventName\" : \"ObjectCreated:Put\",\n"
454+
+ " \"userIdentity\" : {\n"
455+
+ " \"principalId\" : \"AIDAJDPLRKLG7UEXAMUID\"\n"
456+
+ " },\n"
457+
+ " \"requestParameters\" : {\n"
458+
+ " \"sourceIPAddress\" : \"127.1.2.3\"\n"
459+
+ " },\n"
460+
+ " \"responseElements\":{\n"
461+
+ " \"x-amz-request-id\":\"C3D13FE58DE4C810\",\n"
462+
+ " \"x-amz-id-2\":\"FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD\"\n"
463+
+ " },\n"
464+
+ " \"s3\" : {\n"
465+
+ " \"s3SchemaVersion\" : \"1.0\",\n"
466+
+ " \"configurationId\" : \"testConfigRule\",\n"
467+
+ " \"bucket\" : {\n"
468+
+ " \"name\" : \"mybucket-test\",\n"
469+
+ " \"ownerIdentity\" : {\n"
470+
+ " \"principalId\" : \"A3NL1KOZZKExample\"\n"
471+
+ " },\n"
472+
+ " \"arn\" : \"arn:aws:s3:::mybucket\"\n"
473+
+ " },\n"
474+
+ " \"object\" : {\n"
475+
+ " \"key\" : \"HappyFace-test.jpg\",\n"
476+
+ " \"size\" : 2048,\n"
477+
+ " \"eTag\" : \"d41d8cd98f00b204e9800998ecf8etag\",\n"
478+
+ " \"versionId\" : \"096fKKXTRTtl3on89fVO.nfljtsv6vid\",\n"
479+
+ " \"sequencer\" : \"0055AED6DCD9028SEQ\"\n"
480+
+ " }\n"
481+
+ " }\n"
482+
+ " } ]\n"
483+
+ "}";
484+
485+
S3EventNotification event = S3EventNotification.fromJson(json);
486+
S3EventNotificationRecord rec = event.getRecords().get(0);
487+
assertThat(rec).isNotNull();
488+
assertThat(rec.getEventName()).isEqualTo("ObjectCreated:Put");
489+
assertThat(rec.getEventTime()).isNull();
490+
}
491+
445492
@Test
446493
void extraFields_areIgnored() {
447494
String json = "{\"Records\":[], \"toto\":123}";

0 commit comments

Comments
 (0)