From 096d1e100f30e99617b4fd8ddd84873754c36639 Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Fri, 20 Sep 2024 15:00:53 -0700 Subject: [PATCH 1/2] Organize codegen tests & refactor setup tests for XML codegen tests to reduce duplicate code. --- .../HttpProtocolClientGeneratorTests.kt | 3 +++ ...HttpProtocolUnitTestErrorGeneratorTests.kt | 2 ++ ...pProtocolUnitTestResponseGeneratorTests.kt | 4 ++- .../swift/codegen}/PaginatorGeneratorTest.kt | 7 +++++ .../swift/codegen}/ServiceRenamesTests.kt | 2 ++ .../amazon/smithy/swift/codegen}/TestUtils.kt | 5 +++- .../basicshapes}/EnumGeneratorTests.kt | 8 +++++- .../basicshapes}/IntEnumGeneratorTests.kt | 11 +++++++- .../StructDecodeGenerationTests.kt | 10 ++++++- .../StructEncodeGenerationIsolatedTests.kt | 6 +++++ .../StructEncodeGenerationTests.kt | 10 ++++++- .../basicshapes}/StructureGeneratorTests.kt | 27 +++++++++++++------ .../basicshapes}/UnionDecodeGeneratorTests.kt | 10 ++++++- .../basicshapes}/UnionEncodeGeneratorTests.kt | 10 ++++++- .../basicshapes}/UnionGeneratorTests.kt | 4 +++ .../codegencomponents}/CaseUtilsTests.kt | 7 +++++ ...tomDebugStringConvertibleGeneratorTests.kt | 12 +++++++++ .../RecursiveShapeBoxerTests.kt | 11 +++++--- .../ReservedWordsGeneratorTests.kt | 4 +++ .../ShapeValueGeneratorTest.kt | 3 +++ .../codegencomponents}/SwiftDelegatorTests.kt | 10 ++++--- .../SwiftImportContainerTest.kt | 2 ++ .../codegencomponents}/SwiftSettingsTest.kt | 6 ++++- .../SwiftSymbolProviderTest.kt | 5 ++-- .../codegencomponents}/SwiftWriterTests.kt | 2 ++ .../codegencomponents}/SymbolBuilderTest.kt | 3 ++- .../codegencomponents}/SymbolProviderTest.kt | 5 ++++ .../DocumentationConverterTests.kt | 7 +++++ .../PackageManifestGeneratorTests.kt | 13 ++++++--- .../MockHTTPAWSJson11ProtocolGenerator.kt | 5 ++-- .../MockHTTPEC2QueryProtocolGenerator.kt | 6 ++--- .../MockHTTPRestJsonProtocolGenerator.kt | 3 +++ .../MockHTTPRestXMLProtocolGenerator.kt | 3 +++ .../NestedListEncodeJSONGenerationTests.kt | 17 +++++++----- .../OutputResponseDeserializerTests.kt | 21 +++++++++------ .../ec2query}/Ec2QueryNameTests.kt | 14 +++++----- .../OnlyFlattenedListEncodeGeneratorTests.kt} | 16 +++++------ .../xml/BlobDecodeXMLGenerationTests.kt | 17 +++--------- .../xml/BlobEncodeXMLGenerationTests.kt | 18 +++---------- .../xml/EnumDecodeXMLGenerationTests.kt | 17 +++--------- .../xml/EnumEncodeXMLGenerationTests.kt | 19 +++---------- .../xml/ListDecodeXMLGenerationTests.kt | 17 +++--------- .../xml/ListEncodeXMLGenerationTests.kt | 18 +++---------- .../xml/MapDecodeXMLGenerationTests.kt | 17 +++--------- .../xml/MapEncodeXMLGenerationTests.kt | 19 +++---------- .../xml/NamespaceEncodeXMLGenerationTests.kt | 18 +++---------- ...RecursiveShapesDecodeXMLGenerationTests.kt | 18 +++---------- ...RecursiveShapesEncodeXMLGenerationTests.kt | 18 +++---------- .../xml/SetDecodeXMLGenerationTests.kt | 18 +++---------- .../xml/SetEncodeXMLGenerationTests.kt | 19 +++---------- .../xml/SetUpXMLCodegenTests.kt | 23 ++++++++++++++++ .../xml/StructDecodeXMLGenerationTests.kt | 18 +++---------- .../xml/StructEncodeXMLGenerationTests.kt | 19 +++---------- .../xml/TimeStampDecodeGenerationTests.kt | 17 +++--------- .../xml/TimeStampEncodeGenerationTests.kt | 18 +++---------- .../xml/UnionEncodeXMLGenerationTests.kt | 19 +++---------- .../requestandresponse}/EventStreamTests.kt | 11 ++++++++ .../HTTPBindingProtocolGeneratorTests.kt | 10 ++++++- .../AuthSchemeResolverGeneratorTests.kt | 14 +++++++--- .../requestflow}/ContentMd5MiddlewareTests.kt | 18 ++++++------- .../HttpHeaderProviderGeneratorTests.kt | 10 ++++++- .../HttpQueryItemProviderGeneratorTests.kt | 6 +++++ .../requestflow}/HttpUrlPathProviderTests.kt | 15 ++++++++++- .../requestflow}/MiddlewareGeneratorTests.kt | 2 ++ .../requestflow}/RetryMiddlewareTests.kt | 18 ++++++------- .../EventStreamsInitialResponseTests.kt | 8 +++++- .../HttpResponseBindingIgnoreQuery.kt | 21 ++++++++------- .../traits}/EndpointTraitConstructorTests.kt | 4 +++ .../traits}/IdempotencyTokenTraitTests.kt | 19 ++++++------- .../traits}/SensitiveTraitGeneratorTests.kt | 7 ++++- .../waiters/WaiterAcceptorGeneratorTests.kt | 13 +++++---- .../waiters/WaiterConfigGeneratorTests.kt | 13 +++++---- .../codegen}/waiters/WaiterGeneratorTests.kt | 13 +++++---- .../waiters/WaiterIntegrationTests.kt | 11 ++++---- .../waiters/WaiterMethodGeneratorTests.kt | 13 +++++---- ...wsjson-output-response-deserializer.smithy | 0 76 files changed, 453 insertions(+), 414 deletions(-) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/HttpProtocolClientGeneratorTests.kt (99%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/HttpProtocolUnitTestErrorGeneratorTests.kt (98%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/HttpProtocolUnitTestResponseGeneratorTests.kt (98%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/PaginatorGeneratorTest.kt (97%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/ServiceRenamesTests.kt (99%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/TestUtils.kt (98%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/EnumGeneratorTests.kt (94%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/IntEnumGeneratorTests.kt (78%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/StructDecodeGenerationTests.kt (92%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/StructEncodeGenerationIsolatedTests.kt (91%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/StructEncodeGenerationTests.kt (96%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/StructureGeneratorTests.kt (92%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/UnionDecodeGeneratorTests.kt (91%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/UnionEncodeGeneratorTests.kt (94%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/basicshapes}/UnionGeneratorTests.kt (97%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/CaseUtilsTests.kt (88%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/CustomDebugStringConvertibleGeneratorTests.kt (88%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/RecursiveShapeBoxerTests.kt (91%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/ReservedWordsGeneratorTests.kt (95%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/ShapeValueGeneratorTest.kt (99%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/SwiftDelegatorTests.kt (85%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/SwiftImportContainerTest.kt (97%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/SwiftSettingsTest.kt (76%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/SwiftSymbolProviderTest.kt (90%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/SwiftWriterTests.kt (98%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/SymbolBuilderTest.kt (96%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/codegencomponents}/SymbolProviderTest.kt (98%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/manifestanddocs}/DocumentationConverterTests.kt (98%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/manifestanddocs}/PackageManifestGeneratorTests.kt (82%) rename smithy-swift-codegen/src/test/kotlin/{mocks => software/amazon/smithy/swift/codegen/protocolgeneratormocks}/MockHTTPAWSJson11ProtocolGenerator.kt (95%) rename smithy-swift-codegen/src/test/kotlin/{mocks => software/amazon/smithy/swift/codegen/protocolgeneratormocks}/MockHTTPEC2QueryProtocolGenerator.kt (94%) rename smithy-swift-codegen/src/test/kotlin/{mocks => software/amazon/smithy/swift/codegen/protocolgeneratormocks}/MockHTTPRestJsonProtocolGenerator.kt (92%) rename smithy-swift-codegen/src/test/kotlin/{mocks => software/amazon/smithy/swift/codegen/protocolgeneratormocks}/MockHTTPRestXMLProtocolGenerator.kt (92%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/awsjson11/NestedListEncodeJSONGenerationTests.kt (81%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/awsjson11/OutputResponseDeserializerTests.kt (84%) rename smithy-swift-codegen/src/test/kotlin/{serde/ec2 => software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query}/Ec2QueryNameTests.kt (82%) rename smithy-swift-codegen/src/test/kotlin/{serde/ec2/OnlyFlattenedListEncodeFormURLGeneratorTests.kt => software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt} (84%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/BlobDecodeXMLGenerationTests.kt (77%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/BlobEncodeXMLGenerationTests.kt (70%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/EnumDecodeXMLGenerationTests.kt (80%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/EnumEncodeXMLGenerationTests.kt (74%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/ListDecodeXMLGenerationTests.kt (93%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/ListEncodeXMLGenerationTests.kt (94%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/MapDecodeXMLGenerationTests.kt (97%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/MapEncodeXMLGenerationTests.kt (96%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/NamespaceEncodeXMLGenerationTests.kt (90%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/RecursiveShapesDecodeXMLGenerationTests.kt (79%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/RecursiveShapesEncodeXMLGenerationTests.kt (85%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/SetDecodeXMLGenerationTests.kt (79%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/SetEncodeXMLGenerationTests.kt (73%) create mode 100644 smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/StructDecodeXMLGenerationTests.kt (90%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/StructEncodeXMLGenerationTests.kt (78%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/TimeStampDecodeGenerationTests.kt (89%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/TimeStampEncodeGenerationTests.kt (87%) rename smithy-swift-codegen/src/test/kotlin/{serde => software/amazon/smithy/swift/codegen/protocolspecificserde}/xml/UnionEncodeXMLGenerationTests.kt (87%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse}/EventStreamTests.kt (97%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse}/HTTPBindingProtocolGeneratorTests.kt (92%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/requestflow}/AuthSchemeResolverGeneratorTests.kt (90%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/requestflow}/ContentMd5MiddlewareTests.kt (54%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/requestflow}/HttpHeaderProviderGeneratorTests.kt (88%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/requestflow}/HttpQueryItemProviderGeneratorTests.kt (97%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/requestflow}/HttpUrlPathProviderTests.kt (79%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/requestflow}/MiddlewareGeneratorTests.kt (94%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/requestflow}/RetryMiddlewareTests.kt (56%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/requestandresponse/responseflow}/EventStreamsInitialResponseTests.kt (88%) rename smithy-swift-codegen/src/test/kotlin/{httpResponse => software/amazon/smithy/swift/codegen/requestandresponse/responseflow}/HttpResponseBindingIgnoreQuery.kt (67%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/traits}/EndpointTraitConstructorTests.kt (90%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/traits}/IdempotencyTokenTraitTests.kt (54%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen/traits}/SensitiveTraitGeneratorTests.kt (88%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/waiters/WaiterAcceptorGeneratorTests.kt (95%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/waiters/WaiterConfigGeneratorTests.kt (93%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/waiters/WaiterGeneratorTests.kt (92%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/waiters/WaiterIntegrationTests.kt (93%) rename smithy-swift-codegen/src/test/kotlin/{ => software/amazon/smithy/swift/codegen}/waiters/WaiterMethodGeneratorTests.kt (93%) rename smithy-swift-codegen/src/test/resources/{serde/awsjson11 => }/awsjson-output-response-deserializer.smithy (100%) diff --git a/smithy-swift-codegen/src/test/kotlin/HttpProtocolClientGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt similarity index 99% rename from smithy-swift-codegen/src/test/kotlin/HttpProtocolClientGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt index 77d9de6cc..ffb1f0ad7 100644 --- a/smithy-swift-codegen/src/test/kotlin/HttpProtocolClientGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -7,6 +9,7 @@ import io.kotest.matchers.string.shouldContain import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.DefaultClientConfigurationIntegration +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator class HttpProtocolClientGeneratorTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/HttpProtocolUnitTestErrorGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolUnitTestErrorGeneratorTests.kt similarity index 98% rename from smithy-swift-codegen/src/test/kotlin/HttpProtocolUnitTestErrorGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolUnitTestErrorGeneratorTests.kt index bdd9874b1..0de394a3a 100644 --- a/smithy-swift-codegen/src/test/kotlin/HttpProtocolUnitTestErrorGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolUnitTestErrorGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. diff --git a/smithy-swift-codegen/src/test/kotlin/HttpProtocolUnitTestResponseGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolUnitTestResponseGeneratorTests.kt similarity index 98% rename from smithy-swift-codegen/src/test/kotlin/HttpProtocolUnitTestResponseGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolUnitTestResponseGeneratorTests.kt index 043c91175..1706b32c0 100644 --- a/smithy-swift-codegen/src/test/kotlin/HttpProtocolUnitTestResponseGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolUnitTestResponseGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -8,7 +10,7 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.model.AddOperationShapes open class HttpProtocolUnitTestResponseGeneratorTests { - var model = javaClass.getResource("http-binding-protocol-generator-test.smithy").asSmithy() + var model = javaClass.classLoader.getResource("http-binding-protocol-generator-test.smithy").asSmithy() private fun newTestContext(): TestContext { val settings = model.defaultSettings() model = AddOperationShapes.execute(model, settings.getService(model), settings.moduleName) diff --git a/smithy-swift-codegen/src/test/kotlin/PaginatorGeneratorTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt similarity index 97% rename from smithy-swift-codegen/src/test/kotlin/PaginatorGeneratorTest.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt index 0968dcb12..34507054a 100644 --- a/smithy-swift-codegen/src/test/kotlin/PaginatorGeneratorTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt @@ -1,3 +1,9 @@ +package software.amazon.smithy.swift.codegen + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test @@ -12,6 +18,7 @@ import software.amazon.smithy.swift.codegen.SwiftWriter import software.amazon.smithy.swift.codegen.core.SwiftCodegenContext import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator class PaginatorGeneratorTest { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/ServiceRenamesTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/ServiceRenamesTests.kt similarity index 99% rename from smithy-swift-codegen/src/test/kotlin/ServiceRenamesTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/ServiceRenamesTests.kt index 008d252c5..02e8aebc2 100644 --- a/smithy-swift-codegen/src/test/kotlin/ServiceRenamesTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/ServiceRenamesTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. diff --git a/smithy-swift-codegen/src/test/kotlin/TestUtils.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt similarity index 98% rename from smithy-swift-codegen/src/test/kotlin/TestUtils.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt index da6209874..5e49caf10 100644 --- a/smithy-swift-codegen/src/test/kotlin/TestUtils.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -32,6 +34,7 @@ import software.amazon.smithy.swift.codegen.model.AddOperationShapes import software.amazon.smithy.swift.codegen.model.NeedsReaderWriterTransformer import software.amazon.smithy.swift.codegen.model.NestedShapeTransformer import software.amazon.smithy.swift.codegen.model.RecursiveShapeBoxer +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator import java.net.URL /** @@ -277,7 +280,7 @@ class TestContext( var modelAssembler = Model.assembler() for (smithyFile in smithyFiles) { - modelAssembler.addImport(javaClass.getResource(smithyFile)) + modelAssembler.addImport(javaClass.classLoader.getResource(smithyFile)) } var model = modelAssembler .discoverModels() diff --git a/smithy-swift-codegen/src/test/kotlin/EnumGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/EnumGeneratorTests.kt similarity index 94% rename from smithy-swift-codegen/src/test/kotlin/EnumGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/EnumGeneratorTests.kt index 937e891d0..818b47181 100644 --- a/smithy-swift-codegen/src/test/kotlin/EnumGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/EnumGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -15,6 +17,10 @@ import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.swift.codegen.EnumGenerator import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.buildMockPluginContext +import software.amazon.smithy.swift.codegen.createModelFromShapes +import software.amazon.smithy.swift.codegen.defaultSettings class EnumGeneratorTests { @@ -130,7 +136,7 @@ public enum MyEnum: Swift.Equatable, Swift.RawRepresentable, Swift.CaseIterable, @Test fun `generates enums from IDL-2 enum shape`() { - val model = javaClass.getResource("enum-shape-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("enum-shape-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) diff --git a/smithy-swift-codegen/src/test/kotlin/IntEnumGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/IntEnumGeneratorTests.kt similarity index 78% rename from smithy-swift-codegen/src/test/kotlin/IntEnumGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/IntEnumGeneratorTests.kt index 1b373c80d..24b0ab901 100644 --- a/smithy-swift-codegen/src/test/kotlin/IntEnumGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/IntEnumGeneratorTests.kt @@ -1,14 +1,23 @@ +package software.amazon.smithy.swift.codegen.basicshapes + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContain import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import software.amazon.smithy.build.MockManifest import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.buildMockPluginContext class IntEnumGeneratorTests { @Test fun `generates int enum`() { - val model = javaClass.getResource("int-enum-shape-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("int-enum-shape-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) diff --git a/smithy-swift-codegen/src/test/kotlin/StructDecodeGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructDecodeGenerationTests.kt similarity index 92% rename from smithy-swift-codegen/src/test/kotlin/StructDecodeGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructDecodeGenerationTests.kt index 20c99cfcf..39259ad75 100644 --- a/smithy-swift-codegen/src/test/kotlin/StructDecodeGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructDecodeGenerationTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -6,13 +8,19 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.model.AddOperationShapes import software.amazon.smithy.swift.codegen.model.NeedsReaderWriterTransformer import software.amazon.smithy.swift.codegen.model.NestedShapeTransformer import software.amazon.smithy.swift.codegen.model.RecursiveShapeBoxer +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class StructDecodeGenerationTests { - var model = javaClass.getResource("http-binding-protocol-generator-test.smithy").asSmithy() + var model = javaClass.classLoader.getResource("http-binding-protocol-generator-test.smithy").asSmithy() private fun newTestContext(): TestContext { val settings = model.defaultSettings() model = AddOperationShapes.execute(model, settings.getService(model), settings.moduleName) diff --git a/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationIsolatedTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructEncodeGenerationIsolatedTests.kt similarity index 91% rename from smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationIsolatedTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructEncodeGenerationIsolatedTests.kt index 19a6c0014..e84d85afd 100644 --- a/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationIsolatedTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructEncodeGenerationIsolatedTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -6,6 +8,10 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.getModelFileContents +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class StructEncodeGenerationIsolatedTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructEncodeGenerationTests.kt similarity index 96% rename from smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructEncodeGenerationTests.kt index 1f040d881..165fbcfa1 100644 --- a/smithy-swift-codegen/src/test/kotlin/StructEncodeGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructEncodeGenerationTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -6,12 +8,18 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.model.AddOperationShapes import software.amazon.smithy.swift.codegen.model.NeedsReaderWriterTransformer import software.amazon.smithy.swift.codegen.model.RecursiveShapeBoxer +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class StructEncodeGenerationTests { - var model = javaClass.getResource("http-binding-protocol-generator-test.smithy").asSmithy() + var model = javaClass.classLoader.getResource("http-binding-protocol-generator-test.smithy").asSmithy() private fun newTestContext(): TestContext { val settings = model.defaultSettings() model = AddOperationShapes.execute(model, settings.getService(model), settings.moduleName) diff --git a/smithy-swift-codegen/src/test/kotlin/StructureGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructureGeneratorTests.kt similarity index 92% rename from smithy-swift-codegen/src/test/kotlin/StructureGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructureGeneratorTests.kt index d321e323b..b4ba407bb 100644 --- a/smithy-swift-codegen/src/test/kotlin/StructureGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/StructureGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -16,6 +18,15 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.swift.codegen.StructureGenerator import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.buildMockPluginContext +import software.amazon.smithy.swift.codegen.createModelWithStructureWithoutErrorTrait +import software.amazon.smithy.swift.codegen.createStructureContainingNestedRecursiveShape +import software.amazon.smithy.swift.codegen.createStructureContainingNestedRecursiveShapeList +import software.amazon.smithy.swift.codegen.createStructureWithOptionalErrorMessage +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck import java.util.function.Consumer class StructureGeneratorTests { @@ -58,7 +69,7 @@ class StructureGeneratorTests { @Test fun `it renders struct with primitive types`() { - val model = javaClass.getResource("primitive-type-encode-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("primitive-type-encode-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) @@ -127,7 +138,7 @@ class StructureGeneratorTests { @Test fun `it renders recursive nested shapes`() { val structs = createStructureContainingNestedRecursiveShape() - val model = javaClass.getResource("recursive-shape-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("recursive-shape-test.smithy").asSmithy() val swiftSettings = model.defaultSettings() val provider = SwiftCodegenPlugin.createSymbolProvider(model, swiftSettings) val writer = SwiftWriter("MockPackage") @@ -185,7 +196,7 @@ public struct RecursiveShapesInputOutput { @Test fun `it renders recursive nested shapes in lists`() { val structs = createStructureContainingNestedRecursiveShapeList() - val model = javaClass.getResource("recursive-shape-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("recursive-shape-test.smithy").asSmithy() val swiftSettings = model.defaultSettings() val provider = SwiftCodegenPlugin.createSymbolProvider(model, swiftSettings) val writer = SwiftWriter("MockPackage") @@ -301,7 +312,7 @@ public struct MyError: ClientRuntime.ModeledError, ClientRuntime.ServiceError, C @Test fun `check for sparse and dense datatypes in list`() { - val model = javaClass.getResource("sparse-trait-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("sparse-trait-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) @@ -347,7 +358,7 @@ public struct JsonListsInput { separate structs for input and output with members given in smithy model, without creating additional structs in the model */ - val model = javaClass.getResource("sparse-trait-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("sparse-trait-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) @@ -431,7 +442,7 @@ public struct JsonMapsOutput { @Test fun `deprecated trait on structure`() { - val model = javaClass.getResource("deprecated-trait-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("deprecated-trait-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) @@ -459,7 +470,7 @@ public struct JsonMapsOutput { @Test fun `deprecated trait on synthetically cloned structure and structure member`() { - val model = javaClass.getResource("deprecated-trait-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("deprecated-trait-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) @@ -485,7 +496,7 @@ public struct JsonMapsOutput { @Test fun `deprecated trait fetched from the target of a struct member`() { - val model = javaClass.getResource("deprecated-trait-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("deprecated-trait-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) diff --git a/smithy-swift-codegen/src/test/kotlin/UnionDecodeGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionDecodeGeneratorTests.kt similarity index 91% rename from smithy-swift-codegen/src/test/kotlin/UnionDecodeGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionDecodeGeneratorTests.kt index 5986a3e9e..eb21f6999 100644 --- a/smithy-swift-codegen/src/test/kotlin/UnionDecodeGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionDecodeGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -6,12 +8,18 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.model.AddOperationShapes import software.amazon.smithy.swift.codegen.model.NeedsReaderWriterTransformer import software.amazon.smithy.swift.codegen.model.NestedShapeTransformer +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class UnionDecodeGeneratorTests { - var model = javaClass.getResource("http-binding-protocol-generator-test.smithy").asSmithy() + var model = javaClass.classLoader.getResource("http-binding-protocol-generator-test.smithy").asSmithy() private fun newTestContext(): TestContext { val settings = model.defaultSettings() model = AddOperationShapes.execute(model, settings.getService(model), settings.moduleName) diff --git a/smithy-swift-codegen/src/test/kotlin/UnionEncodeGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionEncodeGeneratorTests.kt similarity index 94% rename from smithy-swift-codegen/src/test/kotlin/UnionEncodeGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionEncodeGeneratorTests.kt index 1fd2706b5..f59b4ee31 100644 --- a/smithy-swift-codegen/src/test/kotlin/UnionEncodeGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionEncodeGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -7,13 +9,19 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test import software.amazon.smithy.model.Model +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.model.AddOperationShapes import software.amazon.smithy.swift.codegen.model.NeedsReaderWriterTransformer import software.amazon.smithy.swift.codegen.model.NestedShapeTransformer import software.amazon.smithy.swift.codegen.model.RecursiveShapeBoxer +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class UnionEncodeGeneratorTests { - var model = javaClass.getResource("http-binding-protocol-generator-test.smithy").asSmithy() + var model = javaClass.classLoader.getResource("http-binding-protocol-generator-test.smithy").asSmithy() private fun newTestContext(): TestContext { model = preprocessModel(model) return model.newTestContext() diff --git a/smithy-swift-codegen/src/test/kotlin/UnionGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionGeneratorTests.kt similarity index 97% rename from smithy-swift-codegen/src/test/kotlin/UnionGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionGeneratorTests.kt index 9e9585d5d..b03b2b988 100644 --- a/smithy-swift-codegen/src/test/kotlin/UnionGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/basicshapes/UnionGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.basicshapes + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -13,6 +15,8 @@ import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin import software.amazon.smithy.swift.codegen.SwiftWriter import software.amazon.smithy.swift.codegen.UnionGenerator +import software.amazon.smithy.swift.codegen.createModelFromShapes +import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.model.UnionIndirectivizer class UnionGeneratorTests { diff --git a/smithy-swift-codegen/src/test/kotlin/CaseUtilsTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/CaseUtilsTests.kt similarity index 88% rename from smithy-swift-codegen/src/test/kotlin/CaseUtilsTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/CaseUtilsTests.kt index 028dd7e7a..7f92d909d 100644 --- a/smithy-swift-codegen/src/test/kotlin/CaseUtilsTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/CaseUtilsTests.kt @@ -1,3 +1,10 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.utils.toLowerCamelCase diff --git a/smithy-swift-codegen/src/test/kotlin/CustomDebugStringConvertibleGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/CustomDebugStringConvertibleGeneratorTests.kt similarity index 88% rename from smithy-swift-codegen/src/test/kotlin/CustomDebugStringConvertibleGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/CustomDebugStringConvertibleGeneratorTests.kt index d4ea9fb2e..4c7545fa3 100644 --- a/smithy-swift-codegen/src/test/kotlin/CustomDebugStringConvertibleGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/CustomDebugStringConvertibleGeneratorTests.kt @@ -1,6 +1,18 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.DefaultClientConfigurationIntegration +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class CustomDebugStringConvertibleGeneratorTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/RecursiveShapeBoxerTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/RecursiveShapeBoxerTests.kt similarity index 91% rename from smithy-swift-codegen/src/test/kotlin/RecursiveShapeBoxerTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/RecursiveShapeBoxerTests.kt index f2052964b..dc6a6e7bb 100644 --- a/smithy-swift-codegen/src/test/kotlin/RecursiveShapeBoxerTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/RecursiveShapeBoxerTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -9,15 +11,16 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.build.MockManifest import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.buildMockPluginContext import software.amazon.smithy.swift.codegen.customtraits.SwiftBoxTrait import software.amazon.smithy.swift.codegen.model.RecursiveShapeBoxer -import kotlin.streams.toList internal class RecursiveShapeBoxerTests { @Test fun `leave non-recursive models unchanged`() { - val model = javaClass.getResource("simple-service-with-operation-and-dependency.smithy").asSmithy() + val model = javaClass.classLoader.getResource("simple-service-with-operation-and-dependency.smithy").asSmithy() val transformed = RecursiveShapeBoxer.transform(model) transformed.shapes().toList().forEach { Assertions.assertFalse(transformed.getShape(it.id).get().hasTrait(SwiftBoxTrait::class.java)) @@ -26,7 +29,7 @@ internal class RecursiveShapeBoxerTests { @Test fun `add the box trait to recursive shapes`() { - val model = javaClass.getResource("recursive-shape-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("recursive-shape-test.smithy").asSmithy() val transformed = RecursiveShapeBoxer.transform(model) val traitedMember = "smithy.example#RecursiveShapesInputOutputNested1\$nested" @@ -40,7 +43,7 @@ internal class RecursiveShapeBoxerTests { @Test fun `add the box trait to recursive shapes during integration with SwiftCodegenPlugin`() { - val model = javaClass.getResource("recursive-shape-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("recursive-shape-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) diff --git a/smithy-swift-codegen/src/test/kotlin/ReservedWordsGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/ReservedWordsGeneratorTests.kt similarity index 95% rename from smithy-swift-codegen/src/test/kotlin/ReservedWordsGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/ReservedWordsGeneratorTests.kt index 3d9b9796c..7d07f0e96 100644 --- a/smithy-swift-codegen/src/test/kotlin/ReservedWordsGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/ReservedWordsGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -5,6 +7,8 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.getFileContents class ReservedWordsGeneratorTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/ShapeValueGeneratorTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/ShapeValueGeneratorTest.kt similarity index 99% rename from smithy-swift-codegen/src/test/kotlin/ShapeValueGeneratorTest.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/ShapeValueGeneratorTest.kt index bcaa2bc59..e25d2a2ad 100644 --- a/smithy-swift-codegen/src/test/kotlin/ShapeValueGeneratorTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/ShapeValueGeneratorTest.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -21,6 +23,7 @@ import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.swift.codegen.ShapeValueGenerator import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.model.RecursiveShapeBoxer class ShapeValueGeneratorTest { diff --git a/smithy-swift-codegen/src/test/kotlin/SwiftDelegatorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftDelegatorTests.kt similarity index 85% rename from smithy-swift-codegen/src/test/kotlin/SwiftDelegatorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftDelegatorTests.kt index 30735f5df..b0de51d84 100644 --- a/smithy-swift-codegen/src/test/kotlin/SwiftDelegatorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftDelegatorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -12,12 +14,14 @@ import software.amazon.smithy.model.shapes.ShapeId import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin import software.amazon.smithy.swift.codegen.SwiftDelegator import software.amazon.smithy.swift.codegen.SwiftSettings +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.buildMockPluginContext class SwiftDelegatorTests { @Test fun `it renders files into namespace`() { - val model = javaClass.getResource("simple-service-with-operation.smithy").asSmithy() + val model = javaClass.classLoader.getResource("simple-service-with-operation.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") @@ -30,7 +34,7 @@ class SwiftDelegatorTests { @Test fun `it vends writers for shapes`() { - val model = javaClass.getResource("simple-service-with-operation.smithy").asSmithy() + val model = javaClass.classLoader.getResource("simple-service-with-operation.smithy").asSmithy() val getFooInputShape = model.expectShape(ShapeId.from("smithy.example#GetFooInput")) val manifest = MockManifest() val context = buildMockPluginContext(model, manifest) @@ -49,7 +53,7 @@ class SwiftDelegatorTests { @Test fun `it uses opened writer separating with newline`() { - val model = javaClass.getResource("simple-service-with-operation.smithy").asSmithy() + val model = javaClass.classLoader.getResource("simple-service-with-operation.smithy").asSmithy() val getFooInputShape = model.expectShape(ShapeId.from("smithy.example#GetFooInput")) val manifest = MockManifest() val context = buildMockPluginContext(model, manifest) diff --git a/smithy-swift-codegen/src/test/kotlin/SwiftImportContainerTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftImportContainerTest.kt similarity index 97% rename from smithy-swift-codegen/src/test/kotlin/SwiftImportContainerTest.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftImportContainerTest.kt index ed6b429fe..2296385d9 100644 --- a/smithy-swift-codegen/src/test/kotlin/SwiftImportContainerTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftImportContainerTest.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. diff --git a/smithy-swift-codegen/src/test/kotlin/SwiftSettingsTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftSettingsTest.kt similarity index 76% rename from smithy-swift-codegen/src/test/kotlin/SwiftSettingsTest.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftSettingsTest.kt index 46fb5302f..f58a12ac9 100644 --- a/smithy-swift-codegen/src/test/kotlin/SwiftSettingsTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftSettingsTest.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -6,10 +8,12 @@ import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import software.amazon.smithy.model.shapes.ShapeId +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings class SwiftSettingsTest { @Test fun `infers default service`() { - val model = javaClass.getResource("simple-service.smithy").asSmithy() + val model = javaClass.classLoader.getResource("simple-service.smithy").asSmithy() val settings = model.defaultSettings(serviceShapeId = "smithy.example#Example") diff --git a/smithy-swift-codegen/src/test/kotlin/SwiftSymbolProviderTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftSymbolProviderTest.kt similarity index 90% rename from smithy-swift-codegen/src/test/kotlin/SwiftSymbolProviderTest.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftSymbolProviderTest.kt index b763ba74e..fb70f4c93 100644 --- a/smithy-swift-codegen/src/test/kotlin/SwiftSymbolProviderTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftSymbolProviderTest.kt @@ -1,12 +1,13 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package software.amazon.smithy.swift.codegen.utils - import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.utils.clientName class SwiftSymbolProviderTest { diff --git a/smithy-swift-codegen/src/test/kotlin/SwiftWriterTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftWriterTests.kt similarity index 98% rename from smithy-swift-codegen/src/test/kotlin/SwiftWriterTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftWriterTests.kt index b79de5c02..e14d31daa 100644 --- a/smithy-swift-codegen/src/test/kotlin/SwiftWriterTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SwiftWriterTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. diff --git a/smithy-swift-codegen/src/test/kotlin/SymbolBuilderTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SymbolBuilderTest.kt similarity index 96% rename from smithy-swift-codegen/src/test/kotlin/SymbolBuilderTest.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SymbolBuilderTest.kt index 60a1048ab..0e4c862d2 100644 --- a/smithy-swift-codegen/src/test/kotlin/SymbolBuilderTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SymbolBuilderTest.kt @@ -1,9 +1,10 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package software.amazon.smithy.kotlin.codegen.model // copied and modified from https://github.com/awslabs/smithy-kotlin/blob/b386392b1cd7cc73a9bc08bedcff0c109487b74f/smithy-kotlin-codegen/src/test/kotlin/software/amazon/smithy/kotlin/codegen/model/SymbolBuilderTest.kt import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertFalse diff --git a/smithy-swift-codegen/src/test/kotlin/SymbolProviderTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SymbolProviderTest.kt similarity index 98% rename from smithy-swift-codegen/src/test/kotlin/SymbolProviderTest.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SymbolProviderTest.kt index b983b6cb9..aa6c324ff 100644 --- a/smithy-swift-codegen/src/test/kotlin/SymbolProviderTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/codegencomponents/SymbolProviderTest.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.codegencomponents + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -23,6 +25,9 @@ import software.amazon.smithy.model.shapes.StructureShape import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin import software.amazon.smithy.swift.codegen.SwiftSymbolProvider +import software.amazon.smithy.swift.codegen.asSmithyModel +import software.amazon.smithy.swift.codegen.createModelFromShapes +import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.model.NestedShapeTransformer import software.amazon.smithy.swift.codegen.model.defaultValue import software.amazon.smithy.swift.codegen.model.expectShape diff --git a/smithy-swift-codegen/src/test/kotlin/DocumentationConverterTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/DocumentationConverterTests.kt similarity index 98% rename from smithy-swift-codegen/src/test/kotlin/DocumentationConverterTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/DocumentationConverterTests.kt index 21c2251db..9c1890c1f 100644 --- a/smithy-swift-codegen/src/test/kotlin/DocumentationConverterTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/DocumentationConverterTests.kt @@ -1,3 +1,10 @@ +package software.amazon.smithy.swift.codegen.manifestanddocs + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.swift.cod.DocumentationConverter diff --git a/smithy-swift-codegen/src/test/kotlin/PackageManifestGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/PackageManifestGeneratorTests.kt similarity index 82% rename from smithy-swift-codegen/src/test/kotlin/PackageManifestGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/PackageManifestGeneratorTests.kt index 3721ef4d3..63bf80ee4 100644 --- a/smithy-swift-codegen/src/test/kotlin/PackageManifestGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/PackageManifestGeneratorTests.kt @@ -1,13 +1,17 @@ +package software.amazon.smithy.swift.codegen.manifestanddocs + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ import io.kotest.matchers.string.shouldContain -import mocks.MockHTTPAWSJson11ProtocolGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.PackageManifestGenerator +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings class PackageManifestGeneratorTests { private val testContext = setupTests("simple-service-with-operation-and-dependency.smithy", "smithy.example#Example") @@ -65,9 +69,10 @@ class PackageManifestGeneratorTests { } private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPAWSJson11ProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "MockSDK", "2019-12-16", "MockSDKID") - } + val context = + TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPAWSJson11ProtocolGenerator()) { model -> + model.defaultSettings(serviceShapeId, "MockSDK", "2019-12-16", "MockSDKID") + } PackageManifestGenerator(context.generationCtx).writePackageManifest(context.generationCtx.delegator.dependencies) context.generationCtx.delegator.flushWriters() return context diff --git a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPAWSJson11ProtocolGenerator.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPAWSJson11ProtocolGenerator.kt similarity index 95% rename from smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPAWSJson11ProtocolGenerator.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPAWSJson11ProtocolGenerator.kt index 840fbb773..7a0f0965d 100644 --- a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPAWSJson11ProtocolGenerator.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPAWSJson11ProtocolGenerator.kt @@ -1,10 +1,10 @@ +package software.amazon.smithy.swift.codegen.protocolgeneratormocks + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package mocks -import TestHttpProtocolClientGeneratorFactory import software.amazon.smithy.aws.traits.protocols.AwsJson1_1Trait import software.amazon.smithy.model.pattern.UriPattern import software.amazon.smithy.model.shapes.OperationShape @@ -20,6 +20,7 @@ import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestRequ import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestResponseGenerator import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.protocols.core.StaticHttpBindingResolver +import software.amazon.smithy.swift.codegen.requestandresponse.TestHttpProtocolClientGeneratorFactory class MockJsonHttpBindingResolver( private val context: ProtocolGenerator.GenerationContext, diff --git a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPEC2QueryProtocolGenerator.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPEC2QueryProtocolGenerator.kt similarity index 94% rename from smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPEC2QueryProtocolGenerator.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPEC2QueryProtocolGenerator.kt index a35418f78..9cc95f880 100644 --- a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPEC2QueryProtocolGenerator.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPEC2QueryProtocolGenerator.kt @@ -1,11 +1,10 @@ +package software.amazon.smithy.swift.codegen.protocolgeneratormocks + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package mocks - -import TestHttpProtocolClientGeneratorFactory import software.amazon.smithy.aws.traits.protocols.Ec2QueryTrait import software.amazon.smithy.model.pattern.UriPattern import software.amazon.smithy.model.shapes.OperationShape @@ -20,6 +19,7 @@ import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestRequ import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestResponseGenerator import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.protocols.core.StaticHttpBindingResolver +import software.amazon.smithy.swift.codegen.requestandresponse.TestHttpProtocolClientGeneratorFactory class MockEC2QueryHTTPProtocolCustomizations() : DefaultHTTPProtocolCustomizations() diff --git a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPRestJsonProtocolGenerator.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPRestJsonProtocolGenerator.kt similarity index 92% rename from smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPRestJsonProtocolGenerator.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPRestJsonProtocolGenerator.kt index 5fad473b1..271b08c93 100644 --- a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPRestJsonProtocolGenerator.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPRestJsonProtocolGenerator.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.protocolgeneratormocks + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -13,6 +15,7 @@ import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestErro import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestRequestGenerator import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestResponseGenerator import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator +import software.amazon.smithy.swift.codegen.requestandresponse.TestHttpProtocolClientGeneratorFactory class MockRestJsonHTTPProtocolCustomizations() : DefaultHTTPProtocolCustomizations() class MockHTTPRestJsonProtocolGenerator : HTTPBindingProtocolGenerator(MockRestJsonHTTPProtocolCustomizations()) { diff --git a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPRestXMLProtocolGenerator.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPRestXMLProtocolGenerator.kt similarity index 92% rename from smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPRestXMLProtocolGenerator.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPRestXMLProtocolGenerator.kt index 497019649..35e53c237 100644 --- a/smithy-swift-codegen/src/test/kotlin/mocks/MockHTTPRestXMLProtocolGenerator.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolgeneratormocks/MockHTTPRestXMLProtocolGenerator.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.protocolgeneratormocks + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -13,6 +15,7 @@ import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestErro import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestRequestGenerator import software.amazon.smithy.swift.codegen.integration.HttpProtocolUnitTestResponseGenerator import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator +import software.amazon.smithy.swift.codegen.requestandresponse.TestHttpProtocolClientGeneratorFactory class MockRestXMLHTTPProtocolCustomizations() : DefaultHTTPProtocolCustomizations() diff --git a/smithy-swift-codegen/src/test/kotlin/serde/awsjson11/NestedListEncodeJSONGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/NestedListEncodeJSONGenerationTests.kt similarity index 81% rename from smithy-swift-codegen/src/test/kotlin/serde/awsjson11/NestedListEncodeJSONGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/NestedListEncodeJSONGenerationTests.kt index 6f6a1d19c..0bb1baa00 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/awsjson11/NestedListEncodeJSONGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/NestedListEncodeJSONGenerationTests.kt @@ -1,12 +1,17 @@ -package serde.awsjson11 +package software.amazon.smithy.swift.codegen.protocolspecificserde.awsjson11 + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce -import mocks.MockHTTPAWSJson11ProtocolGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import org.junit.jupiter.api.Test -import shouldSyntacticSanityCheck +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class NestedListEncodeJSONGenerationTests { diff --git a/smithy-swift-codegen/src/test/kotlin/serde/awsjson11/OutputResponseDeserializerTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/OutputResponseDeserializerTests.kt similarity index 84% rename from smithy-swift-codegen/src/test/kotlin/serde/awsjson11/OutputResponseDeserializerTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/OutputResponseDeserializerTests.kt index 77f68dea1..7a446c4b1 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/awsjson11/OutputResponseDeserializerTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/OutputResponseDeserializerTests.kt @@ -1,18 +1,23 @@ -package serde.awsjson11 +package software.amazon.smithy.swift.codegen.protocolspecificserde.awsjson11 + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ -import TestContext -import asSmithy -import defaultSettings -import getModelFileContents import io.kotest.matchers.string.shouldContainOnlyOnce -import newTestContext import org.junit.jupiter.api.Test -import shouldSyntacticSanityCheck +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.model.AddOperationShapes +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck // NOTE: protocol conformance is mostly handled by the protocol tests suite class OutputDeserializerTests { - private var model = javaClass.getResource("awsjson-output-response-deserializer.smithy").asSmithy() + private var model = javaClass.classLoader.getResource("awsjson-output-response-deserializer.smithy").asSmithy() private fun newTestContext(): TestContext { val settings = model.defaultSettings() model = AddOperationShapes.execute(model, settings.getService(model), settings.moduleName) diff --git a/smithy-swift-codegen/src/test/kotlin/serde/ec2/Ec2QueryNameTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/Ec2QueryNameTests.kt similarity index 82% rename from smithy-swift-codegen/src/test/kotlin/serde/ec2/Ec2QueryNameTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/Ec2QueryNameTests.kt index afdbc4544..897aaf058 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/ec2/Ec2QueryNameTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/Ec2QueryNameTests.kt @@ -1,17 +1,17 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.ec2query + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.ec2 - -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce -import mocks.MockHTTPEC2QueryProtocolGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPEC2QueryProtocolGenerator import org.junit.jupiter.api.Test -import shouldSyntacticSanityCheck +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class Ec2QueryNameTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/serde/ec2/OnlyFlattenedListEncodeFormURLGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt similarity index 84% rename from smithy-swift-codegen/src/test/kotlin/serde/ec2/OnlyFlattenedListEncodeFormURLGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt index 16acec5cc..7a960c936 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/ec2/OnlyFlattenedListEncodeFormURLGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt @@ -1,19 +1,19 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.ec2query + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.ec2 - -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce -import mocks.MockHTTPEC2QueryProtocolGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPEC2QueryProtocolGenerator import org.junit.jupiter.api.Test -import shouldSyntacticSanityCheck +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck -class OnlyFlattenedListEncodeFormURLGeneratorTests { +class OnlyFlattenedListEncodeGeneratorTests { @Test fun `001 encode different types of lists`() { diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/BlobDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/BlobDecodeXMLGenerationTests.kt similarity index 77% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/BlobDecodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/BlobDecodeXMLGenerationTests.kt index 001bec348..86f8ebfbb 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/BlobDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/BlobDecodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class BlobDecodeXMLGenerationTests { @@ -53,12 +50,4 @@ extension XmlBlobsNestedOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/BlobEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/BlobEncodeXMLGenerationTests.kt similarity index 70% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/BlobEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/BlobEncodeXMLGenerationTests.kt index ef81f7197..f1ab57a54 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/BlobEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/BlobEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class BlobEncodeXMLGenerationTests { @Test @@ -44,13 +41,4 @@ extension XmlBlobsNestedInput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateSerializers(context.generationCtx) - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/EnumDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/EnumDecodeXMLGenerationTests.kt similarity index 80% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/EnumDecodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/EnumDecodeXMLGenerationTests.kt index f7644d2cc..246d75112 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/EnumDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/EnumDecodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class EnumDecodeXMLGenerationTests { @@ -56,12 +53,4 @@ extension XmlEnumsNestedOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/EnumEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/EnumEncodeXMLGenerationTests.kt similarity index 74% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/EnumEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/EnumEncodeXMLGenerationTests.kt index 235adf222..30efa67f8 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/EnumEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/EnumEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class EnumEncodeXMLGenerationTests { @Test @@ -47,14 +44,4 @@ extension XmlEnumsNestedInput { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateSerializers(context.generationCtx) - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/ListDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/ListDecodeXMLGenerationTests.kt similarity index 93% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/ListDecodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/ListDecodeXMLGenerationTests.kt index 5f3d60c56..01bcfaa6d 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/ListDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/ListDecodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class ListDecodeXMLGenerationTests { @Test @@ -156,12 +153,4 @@ extension XmlListFlattenedContainMapOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/ListEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/ListEncodeXMLGenerationTests.kt similarity index 94% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/ListEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/ListEncodeXMLGenerationTests.kt index 0d542a689..e559bb533 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/ListEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/ListEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class ListEncodeXMLGenerationTests { @Test @@ -224,13 +221,4 @@ extension XmlListFlattenedContainMapInput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generator.generateSerializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/MapDecodeXMLGenerationTests.kt similarity index 97% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/MapDecodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/MapDecodeXMLGenerationTests.kt index e56cd166d..6abb15d57 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/MapDecodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class MapDecodeXMLGenerationTests { @@ -390,12 +387,4 @@ extension XmlMapsTwoOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/MapEncodeXMLGenerationTests.kt similarity index 96% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/MapEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/MapEncodeXMLGenerationTests.kt index 47bb0dbea..11e65277a 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/MapEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/MapEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class MapEncodeXMLGenerationTests { @Test @@ -312,14 +309,4 @@ extension NestedXmlMapsInput { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateSerializers(context.generationCtx) - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/NamespaceEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/NamespaceEncodeXMLGenerationTests.kt similarity index 90% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/NamespaceEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/NamespaceEncodeXMLGenerationTests.kt index a1acd634e..5f2449737 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/NamespaceEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/NamespaceEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class NamespaceEncodeXMLGenerationTests { @Test @@ -119,13 +116,4 @@ extension XmlNamespacesOnServiceOverridableInput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generator.generateSerializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/RecursiveShapesDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/RecursiveShapesDecodeXMLGenerationTests.kt similarity index 79% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/RecursiveShapesDecodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/RecursiveShapesDecodeXMLGenerationTests.kt index 74d04e106..cf9026d9f 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/RecursiveShapesDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/RecursiveShapesDecodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class RecursiveShapesDecodeXMLGenerationTests { @Test @@ -52,13 +49,4 @@ extension XmlNestedRecursiveShapesOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/RecursiveShapesEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/RecursiveShapesEncodeXMLGenerationTests.kt similarity index 85% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/RecursiveShapesEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/RecursiveShapesEncodeXMLGenerationTests.kt index b1fac0161..fbd6732dc 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/RecursiveShapesEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/RecursiveShapesEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class RecursiveShapesEncodeXMLGenerationTests { @Test @@ -77,13 +74,4 @@ extension XmlNestedRecursiveShapesInput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateSerializers(context.generationCtx) - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/SetDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetDecodeXMLGenerationTests.kt similarity index 79% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/SetDecodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetDecodeXMLGenerationTests.kt index 92992604c..cbfc702dd 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/SetDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetDecodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class SetDecodeXMLGenerationTests { @Test @@ -52,13 +49,4 @@ extension XmlEnumNestedSetOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/SetEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetEncodeXMLGenerationTests.kt similarity index 73% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/SetEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetEncodeXMLGenerationTests.kt index 5036c8c23..fb07ddfd1 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/SetEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class SetEncodeXMLGenerationTests { @Test @@ -44,14 +41,4 @@ extension XmlEnumNestedSetInput { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generator.generateSerializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt new file mode 100644 index 000000000..b61a46ea8 --- /dev/null +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt @@ -0,0 +1,23 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestXMLProtocolGenerator + +fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { + val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> + model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") + } + context.generator.initializeMiddleware(context.generationCtx) + context.generator.generateSerializers(context.generationCtx) + context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) + context.generator.generateDeserializers(context.generationCtx) + context.generator.generateProtocolClient(context.generationCtx) + context.generationCtx.delegator.flushWriters() + return context +} \ No newline at end of file diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/StructDecodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/StructDecodeXMLGenerationTests.kt similarity index 90% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/StructDecodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/StructDecodeXMLGenerationTests.kt index fd772788b..e56c188a7 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/StructDecodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/StructDecodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class StructDecodeXMLGenerationTests { @Test @@ -109,13 +106,4 @@ extension XmlEmptyListsOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/StructEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/StructEncodeXMLGenerationTests.kt similarity index 78% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/StructEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/StructEncodeXMLGenerationTests.kt index 61da2da57..940d00b31 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/StructEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/StructEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class StructEncodeXMLGenerationTests { @Test @@ -62,14 +59,4 @@ extension RestXmlProtocolClientTypes.StructureListMember { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generator.generateSerializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampDecodeGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/TimeStampDecodeGenerationTests.kt similarity index 89% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampDecodeGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/TimeStampDecodeGenerationTests.kt index eeb9e2382..fe2153237 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampDecodeGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/TimeStampDecodeGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class TimeStampDecodeGenerationTests { @Test @@ -95,12 +92,4 @@ extension XmlTimestampsNestedXmlNameOutput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateDeserializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampEncodeGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/TimeStampEncodeGenerationTests.kt similarity index 87% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampEncodeGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/TimeStampEncodeGenerationTests.kt index bda9e17b5..56814b9b1 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/TimeStampEncodeGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/TimeStampEncodeGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class TimeStampEncodeGenerationTests { @Test @@ -96,13 +93,4 @@ extension XmlTimestampsXmlNameInput { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generator.generateSerializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/serde/xml/UnionEncodeXMLGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/UnionEncodeXMLGenerationTests.kt similarity index 87% rename from smithy-swift-codegen/src/test/kotlin/serde/xml/UnionEncodeXMLGenerationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/UnionEncodeXMLGenerationTests.kt index 1e24755af..1eb1e0acc 100644 --- a/smithy-swift-codegen/src/test/kotlin/serde/xml/UnionEncodeXMLGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/UnionEncodeXMLGenerationTests.kt @@ -1,16 +1,13 @@ +package software.amazon.smithy.swift.codegen.protocolspecificserde.xml + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package serde.xml - -import MockHTTPRestXMLProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents class UnionEncodeXMLGenerationTests { @Test @@ -90,14 +87,4 @@ extension ExampleClientTypes { """ contents.shouldContainOnlyOnce(expectedContents) } - - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.generateCodableConformanceForNestedTypes(context.generationCtx) - context.generator.generateSerializers(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/EventStreamTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/EventStreamTests.kt similarity index 97% rename from smithy-swift-codegen/src/test/kotlin/EventStreamTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/EventStreamTests.kt index bc5667636..84b22a3f9 100644 --- a/smithy-swift-codegen/src/test/kotlin/EventStreamTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/EventStreamTests.kt @@ -1,6 +1,17 @@ +package software.amazon.smithy.swift.codegen.requestandresponse + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.DefaultClientConfigurationIntegration +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator class EventStreamTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/HTTPBindingProtocolGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/HTTPBindingProtocolGeneratorTests.kt similarity index 92% rename from smithy-swift-codegen/src/test/kotlin/HTTPBindingProtocolGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/HTTPBindingProtocolGeneratorTests.kt index 34c92f140..954053e0b 100644 --- a/smithy-swift-codegen/src/test/kotlin/HTTPBindingProtocolGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/HTTPBindingProtocolGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.requestandresponse + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -7,6 +9,10 @@ import io.kotest.matchers.comparables.shouldBeEqualComparingTo import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.integration.DefaultServiceConfig import software.amazon.smithy.swift.codegen.integration.HTTPProtocolCustomizable import software.amazon.smithy.swift.codegen.integration.HttpBindingResolver @@ -16,6 +22,8 @@ import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.ServiceConfig import software.amazon.smithy.swift.codegen.middleware.OperationMiddleware import software.amazon.smithy.swift.codegen.model.AddOperationShapes +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class TestHttpProtocolClientGeneratorFactory : HttpProtocolClientGeneratorFactory { override fun createHttpProtocolClientGenerator( @@ -39,7 +47,7 @@ class TestHttpProtocolClientGeneratorFactory : HttpProtocolClientGeneratorFactor // NOTE: protocol conformance is mostly handled by the protocol tests suite class HTTPBindingProtocolGeneratorTests { - private var model = javaClass.getResource("http-binding-protocol-generator-test.smithy").asSmithy() + private var model = javaClass.classLoader.getResource("http-binding-protocol-generator-test.smithy").asSmithy() private fun newTestContext(): TestContext { val settings = model.defaultSettings() model = AddOperationShapes.execute(model, settings.getService(model), settings.moduleName) diff --git a/smithy-swift-codegen/src/test/kotlin/AuthSchemeResolverGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/AuthSchemeResolverGeneratorTests.kt similarity index 90% rename from smithy-swift-codegen/src/test/kotlin/AuthSchemeResolverGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/AuthSchemeResolverGeneratorTests.kt index 973cc9e79..414272a01 100644 --- a/smithy-swift-codegen/src/test/kotlin/AuthSchemeResolverGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/AuthSchemeResolverGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.requestflow + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -5,6 +7,11 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class AuthSchemeResolverGeneratorTests { @Test @@ -97,9 +104,10 @@ public struct DefaultExampleAuthSchemeResolver: ExampleAuthSchemeResolver { } private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestJsonProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "Example", "2023-11-02", "Example") - } + val context = + TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestJsonProtocolGenerator()) { model -> + model.defaultSettings(serviceShapeId, "Example", "2023-11-02", "Example") + } context.generator.initializeMiddleware(context.generationCtx) context.generator.generateProtocolClient(context.generationCtx) context.generator.generateSerializers(context.generationCtx) diff --git a/smithy-swift-codegen/src/test/kotlin/ContentMd5MiddlewareTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/ContentMd5MiddlewareTests.kt similarity index 54% rename from smithy-swift-codegen/src/test/kotlin/ContentMd5MiddlewareTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/ContentMd5MiddlewareTests.kt index 9e8a6ea4b..318e685f1 100644 --- a/smithy-swift-codegen/src/test/kotlin/ContentMd5MiddlewareTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/ContentMd5MiddlewareTests.kt @@ -1,5 +1,14 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.requestflow + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolspecificserde.xml.setupTests class ContentMd5MiddlewareTests { @Test @@ -11,13 +20,4 @@ class ContentMd5MiddlewareTests { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.initializeMiddleware(context.generationCtx) - context.generator.generateProtocolClient(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/HttpHeaderProviderGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpHeaderProviderGeneratorTests.kt similarity index 88% rename from smithy-swift-codegen/src/test/kotlin/HttpHeaderProviderGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpHeaderProviderGeneratorTests.kt index 156a865d6..86d54864d 100644 --- a/smithy-swift-codegen/src/test/kotlin/HttpHeaderProviderGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpHeaderProviderGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.requestflow + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -5,10 +7,16 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.model.AddOperationShapes +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class HttpHeaderProviderGeneratorTests { - private var model = javaClass.getResource("http-binding-protocol-generator-test.smithy").asSmithy() + private var model = javaClass.classLoader.getResource("http-binding-protocol-generator-test.smithy").asSmithy() var newTestContext: TestContext init { newTestContext = newTestContext() diff --git a/smithy-swift-codegen/src/test/kotlin/HttpQueryItemProviderGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpQueryItemProviderGeneratorTests.kt similarity index 97% rename from smithy-swift-codegen/src/test/kotlin/HttpQueryItemProviderGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpQueryItemProviderGeneratorTests.kt index d9f38261f..a99b7b785 100644 --- a/smithy-swift-codegen/src/test/kotlin/HttpQueryItemProviderGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpQueryItemProviderGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.requestflow + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -6,6 +8,10 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.getModelFileContents +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck import java.util.Optional class HttpQueryItemProviderGeneratorTests { diff --git a/smithy-swift-codegen/src/test/kotlin/HttpUrlPathProviderTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpUrlPathProviderTests.kt similarity index 79% rename from smithy-swift-codegen/src/test/kotlin/HttpUrlPathProviderTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpUrlPathProviderTests.kt index 28e92c928..fb266f150 100644 --- a/smithy-swift-codegen/src/test/kotlin/HttpUrlPathProviderTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/HttpUrlPathProviderTests.kt @@ -1,6 +1,19 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.requestflow + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getModelFileContents import software.amazon.smithy.swift.codegen.model.AddOperationShapes +import software.amazon.smithy.swift.codegen.newTestContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class HttpUrlPathProviderTests { @Test @@ -47,7 +60,7 @@ extension RequiredHttpFieldsInput { } private fun setupTests(smithyFile: String): TestContext { - var model = javaClass.getResource(smithyFile).asSmithy() + var model = javaClass.classLoader.getResource(smithyFile).asSmithy() val settings = model.defaultSettings() model = AddOperationShapes.execute(model, settings.getService(model), settings.moduleName) val context = model.newTestContext() diff --git a/smithy-swift-codegen/src/test/kotlin/MiddlewareGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/MiddlewareGeneratorTests.kt similarity index 94% rename from smithy-swift-codegen/src/test/kotlin/MiddlewareGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/MiddlewareGeneratorTests.kt index 12490e3d4..e4b01dd0e 100644 --- a/smithy-swift-codegen/src/test/kotlin/MiddlewareGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/MiddlewareGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.requestflow + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. diff --git a/smithy-swift-codegen/src/test/kotlin/RetryMiddlewareTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/RetryMiddlewareTests.kt similarity index 56% rename from smithy-swift-codegen/src/test/kotlin/RetryMiddlewareTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/RetryMiddlewareTests.kt index 482c9baf9..917f3fcc1 100644 --- a/smithy-swift-codegen/src/test/kotlin/RetryMiddlewareTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/requestflow/RetryMiddlewareTests.kt @@ -1,5 +1,14 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.requestflow + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolspecificserde.xml.setupTests class RetryMiddlewareTests { @@ -13,13 +22,4 @@ class RetryMiddlewareTests { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.initializeMiddleware(context.generationCtx) - context.generator.generateProtocolClient(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/EventStreamsInitialResponseTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/EventStreamsInitialResponseTests.kt similarity index 88% rename from smithy-swift-codegen/src/test/kotlin/EventStreamsInitialResponseTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/EventStreamsInitialResponseTests.kt index e68016348..7a2a12ec3 100644 --- a/smithy-swift-codegen/src/test/kotlin/EventStreamsInitialResponseTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/EventStreamsInitialResponseTests.kt @@ -1,12 +1,18 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.responseflow + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ import io.kotest.matchers.string.shouldContainOnlyOnce -import mocks.MockHTTPAWSJson11ProtocolGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents import software.amazon.smithy.swift.codegen.integration.HTTPBindingProtocolGenerator +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class EventStreamsInitialResponseTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/httpResponse/HttpResponseBindingIgnoreQuery.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/HttpResponseBindingIgnoreQuery.kt similarity index 67% rename from smithy-swift-codegen/src/test/kotlin/httpResponse/HttpResponseBindingIgnoreQuery.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/HttpResponseBindingIgnoreQuery.kt index 59b122cee..a2044b8b0 100644 --- a/smithy-swift-codegen/src/test/kotlin/httpResponse/HttpResponseBindingIgnoreQuery.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/HttpResponseBindingIgnoreQuery.kt @@ -1,17 +1,17 @@ +package software.amazon.smithy.swift.codegen.requestandresponse.responseflow + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package httpResponse - -import MockHTTPRestJsonProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test -import shouldSyntacticSanityCheck +import software.amazon.smithy.swift.codegen.TestContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class HttpResponseBindingIgnoreQuery { @@ -37,9 +37,10 @@ extension IgnoreQueryParamsInResponseOutput { } private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestJsonProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestJson", "2019-12-16", "Rest Json Protocol") - } + val context = + TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestJsonProtocolGenerator()) { model -> + model.defaultSettings(serviceShapeId, "RestJson", "2019-12-16", "Rest Json Protocol") + } context.generator.generateDeserializers(context.generationCtx) context.generationCtx.delegator.flushWriters() return context diff --git a/smithy-swift-codegen/src/test/kotlin/EndpointTraitConstructorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/EndpointTraitConstructorTests.kt similarity index 90% rename from smithy-swift-codegen/src/test/kotlin/EndpointTraitConstructorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/EndpointTraitConstructorTests.kt index ea099e31c..ffbdc4e8f 100644 --- a/smithy-swift-codegen/src/test/kotlin/EndpointTraitConstructorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/EndpointTraitConstructorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.traits + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -5,7 +7,9 @@ import org.junit.jupiter.api.Test import software.amazon.smithy.model.traits.EndpointTrait +import software.amazon.smithy.swift.codegen.asSmithyModel import software.amazon.smithy.swift.codegen.integration.EndpointTraitConstructor +import software.amazon.smithy.swift.codegen.newTestContext class EndpointTraitConstructorTests { @Test diff --git a/smithy-swift-codegen/src/test/kotlin/IdempotencyTokenTraitTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/IdempotencyTokenTraitTests.kt similarity index 54% rename from smithy-swift-codegen/src/test/kotlin/IdempotencyTokenTraitTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/IdempotencyTokenTraitTests.kt index 56ab5d975..057dd993f 100644 --- a/smithy-swift-codegen/src/test/kotlin/IdempotencyTokenTraitTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/IdempotencyTokenTraitTests.kt @@ -1,5 +1,15 @@ +package software.amazon.smithy.swift.codegen.traits + +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * SPDX-License-Identifier: Apache-2.0. + */ + import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test +import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolspecificserde.xml.setupTests + class IdempotencyTokenTraitTests { @Test fun `generates idempotent middleware`() { @@ -10,13 +20,4 @@ class IdempotencyTokenTraitTests { """ contents.shouldContainOnlyOnce(expectedContents) } - private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { - val context = TestContext.initContextFrom(smithyFile, serviceShapeId, MockHTTPRestXMLProtocolGenerator()) { model -> - model.defaultSettings(serviceShapeId, "RestXml", "2019-12-16", "Rest Xml Protocol") - } - context.generator.initializeMiddleware(context.generationCtx) - context.generator.generateProtocolClient(context.generationCtx) - context.generationCtx.delegator.flushWriters() - return context - } } diff --git a/smithy-swift-codegen/src/test/kotlin/SensitiveTraitGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/SensitiveTraitGeneratorTests.kt similarity index 88% rename from smithy-swift-codegen/src/test/kotlin/SensitiveTraitGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/SensitiveTraitGeneratorTests.kt index 8e48fdc90..2757b00a6 100644 --- a/smithy-swift-codegen/src/test/kotlin/SensitiveTraitGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/traits/SensitiveTraitGeneratorTests.kt @@ -1,3 +1,5 @@ +package software.amazon.smithy.swift.codegen.traits + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. @@ -6,6 +8,9 @@ import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.build.MockManifest import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin +import software.amazon.smithy.swift.codegen.asSmithy +import software.amazon.smithy.swift.codegen.buildMockPluginContext +import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class SensitiveTraitGeneratorTests { @Test @@ -55,7 +60,7 @@ extension SensitiveTraitTestRequestOutput: Swift.CustomDebugStringConvertible { } private fun setupTest(): MockManifest { - val model = javaClass.getResource("sensitive-trait-test.smithy").asSmithy() + val model = javaClass.classLoader.getResource("sensitive-trait-test.smithy").asSmithy() val manifest = MockManifest() val context = buildMockPluginContext(model, manifest, "smithy.example#Example") SwiftCodegenPlugin().execute(context) diff --git a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterAcceptorGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterAcceptorGeneratorTests.kt similarity index 95% rename from smithy-swift-codegen/src/test/kotlin/waiters/WaiterAcceptorGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterAcceptorGeneratorTests.kt index 1b20f822c..c1ac0c888 100644 --- a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterAcceptorGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterAcceptorGeneratorTests.kt @@ -1,14 +1,10 @@ +package software.amazon.smithy.swift.codegen.waiters + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package waiters - -import MockHTTPRestJsonProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.build.FileManifest @@ -20,11 +16,14 @@ import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.swift.codegen.SwiftDelegator import software.amazon.smithy.swift.codegen.SwiftSettings import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.core.SwiftCodegenContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration import software.amazon.smithy.swift.codegen.model.expectShape -import software.amazon.smithy.swift.codegen.waiters.WaiterAcceptorGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator import software.amazon.smithy.waiters.WaitableTrait class WaiterAcceptorGeneratorTests { diff --git a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterConfigGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterConfigGeneratorTests.kt similarity index 93% rename from smithy-swift-codegen/src/test/kotlin/waiters/WaiterConfigGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterConfigGeneratorTests.kt index 89b15ce00..fc96c5bd3 100644 --- a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterConfigGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterConfigGeneratorTests.kt @@ -1,14 +1,10 @@ +package software.amazon.smithy.swift.codegen.waiters + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package waiters - -import MockHTTPRestJsonProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.build.FileManifest @@ -20,11 +16,14 @@ import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.swift.codegen.SwiftDelegator import software.amazon.smithy.swift.codegen.SwiftSettings import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.core.SwiftCodegenContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration import software.amazon.smithy.swift.codegen.model.expectShape -import software.amazon.smithy.swift.codegen.waiters.WaiterConfigGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator import software.amazon.smithy.waiters.WaitableTrait class WaiterConfigGeneratorTests { diff --git a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterGeneratorTests.kt similarity index 92% rename from smithy-swift-codegen/src/test/kotlin/waiters/WaiterGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterGeneratorTests.kt index 722c85912..2a62a9bd5 100644 --- a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterGeneratorTests.kt @@ -1,14 +1,10 @@ +package software.amazon.smithy.swift.codegen.waiters + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package waiters - -import MockHTTPRestJsonProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.build.FileManifest @@ -18,10 +14,13 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.swift.codegen.SwiftDelegator import software.amazon.smithy.swift.codegen.SwiftSettings import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.core.SwiftCodegenContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration -import software.amazon.smithy.swift.codegen.waiters.WaiterGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator class WaiterGeneratorTests { diff --git a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterIntegrationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterIntegrationTests.kt similarity index 93% rename from smithy-swift-codegen/src/test/kotlin/waiters/WaiterIntegrationTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterIntegrationTests.kt index f47ebb84c..b4433060b 100644 --- a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterIntegrationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterIntegrationTests.kt @@ -1,13 +1,10 @@ +package software.amazon.smithy.swift.codegen.waiters + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package waiters - -import MockHTTPRestJsonProtocolGenerator -import TestContext -import defaultSettings import io.kotest.matchers.booleans.shouldBeFalse import io.kotest.matchers.booleans.shouldBeTrue import io.kotest.matchers.collections.shouldContain @@ -20,10 +17,12 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.swift.codegen.SwiftDelegator import software.amazon.smithy.swift.codegen.SwiftSettings import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.core.SwiftCodegenContext +import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration -import software.amazon.smithy.swift.codegen.waiters.WaiterIntegration +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator import kotlin.io.path.Path class WaiterIntegrationTests { diff --git a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterMethodGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterMethodGeneratorTests.kt similarity index 93% rename from smithy-swift-codegen/src/test/kotlin/waiters/WaiterMethodGeneratorTests.kt rename to smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterMethodGeneratorTests.kt index 67e429b53..7dfa98673 100644 --- a/smithy-swift-codegen/src/test/kotlin/waiters/WaiterMethodGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/waiters/WaiterMethodGeneratorTests.kt @@ -1,14 +1,10 @@ +package software.amazon.smithy.swift.codegen.waiters + /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ -package waiters - -import MockHTTPRestJsonProtocolGenerator -import TestContext -import defaultSettings -import getFileContents import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test import software.amazon.smithy.build.FileManifest @@ -20,11 +16,14 @@ import software.amazon.smithy.model.shapes.ServiceShape import software.amazon.smithy.swift.codegen.SwiftDelegator import software.amazon.smithy.swift.codegen.SwiftSettings import software.amazon.smithy.swift.codegen.SwiftWriter +import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.core.SwiftCodegenContext +import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.getFileContents import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration import software.amazon.smithy.swift.codegen.model.expectShape -import software.amazon.smithy.swift.codegen.waiters.WaiterMethodGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator import software.amazon.smithy.waiters.WaitableTrait class WaiterMethodGeneratorTests { diff --git a/smithy-swift-codegen/src/test/resources/serde/awsjson11/awsjson-output-response-deserializer.smithy b/smithy-swift-codegen/src/test/resources/awsjson-output-response-deserializer.smithy similarity index 100% rename from smithy-swift-codegen/src/test/resources/serde/awsjson11/awsjson-output-response-deserializer.smithy rename to smithy-swift-codegen/src/test/resources/awsjson-output-response-deserializer.smithy From 05b280f53f9e2d5a51ac6902ebd795475d79ae0e Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Fri, 20 Sep 2024 15:07:41 -0700 Subject: [PATCH 2/2] ktlint --- .../smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt | 1 - .../amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt | 4 ---- .../kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt | 3 --- .../codegen/manifestanddocs/PackageManifestGeneratorTests.kt | 2 +- .../awsjson11/NestedListEncodeJSONGenerationTests.kt | 2 +- .../protocolspecificserde/ec2query/Ec2QueryNameTests.kt | 2 +- .../ec2query/OnlyFlattenedListEncodeGeneratorTests.kt | 2 +- .../codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt | 2 +- .../responseflow/EventStreamsInitialResponseTests.kt | 2 +- 9 files changed, 6 insertions(+), 14 deletions(-) diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt index ffb1f0ad7..5a2972a58 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/HttpProtocolClientGeneratorTests.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.swift.codegen import io.kotest.matchers.string.shouldContain import io.kotest.matchers.string.shouldContainOnlyOnce import org.junit.jupiter.api.Test -import software.amazon.smithy.swift.codegen.DefaultClientConfigurationIntegration import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPRestJsonProtocolGenerator class HttpProtocolClientGeneratorTests { diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt index 34507054a..463a66f4a 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/PaginatorGeneratorTest.kt @@ -11,10 +11,6 @@ import software.amazon.smithy.build.FileManifest import software.amazon.smithy.codegen.core.SymbolProvider import software.amazon.smithy.codegen.core.WriterDelegator import software.amazon.smithy.model.Model -import software.amazon.smithy.swift.codegen.PaginatorGenerator -import software.amazon.smithy.swift.codegen.SwiftDelegator -import software.amazon.smithy.swift.codegen.SwiftSettings -import software.amazon.smithy.swift.codegen.SwiftWriter import software.amazon.smithy.swift.codegen.core.SwiftCodegenContext import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator import software.amazon.smithy.swift.codegen.integration.SwiftIntegration diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt index 5e49caf10..03d63284b 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/TestUtils.kt @@ -23,9 +23,6 @@ import software.amazon.smithy.model.traits.DocumentationTrait import software.amazon.smithy.model.traits.ErrorTrait import software.amazon.smithy.model.traits.HttpErrorTrait import software.amazon.smithy.model.traits.RetryableTrait -import software.amazon.smithy.swift.codegen.SwiftCodegenPlugin -import software.amazon.smithy.swift.codegen.SwiftDelegator -import software.amazon.smithy.swift.codegen.SwiftSettings import software.amazon.smithy.swift.codegen.customtraits.SwiftBoxTrait import software.amazon.smithy.swift.codegen.integration.HTTPBindingProtocolGenerator import software.amazon.smithy.swift.codegen.integration.ProtocolGenerator diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/PackageManifestGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/PackageManifestGeneratorTests.kt index 63bf80ee4..935484b57 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/PackageManifestGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/manifestanddocs/PackageManifestGeneratorTests.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.swift.codegen.manifestanddocs */ import io.kotest.matchers.string.shouldContain -import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.PackageManifestGenerator import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.defaultSettings +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator class PackageManifestGeneratorTests { private val testContext = setupTests("simple-service-with-operation-and-dependency.smithy", "smithy.example#Example") diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/NestedListEncodeJSONGenerationTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/NestedListEncodeJSONGenerationTests.kt index 0bb1baa00..312b760f7 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/NestedListEncodeJSONGenerationTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/awsjson11/NestedListEncodeJSONGenerationTests.kt @@ -6,11 +6,11 @@ package software.amazon.smithy.swift.codegen.protocolspecificserde.awsjson11 */ import io.kotest.matchers.string.shouldContainOnlyOnce -import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class NestedListEncodeJSONGenerationTests { diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/Ec2QueryNameTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/Ec2QueryNameTests.kt index 897aaf058..d284682eb 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/Ec2QueryNameTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/Ec2QueryNameTests.kt @@ -6,11 +6,11 @@ package software.amazon.smithy.swift.codegen.protocolspecificserde.ec2query */ import io.kotest.matchers.string.shouldContainOnlyOnce -import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPEC2QueryProtocolGenerator import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPEC2QueryProtocolGenerator import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class Ec2QueryNameTests { diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt index 7a960c936..2f0946825 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/ec2query/OnlyFlattenedListEncodeGeneratorTests.kt @@ -6,11 +6,11 @@ package software.amazon.smithy.swift.codegen.protocolspecificserde.ec2query */ import io.kotest.matchers.string.shouldContainOnlyOnce -import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPEC2QueryProtocolGenerator import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.getFileContents +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPEC2QueryProtocolGenerator import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class OnlyFlattenedListEncodeGeneratorTests { diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt index b61a46ea8..e2db3b171 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/protocolspecificserde/xml/SetUpXMLCodegenTests.kt @@ -20,4 +20,4 @@ fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { context.generator.generateProtocolClient(context.generationCtx) context.generationCtx.delegator.flushWriters() return context -} \ No newline at end of file +} diff --git a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/EventStreamsInitialResponseTests.kt b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/EventStreamsInitialResponseTests.kt index 7a2a12ec3..d1cb8cb5a 100644 --- a/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/EventStreamsInitialResponseTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/software/amazon/smithy/swift/codegen/requestandresponse/responseflow/EventStreamsInitialResponseTests.kt @@ -6,12 +6,12 @@ package software.amazon.smithy.swift.codegen.requestandresponse.responseflow */ import io.kotest.matchers.string.shouldContainOnlyOnce -import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import org.junit.jupiter.api.Test import software.amazon.smithy.swift.codegen.TestContext import software.amazon.smithy.swift.codegen.defaultSettings import software.amazon.smithy.swift.codegen.getFileContents import software.amazon.smithy.swift.codegen.integration.HTTPBindingProtocolGenerator +import software.amazon.smithy.swift.codegen.protocolgeneratormocks.MockHTTPAWSJson11ProtocolGenerator import software.amazon.smithy.swift.codegen.shouldSyntacticSanityCheck class EventStreamsInitialResponseTests {