Skip to content

Commit 1a271f9

Browse files
committed
Fixing Lambda integ tests and adding protocol tests for status code
1 parent 0569a80 commit 1a271f9

File tree

7 files changed

+51
-2
lines changed

7 files changed

+51
-2
lines changed

codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ParameterHttpMapping.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ public MarshallLocation getMarshallLocation() {
173173
switch (location) {
174174
default:
175175
return MarshallLocation.PAYLOAD;
176+
case STATUS_CODE:
177+
return MarshallLocation.STATUS_CODE;
176178
case HEADER:
177179
case HEADERS:
178180
return MarshallLocation.HEADER;

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/protocol/json/unmarshall/JsonProtocolUnmarshaller.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public final class JsonProtocolUnmarshaller<TypeT extends SdkPojo> {
4646

4747
private static final UnmarshallerRegistry REGISTRY = UnmarshallerRegistry
4848
.builder()
49+
.statusCodeUnmarshaller(MarshallingType.INTEGER, (context, json, f) -> context.response().statusCode())
4950
.headerUnmarshaller(MarshallingType.STRING, HeaderUnmarshaller.STRING)
5051
.headerUnmarshaller(MarshallingType.INTEGER, HeaderUnmarshaller.INTEGER)
5152
.headerUnmarshaller(MarshallingType.LONG, HeaderUnmarshaller.LONG)

core/sdk-core/src/main/java/software/amazon/awssdk/core/internal/protocol/json/unmarshall/UnmarshallerRegistry.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ public <T> Builder headerUnmarshaller(MarshallingType<T> marshallingType,
6666
return addUnmarshaller(MarshallLocation.HEADER, marshallingType, marshaller);
6767
}
6868

69+
public <T> Builder statusCodeUnmarshaller(MarshallingType<T> marshallingType,
70+
JsonUnmarshaller<T> marshaller) {
71+
return addUnmarshaller(MarshallLocation.STATUS_CODE, marshallingType, marshaller);
72+
}
73+
6974
private <T> Builder addUnmarshaller(MarshallLocation marshallLocation,
7075
MarshallingType<T> marshallingType,
7176
JsonUnmarshaller<T> marshaller) {

core/sdk-core/src/main/java/software/amazon/awssdk/core/protocol/MarshallLocation.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,11 @@ public enum MarshallLocation {
4848
* the only difference is whether it's URL encoded or not. Members bound to the {@link #PATH} will be URL
4949
* encoded before replacing, members bound to {@link #GREEDY_PATH} will not be URL encoded.
5050
*/
51-
GREEDY_PATH
51+
GREEDY_PATH,
52+
53+
/**
54+
* HTTP status code of response.
55+
*/
56+
STATUS_CODE;
57+
5258
}

test/protocol-tests-core/src/main/resources/software/amazon/awssdk/protocol/suites/cases/rest-json-output.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,22 @@
9797
"IsoTimestampMember": 1398796238000
9898
}
9999
}
100+
},
101+
{
102+
"description": "Integer bound to HTTP status code is unmarshalled correctly",
103+
"given": {
104+
"response": {
105+
"status_code": 201
106+
}
107+
},
108+
"when": {
109+
"action": "unmarshall",
110+
"operation": "StatusCodeInOutputOperation"
111+
},
112+
"then": {
113+
"deserializedAs": {
114+
"StatusCodeMember": 201
115+
}
116+
}
100117
}
101118
]

test/protocol-tests/src/main/resources/codegen-resources/restjson/customization.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"headOperation",
1616
"jsonValuesOperation",
1717
"nestedContainers",
18-
"furtherNestedContainers"
18+
"furtherNestedContainers",
19+
"statusCodeInOutputOperation"
1920
]
2021
}

test/protocol-tests/src/main/resources/codegen-resources/restjson/service-2.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@
167167
},
168168
"input":{"shape":"QueryParamWithoutValueInput"}
169169
},
170+
"StatusCodeInOutputOperation":{
171+
"name":"StatusCodeInOutputOperation",
172+
"http":{
173+
"method":"GET",
174+
"requestUri":"/2016-03-11/statusCodeInOutput"
175+
},
176+
"output":{"shape":"StatusCodeInOutputStructure"}
177+
},
170178
"StreamingInputOperation":{
171179
"name":"StreamingInputOperation",
172180
"http":{
@@ -603,6 +611,15 @@
603611
"StringMember":{"shape":"String"}
604612
}
605613
},
614+
"StatusCodeInOutputStructure":{
615+
"type":"structure",
616+
"members":{
617+
"StatusCodeMember":{
618+
"shape":"Integer",
619+
"location":"statusCode"
620+
}
621+
}
622+
},
606623
"StreamType":{
607624
"type":"blob",
608625
"streaming":true

0 commit comments

Comments
 (0)