diff --git a/aws-lambda-java-events/README.md b/aws-lambda-java-events/README.md
index db423e07..63ecd80e 100644
--- a/aws-lambda-java-events/README.md
+++ b/aws-lambda-java-events/README.md
@@ -53,6 +53,7 @@
* `S3BatchResponse`
* `S3Event`
* `ScheduledEvent`
+* `ScheduledV2Event`
* `SecretsManagerRotationEvent`
* `SimpleIAMPolicyResponse`
* `SNSEvent`
diff --git a/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ScheduledV2Event.java b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ScheduledV2Event.java
new file mode 100644
index 00000000..c5442457
--- /dev/null
+++ b/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ScheduledV2Event.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package com.amazonaws.services.lambda.runtime.events;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.joda.time.DateTime;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Represents a Scheduled V2 event sent to Lambda
+ * Using Lambda with Amazon EventBridge Scheduler
+ */
+@Data
+@Builder(setterPrefix = "with")
+@NoArgsConstructor
+@AllArgsConstructor
+public class ScheduledV2Event implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = -463442139623175611L;
+
+ private String version;
+
+ private String account;
+
+ private String region;
+
+ private String detail;
+
+ private String detailType;
+
+ private String source;
+
+ private String id;
+
+ private DateTime time;
+
+ private List resources;
+
+}
diff --git a/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEventTest.java b/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEventTest.java
index 8f1662cd..52735b67 100644
--- a/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEventTest.java
+++ b/aws-lambda-java-events/src/test/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEventTest.java
@@ -1,8 +1,10 @@
package com.amazonaws.services.lambda.runtime.events;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.time.Instant;
+import java.util.Locale;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -12,6 +14,11 @@ public class APIGatewayV2CustomAuthorizerEventTest {
private static final long TIME_EPOCH = 1601306426515L;
private static final String TIME = "28/Sep/2020:15:14:43 +0000";
+ @BeforeAll
+ static void beforeAll() {
+ Locale.setDefault(new Locale("en", "US"));
+ }
+
@Test
public void testEpochLongAsAnInstant() {
APIGatewayV2CustomAuthorizerEvent customAuthorizerEvent = APIGatewayV2CustomAuthorizerEvent.builder()
diff --git a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializers.java b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializers.java
index 4173211e..c60259c6 100644
--- a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializers.java
+++ b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializers.java
@@ -142,6 +142,8 @@ public class LambdaEventSerializers {
KinesisTimeWindowEventMixin.class),
new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ScheduledEvent",
ScheduledEventMixin.class),
+ new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.ScheduledV2Event",
+ ScheduledEventMixin.class),
new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SecretsManagerRotationEvent",
SecretsManagerRotationEventMixin.class),
new SimpleEntry<>("com.amazonaws.services.lambda.runtime.events.SNSEvent",
diff --git a/aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/EventLoader.java b/aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/EventLoader.java
index 0c5d6620..c5574d72 100644
--- a/aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/EventLoader.java
+++ b/aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/EventLoader.java
@@ -1,13 +1,12 @@
/* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
package com.amazonaws.services.lambda.runtime.tests;
+import com.amazonaws.services.lambda.runtime.events.*;
import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer;
import com.amazonaws.services.lambda.runtime.serialization.events.LambdaEventSerializers;
import java.io.*;
-import com.amazonaws.services.lambda.runtime.events.*;
-
/**
* Load events from json files and serialize them in Events
*/
@@ -117,6 +116,10 @@ public static ScheduledEvent loadScheduledEvent(String filename) {
return loadEvent(filename, ScheduledEvent.class);
}
+ public static ScheduledV2Event loadScheduledV2Event(String filename) {
+ return loadEvent(filename, ScheduledV2Event.class);
+ }
+
public static SNSEvent loadSNSEvent(String filename) {
return loadEvent(filename, SNSEvent.class);
}
@@ -147,7 +150,7 @@ public static T loadEvent(String filename, Class targetClass) {
}
if (stream == null) {
try {
- stream = new FileInputStream(new File(filename));
+ stream = new FileInputStream(filename);
} catch (FileNotFoundException e) {
throw new EventLoadingException("Cannot load " + filename, e);
}
diff --git a/aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventLoaderTest.java b/aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventLoaderTest.java
index 4aa920f8..4f80d871 100644
--- a/aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventLoaderTest.java
+++ b/aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventLoaderTest.java
@@ -32,6 +32,7 @@
import com.amazonaws.services.lambda.runtime.events.SNSEvent;
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
import com.amazonaws.services.lambda.runtime.events.ScheduledEvent;
+import com.amazonaws.services.lambda.runtime.events.ScheduledV2Event;
import com.amazonaws.services.lambda.runtime.events.SecretsManagerRotationEvent;
import com.amazonaws.services.lambda.runtime.events.models.dynamodb.AttributeValue;
import com.amazonaws.services.lambda.runtime.events.models.dynamodb.Record;
@@ -40,13 +41,12 @@
import org.junit.jupiter.api.Test;
import java.time.Instant;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static java.time.Instant.ofEpochSecond;
import static org.assertj.core.api.Assertions.*;
+
public class EventLoaderTest {
@Test
@@ -406,6 +406,23 @@ public void testLoadRabbitMQEvent() {
assertThat((Integer) headers.get("numberInHeader")).isEqualTo(10);
}
+ @Test
+ public void testLoadScheduledV2Event() {
+ ScheduledV2Event event = EventLoader.loadScheduledV2Event("scheduler_event.json");
+
+ assertThat(event).isNotNull();
+ assertThat(event.getVersion()).isEqualTo("0");
+ assertThat(event.getId()).isEqualTo("4e6638b7-b892-4482-9762-8c58d4e71ecc");
+ assertThat(event.getDetailType()).isEqualTo("Scheduled Event");
+ assertThat(event.getSource()).isEqualTo("aws.scheduler");
+ assertThat(event.getAccount()).isEqualTo("123456789012");
+ assertThat(event.getTime()).isEqualTo(DateTime.parse("2024-05-07T15:58:34Z"));
+ assertThat(event.getRegion()).isEqualTo("eu-central-1");
+ assertThat(event.getResources()).isNotEmpty();
+ assertThat(event.getResources()).isEqualTo(Collections.singletonList("arn:aws:scheduler:eu-central-1:123456789012:schedule/default/demoschedule"));
+ assertThat(event.getDetail()).isEqualTo("{}");
+ }
+
@Test
public void testLoadCognitoUserPoolPreTokenGenerationEventV2() {
CognitoUserPoolPreTokenGenerationEventV2 event = EventLoader.loadCognitoUserPoolPreTokenGenerationEventV2("cognito_user_pool_pre_token_generation_event_v2.json");
diff --git a/aws-lambda-java-tests/src/test/resources/scheduler_event.json b/aws-lambda-java-tests/src/test/resources/scheduler_event.json
new file mode 100644
index 00000000..b56f3fb3
--- /dev/null
+++ b/aws-lambda-java-tests/src/test/resources/scheduler_event.json
@@ -0,0 +1,13 @@
+{
+ "version": "0",
+ "id": "4e6638b7-b892-4482-9762-8c58d4e71ecc",
+ "detail-type": "Scheduled Event",
+ "source": "aws.scheduler",
+ "account": "123456789012",
+ "time": "2024-05-07T15:58:34Z",
+ "region": "eu-central-1",
+ "resources": [
+ "arn:aws:scheduler:eu-central-1:123456789012:schedule/default/demoschedule"
+ ],
+ "detail": "{}"
+}
\ No newline at end of file