Skip to content

Commit cde5fc7

Browse files
jeromevdlcarlzogh
authored andcommitted
review + javadoc + release
1 parent db42970 commit cde5fc7

File tree

17 files changed

+248
-72
lines changed

17 files changed

+248
-72
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Check out the per-module release notes:
2121
- [aws-lambda-java-log4j2](aws-lambda-java-log4j2/RELEASE.CHANGELOG.md)
2222
- [aws-lambda-java-runtime-interface-client](aws-lambda-java-runtime-interface-client/RELEASE.CHANGELOG.md)
2323
- [aws-lambda-java-serialization](aws-lambda-java-serialization/RELEASE.CHANGELOG.md)
24+
- [aws-lambda-java-test](aws-lambda-java-tests/RELEASE.CHANGELOG.md)
2425

2526
# Where to get packages
2627
___
@@ -53,6 +54,12 @@ ___
5354
<artifactId>aws-lambda-java-runtime-interface-client</artifactId>
5455
<version>1.0.0</version>
5556
</dependency>
57+
<dependency>
58+
<groupId>com.amazonaws</groupId>
59+
<artifactId>aws-lambda-java-tests</artifactId>
60+
<version>1.0.0</version>
61+
<scope>test</scope>
62+
</dependency>
5663
```
5764

5865
[Gradle](https://gradle.org)
@@ -63,6 +70,7 @@ ___
6370
'com.amazonaws:aws-lambda-java-events-sdk-transformer:3.0.1'
6471
'com.amazonaws:aws-lambda-java-log4j2:1.2.0'
6572
'com.amazonaws:aws-lambda-java-runtime-interface-client:1.0.0'
73+
'com.amazonaws:aws-lambda-java-tests:1.0.0'
6674
```
6775

