forked from markusklems/aws-lambda-java-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestContext.java
More file actions
116 lines (93 loc) · 2.71 KB
/
Copy pathTestContext.java
File metadata and controls
116 lines (93 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package lambda;
import com.amazonaws.services.lambda.runtime.ClientContext;
import com.amazonaws.services.lambda.runtime.CognitoIdentity;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.LambdaLogger;
/**
* A simple mock implementation of the {@code Context} interface. Default
* values are stubbed out, and setters are provided so you can customize
* the context before passing it to your function.
*/
public class TestContext implements Context {
private String awsRequestId = "EXAMPLE";
private ClientContext clientContext;
private String functionName = "EXAMPLE";
private CognitoIdentity identity;
private String logGroupName = "EXAMPLE";
private String logStreamName = "EXAMPLE";
private LambdaLogger logger = new TestLogger();
private int memoryLimitInMB = 128;
private int remainingTimeInMillis = 15000;
@Override
public String getAwsRequestId() {
return awsRequestId;
}
public void setAwsRequestId(String value) {
awsRequestId = value;
}
@Override
public ClientContext getClientContext() {
return clientContext;
}
public void setClientContext(ClientContext value) {
clientContext = value;
}
@Override
public String getFunctionName() {
return functionName;
}
public void setFunctionName(String value) {
functionName = value;
}
@Override
public CognitoIdentity getIdentity() {
return identity;
}
public void setIdentity(CognitoIdentity value) {
identity = value;
}
@Override
public String getLogGroupName() {
return logGroupName;
}
public void setLogGroupName(String value) {
logGroupName = value;
}
@Override
public String getLogStreamName() {
return logStreamName;
}
public void setLogStreamName(String value) {
logStreamName = value;
}
@Override
public LambdaLogger getLogger() {
return logger;
}
public void setLogger(LambdaLogger value) {
logger = value;
}
@Override
public int getMemoryLimitInMB() {
return memoryLimitInMB;
}
public void setMemoryLimitInMB(int value) {
memoryLimitInMB = value;
}
@Override
public int getRemainingTimeInMillis() {
return remainingTimeInMillis;
}
public void setRemainingTimeInMillis(int value) {
remainingTimeInMillis = value;
}
/**
* A simple {@code LambdaLogger} that prints everything to stderr.
*/
private static class TestLogger implements LambdaLogger {
@Override
public void log(String message) {
System.err.println(message);
}
}
}