Skip to content

Commit

Permalink
Add JSON protocol tests for a map of sets
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Jun 11, 2021
1 parent 301436a commit 0a3b325
Showing 1 changed file with 176 additions and 3 deletions.
179 changes: 176 additions & 3 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 Down Expand Up @@ -330,11 +503,11 @@ map SparseNumberMap {

map DenseSetMap {
key: String,
value: aws.protocoltests.shared#StringSet
value: StringSet
}

@sparse
map SparseSetMap {
key: String,
value: aws.protocoltests.shared#StringSet
}
value: StringSet
}

0 comments on commit 0a3b325

Please sign in to comment.