diff --git a/aws-lambda-java-serialization/pom.xml b/aws-lambda-java-serialization/pom.xml
index e3892d6c..4abf42a6 100644
--- a/aws-lambda-java-serialization/pom.xml
+++ b/aws-lambda-java-serialization/pom.xml
@@ -55,7 +55,13 @@
org.junit.jupiter
junit-jupiter-engine
- 5.7.0
+ 5.8.2
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.8.2
test
diff --git a/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializersTest.java b/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializersTest.java
index 151e71f5..c1d9fd0b 100644
--- a/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializersTest.java
+++ b/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializersTest.java
@@ -6,6 +6,9 @@
import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -13,179 +16,48 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
-
public class LambdaEventSerializersTest {
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
public static final ClassLoader SYSTEM_CLASS_LOADER = ClassLoader.getSystemClassLoader();
- @Test
- public void testAPIGatewayProxyRequestEvent() throws IOException {
- String expected = readEvent("api_gateway_proxy_request_event.json");
- String actual = deserializeSerializeJsonToString(expected, APIGatewayProxyRequestEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testAPIGatewayProxyResponseEvent() throws IOException {
- String expected = readEvent("api_gateway_proxy_response_event.json");
- String actual = deserializeSerializeJsonToString(expected, APIGatewayProxyResponseEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testCloudFrontEvent() throws IOException {
- String expected = readEvent("cloud_front_event.json");
- String actual = deserializeSerializeJsonToString(expected, CloudFrontEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testCloudWatchLogsEvent() throws IOException {
- String expected = readEvent("cloud_watch_logs_event.json");
- String actual = deserializeSerializeJsonToString(expected, CloudWatchLogsEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testCodeCommitEvent() throws IOException {
- String expected = readEvent("code_commit_event.json");
- String actual = deserializeSerializeJsonToString(expected, CodeCommitEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testCognitoEvent() throws IOException {
- String expected = readEvent("cognito_event.json");
- String actual = deserializeSerializeJsonToString(expected, CognitoEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testConfigEvent() throws IOException {
- String expected = readEvent("config_event.json");
- String actual = deserializeSerializeJsonToString(expected, ConfigEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testDynamodbEvent() throws IOException {
- String expected = readEvent("dynamodb_event.json");
- String actual = deserializeSerializeJsonToString(expected, DynamodbEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testIoTButtonEvent() throws IOException {
- String expected = readEvent("iot_button_event.json");
- String actual = deserializeSerializeJsonToString(expected, IoTButtonEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testKinesisAnalyticsFirehoseInputPreprocessingEvent() throws IOException {
- String expected = readEvent("kinesis_analytics_firehose_input_preprocessing_event.json");
- String actual = deserializeSerializeJsonToString(expected, KinesisAnalyticsFirehoseInputPreprocessingEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testKinesisAnalyticsInputPreprocessingResponse() throws IOException {
- String expected = readEvent("kinesis_analytics_input_preprocessing_response_event.json");
- String actual = deserializeSerializeJsonToString(expected, KinesisAnalyticsInputPreprocessingResponse.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testKinesisAnalyticsOutputDeliveryEvent() throws IOException {
- String expected = readEvent("kinesis_analytics_output_delivery_event.json");
- String actual = deserializeSerializeJsonToString(expected, KinesisAnalyticsOutputDeliveryEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testKinesisAnalyticsOutputDeliveryResponse() throws IOException {
- String expected = readEvent("kinesis_analytics_output_delivery_response_event.json");
- String actual = deserializeSerializeJsonToString(expected, KinesisAnalyticsOutputDeliveryResponse.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testKinesisAnalyticsStreamsInputPreprocessingEvent() throws IOException {
- String expected = readEvent("kinesis_analytics_streams_input_preprocessing_event.json");
- String actual = deserializeSerializeJsonToString(expected, KinesisAnalyticsStreamsInputPreprocessingEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testKinesisEvent() throws IOException {
- String expected = readEvent("kinesis_event.json");
- String actual = deserializeSerializeJsonToString(expected, KinesisEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testKinesisFirehoseEvent() throws IOException {
- String expected = readEvent("kinesis_firehose_event.json");
- String actual = deserializeSerializeJsonToString(expected, KinesisFirehoseEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testLexEvent() throws IOException {
- String expected = readEvent("lex_event.json");
- String actual = deserializeSerializeJsonToString(expected, LexEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testS3Event() throws IOException {
- String expected = readEvent("s3_event.json");
- String actual = deserializeSerializeJsonToString(expected, S3Event.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testScheduledEvent() throws IOException {
- String expected = readEvent("scheduled_event.json");
- String actual = deserializeSerializeJsonToString(expected, ScheduledEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testSNSEvent() throws IOException {
- String expected = readEvent("sns_event.json");
- String actual = deserializeSerializeJsonToString(expected, SNSEvent.class);
-
- assertJsonEqual(expected, actual);
- }
-
- @Test
- public void testSQSEvent() throws IOException {
- String expected = readEvent("sqs_event.json");
- String actual = deserializeSerializeJsonToString(expected, SQSEvent.class);
+ private static Stream serdeArguments() {
+ return Stream.of(
+ Arguments.of("api_gateway_proxy_request_event.json", APIGatewayProxyRequestEvent.class),
+ Arguments.of("api_gateway_proxy_response_event.json", APIGatewayProxyResponseEvent.class),
+ Arguments.of("cloud_front_event.json", CloudFrontEvent.class),
+ Arguments.of("cloud_watch_logs_event.json", CloudWatchLogsEvent.class),
+ Arguments.of("code_commit_event.json", CodeCommitEvent.class),
+ Arguments.of("api_gateway_proxy_response_event.json", APIGatewayProxyResponseEvent.class),
+ Arguments.of("cognito_event.json", CognitoEvent.class),
+ Arguments.of("config_event.json", ConfigEvent.class),
+ Arguments.of("dynamodb_event.json", DynamodbEvent.class),
+ Arguments.of("iot_button_event.json", IoTButtonEvent.class),
+ Arguments.of("kinesis_analytics_firehose_input_preprocessing_event.json", KinesisAnalyticsFirehoseInputPreprocessingEvent.class),
+ Arguments.of("kinesis_analytics_input_preprocessing_response_event.json", KinesisAnalyticsInputPreprocessingResponse.class),
+ Arguments.of("kinesis_analytics_output_delivery_event.json", KinesisAnalyticsOutputDeliveryEvent.class),
+ Arguments.of("kinesis_analytics_output_delivery_response_event.json", KinesisAnalyticsOutputDeliveryResponse.class),
+ Arguments.of("kinesis_analytics_streams_input_preprocessing_event.json", KinesisAnalyticsStreamsInputPreprocessingEvent.class),
+ Arguments.of("kinesis_event.json", KinesisEvent.class),
+ Arguments.of("kinesis_firehose_event.json", KinesisFirehoseEvent.class),
+ Arguments.of("lex_event.json", LexEvent.class),
+ Arguments.of("s3_event.json", S3Event.class),
+ Arguments.of("scheduled_event.json", ScheduledEvent.class),
+ Arguments.of("sns_event.json", SNSEvent.class),
+ Arguments.of("sqs_event.json", SQSEvent.class)
+ );
+ }
+
+ @ParameterizedTest(name = "Serde {0} Event")
+ @MethodSource("serdeArguments")
+ public void testAPIGatewayProxyRequestEvent(final String json,
+ final Class> eventClass) throws IOException {
+ String expected = readEvent(json);
+ String actual = deserializeSerializeJsonToString(expected, eventClass);
assertJsonEqual(expected, actual);
}
@@ -213,5 +85,4 @@ private String bytesToString(byte[] bytes) {
private void assertJsonEqual(String expected, String actual) throws IOException {
assertEquals(OBJECT_MAPPER.readTree(expected), OBJECT_MAPPER.readTree(actual));
}
-
}