From cc49649859c084dfe8bbd1fba0e58bdd7958e551 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Fri, 10 Mar 2023 16:47:49 +0000 Subject: [PATCH] 1.1.2 aws-lambda-java-serialization release --- .../aws-lambda-java-serialization.yml | 9 +- aws-lambda-java-events/pom.xml | 360 +++++++++--------- .../pom.xml | 2 +- .../api/client/EventHandlerLoader.java | 5 + .../api/client/PojoSerializerLoader.java | 75 ++++ ...TooManyServiceProvidersFoundException.java | 21 + aws-lambda-java-serialization/pom.xml | 35 +- .../events/modules/DateTimeModule.java | 3 +- .../events/serializers/S3EventSerializer.java | 3 +- .../factories/JacksonFactory.java | 25 -- .../serialization/util/SerializeUtil.java | 7 +- .../events/LambdaEventSerializersTest.java | 89 ----- .../serializers/S3EventSerializerTest.java | 73 ---- .../api_gateway_proxy_request_event.json | 60 --- .../api_gateway_proxy_response_event.json | 23 -- .../event_models/cloud_front_event.json | 30 -- .../event_models/cloud_watch_logs_event.json | 5 - .../event_models/code_commit_event.json | 27 -- .../resources/event_models/cognito_event.json | 20 - .../resources/event_models/config_event.json | 12 - .../event_models/dynamodb_event.json | 166 -------- .../dynamodb_time_window_event.json | 101 ----- .../event_models/iot_button_event.json | 5 - ...cs_firehose_input_preprocessing_event.json | 14 - ...cs_input_preprocessing_response_event.json | 10 - ...nesis_analytics_output_delivery_event.json | 10 - ...lytics_output_delivery_response_event.json | 8 - ...ics_streams_input_preprocessing_event.json | 17 - .../resources/event_models/kinesis_event.json | 35 -- .../event_models/kinesis_firehose_event.json | 33 -- .../kinesis_time_window_event.json | 31 -- .../resources/event_models/lex_event.json | 24 -- .../test/resources/event_models/s3_event.json | 40 -- .../event_models/scheduled_event.json | 12 - .../resources/event_models/sns_event.json | 31 -- .../resources/event_models/sqs_event.json | 40 -- aws-lambda-java-tests/pom.xml | 2 +- 37 files changed, 311 insertions(+), 1152 deletions(-) create mode 100644 aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/PojoSerializerLoader.java create mode 100644 aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/TooManyServiceProvidersFoundException.java delete mode 100644 aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializersTest.java delete mode 100644 aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializerTest.java delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_request_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_response_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/cloud_front_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/cloud_watch_logs_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/code_commit_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/cognito_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/config_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_time_window_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/iot_button_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_firehose_input_preprocessing_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_input_preprocessing_response_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_response_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_streams_input_preprocessing_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_firehose_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/kinesis_time_window_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/lex_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/s3_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/scheduled_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/sns_event.json delete mode 100644 aws-lambda-java-serialization/src/test/resources/event_models/sqs_event.json diff --git a/.github/workflows/aws-lambda-java-serialization.yml b/.github/workflows/aws-lambda-java-serialization.yml index 2febf33a..9d71cbab 100644 --- a/.github/workflows/aws-lambda-java-serialization.yml +++ b/.github/workflows/aws-lambda-java-serialization.yml @@ -29,6 +29,11 @@ jobs: # Install base module - name: Install events with Maven run: mvn -B install --file aws-lambda-java-events/pom.xml - # Package target module + + # Package and install target module - name: Package serialization with Maven - run: mvn -B package --file aws-lambda-java-serialization/pom.xml + run: mvn -B package install --file aws-lambda-java-serialization/pom.xml + + # Run tests + - name: Run tests from aws-lambda-java-tests + run: mvn test --file aws-lambda-java-tests/pom.xml diff --git a/aws-lambda-java-events/pom.xml b/aws-lambda-java-events/pom.xml index af786d91..75801138 100644 --- a/aws-lambda-java-events/pom.xml +++ b/aws-lambda-java-events/pom.xml @@ -1,190 +1,190 @@ - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd"> + 4.0.0 - com.amazonaws - aws-lambda-java-events - 3.11.0 - jar + com.amazonaws + aws-lambda-java-events + 3.11.0 + jar - AWS Lambda Java Events Library - - Event interface definitions AWS services supported by AWS Lambda. - - https://aws.amazon.com/lambda/ - - - Apache License, Version 2.0 - https://aws.amazon.com/apache2.0 - repo - - - - https://github.com/aws/aws-lambda-java-libs.git - - - - AWS Lambda team - Amazon Web Services - https://aws.amazon.com/ - - + AWS Lambda Java Events Library + + Event interface definitions AWS services supported by AWS Lambda. + + https://aws.amazon.com/lambda/ + + + Apache License, Version 2.0 + https://aws.amazon.com/apache2.0 + repo + + + + https://github.com/aws/aws-lambda-java-libs.git + + + + AWS Lambda team + Amazon Web Services + https://aws.amazon.com/ + + - - 1.8 - 1.8 - 1.18.22 - + + 1.8 + 1.8 + 1.18.22 + - - - sonatype-nexus-staging - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + + sonatype-nexus-staging + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + - - - joda-time - joda-time - 2.6 - + + + joda-time + joda-time + 2.10.8 + - - org.junit.jupiter - junit-jupiter-engine - 5.7.0 - test - - - com.fasterxml.jackson.core - jackson-databind - 2.13.4.1 - test - - - net.javacrumbs.json-unit - json-unit-assertj - 2.22.0 - test - + + org.junit.jupiter + junit-jupiter-engine + 5.9.2 + test + + + com.fasterxml.jackson.core + jackson-databind + 2.14.2 + test + + + net.javacrumbs.json-unit + json-unit-assertj + 2.36.1 + test + - - org.projectlombok - lombok - ${lombok.version} - provided - - + + org.projectlombok + lombok + ${lombok.version} + provided + + - - - dev - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - -Xdoclint:none - - - - attach-javadocs - - jar - - - - - - - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.2.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - -Xdoclint:none - - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.3 - true - - sonatype-nexus-staging - https://aws.oss.sonatype.org/ - false - - - - org.apache.maven.plugins - maven-resources-plugin - 3.2.0 - - UTF-8 - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.8.1 - - - - org.projectlombok - lombok - ${lombok.version} - - - UTF-8 - - - - - - + + + dev + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + -Xdoclint:none + + + + attach-javadocs + + jar + + + + + + + + + release + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + -Xdoclint:none + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.3 + true + + sonatype-nexus-staging + https://aws.oss.sonatype.org/ + false + + + + org.apache.maven.plugins + maven-resources-plugin + 3.2.0 + + UTF-8 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + + org.projectlombok + lombok + ${lombok.version} + + + UTF-8 + + + + + + diff --git a/aws-lambda-java-runtime-interface-client/pom.xml b/aws-lambda-java-runtime-interface-client/pom.xml index 8de738de..cf769fa5 100644 --- a/aws-lambda-java-runtime-interface-client/pom.xml +++ b/aws-lambda-java-runtime-interface-client/pom.xml @@ -56,7 +56,7 @@ com.amazonaws aws-lambda-java-serialization - 1.0.0 + 1.1.0 diff --git a/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/EventHandlerLoader.java b/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/EventHandlerLoader.java index fc16d43f..65b95fcb 100644 --- a/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/EventHandlerLoader.java +++ b/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/EventHandlerLoader.java @@ -69,6 +69,11 @@ private EventHandlerLoader() { } */ @SuppressWarnings({"unchecked", "rawtypes"}) private static PojoSerializer getSerializer(Platform platform, Type type) { + PojoSerializer customSerializer = PojoSerializerLoader.getCustomerSerializer(type); + if (customSerializer != null) { + return customSerializer; + } + // if serializing a Class that is a Lambda supported event, use Jackson with customizations if (type instanceof Class) { Class clazz = ((Class)type); diff --git a/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/PojoSerializerLoader.java b/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/PojoSerializerLoader.java new file mode 100644 index 00000000..a65f17c7 --- /dev/null +++ b/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/PojoSerializerLoader.java @@ -0,0 +1,75 @@ +/* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ + +package com.amazonaws.services.lambda.runtime.api.client; + +import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; +import com.amazonaws.services.lambda.runtime.CustomPojoSerializer; + +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Type; +import java.util.Iterator; +import java.util.ServiceConfigurationError; +import java.util.ServiceLoader; + +public class PojoSerializerLoader { + // The serializer obtained from the provider will always be the same so we can cache it as a filed. + private static CustomPojoSerializer customPojoSerializer; + // If Input and Output type are different, the runtime will try to search for a serializer twice due to + // the getSerializerCached method. Save the initialization state in order to search for the provider only once. + private static boolean initialized = false; + + private static CustomPojoSerializer loadSerializer() + throws ServiceConfigurationError, TooManyServiceProvidersFoundException { + + if (customPojoSerializer != null) { + return customPojoSerializer; + } + + ServiceLoader loader = ServiceLoader.load(CustomPojoSerializer.class, AWSLambda.customerClassLoader); + Iterator serializers = loader.iterator(); + + if (!serializers.hasNext()) { + initialized = true; + return null; + } + + customPojoSerializer = serializers.next(); + + if (serializers.hasNext()) { + throw new TooManyServiceProvidersFoundException( + "Too many serializers provided inside the META-INF/services folder, only one is allowed" + ); + } + + initialized = true; + return customPojoSerializer; + } + + public static PojoSerializer getCustomerSerializer(Type type) { + if (!initialized) { + customPojoSerializer = loadSerializer(); + } + + if (customPojoSerializer == null) { + return null; + } + + return new PojoSerializer() { + @Override + public Object fromJson(InputStream input) { + return customPojoSerializer.fromJson(input, type); + } + + @Override + public Object fromJson(String input) { + return customPojoSerializer.fromJson(input, type); + } + + @Override + public void toJson(Object value, OutputStream output) { + customPojoSerializer.toJson(value, output, type); + } + }; + } +} diff --git a/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/TooManyServiceProvidersFoundException.java b/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/TooManyServiceProvidersFoundException.java new file mode 100644 index 00000000..c4b94e37 --- /dev/null +++ b/aws-lambda-java-runtime-interface-client/src/main/java/com/amazonaws/services/lambda/runtime/api/client/TooManyServiceProvidersFoundException.java @@ -0,0 +1,21 @@ +/* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ + +package com.amazonaws.services.lambda.runtime.api.client; + +public class TooManyServiceProvidersFoundException extends RuntimeException { + public TooManyServiceProvidersFoundException() { + + } + + public TooManyServiceProvidersFoundException(String errorMessage) { + super(errorMessage); + } + + public TooManyServiceProvidersFoundException(Throwable cause) { + super(cause); + } + + public TooManyServiceProvidersFoundException(String message, Throwable cause) { + super(message, cause); + } +} \ No newline at end of file diff --git a/aws-lambda-java-serialization/pom.xml b/aws-lambda-java-serialization/pom.xml index 1885311c..6395ce24 100644 --- a/aws-lambda-java-serialization/pom.xml +++ b/aws-lambda-java-serialization/pom.xml @@ -4,7 +4,7 @@ com.amazonaws aws-lambda-java-serialization - 1.1.1 + 1.1.2 jar AWS Lambda Java Runtime Serialization @@ -34,7 +34,7 @@ com.amazonaws.lambda.thirdparty 2.14.2 2.10.1 - 5.9.1 + 20230227 7.3.2 @@ -68,26 +68,7 @@ org.json json - 20160810 - - - - org.junit.jupiter - junit-jupiter-engine - ${junit.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit.version} - test - - - com.amazonaws - aws-lambda-java-events - 3.11.0 - test + ${json.version} @@ -243,6 +224,16 @@ org.json ${relocation.prefix}.org.json + + org.joda.time + ${relocation.prefix}.org.joda.time + + + + com.amazonaws.lambda.unshade.thirdparty.org.joda.time + org.joda.time + diff --git a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/modules/DateTimeModule.java b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/modules/DateTimeModule.java index 592d0533..a02857e0 100644 --- a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/modules/DateTimeModule.java +++ b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/modules/DateTimeModule.java @@ -23,7 +23,8 @@ public class DateTimeModule extends JodaModule { * creates a DateTimeModule using customer class loader to pull org.joda.time.DateTime */ public DateTimeModule(ClassLoader classLoader) { - Class dateTimeClass = SerializeUtil.loadCustomerClass("org.joda.time.DateTime", classLoader); + // Workaround not to let maven shade plugin relocating string literals https://issues.apache.org/jira/browse/MSHADE-156 + Class dateTimeClass = SerializeUtil.loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.DateTime", classLoader); this.addSerializer(dateTimeClass, getSerializer(dateTimeClass, classLoader)); this.addDeserializer(dateTimeClass, getDeserializer(dateTimeClass)); } diff --git a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializer.java b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializer.java index 6c6f6587..c833abcc 100644 --- a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializer.java +++ b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializer.java @@ -220,7 +220,8 @@ private JSONObject serializeEventNotificationRecord(A eventNotificationRecor Class requestParametersClass = SerializeUtil.loadCustomerClass(baseClassName + "$RequestParametersEntity", classLoader); Class responseElementsClass = SerializeUtil.loadCustomerClass(baseClassName + "$ResponseElementsEntity", classLoader); Class userIdentityClass = SerializeUtil.loadCustomerClass(baseClassName + "$UserIdentityEntity", classLoader); - Class dateTimeClass = SerializeUtil.loadCustomerClass("org.joda.time.DateTime", classLoader); + // Workaround not to let maven shade plugin relocating string literals https://issues.apache.org/jira/browse/MSHADE-156 + Class dateTimeClass = SerializeUtil.loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.DateTime", classLoader); // serialize object JSONObject jsonObject = new JSONObject(); Functions.R0 getAwsRegionMethod = diff --git a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/JacksonFactory.java b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/JacksonFactory.java index f7c1dd4a..660ca8f5 100644 --- a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/JacksonFactory.java +++ b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/JacksonFactory.java @@ -114,37 +114,12 @@ private static ObjectMapper createObjectMapper() { mapper.setConfig(dcfg); mapper.setSerializationInclusion(Include.NON_NULL); - SimpleModule module = new SimpleModule(); - module.addDeserializer(Void.class, new VoidDeserializer()); - mapper.registerModule(module); - mapper.registerModule(new JavaTimeModule()); mapper.registerModule(new Jdk8Module()); return mapper; } - public static final class VoidDeserializer extends JsonDeserializer { - - private final static Void VOID = createVoid(); - - private static Void createVoid() { - try { - Constructor constructor = Void.class.getDeclaredConstructor(); - constructor.setAccessible(true); - return constructor.newInstance(); - } catch(Exception e) { - return null; - } - } - - @Override - public Void deserialize(JsonParser parser, DeserializationContext ctx) { - return VOID; - } - - } - private static JsonFactory createJsonFactory() { JsonFactory factory = JsonFactory.builder() //Json Read enabled diff --git a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/SerializeUtil.java b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/SerializeUtil.java index bd4c7450..f6acb528 100644 --- a/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/SerializeUtil.java +++ b/aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/util/SerializeUtil.java @@ -71,9 +71,10 @@ public static T deserializeDateTime(Class dateTimeClass, String dateTimeS */ @SuppressWarnings({"unchecked"}) public static String serializeDateTime(T dateTime, ClassLoader classLoader) { - Class dateTimeFormatterClass = loadCustomerClass("org.joda.time.format.DateTimeFormatter", classLoader); - Class dateTimeFormatClass = loadCustomerClass("org.joda.time.format.ISODateTimeFormat", classLoader); - Class readableInstantInterface = loadCustomerClass("org.joda.time.ReadableInstant", classLoader); + // Workaround not to let maven shade plugin relocating string literals https://issues.apache.org/jira/browse/MSHADE-156 + Class dateTimeFormatterClass = loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.format.DateTimeFormatter", classLoader); + Class dateTimeFormatClass = loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.format.ISODateTimeFormat", classLoader); + Class readableInstantInterface = loadCustomerClass("com.amazonaws.lambda.unshade.thirdparty.org.joda.time.ReadableInstant", classLoader); return serializeDateTimeHelper(dateTime, dateTimeFormatterClass, dateTimeFormatClass, readableInstantInterface); } 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 deleted file mode 100644 index 13358f72..00000000 --- a/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/LambdaEventSerializersTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ - -package com.amazonaws.services.lambda.runtime.serialization.events; - -import com.amazonaws.services.lambda.runtime.events.*; -import com.amazonaws.services.lambda.runtime.serialization.PojoSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -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; -import java.nio.charset.StandardCharsets; -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(); - - 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("dynamodb_time_window_event.json", DynamodbTimeWindowEvent.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_time_window_event.json", KinesisTimeWindowEvent.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); - } - - private String readEvent(String filename) throws IOException { - Path filePath = Paths.get("src", "test", "resources", "event_models", filename); - byte[] bytes = Files.readAllBytes(filePath); - return bytesToString(bytes); - } - - private String deserializeSerializeJsonToString(String expected, Class modelClass) { - PojoSerializer serializer = LambdaEventSerializers.serializerFor(modelClass, SYSTEM_CLASS_LOADER); - - T event = serializer.fromJson(expected); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - serializer.toJson(event, baos); - return bytesToString(baos.toByteArray()); - } - - private String bytesToString(byte[] bytes) { - return new String(bytes, StandardCharsets.UTF_8); - } - - private void assertJsonEqual(String expected, String actual) throws IOException { - assertEquals(OBJECT_MAPPER.readTree(expected), OBJECT_MAPPER.readTree(actual)); - } -} diff --git a/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializerTest.java b/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializerTest.java deleted file mode 100644 index 8b2d2e87..00000000 --- a/aws-lambda-java-serialization/src/test/java/com/amazonaws/services/lambda/runtime/serialization/events/serializers/S3EventSerializerTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ - -package com.amazonaws.services.lambda.runtime.serialization.events.serializers; - -import com.amazonaws.services.lambda.runtime.events.S3Event; -import com.amazonaws.services.lambda.runtime.events.models.s3.S3EventNotification; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.jupiter.api.Test; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertEquals; - - -public class S3EventSerializerTest { - - private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); - public static final ClassLoader SYSTEM_CLASS_LOADER = ClassLoader.getSystemClassLoader(); - - @Test - public void testSerDeS3Event() throws IOException { - S3EventSerializer s3EventSerializer = getS3EventSerializerWithClass(S3Event.class); - - String expected = readEvent("s3_event.json"); - String actual = deserializeSerializeJsonToString(s3EventSerializer, expected); - - assertJsonEqual(expected, actual); - } - - @Test - public void testSerDeS3EventNotification() throws IOException { - S3EventSerializer s3EventSerializer = getS3EventSerializerWithClass(S3EventNotification.class); - - String expected = readEvent("s3_event.json"); - String actual = deserializeSerializeJsonToString(s3EventSerializer, expected); - - assertJsonEqual(expected, actual); - } - - private S3EventSerializer getS3EventSerializerWithClass(Class modelClass) { - return new S3EventSerializer() - .withClass(modelClass) - .withClassLoader(SYSTEM_CLASS_LOADER); - } - - private String readEvent(String filename) throws IOException { - Path filePath = Paths.get("src", "test", "resources", "event_models", filename); - byte[] bytes = Files.readAllBytes(filePath); - return bytesToString(bytes); - } - - private String bytesToString(byte[] bytes) { - return new String(bytes, StandardCharsets.UTF_8); - } - - private void assertJsonEqual(String expected, String actual) throws IOException { - assertEquals(OBJECT_MAPPER.readTree(expected), OBJECT_MAPPER.readTree(actual)); - } - - private String deserializeSerializeJsonToString(S3EventSerializer s3EventSerializer, String expected) { - T event = s3EventSerializer.fromJson(expected); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - s3EventSerializer.toJson(event, baos); - return bytesToString(baos.toByteArray()); - } - -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_request_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_request_event.json deleted file mode 100644 index 66c5d953..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_request_event.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "version": "1.0", - "path": "/test/hello", - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, lzma, sdch, br", - "Accept-Language": "en-US,en;q=0.8", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "wt6mne2s9k.execute-api.us-west-2.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36 OPR/39.0.2256.48", - "Via": "1.1 fb7cca60f0ecd82ce07790c9c5eef16c.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "nBsWBOrSHMgnaROZJK1wGCZ9PcRcSpq_oSXZNQwQ10OTZL4cimZo3g==", - "X-Forwarded-For": "192.168.100.1, 192.168.1.1", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "pathParameters": { - "proxy": "hello" - }, - "requestContext": { - "path": "/{proxy+}", - "accountId": "123456789012", - "resourceId": "nl9h80", - "stage": "test-invoke-stage", - "requestId": "test-invoke-request", - "identity": { - "cognitoIdentityPoolId": "", - "accountId": "123456789012", - "cognitoIdentityId": "", - "caller": "AIDAJTIRKKKER4HCKVJZG", - "apiKey": "test-invoke-api-key", - "sourceIp": "test-invoke-source-ip", - "accessKey": "ASIAI6ANUE2RZBMJDQ5A", - "cognitoAuthenticationType": "", - "cognitoAuthenticationProvider": "", - "userArn": "arn:aws:iam::123456789012:user/kdeding", - "userAgent": "Apache-HttpClient/4.5.x (Java/1.8.0_131)", - "user": "AIDAJTIRKKKER4HCKVJZG" - }, - "resourcePath": "/{proxy+}", - "httpMethod": "POST", - "apiId": "r275xc9bmd" - }, - "resource": "/{proxy+}", - "httpMethod": "GET", - "isBase64Encoded": false, - "body": "{ \"callerName\": \"John\" }", - "queryStringParameters": { - "name": "me" - }, - "stageVariables": { - "stageVarName": "stageVarValue" - } -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_response_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_response_event.json deleted file mode 100644 index 1b18bcfd..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/api_gateway_proxy_response_event.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "statusCode": 200, - "headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", - "Accept-Encoding": "gzip, deflate, lzma, sdch, br", - "Accept-Language": "en-US,en;q=0.8", - "CloudFront-Forwarded-Proto": "https", - "CloudFront-Is-Desktop-Viewer": "true", - "CloudFront-Is-Mobile-Viewer": "false", - "CloudFront-Is-SmartTV-Viewer": "false", - "CloudFront-Is-Tablet-Viewer": "false", - "CloudFront-Viewer-Country": "US", - "Host": "wt6mne2s9k.execute-api.us-west-2.amazonaws.com", - "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36 OPR/39.0.2256.48", - "Via": "1.1 fb7cca60f0ecd82ce07790c9c5eef16c.cloudfront.net (CloudFront)", - "X-Amz-Cf-Id": "nBsWBOrSHMgnaROZJK1wGCZ9PcRcSpq_oSXZNQwQ10OTZL4cimZo3g==", - "X-Forwarded-For": "192.168.100.1, 192.168.1.1", - "X-Forwarded-Port": "443", - "X-Forwarded-Proto": "https" - }, - "body": "Hello World" -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/cloud_front_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/cloud_front_event.json deleted file mode 100644 index e9167480..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/cloud_front_event.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "Records": [ - { - "cf": { - "config": { - "distributionId": "EDFDVBD6EXAMPLE" - }, - "request": { - "clientIp": "2001:0db8:85a3:0:0:8a2e:0370:7334", - "method": "GET", - "uri": "/picture.jpg", - "headers": { - "host": [ - { - "key": "Host", - "value": "d111111abcdef8.cloudfront.net" - } - ], - "user-agent": [ - { - "key": "User-Agent", - "value": "curl/7.51.0" - } - ] - } - } - } - } - ] -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/cloud_watch_logs_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/cloud_watch_logs_event.json deleted file mode 100644 index 2b455b9b..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/cloud_watch_logs_event.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "awslogs": { - "data": "H4sIAAAAAAAAAHWPwQqCQBCGX0Xm7EFtK+smZBEUgXoLCdMhFtKV3akI8d0bLYmibvPPN3wz00CJxmQnTO41whwWQRIctmEcB6sQbFC3CjW3XW8kxpOpP+OC22d1Wml1qZkQGtoMsScxaczKN3plG8zlaHIta5KqWsozoTYw3/djzwhpLwivWFGHGpAFe7DL68JlBUk+l7KSN7tCOEJ4M3/qOI49vMHj+zCKdlFqLaU2ZHV2a4Ct/an0/ivdX8oYc1UVX860fQDQiMdxRQEAAA==" - } -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/code_commit_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/code_commit_event.json deleted file mode 100644 index 4e111cdd..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/code_commit_event.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "Records": [ - { - "eventId": "163179e8-a983-4e22-8423-38473a2589fd", - "eventVersion": "1.0", - "eventTime": "2017-07-17T19:38:56.745Z", - "eventTriggerName": "notifyme", - "eventPartNumber": 1, - "codecommit": { - "references": [ - { - "commit": "7a95e78397313b32dc3c1beda4f5c2676c0c1bea", - "ref": "refs/heads/master", - "created": true - } - ] - }, - "eventName": "ReferenceChanges", - "eventTriggerConfigId": "e6f61a39-7e60-47b0-b206-0dfbd2ca0e6e", - "eventSourceARN": "arn:aws:codecommit:us-west-2:303480592763:garbage", - "userIdentityARN": "arn:aws:sts::303480592763:assumed-role/Admin/adsuresh-Isengard", - "eventSource": "aws:codecommit", - "awsRegion": "us-west-2", - "eventTotalParts": 1 - } - ] -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/cognito_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/cognito_event.json deleted file mode 100644 index 88cc6062..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/cognito_event.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": 2, - "eventType": "SyncTrigger", - "region": "us-east-1", - "identityPoolId": "identityPoolId", - "identityId": "identityId", - "datasetName": "datasetName", - "datasetRecords": { - "sampleKey1": { - "oldValue": "oldValue1", - "newValue": "newValue1", - "op": "replace" - }, - "sampleKey2": { - "oldValue": "oldValue2", - "newValue": "newValue2", - "op": "replace" - } - } -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/config_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/config_event.json deleted file mode 100644 index a5d158de..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/config_event.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "invokingEvent": "{\"configurationItem\":{\"configurationItemCaptureTime\":\"2016-02-17T01:36:34.043Z\",\"awsAccountId\":\"000000000000\",\"configurationItemStatus\":\"OK\",\"resourceId\":\"i-00000000\",\"ARN\":\"arn:aws:ec2:us-east-1:000000000000:instance/i-00000000\",\"awsRegion\":\"us-east-1\",\"availabilityZone\":\"us-east-1a\",\"resourceType\":\"AWS::EC2::Instance\",\"tags\":{\"Foo\":\"Bar\"},\"relationships\":[{\"resourceId\":\"eipalloc-00000000\",\"resourceType\":\"AWS::EC2::EIP\",\"name\":\"Is attached to ElasticIp\"}],\"configuration\":{\"foo\":\"bar\"}},\"messageType\":\"ConfigurationItemChangeNotification\"}", - "ruleParameters": "{\"myParameterKey\":\"myParameterValue\"}", - "resultToken": "myResultToken", - "eventLeftScope": false, - "executionRoleArn": "arn:aws:iam::012345678912:role/config-role", - "configRuleArn": "arn:aws:config:us-east-1:012345678912:config-rule/config-rule-0123456", - "configRuleName": "change-triggered-config-rule", - "configRuleId": "config-rule-0123456", - "accountId": "012345678912", - "version": "1.0" -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_event.json deleted file mode 100644 index 6a9c6ac4..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_event.json +++ /dev/null @@ -1,166 +0,0 @@ -{ - "Records": [ - { - "eventID": "1", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "NewImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "StreamViewType": "NEW_AND_OLD_IMAGES", - "SequenceNumber": "111", - "SizeBytes": 26 - }, - "awsRegion": "us-west-2", - "eventName": "INSERT", - "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" - }, - { - "eventID": "2", - "dynamodb": { - "OldImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "SequenceNumber": "222", - "Keys": { - "Id": { - "N": "101" - } - }, - "SizeBytes": 59, - "NewImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "awsRegion": "us-west-2", - "eventName": "MODIFY", - "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" - }, - { - "eventID": "3", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "SizeBytes": 38, - "SequenceNumber": "333", - "OldImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "awsRegion": "us-west-2", - "eventName": "REMOVE", - "eventSourceARN": "arn:aws:dynamodb:us-west-2:account-id:table/ExampleTableWithStream/stream/2015-06-27T00:48:05.899", - "eventSource": "aws:dynamodb" - }, - { - "eventID": "77742f55658ca1effb9ae758c65c8a51", - "eventName": "INSERT", - "eventSource": "aws:dynamodb", - "awsRegion": "us-west-2", - "dynamodb": { - "ApproximateCreationDateTime": 1.44130524E9, - "Keys": { - "Id": { - "N": "147" - } - }, - "NewImage": { - "attr_M": { - "M": { - "attr_M1": { - "N": "1580756226" - }, - "attr_M2": { - "S": "1580756226" - } - } - }, - "attr_L": { - "L": [ - { - "N": "1580756226" - }, - { - "S": "1580756226" - } - ] - }, - "attr_BOOL": { - "BOOL": true - }, - "s3info": { - "S": "lambda-ddb-streams-int-test/a2b4c06b-2360-44ac-9bd7-2bab669246b8" - }, - "attr_NULL": { - "NULL": true - }, - "attr_NS": { - "NS": [ - "1580756227", - "1580756226" - ] - }, - "attr_SS": { - "SS": [ - "1580756226", - "1580756227" - ] - }, - "attr_BS": { - "BS": [ - "MTU4MDc1NjIyNg==", - "MTU4MDc1NjIyNw==" - ] - }, - "attr_S": { - "S": "1580756226" - }, - "Id": { - "N": "147" - }, - "attr_B": { - "B": "MTU4MDc1NjIyNg==" - }, - "attr_N": { - "N": "1580756226" - } - }, - "SequenceNumber": "2700000000000002229109", - "SizeBytes": 285, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "eventSourceARN": "arn:aws:dynamodb:us-west-2:059493405231:table/lambda-ddb-streams-int-test/stream/2015-06-26T18:21:25.123" - } - ] -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_time_window_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_time_window_event.json deleted file mode 100644 index 237b7bd2..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/dynamodb_time_window_event.json +++ /dev/null @@ -1,101 +0,0 @@ -{ - "Records": [ - { - "eventID": "1", - "eventName": "INSERT", - "eventVersion": "1.0", - "eventSource": "aws:dynamodb", - "awsRegion": "us-east-1", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "NewImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "SequenceNumber": "111", - "SizeBytes": 26, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "eventSourceARN": "stream-ARN" - }, - { - "eventID": "2", - "eventName": "MODIFY", - "eventVersion": "1.0", - "eventSource": "aws:dynamodb", - "awsRegion": "us-east-1", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "NewImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "OldImage": { - "Message": { - "S": "New item!" - }, - "Id": { - "N": "101" - } - }, - "SequenceNumber": "222", - "SizeBytes": 59, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "eventSourceARN": "stream-ARN" - }, - { - "eventID": "3", - "eventName": "REMOVE", - "eventVersion": "1.0", - "eventSource": "aws:dynamodb", - "awsRegion": "us-east-1", - "dynamodb": { - "Keys": { - "Id": { - "N": "101" - } - }, - "OldImage": { - "Message": { - "S": "This item has changed" - }, - "Id": { - "N": "101" - } - }, - "SequenceNumber": "333", - "SizeBytes": 38, - "StreamViewType": "NEW_AND_OLD_IMAGES" - }, - "eventSourceARN": "stream-ARN" - } - ], - "window": { - "start": "2021-10-26T17:00:00Z", - "end": "2021-10-26T17:05:00Z" - }, - "state": { - "1": "state1" - }, - "shardId": "shard123456789", - "eventSourceARN": "stream-ARN", - "isFinalInvokeForWindow": false, - "isWindowTerminatedEarly": false -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/iot_button_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/iot_button_event.json deleted file mode 100644 index 8988caf0..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/iot_button_event.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "serialNumber": "ABCDEFG12345", - "clickType": "SINGLE", - "batteryVoltage": "2000 mV" -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_firehose_input_preprocessing_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_firehose_input_preprocessing_event.json deleted file mode 100644 index 862f17f2..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_firehose_input_preprocessing_event.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "invocationId":"00540a87-5050-496a-84e4-e7d92bbaf5e2", - "applicationArn":"arn:aws:kinesisanalytics:us-east-1:12345678911:application/lambda-test", - "streamArn":"arn:aws:firehose:us-east-1:AAAAAAAAAAAA:deliverystream/lambda-test", - "records":[ - { - "recordId":"49572672223665514422805246926656954630972486059535892482", - "data":"aGVsbG8gd29ybGQ=", - "kinesisFirehoseRecordMetadata":{ - "approximateArrivalTimestamp":1520280173 - } - } - ] - } \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_input_preprocessing_response_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_input_preprocessing_response_event.json deleted file mode 100644 index 59b899d6..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_input_preprocessing_response_event.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "records": [ - { - "recordId": "49572672223665514422805246926656954630972486059535892482", - "result": "Ok", - "data": "SEVMTE8gV09STEQ=" - } - ] - } - \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_event.json deleted file mode 100644 index d42688d7..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_event.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "invocationId": "00540a87-5050-496a-84e4-e7d92bbaf5e2", - "applicationArn": "arn:aws:kinesisanalytics:us-east-1:12345678911:application/lambda-test", - "records": [ - { - "recordId": "49572672223665514422805246926656954630972486059535892482", - "data": "aGVsbG8gd29ybGQ=" - } - ] -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_response_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_response_event.json deleted file mode 100644 index dba7b21d..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_output_delivery_response_event.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "records": [ - { - "recordId": "49572672223665514422805246926656954630972486059535892482", - "result": "Ok" - } - ] -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_streams_input_preprocessing_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_streams_input_preprocessing_event.json deleted file mode 100644 index f7ec383b..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_analytics_streams_input_preprocessing_event.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "invocationId": "00540a87-5050-496a-84e4-e7d92bbaf5e2", - "applicationArn": "arn:aws:kinesisanalytics:us-east-1:12345678911:application/lambda-test", - "streamArn": "arn:aws:kinesis:us-east-1:AAAAAAAAAAAA:stream/lambda-test", - "records": [ - { - "recordId": "49572672223665514422805246926656954630972486059535892482", - "data": "aGVsbG8gd29ybGQ=", - "kinesisStreamRecordMetadata":{ - "shardId" :"shardId-000000000003", - "partitionKey":"7400791606", - "sequenceNumber":"49572672223665514422805246926656954630972486059535892482", - "approximateArrivalTimestamp":1520280173 - } - } - ] -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_event.json deleted file mode 100644 index 854794cf..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_event.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "Records": [ - { - "kinesis": { - "partitionKey": "partitionKey-3", - "kinesisSchemaVersion": "1.0", - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=", - "sequenceNumber": "49545115243490985018280067714973144582180062593244200961" - }, - "eventSource": "aws:kinesis", - "eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", - "invokeIdentityArn": "arn:aws:iam::EXAMPLE", - "eventVersion": "1.0", - "eventName": "aws:kinesis:record", - "eventSourceARN": "arn:aws:kinesis:EXAMPLE", - "awsRegion": "us-east-1" - }, - { - "kinesis": { - "partitionKey": "partitionKey-3", - "kinesisSchemaVersion": "1.0", - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0IDEyMy4=", - "sequenceNumber": "49545115243490985018280067714973144582180062593244200961", - "approximateArrivalTimestamp": 1.455606024806E9 - }, - "eventSource": "aws:kinesis", - "eventID": "shardId-000000000000:49545115243490985018280067714973144582180062593244200961", - "invokeIdentityArn": "arn:aws:iam::EXAMPLE", - "eventVersion": "1.0", - "eventName": "aws:kinesis:record", - "eventSourceARN": "arn:aws:kinesis:EXAMPLE", - "awsRegion": "us-east-1" - } - ] -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_firehose_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_firehose_event.json deleted file mode 100644 index 3b1cd6c7..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_firehose_event.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "invocationId": "invoked123", - "deliveryStreamArn": "aws:lambda:events", - "region": "us-west-2", - "records": [ - { - "data": "SGVsbG8gV29ybGQ=", - "recordId": "record1", - "approximateArrivalEpoch": 1507217624302, - "approximateArrivalTimestamp": 1507217624302, - "kinesisRecordMetadata": { - "shardId": "shardId-000000000000", - "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c317a", - "approximateArrivalTimestamp": "1507217624302", - "sequenceNumber": "49546986683135544286507457936321625675700192471156785154", - "subsequenceNumber": "" - } - }, - { - "data": "SGVsbG8gV29ybGQ=", - "recordId": "record2", - "approximateArrivalEpoch": 1507217624302, - "approximateArrivalTimestamp": 1507217624302, - "kinesisRecordMetadata": { - "shardId": "shardId-000000000001", - "partitionKey": "4d1ad2b9-24f8-4b9d-a088-76e9947c318a", - "approximateArrivalTimestamp": "1507217624302", - "sequenceNumber": "49546986683135544286507457936321625675700192471156785155", - "subsequenceNumber": "" - } - } - ] -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_time_window_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_time_window_event.json deleted file mode 100644 index 02499226..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/kinesis_time_window_event.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "Records": [ - { - "kinesis": { - "kinesisSchemaVersion": "1.0", - "partitionKey": "1", - "sequenceNumber": "49590338271490256608559692538361571095921575989136588898", - "data": "SGVsbG8sIHRoaXMgaXMgYSB0ZXN0Lg==", - "approximateArrivalTimestamp": 1545084650.987 - }, - "eventSource": "aws:kinesis", - "eventVersion": "1.0", - "eventID": "shardId-000000000006:49590338271490256608559692538361571095921575989136588898", - "eventName": "aws:kinesis:record", - "invokeIdentityArn": "arn:aws:iam::123456789012:role/lambda-kinesis-role", - "awsRegion": "us-east-2", - "eventSourceARN": "arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream" - } - ], - "window": { - "start": "2021-10-26T17:00:00Z", - "end": "2021-10-26T17:05:00Z" - }, - "state": { - "1": "state1" - }, - "shardId": "shardId-000000000006", - "eventSourceARN": "arn:aws:kinesis:us-east-2:123456789012:stream/lambda-stream", - "isFinalInvokeForWindow": false, - "isWindowTerminatedEarly": false -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/lex_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/lex_event.json deleted file mode 100644 index 2961ac28..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/lex_event.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "messageVersion": "1.0", - "invocationSource": "FulfillmentCodeHook or DialogCodeHook", - "userId": "user-id specified in the POST request to Amazon Lex.", - "sessionAttributes": { - "key1": "value1", - "key2": "value2" - }, - "bot": { - "name": "bot-name", - "alias": "bot-alias", - "version": "bot-version" - }, - "outputDialogMode": "Text or Voice, based on ContentType request header in runtime API request", - "currentIntent": { - "name": "intent-name", - "slots": { - "slot1": "value", - "slot2": "value", - "slot3": "value" - }, - "confirmationStatus": "None" - } -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/s3_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/s3_event.json deleted file mode 100644 index 519bc1ce..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/s3_event.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Records": [ - { - "eventVersion": "2.0", - "eventSource": "aws:s3", - "awsRegion": "us-east-1", - "eventTime": "1970-01-01T00:00:00.000Z", - "eventName": "ObjectCreated:Put", - "userIdentity": { - "principalId": "EXAMPLE" - }, - "requestParameters": { - "sourceIPAddress": "127.0.0.1" - }, - "responseElements": { - "x-amz-request-id": "C3D13FE58DE4C810", - "x-amz-id-2": "FMyUVURIY8/IgAtTv8xRjskZQpcIZ9KG4V5Wp6S7S/JRWeUWerMUE5JgHvANOjpD" - }, - "s3": { - "s3SchemaVersion": "1.0", - "configurationId": "testConfigRule", - "bucket": { - "name": "sourcebucket", - "ownerIdentity": { - "principalId": "EXAMPLE" - }, - "arn": "arn:aws:s3:::mybucket" - }, - "object": { - "key": "Happy%20Face.jpg", - "size": 1024, - "urlDecodedKey": "Happy Face.jpg", - "versionId": "version", - "eTag": "d41d8cd98f00b204e9800998ecf8427e", - "sequencer": "Happy Sequencer" - } - } - } - ] -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/scheduled_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/scheduled_event.json deleted file mode 100644 index 3d803cc2..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/scheduled_event.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "account": "123456789012", - "region": "us-east-1", - "detail": {}, - "detail-type": "Scheduled Event", - "source": "aws.events", - "time": "1970-01-01T00:00:00.000Z", - "id": "cdc73f9d-aea9-11e3-9d5a-835b769c0d9c", - "resources": [ - "arn:aws:events:us-east-1:123456789012:rule/my-schedule" - ] -} \ No newline at end of file diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/sns_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/sns_event.json deleted file mode 100644 index ff624635..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/sns_event.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "Records": [ - { - "EventVersion": "1.0", - "EventSubscriptionArn": "arn:aws:sns:EXAMPLE", - "EventSource": "aws:sns", - "Sns": { - "Signature": "EXAMPLE", - "MessageId": "95df01b4-ee98-5cb9-9903-4c221d41eb5e", - "Type": "Notification", - "TopicArn": "arn:aws:sns:EXAMPLE", - "MessageAttributes": { - "Test": { - "Type": "String", - "Value": "TestString" - }, - "TestBinary": { - "Type": "Binary", - "Value": "TestBinary" - } - }, - "SignatureVersion": "1", - "Timestamp": "2015-06-03T17:43:27.020Z", - "SigningCertUrl": "EXAMPLE", - "Message": "Hello from SNS!", - "UnsubscribeUrl": "EXAMPLE", - "Subject": "TestInvoke" - } - } - ] -} diff --git a/aws-lambda-java-serialization/src/test/resources/event_models/sqs_event.json b/aws-lambda-java-serialization/src/test/resources/event_models/sqs_event.json deleted file mode 100644 index aa69c350..00000000 --- a/aws-lambda-java-serialization/src/test/resources/event_models/sqs_event.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "Records": [ - { - "messageId" : "MessageID_1", - "receiptHandle" : "MessageReceiptHandle", - "body" : "Message Body", - "md5OfBody" : "fce0ea8dd236ccb3ed9b37dae260836f", - "md5OfMessageAttributes" : "582c92c5c5b6ac403040a4f3ab3115c9", - "eventSourceARN": "arn:aws:sqs:us-west-2:123456789012:SQSQueue", - "eventSource": "aws:sqs", - "awsRegion": "us-west-2", - "attributes" : { - "ApproximateReceiveCount" : "2", - "SentTimestamp" : "1520621625029", - "SenderId" : "AROAIWPX5BD2BHG722MW4:sender", - "ApproximateFirstReceiveTimestamp" : "1520621634884" - }, - "messageAttributes" : { - "Attribute3" : { - "binaryValue" : "MTEwMA==", - "stringListValues" : ["abc", "123"], - "binaryListValues" : ["MA==", "MQ==", "MA=="], - "dataType" : "Binary" - }, - "Attribute2" : { - "stringValue" : "123", - "stringListValues" : [ ], - "binaryListValues" : ["MQ==", "MA=="], - "dataType" : "Number" - }, - "Attribute1" : { - "stringValue" : "AttributeValue1", - "stringListValues" : [ ], - "binaryListValues" : [ ], - "dataType" : "String" - } - } - } - ] -} diff --git a/aws-lambda-java-tests/pom.xml b/aws-lambda-java-tests/pom.xml index fa986750..2a2f1d0a 100644 --- a/aws-lambda-java-tests/pom.xml +++ b/aws-lambda-java-tests/pom.xml @@ -40,7 +40,7 @@ com.amazonaws aws-lambda-java-serialization - 1.0.0 + 1.1.2 com.amazonaws