Skip to content

Commit a57b6ae

Browse files
committed
Add support for generating endpoint tests with integer parameter values.
1 parent e011839 commit a57b6ae

5 files changed

Lines changed: 56 additions & 2 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "bugfix",
3+
"category": "AWS SDK for Java v2 Codegen\"",
4+
"contributor": "",
5+
"description": "Add support for generating endpoint tests with integer parameter values."
6+
}

codegen/src/main/java/software/amazon/awssdk/codegen/poet/rules/EndpointRulesSpecUtils.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.fasterxml.jackson.core.TreeNode;
1919
import com.fasterxml.jackson.jr.stree.JrsArray;
2020
import com.fasterxml.jackson.jr.stree.JrsBoolean;
21+
import com.fasterxml.jackson.jr.stree.JrsNumber;
2122
import com.fasterxml.jackson.jr.stree.JrsString;
2223
import com.fasterxml.jackson.jr.stree.JrsValue;
2324
import com.squareup.javapoet.ClassName;
@@ -189,6 +190,9 @@ public CodeBlock treeNodeToLiteral(TreeNode treeNode) {
189190
case VALUE_FALSE:
190191
b.add("$L", Validate.isInstanceOf(JrsBoolean.class, treeNode, "Expected boolean").booleanValue());
191192
break;
193+
case VALUE_NUMBER_INT:
194+
b.add("$L", Validate.isInstanceOf(JrsNumber.class, treeNode, "Expected number").getValue().intValue());
195+
break;
192196
case START_ARRAY:
193197
handleArrayDefaultValue(b, "stringarray",
194198
Validate.isInstanceOf(JrsArray.class, treeNode, "Expected string array"));

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/endpoint-tests.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,26 @@
183183
}
184184
]
185185
},
186+
{
187+
"documentation": "Has integer operation input",
188+
"expect": {
189+
"endpoint": {
190+
"url": "https://myservice.aws"
191+
}
192+
},
193+
"params": {
194+
"region": "us-east-1"
195+
},
196+
"operationInputs": [
197+
{
198+
"operationName": "OperationWithContextParam",
199+
"operationParams": {
200+
"StringMember": "this is a test",
201+
"IntegerMember": 42
202+
}
203+
}
204+
]
205+
},
186206
{
187207
"documentation": "Has has undeclared input parameter",
188208
"expect": {

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/c2j/query/service-2.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@
216216
"name": "operationContextParam"
217217
}
218218
},
219+
"IntegerMember": {
220+
"shape": "Integer"
221+
},
219222
"NestedMember": {
220223
"shape": "ChecksumStructure"
221224
}
@@ -453,6 +456,7 @@
453456
"payload":"Body"
454457
},
455458
"String":{"type":"string"},
459+
"Integer":{"type":"integer"},
456460
"BearerAuthOperationRequest": {
457461
"type": "structure",
458462
"members": {

codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/endpoint-rules-test-class.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,17 @@ private static List<SyncTestCase> syncTestCases() {
117117
OperationWithContextParamRequest request = OperationWithContextParamRequest.builder()
118118
.nestedMember(ChecksumStructure.builder().checksumMode("foo").build()).build();
119119
builder.build().operationWithContextParam(request);
120-
}, Expect.builder().error("Missing info").build()));
120+
}, Expect.builder().error("Missing info").build()),
121+
new SyncTestCase("Has integer operation input", () -> {
122+
QueryClientBuilder builder = QueryClient.builder();
123+
builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER);
124+
builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER);
125+
builder.httpClient(getSyncHttpClient());
126+
builder.region(Region.of("us-east-1"));
127+
OperationWithContextParamRequest request = OperationWithContextParamRequest.builder()
128+
.stringMember("this is a test").integerMember(42).build();
129+
builder.build().operationWithContextParam(request);
130+
}, Expect.builder().endpoint(Endpoint.builder().url(URI.create("https://myservice.aws")).build()).build()));
121131
}
122132

123133
private static List<AsyncTestCase> asyncTestCases() {
@@ -189,6 +199,16 @@ private static List<AsyncTestCase> asyncTestCases() {
189199
OperationWithContextParamRequest request = OperationWithContextParamRequest.builder()
190200
.nestedMember(ChecksumStructure.builder().checksumMode("foo").build()).build();
191201
return builder.build().operationWithContextParam(request);
192-
}, Expect.builder().error("Missing info").build()));
202+
}, Expect.builder().error("Missing info").build()),
203+
new AsyncTestCase("Has integer operation input", () -> {
204+
QueryAsyncClientBuilder builder = QueryAsyncClient.builder();
205+
builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER);
206+
builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER);
207+
builder.httpClient(getAsyncHttpClient());
208+
builder.region(Region.of("us-east-1"));
209+
OperationWithContextParamRequest request = OperationWithContextParamRequest.builder()
210+
.stringMember("this is a test").integerMember(42).build();
211+
return builder.build().operationWithContextParam(request);
212+
}, Expect.builder().endpoint(Endpoint.builder().url(URI.create("https://myservice.aws")).build()).build()));
193213
}
194214
}

0 commit comments

Comments
 (0)