Skip to content

Commit 442ca30

Browse files
committed
Code review related update
1 parent 1aad3e4 commit 442ca30

File tree

2 files changed

+18
-218
lines changed

2 files changed

+18
-218
lines changed

aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/ScheduledV2Event.java

Lines changed: 11 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55

66
package com.amazonaws.services.lambda.runtime.events;
77

8+
import lombok.AllArgsConstructor;
9+
import lombok.Builder;
10+
import lombok.Data;
11+
import lombok.NoArgsConstructor;
812
import org.joda.time.DateTime;
913

1014
import java.io.Serializable;
1115
import java.util.List;
1216

1317
/**
14-
* represents a scheduled V2 event
18+
* Represents a Scheduled V2 event sent to Lambda
19+
* <a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-function-schedulev2.html">ScheduleV2</a>
1520
*/
21+
@Data
22+
@Builder(setterPrefix = "with")
23+
@NoArgsConstructor
24+
@AllArgsConstructor
1625
public class ScheduledV2Event implements Serializable, Cloneable {
1726

1827
private static final long serialVersionUID = -463442139623175611L;
@@ -35,219 +44,6 @@ public class ScheduledV2Event implements Serializable, Cloneable {
3544

3645
private List<String> resources;
3746

38-
/**
39-
* default constructor
40-
*/
41-
public ScheduledV2Event() {
42-
}
43-
44-
/**
45-
* @return the version number
46-
*/
47-
public String getVersion() {
48-
return version;
49-
}
50-
51-
/**
52-
* @param version the version number
53-
*/
54-
public void setVersion(String version) {
55-
this.version = version;
56-
}
57-
58-
/**
59-
* @param version version number
60-
* @return ScheduledV2Event
61-
*/
62-
public ScheduledV2Event withVersion(String version) {
63-
setVersion(version);
64-
return this;
65-
}
66-
67-
/**
68-
* @return the account id
69-
*/
70-
public String getAccount() {
71-
return account;
72-
}
73-
74-
/**
75-
* @param account the account id
76-
*/
77-
public void setAccount(String account) {
78-
this.account = account;
79-
}
80-
81-
/**
82-
* @param account account id
83-
* @return ScheduledV2Event
84-
*/
85-
public ScheduledV2Event withAccount(String account) {
86-
setAccount(account);
87-
return this;
88-
}
89-
90-
/**
91-
* @return the aws region
92-
*/
93-
public String getRegion() {
94-
return region;
95-
}
96-
97-
/**
98-
* @param region the aws region
99-
*/
100-
public void setRegion(String region) {
101-
this.region = region;
102-
}
103-
104-
/**
105-
* @param region aws region
106-
* @return ScheduledV2Event
107-
*/
108-
public ScheduledV2Event withRegion(String region) {
109-
setRegion(region);
110-
return this;
111-
}
112-
113-
/**
114-
* @return The details of the events (usually left blank)
115-
*/
116-
public String getDetail() {
117-
return detail;
118-
}
119-
120-
/**
121-
* @param detail The details of the events (usually left blank)
122-
*/
123-
public void setDetail(String detail) {
124-
this.detail = detail;
125-
}
126-
127-
/**
128-
* @param detail details of the events (usually left blank)
129-
* @return ScheduledV2Event
130-
*/
131-
public ScheduledV2Event withDetail(String detail) {
132-
setDetail(detail);
133-
return this;
134-
}
135-
136-
/**
137-
* @return The details type - see cloud watch events for more info
138-
*/
139-
public String getDetailType() {
140-
return detailType;
141-
}
142-
143-
/**
144-
* @param detailType The details type - see cloud watch events for more info
145-
*/
146-
public void setDetailType(String detailType) {
147-
this.detailType = detailType;
148-
}
149-
150-
/**
151-
* @param detailType The details type - see cloud watch events for more info
152-
* @return ScheduledV2Event
153-
*/
154-
public ScheduledV2Event withDetailType(String detailType) {
155-
setDetailType(detailType);
156-
return this;
157-
}
158-
159-
/**
160-
* @return the source of the event
161-
*/
162-
public String getSource() {
163-
return source;
164-
}
165-
166-
/**
167-
* @param source the source of the event
168-
*/
169-
public void setSource(String source) {
170-
this.source = source;
171-
}
172-
173-
/**
174-
* @param source source of the event
175-
* @return ScheduledV2Event
176-
*/
177-
public ScheduledV2Event withSource(String source) {
178-
setSource(source);
179-
return this;
180-
}
181-
182-
/**
183-
* @return the timestamp for when the event is scheduled
184-
*/
185-
public DateTime getTime() {
186-
return this.time;
187-
}
188-
189-
/**
190-
* @param time the timestamp for when the event is scheduled
191-
*/
192-
public void setTime(DateTime time) {
193-
this.time = time;
194-
}
195-
196-
/**
197-
* @param time the timestamp for when the event is scheduled
198-
* @return ScheduledV2Event
199-
*/
200-
public ScheduledV2Event withTime(DateTime time) {
201-
setTime(time);
202-
return this;
203-
}
204-
205-
/**
206-
* @return the id of the event
207-
*/
208-
public String getId() {
209-
return id;
210-
}
211-
212-
/**
213-
* @param id the id of the event
214-
*/
215-
public void setId(String id) {
216-
this.id = id;
217-
}
218-
219-
/**
220-
* @param id id of event
221-
* @return ScheduledV2Event
222-
*/
223-
public ScheduledV2Event withId(String id) {
224-
setId(id);
225-
return this;
226-
}
227-
228-
/**
229-
* @return the resources used by event
230-
*/
231-
public List<String> getResources() {
232-
return this.resources;
233-
}
234-
235-
/**
236-
* @param resources the resources used by event
237-
*/
238-
public void setResources(List<String> resources) {
239-
this.resources = resources;
240-
}
241-
242-
/**
243-
* @param resources list of resource names
244-
* @return Scheduled V2 event object
245-
*/
246-
public ScheduledV2Event withResources(List<String> resources) {
247-
setResources(resources);
248-
return this;
249-
}
250-
25147
/**
25248
* Returns a string representation of this object; useful for testing and debugging.
25349
*
@@ -287,7 +83,7 @@ public boolean equals(Object obj) {
28783
if (obj == null)
28884
return false;
28985

290-
if (obj instanceof ScheduledV2Event == false)
86+
if (!(obj instanceof ScheduledV2Event))
29187
return false;
29288
ScheduledV2Event other = (ScheduledV2Event) obj;
29389
if (other.getVersion() == null ^ this.getVersion() == null)

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import org.junit.jupiter.api.Test;
1010

1111
import java.time.Instant;
12-
import java.util.Date;
13-
import java.util.List;
14-
import java.util.Map;
12+
import java.util.*;
1513

1614
import static java.time.Instant.ofEpochSecond;
1715
import static org.assertj.core.api.Assertions.*;
@@ -367,9 +365,15 @@ public void testLoadScheduledV2Event() {
367365
ScheduledV2Event event = EventLoader.loadScheduledV2Event("scheduler_event.json");
368366

369367
assertThat(event).isNotNull();
368+
assertThat(event.getVersion()).isEqualTo("0");
369+
assertThat(event.getId()).isEqualTo("4e6638b7-b892-4482-9762-8c58d4e71ecc");
370370
assertThat(event.getDetailType()).isEqualTo("Scheduled Event");
371371
assertThat(event.getSource()).isEqualTo("aws.scheduler");
372+
assertThat(event.getAccount()).isEqualTo("123456789012");
372373
assertThat(event.getTime()).isEqualTo(DateTime.parse("2024-05-07T15:58:34Z"));
374+
assertThat(event.getRegion()).isEqualTo("eu-central-1");
375+
assertThat(event.getResources()).isNotEmpty();
376+
assertThat(event.getResources()).isEqualTo(Collections.singletonList("arn:aws:scheduler:eu-central-1:123456789012:schedule/default/demoschedule"));
373377
assertThat(event.getDetail()).isEqualTo("{}");
374378
}
375379
}

0 commit comments

Comments
 (0)