Skip to content

Commit

Permalink
Really enable exception response tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adwsingh committed Feb 18, 2025
1 parent 3676bcb commit 6e1f346
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ public void requestTest(DataStream expected, DataStream actual) {
@ProtocolTestFilter(
skipTests = {
"AwsJson10ClientPopulatesDefaultsValuesWhenMissingInResponse",
"AwsJson10ClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse"
"AwsJson10ClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse",
//The below fail because we haven't implemented code based exception handling
"AwsJson10FooErrorUsingCode",
"AwsJson10FooErrorUsingCodeAndNamespace",
"AwsJson10FooErrorUsingCodeUriAndNamespace",
"AwsJson10FooErrorWithDunderTypeUriAndNamespace"

},
skipOperations = "aws.protocoltests.json10#OperationWithRequiredMembersWithDefaults")
public void responseTest(Runnable test) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ public void requestTest(DataStream expected, DataStream actual) {
@HttpClientResponseTests
@ProtocolTestFilter(
skipTests = {
"RestJsonInputAndOutputWithQuotedStringHeaders"
"RestJsonInputAndOutputWithQuotedStringHeaders",
"RestJsonFooErrorUsingCode",
"RestJsonFooErrorUsingCodeAndNamespace",
"RestJsonFooErrorUsingCodeUriAndNamespace",
"RestJsonFooErrorWithDunderTypeUriAndNamespace"
})
public void responseTest(Runnable test) {
test.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public void requestTest(DataStream expected, DataStream actual) {
}

@HttpClientResponseTests
@ProtocolTestFilter(skipTests = {
"InvalidGreetingError",
"ComplexError"
})
public void responseTest(Runnable test) {
test.run();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ public void requestTest(Runnable test) {
"RestJsonStreamingTraitsWithMediaTypeWithBlob",
"RestJsonDeserializesDenseSetMapAndSkipsNull",
"RestJsonServerPopulatesDefaultsInResponseWhenMissingInParams",
// These can be fixed after https://github.com/smithy-lang/smithy-java/blob/main/http-binding/src/main/java/software/amazon/smithy/java/http/binding/HttpBindingSerializer.java#L109
"RestJsonInvalidGreetingError",
"RestJsonComplexErrorWithNoMessage",
"RestJsonEmptyComplexErrorWithNoMessage",
//TODO this breaks because of Validation and errorCorrection doesn't handle that.
"RestJsonServerPopulatesNestedDefaultValuesWhenMissingInInResponseParams"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public void requestTest(DataStream expected, DataStream actual) {
@HttpClientResponseTests
@ProtocolTestFilter(
skipTests = {
"RpcV2CborClientPopulatesDefaultsValuesWhenMissingInResponse"
"RpcV2CborClientPopulatesDefaultsValuesWhenMissingInResponse",
"RpcV2CborInvalidGreetingError",
"RpcV2CborEmptyComplexError",
"RpcV2CborComplexError"
})
public void responseTest(Runnable test) {
test.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,21 +314,20 @@ private static List<HttpTestOperation> getTestOperations(
});
for (var errorId : operation.getErrors()) {
var error = serviceModel.getShape(errorId);
if (error.map(Shape::isStructureShape).orElse(false)) {
continue;
}
var errorShape = error.get().asStructureShape().get();
errorShape.getTrait(HttpResponseTestsTrait.class).ifPresent(httpResponseTestsTrait -> {
for (var testCase : httpResponseTestsTrait.getTestCases()) {
if (testTypeFiler.test(testCase)) {
responseTestsCases.add(
new HttpResponseProtocolTestCase(
testCase,
true,
getApiExceptionBuilder(symbolProvider, errorShape)));
if (error.isPresent() && error.get().isStructureShape()) {
var errorShape = error.get().asStructureShape().get();
errorShape.getTrait(HttpResponseTestsTrait.class).ifPresent(httpResponseTestsTrait -> {
for (var testCase : httpResponseTestsTrait.getTestCases()) {
if (testTypeFiler.test(testCase)) {
responseTestsCases.add(
new HttpResponseProtocolTestCase(
testCase,
true,
getApiExceptionBuilder(symbolProvider, errorShape)));
}
}
}
});
});
}
}
operation.getTrait(HttpMalformedRequestTestsTrait.class)
.map(HttpMalformedRequestTestsTrait::getTestCases)
Expand Down

0 comments on commit 6e1f346

Please sign in to comment.