Skip to content

Commit 021d0ba

Browse files
committed
Preserve original test models and add union tests
1 parent f1c84d1 commit 021d0ba

File tree

3 files changed

+136
-2
lines changed

3 files changed

+136
-2
lines changed

codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/AwsQueryTest.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@ class AwsQueryTest {
1515
namespace test
1616
use aws.protocols#awsQuery
1717
18+
@awsQuery
19+
@xmlNamespace(uri: "https://example.com/")
20+
service TestService {
21+
version: "2019-12-16",
22+
operations: [SomeOperation]
23+
}
24+
25+
operation SomeOperation {
26+
input: SomeOperationInputOutput,
27+
output: SomeOperationInputOutput,
28+
}
29+
30+
structure SomeOperationInputOutput {
31+
payload: String,
32+
a: String,
33+
b: Integer
34+
}
35+
""".asSmithyModel()
36+
37+
private val modelWithObjectEncryptionFilter =
38+
"""
39+
namespace test
40+
use aws.protocols#awsQuery
41+
1842
@awsQuery
1943
@xmlNamespace(uri: "https://example.com/")
2044
service TestService {
@@ -85,6 +109,11 @@ class AwsQueryTest {
85109
clientIntegrationTest(model) { _, _ -> }
86110
}
87111

112+
@Test
113+
fun `generate aws query service with object encryption filter union`() {
114+
clientIntegrationTest(modelWithObjectEncryptionFilter) { _, _ -> }
115+
}
116+
88117
@Test
89118
fun `union with empty struct generates warning-free code`() {
90119
// This test will fail with unused variable warnings if the fix is not applied

codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestJsonTest.kt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@ internal class RestJsonTest {
1515
namespace test
1616
use aws.protocols#restJson1
1717
use aws.api#service
18+
use smithy.test#httpRequestTests
19+
use smithy.test#httpResponseTests
20+
21+
/// A REST JSON service that sends JSON requests and responses.
22+
@service(sdkId: "Rest Json Protocol")
23+
@restJson1
24+
service RestJsonExtras {
25+
version: "2019-12-16",
26+
operations: [StringPayload]
27+
}
28+
29+
@http(uri: "/StringPayload", method: "POST")
30+
operation StringPayload {
31+
input: StringPayloadInput,
32+
output: StringPayloadInput
33+
}
34+
35+
structure StringPayloadInput {
36+
payload: String,
37+
a: String,
38+
b: Integer
39+
}
40+
""".asSmithyModel()
41+
42+
private val modelWithUnion =
43+
"""
44+
namespace test
45+
use aws.protocols#restJson1
46+
use aws.api#service
1847
1948
@restJson1
2049
service TestService {

codegen-client/src/test/kotlin/software/amazon/smithy/rust/codegen/client/smithy/protocols/RestXmlTest.kt

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,78 @@ internal class RestXmlTest {
1717
use aws.api#service
1818
1919
20+
/// A REST XML service that sends XML requests and responses.
21+
@service(sdkId: "Rest XML UT")
22+
@restXml
23+
service RestXmlExtras {
24+
version: "2019-12-16",
25+
operations: [Op]
26+
}
27+
28+
29+
@http(uri: "/top", method: "POST")
30+
operation Op {
31+
input: Top,
32+
output: Top
33+
}
34+
union Choice {
35+
@xmlFlattened
36+
@xmlName("Hi")
37+
flatMap: MyMap,
38+
39+
deepMap: MyMap,
40+
41+
@xmlFlattened
42+
flatList: SomeList,
43+
44+
deepList: SomeList,
45+
46+
s: String,
47+
48+
enum: FooEnum,
49+
50+
date: Timestamp,
51+
52+
number: Double,
53+
54+
top: Top,
55+
56+
blob: Blob
57+
}
58+
59+
@enum([{name: "FOO", value: "FOO"}])
60+
string FooEnum
61+
62+
map MyMap {
63+
@xmlName("Name")
64+
key: String,
65+
66+
@xmlName("Setting")
67+
value: Choice,
68+
}
69+
70+
list SomeList {
71+
member: Choice
72+
}
73+
74+
structure Top {
75+
choice: Choice,
76+
77+
@xmlAttribute
78+
extra: Long,
79+
80+
@xmlName("prefix:local")
81+
renamedWithPrefix: String
82+
}
83+
84+
""".asSmithyModel()
85+
86+
private val modelWithObjectEncryption =
87+
"""
88+
namespace test
89+
use aws.protocols#restXml
90+
use aws.api#service
91+
2092
/// A REST XML service that sends XML requests and responses.
2193
@service(sdkId: "Rest XML UT")
2294
@restXml
@@ -29,7 +101,7 @@ internal class RestXmlTest {
29101
sses3: SSES3Filter,
30102
}
31103
32-
structure SSES3Filter {
104+
structure SSES3Filter {
33105
// Empty structure - no members
34106
}
35107
@@ -74,7 +146,6 @@ internal class RestXmlTest {
74146
union TestUnion {
75147
// Empty struct - should generate _inner to avoid unused variable warning
76148
emptyStruct: EmptyStruct,
77-
78149
// Normal struct - should generate inner (without underscore)
79150
normalStruct: NormalStruct
80151
}
@@ -91,6 +162,11 @@ internal class RestXmlTest {
91162
clientIntegrationTest(model) { _, _ -> }
92163
}
93164

165+
@Test
166+
fun `generate rest xml service with object encryption filter`() {
167+
clientIntegrationTest(modelWithObjectEncryption) { _, _ -> }
168+
}
169+
94170
@Test
95171
fun `union with empty struct generates warning-free code`() {
96172
// This test will fail with unused variable warnings if the fix is not applied

0 commit comments

Comments
 (0)