6876
[Leiningen](http://leiningen.org) and [Boot](http://boot-clj.com)
@@ -73,6 +81,7 @@ ___
7381
[com.amazonaws/aws-lambda-java-events-sdk-transformer "3.0.1"]
7482
[com.amazonaws/aws-lambda-java-log4j2 "1.2.0"]
7583
[com.amazonaws/aws-lambda-java-runtime-interface-client "1.0.0"]
84+
[com.amazonaws/aws-lambda-java-tests "1.0.0"]
7685
```
7786

7887
[sbt](http://www.scala-sbt.org)
@@ -83,6 +92,7 @@ ___
8392
"com.amazonaws" % "aws-lambda-java-events-sdk-transformer" % "3.0.1"
8493
"com.amazonaws" % "aws-lambda-java-log4j2" % "1.2.0"
8594
"com.amazonaws" % "aws-lambda-java-runtime-interface-client" % "1.0.0"
95+
"com.amazonaws" % "aws-lambda-java-tests" % "1.0.0"
8696
```
8797

8898
# Using aws-lambda-java-core
@@ -114,3 +124,7 @@ The purpose of this package is to allow developers to deploy their applications
114124
# Using aws-lambda-java-serialization
115125

116126
This package defines the Lambda serialization logic using in the aws-lambda-java-runtime-client library. It has no current standalone usage.
127+
128+
# Using aws-lambda-java-tests
129+
130+
This package provides utils to ease Lambda Java testing. Used with `aws-lambda-java-serialization` and `aws-lambda-java-events` to inject events in your JUnit tests.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### December 03, 2020
2+
`1.0.0`:
3+
- Initial release of AWS Lambda Java Tests

aws-lambda-java-tests/pom.xml

+159
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,165 @@
7575
</dependency>
7676
</dependencies>
7777

78+
<profiles>
79+
<profile>
80+
<id>checkDependencies</id>
81+
<activation>
82+
<property>
83+
<name>checkDependencies</name>
84+
</property>
85+
</activation>
86+
<build>
87+
<plugins>
88+
<plugin>
89+
<groupId>org.owasp</groupId>
90+
<artifactId>dependency-check-maven</artifactId>
91+
<version>5.3.2</version>
92+
<executions>
93+
<execution>
94+
<phase>validate</phase>
95+
<goals>
96+
<goal>check</goal>
97+
</goals>
98+
</execution>
99+
</executions>
100+
</plugin>
101+
</plugins>
102+
</build>
103+
</profile>
104+
<profile>
105+
<id>dev</id>
106+
<build>
107+
<plugins>
108+
<plugin>
109+
<groupId>org.apache.maven.plugins</groupId>
110+
<artifactId>maven-javadoc-plugin</artifactId>
111+
<version>3.2.0</version>
112+
<configuration>
113+
<doclint>none</doclint>
114+
<failOnError>false</failOnError>
115+
<source>8</source>
116+
<detectJavaApiLink>false</detectJavaApiLink>
117+
</configuration>
118+
<executions>
119+
<execution>
120+
<id>attach-javadocs</id>
121+
<goals>
122+
<goal>jar</goal>
123+
</goals>
124+
</execution>
125+
</executions>
126+
</plugin>
127+
<plugin>
128+
<groupId>org.jacoco</groupId>
129+
<artifactId>jacoco-maven-plugin</artifactId>
130+
<version>0.8.6</version>
131+
<executions>
132+
<execution>
133+
<id>default-prepare-agent</id>
134+
<goals>
135+
<goal>prepare-agent</goal>
136+
</goals>
137+
</execution>
138+
<execution>
139+
<id>default-report</id>
140+
<phase>test</phase>
141+
<goals>
142+
<goal>report</goal>
143+
</goals>
144+
</execution>
145+
<execution>
146+
<id>default-check</id>
147+
<phase>test</phase>
148+
<goals>
149+
<goal>check</goal>
150+
</goals>
151+
<configuration>
152+
<rules>
153+
<rule>
154+
<element>PACKAGE</element>
155+
<limits>
156+
<limit>
157+
<counter>LINE</counter>
158+
<value>COVEREDRATIO</value>
159+
<minimum>0</minimum>
160+
</limit>
161+
</limits>
162+
</rule>
163+
</rules>
164+
</configuration>
165+
</execution>
166+
</executions>
167+
</plugin>
168+
</plugins>
169+
</build>
170+
</profile>
171+
<profile>
172+
<id>release</id>
173+
<build>
174+
<plugins>
175+
<plugin>
176+
<groupId>org.apache.maven.plugins</groupId>
177+
<artifactId>maven-source-plugin</artifactId>
178+
<version>2.2.1</version>
179+
<executions>
180+
<execution>
181+
<id>attach-sources</id>
182+
<goals>
183+
<goal>jar-no-fork</goal>
184+
</goals>
185+
</execution>
186+
</executions>
187+
</plugin>
188+
<plugin>
189+
<groupId>org.apache.maven.plugins</groupId>
190+
<artifactId>maven-javadoc-plugin</artifactId>
191+
<version>3.2.0</version>
192+
<configuration>
193+
<doclint>none</doclint>
194+
<failOnError>false</failOnError>
195+
<source>8</source>
196+
<detectJavaApiLink>false</detectJavaApiLink>
197+
</configuration>
198+
<executions>
199+
<execution>
200+
<id>attach-javadocs</id>
201+
<goals>
202+
<goal>jar</goal>
203+
</goals>
204+
</execution>
205+
</executions>
206+
</plugin>
207+
<plugin>
208+
<groupId>org.apache.maven.plugins</groupId>
209+
<artifactId>maven-gpg-plugin</artifactId>
210+
<version>1.5</version>
211+
<executions>
212+
<execution>
213+
<id>sign-artifacts</id>
214+
<phase>verify</phase>
215+
<goals>
216+
<goal>sign</goal>
217+
</goals>
218+
</execution>
219+
</executions>
220+
</plugin>
221+
<plugin>
222+
<groupId>org.sonatype.plugins</groupId>
223+
<artifactId>nexus-staging-maven-plugin</artifactId>
224+
<version>1.6.3</version>
225+
<extensions>true</extensions>
226+
<configuration>
227+
<serverId>sonatype-nexus-staging</serverId>
228+
<nexusUrl>https://aws.oss.sonatype.org/</nexusUrl>
229+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
230+
</configuration>
231+
</plugin>
232+
</plugins>
233+
</build>
234+
</profile>
235+
</profiles>
236+
78237
<build>
79238
<plugins>
80239
<plugin>

aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/annotations/Event.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
* This annotation must be used in conjunction with {@link org.junit.jupiter.params.ParameterizedTest}.<br/>
1111
* It enables to inject an event (loaded from a json file) of the desired type into the current test.<br/>
1212
* Example:<br/>
13-
* <pre>{@code
14-
* @ParameterizedTest
15-
* @Event(value = "sqs_event.json", type = SQSEvent.class)
13+
* <pre>
14+
* &#64;ParameterizedTest
15+
* &#64;Event(value = "sqs_event.json", type = SQSEvent.class)
1616
* public void testInjectEvent(SQSEvent event) {
1717
* assertThat(event).isNotNull();
1818
* assertThat(event.getRecords()).hasSize(1);
1919
* }
20-
* }</pre>
20+
* </pre>
2121
*/
2222
@Documented
2323
@Target(ElementType.METHOD)

aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/annotations/Events.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
* <ul>
1515
* <li>
1616
* Using the <code>folder</code> parameter is the more straightforward, and it will use all files in the folder<br/>
17-
* <pre>{@code
18-
* @ParameterizedTest
19-
* @Events(folder = "sqs", type = SQSEvent.class)
17+
* <pre>
18+
* &#64;ParameterizedTest
19+
* &#64;Events(folder = "sqs", type = SQSEvent.class)
2020
* public void testInjectEventsFromFolder(SQSEvent event) {
2121
* assertThat(event).isNotNull();
2222
* assertThat(event.getRecords()).hasSize(1);
2323
* }
24-
* }</pre>
24+
* </pre>
2525
* </li>
2626
* <li>
2727
* Or you can list all the {@link Event}s<br/>
28-
* <pre>{@code
29-
* @ParameterizedTest
30-
* @Events(
28+
* <pre>
29+
* &#64;ParameterizedTest
30+
* &#64;Events(
3131
* events = {
32-
* @Event("sqs/sqs_event.json"),
33-
* @Event("sqs/sqs_event2.json"),
32+
* &#64;Event("sqs/sqs_event.json"),
33+
* &#64;Event("sqs/sqs_event2.json"),
3434
* },
3535
* type = SQSEvent.class
3636
* )
@@ -39,18 +39,18 @@
3939
* assertThat(event.getRecords()).hasSize(1);
4040
* }
4141
*
42-
* @ParameterizedTest
43-
* @Events(
42+
* &#64;ParameterizedTest
43+
* &#64;Events(
4444
* events = {
45-
* @Event(value = "sqs/sqs_event.json", type = SQSEvent.class),
46-
* @Event(value = "sqs/sqs_event2.json", type = SQSEvent.class),
45+
* &#64;Event(value = "sqs/sqs_event.json", type = SQSEvent.class),
46+
* &#64;Event(value = "sqs/sqs_event2.json", type = SQSEvent.class),
4747
* }
4848
* )
4949
* public void testInjectEvents2(SQSEvent event) {
5050
* assertThat(event).isNotNull();
5151
* assertThat(event.getRecords()).hasSize(1);
5252
* }
53-
* }</pre>
53+
* </pre>
5454
* </li>
5555
* </ul>
5656
* </p>

