Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for map of sets to restJson protocol test. #684

Merged
merged 2 commits into from
Jun 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 186 additions & 0 deletions smithy-aws-protocol-tests/model/restJson1/json-maps.smithy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use aws.protocols#restJson1
use aws.protocoltests.shared#FooEnumMap
use aws.protocoltests.shared#GreetingStruct
use aws.protocoltests.shared#SparseStringMap
use aws.protocoltests.shared#StringSet
use smithy.test#httpRequestTests
use smithy.test#httpResponseTests

Expand Down Expand Up @@ -146,6 +147,80 @@ apply JsonMaps @httpRequestTests([
"x": false
}
}
},
{
id: "RestJsonSerializesSparseSetMap",
documentation: "A request that contains a sparse map of sets",
protocol: restJson1,
method: "POST",
uri: "/JsonMaps",
body: """
{
"sparseSetMap": {
"x": [],
"y": ["a", "b"]
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/json"
},
params: {
"sparseSetMap": {
"x": [],
"y": ["a", "b"]
}
}
},
{
id: "RestJsonSerializesDenseSetMap",
documentation: "A request that contains a dense map of sets.",
protocol: restJson1,
method: "POST",
uri: "/JsonMaps",
body: """
{
"denseSetMap": {
"x": [],
"y": ["a", "b"]
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/json"
},
params: {
"denseSetMap": {
"x": [],
"y": ["a", "b"]
}
}
},
{
id: "RestJsonSerializesSparseSetMapAndRetainsNull",
documentation: "A request that contains a sparse map of sets.",
protocol: restJson1,
method: "POST",
uri: "/JsonMaps",
body: """
{
"sparseSetMap": {
"x": [],
"y": ["a", "b"],
"z": null
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/json"
},
params: {
"sparseSetMap": {
"x": [],
"y": ["a", "b"],
"z": null
}
}
}
])

Expand Down Expand Up @@ -274,6 +349,104 @@ apply JsonMaps @httpResponseTests([
"x": false
}
}
},
{
id: "RestJsonDeserializesSparseSetMap",
documentation: "A response that contains a sparse map of sets",
protocol: restJson1,
code: 200,
body: """
{
"sparseSetMap": {
"x": [],
"y": ["a", "b"]
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/json"
},
params: {
"sparseSetMap": {
"x": [],
"y": ["a", "b"]
}
}
},
{
id: "RestJsonDeserializesDenseSetMap",
documentation: "A response that contains a dense map of sets.",
protocol: restJson1,
code: 200,
body: """
{
"denseSetMap": {
"x": [],
"y": ["a", "b"]
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/json"
},
params: {
"denseSetMap": {
"x": [],
"y": ["a", "b"]
}
}
},
{
id: "RestJsonDeserializesSparseSetMapAndRetainsNull",
documentation: "A response that contains a sparse map of sets.",
protocol: restJson1,
code: 200,
body: """
{
"sparseSetMap": {
"x": [],
"y": ["a", "b"],
"z": null
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/json"
},
params: {
"sparseSetMap": {
"x": [],
"y": ["a", "b"],
"z": null
}
}
},
{
id: "RestJsonDeserializesDenseSetMapAndSkipsNull",
documentation: """
Clients SHOULD tolerate seeing a null value in a dense map, and they SHOULD
drop the null key-value pair.""",
protocol: restJson1,
appliesTo: "client",
code: 200,
body: """
{
"denseSetMap": {
"x": [],
"y": ["a", "b"],
"z": null
}
}""",
bodyMediaType: "application/json",
headers: {
"Content-Type": "application/json"
},
params: {
"denseSetMap": {
"x": [],
"y": ["a", "b"]
}
}
}
])

Expand All @@ -286,6 +459,8 @@ structure JsonMapsInputOutput {
sparseNumberMap: SparseNumberMap,
sparseBooleanMap: SparseBooleanMap,
sparseStringMap: SparseStringMap,
denseSetMap: DenseSetMap,
mtdowling marked this conversation as resolved.
Show resolved Hide resolved
sparseSetMap: SparseSetMap,
}

map DenseStructMap {
Expand Down Expand Up @@ -325,3 +500,14 @@ map SparseNumberMap {
key: String,
value: Integer
}

map DenseSetMap {
key: String,
value: StringSet
}

@sparse
map SparseSetMap {
key: String,
value: StringSet
}