@@ -25,3 +25,53 @@ started with SAM in [the examples directory](../README.md)
25
25
26
26
## Test the application
27
27
28
+ ### 1. API Gateway Endpoint
29
+
30
+ To test the HTTP endpoint, we can post a product to the test URL:
31
+
32
+ ``` bash
33
+ curl -X POST https://[REST-API-ID].execute-api.[REGION].amazonaws.com/Prod/product/ -H " Content-Type: application/json" -d ' {"id": 1234, "name": "product", "price": 42}'
34
+ ```
35
+
36
+ The result will indicate that the handler has successfully deserialized the request body:
37
+
38
+ ```
39
+ Received request for productId: 1234
40
+ ```
41
+
42
+ If we look at the logs using ` sam logs --tail --stack-name $MY_STACK ` , we will see the full deserialized request:
43
+
44
+ ``` json
45
+ {
46
+ ...
47
+ "level" : " INFO" ,
48
+ "loggerName" : " org.demo.serialization.APIGatewayRequestDeserializationFunction" ,
49
+ "message" : " product=Product{id=1234, name='product', price=42.0}\n " ,
50
+ ...
51
+ }
52
+ ```
53
+
54
+ ### 2. SQS Queue
55
+ For the SQS handler, we have to send a request to our queue. We can either construct the Queue URL (see below), or
56
+ find it from the SQS section of the AWS console.
57
+
58
+ ``` bash
59
+ aws sqs send-message --queue-url " https://sqs.[REGION].amazonaws.com/[ACCOUNT-ID]/sqs-event-deserialization-queue" --message-body ' {"id": 1234, "name": "product", "price"
60
+ ```
61
+
62
+ Here we can find the message by filtering through the logs for messages that have come back from our SQS handler:
63
+
64
+ ```bash
65
+ sam logs --tail --stack-name $MY_STACK --filter SQS
66
+ ```
67
+
68
+ ```bash
69
+ {
70
+ ...
71
+ "level": "INFO",
72
+ "loggerName": "org.demo.serialization.SQSEventDeserializationFunction",
73
+ "message": "products=[Product{id=1234, name=' product' , price=42.0}]\n",
74
+ ...
75
+ }
76
+
77
+ ```
0 commit comments