File tree 4 files changed +71
-5
lines changed 4 files changed +71
-5
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "TemperatureK " : 281 ,
3
- "WindKmh " : -3 ,
4
- "HumidityPct " : 0.55 ,
5
- "PressureHPa " : 1020
2
+ "temperatureK " : 281 ,
3
+ "windKmh " : -3 ,
4
+ "humidityPct " : 0.55 ,
5
+ "pressureHPa " : 1020
6
6
}
Original file line number Diff line number Diff line change
1
+ package example ;
2
+
3
+ import com .amazonaws .services .lambda .runtime .Context ;
4
+ import com .amazonaws .services .lambda .runtime .RequestHandler ;
5
+ import com .amazonaws .services .lambda .runtime .LambdaLogger ;
6
+
7
+ import com .google .gson .Gson ;
8
+ import com .google .gson .GsonBuilder ;
9
+
10
+ import java .util .Map ;
11
+
12
+ // Handler value: example.HandlerWeatherData
13
+ public class HandlerWeatherData implements RequestHandler <WeatherData , WeatherData >{
14
+ Gson gson = new GsonBuilder ().setPrettyPrinting ().create ();
15
+ @ Override
16
+ public WeatherData handleRequest (WeatherData event , Context context )
17
+ {
18
+ LambdaLogger logger = context .getLogger ();
19
+ // process event
20
+ logger .log ("EVENT: " + gson .toJson (event ));
21
+ logger .log ("EVENT TYPE: " + event .getClass ().toString ());
22
+ return event ;
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ package example ;
2
+
3
+ public class WeatherData {
4
+
5
+ private Integer temperatureK ;
6
+ private Integer windKmh ;
7
+ private Double humidityPct ;
8
+ private Integer pressureHPa ;
9
+
10
+ public Integer getTemperatureK () {
11
+ return temperatureK ;
12
+ }
13
+
14
+ public void setTemperatureK (Integer temperatureK ) {
15
+ this .temperatureK = temperatureK ;
16
+ }
17
+
18
+ public Integer getWindKmh () {
19
+ return windKmh ;
20
+ }
21
+
22
+ public void setWindKmh (Integer windKmh ) {
23
+ this .windKmh = windKmh ;
24
+ }
25
+
26
+ public Double getHumidityPct () {
27
+ return humidityPct ;
28
+ }
29
+
30
+ public void setHumidityPct (Double humidityPct ) {
31
+ this .humidityPct = humidityPct ;
32
+ }
33
+
34
+ public Integer getPressureHPa () {
35
+ return pressureHPa ;
36
+ }
37
+
38
+ public void setPressureHPa (Integer pressureHPa ) {
39
+ this .pressureHPa = pressureHPa ;
40
+ }
41
+
42
+ }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ void invokeTest() {
25
25
String requestId = context .getAwsRequestId ();
26
26
Handler handler = new Handler ();
27
27
String result = handler .handleRequest (event , context );
28
- assertTrue (result .contains ("SUCCESS " ));
28
+ assertTrue (result .contains ("200 OK " ));
29
29
}
30
30
31
31
}
You can’t perform that action at this time.
0 commit comments