From 62f7953e5be6383f4927cf73630360b649ced645 Mon Sep 17 00:00:00 2001 From: Kevin Stich Date: Tue, 23 Feb 2021 10:27:30 -0800 Subject: [PATCH] Update protocol test case generation (#275) --- .../typescript/codegen/HttpProtocolTestGenerator.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java index 7d24d96fbbc..80f835fe7dd 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/HttpProtocolTestGenerator.java @@ -52,6 +52,7 @@ import software.amazon.smithy.model.traits.HttpPrefixHeadersTrait; import software.amazon.smithy.model.traits.IdempotencyTokenTrait; import software.amazon.smithy.model.traits.StreamingTrait; +import software.amazon.smithy.protocoltests.traits.AppliesTo; import software.amazon.smithy.protocoltests.traits.HttpMessageTestCase; import software.amazon.smithy.protocoltests.traits.HttpRequestTestCase; import software.amazon.smithy.protocoltests.traits.HttpRequestTestsTrait; @@ -118,13 +119,13 @@ public void run() { if (!operation.hasTag("server-only")) { // 1. Generate test cases for each request. operation.getTrait(HttpRequestTestsTrait.class).ifPresent(trait -> { - for (HttpRequestTestCase testCase : trait.getTestCases()) { + for (HttpRequestTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) { onlyIfProtocolMatches(testCase, () -> generateRequestTest(operation, testCase)); } }); // 2. Generate test cases for each response. operation.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> { - for (HttpResponseTestCase testCase : trait.getTestCases()) { + for (HttpResponseTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) { onlyIfProtocolMatches(testCase, () -> generateResponseTest(operation, testCase)); } }); @@ -132,7 +133,7 @@ public void run() { for (StructureShape error : operationIndex.getErrors(operation)) { if (!error.hasTag("server-only")) { error.getTrait(HttpResponseTestsTrait.class).ifPresent(trait -> { - for (HttpResponseTestCase testCase : trait.getTestCases()) { + for (HttpResponseTestCase testCase : trait.getTestCasesFor(AppliesTo.CLIENT)) { onlyIfProtocolMatches(testCase, () -> generateErrorResponseTest(operation, error, testCase)); }