aws-lambda-java-tests/src/main/java/com/amazonaws/services/lambda/runtime/tests/annotations/HandlerParams.java

+18-18
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,41 @@
1313
* or {@link #events()} and {@link #responses()} for multiple ones.<br/>
1414
*
1515
* Example:<br/>
16-
* <pre>{@code
17-
* @ParameterizedTest
18-
* @HandlerParams(
19-
* event = @Event(value = "apigw/events/apigw_event.json", type = APIGatewayProxyRequestEvent.class),
20-
* response = @Response(value = "apigw/responses/apigw_response.json", type = APIGatewayProxyResponseEvent.class))
16+
* <pre>
17+
* &#64;ParameterizedTest
18+
* &#64;HandlerParams(
19+
* event = &#64;Event(value = "apigw/events/apigw_event.json", type = APIGatewayProxyRequestEvent.class),
20+
* response = &#64;Response(value = "apigw/responses/apigw_response.json", type = APIGatewayProxyResponseEvent.class))
2121
* public void testSingleEventResponse(APIGatewayProxyRequestEvent event, APIGatewayProxyResponseEvent response) {
2222
* }
2323
*
24-
* @ParameterizedTest
25-
* @HandlerParams(
26-
* events = @Events(folder = "apigw/events/", type = APIGatewayProxyRequestEvent.class),
27-
* responses = @Responses(folder = "apigw/responses/", type = APIGatewayProxyResponseEvent.class))
24+
* &#64;ParameterizedTest
25+
* &#64;HandlerParams(
26+
* events = &#64;Events(folder = "apigw/events/", type = APIGatewayProxyRequestEvent.class),
27+
* responses = &#64;Responses(folder = "apigw/responses/", type = APIGatewayProxyResponseEvent.class))
2828
* public void testMultipleEventsResponsesInFolder(APIGatewayProxyRequestEvent event, APIGatewayProxyResponseEvent response) {
2929
* }
3030
*
31-
* @ParameterizedTest
32-
* @HandlerParams(
33-
* events = @Events(
31+
* &#64;ParameterizedTest
32+
* &#64;HandlerParams(
33+
* events = &#64;Events(
3434
* events = {
35-
* @Event("apigw/events/apigw_event.json"),
36-
* @Event("apigw/events/apigw_event2.json"),
35+
* &#64;Event("apigw/events/apigw_event.json"),
36+
* &#64;Event("apigw/events/apigw_event2.json"),
3737
* },
3838
* type = APIGatewayProxyRequestEvent.class
3939
* ),
40-
* responses = @Responses(
40+
* responses = &#64;Responses(
4141
* responses = {
42-
* @Response("apigw/responses/apigw_response.json"),
43-
* @Response("apigw/responses/apigw_response2.json")
42+
* &#64;Response("apigw/responses/apigw_response.json"),
43+
* &#64;Response("apigw/responses/apigw_response2.json")
4444
* },
4545
* type = APIGatewayProxyResponseEvent.class
4646
* )
4747
* )
4848
* public void testMultipleEventsResponses(APIGatewayProxyRequestEvent event, APIGatewayProxyResponseEvent response) {
4949
* }
50-
* }</pre>
50+
* </pre>
5151
*/
5252
@Documented
5353
@Target(ElementType.METHOD)

aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventLoaderTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void testLoadS3Event() {
124124

125125
@Test
126126
public void testLoadSQSEvent() {
127-
SQSEvent event = EventLoader.loadSQSEvent("sqs/sqs_event.json");
127+
SQSEvent event = EventLoader.loadSQSEvent("sqs/sqs_event_nobody.json");
128128
assertThat(event).isNotNull();
129129
assertThat(event.getRecords()).hasSize(1);
130130
assertThat(event.getRecords().get(0).getEventSourceArn()).isEqualTo("arn:aws:sqs:eu-central-1:123456789012:TestLambda");

aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public class EventTest {
1111

1212
@ParameterizedTest
13-
@Event(value = "sqs/sqs_event.json", type = SQSEvent.class)
13+
@Event(value = "sqs/sqs_event_nobody.json", type = SQSEvent.class)
1414
public void testInjectEvent(SQSEvent event) {
1515
assertThat(event).isNotNull();
1616
assertThat(event.getRecords()).hasSize(1);

aws-lambda-java-tests/src/test/java/com/amazonaws/services/lambda/runtime/tests/EventsTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public class EventsTest {
1414
@ParameterizedTest
1515
@Events(
1616
events = {
17-
@Event("sqs/sqs_event.json"),
18-
@Event("sqs/sqs_event2.json"),
17+
@Event("sqs/sqs_event_nobody.json"),
18+
@Event("sqs/sqs_event_product.json"),
1919
},
2020
type = SQSEvent.class
2121
)
@@ -27,8 +27,8 @@ public void testInjectEvents(SQSEvent event) {
2727
@ParameterizedTest
2828
@Events(
2929
events = {
30-
@Event(value = "sqs/sqs_event.json", type = SQSEvent.class),
31-
@Event(value = "sqs/sqs_event2.json", type = SQSEvent.class),
30+
@Event(value = "sqs/sqs_event_nobody.json", type = SQSEvent.class),
31+
@Event(value = "sqs/sqs_event_product.json", type = SQSEvent.class),
3232
}
3333
)
3434
public void testInjectEvents2(SQSEvent event) {

0 commit comments

Comments
 (0)