@@ -21,12 +21,9 @@ import software.amazon.smithy.model.shapes.*
2121import software.amazon.smithy.model.traits.TimestampFormatTrait
2222import software.amazon.smithy.utils.StringUtils
2323
24- /* *
25- * This file houses test classes and functions relating to the code generator (protocols, serializers, etc)
26- *
27- * Items contained here should be relatively high-level, utilizing all members of codegen classes, Smithy, and
28- * anything else necessary for test functionality.
29- */
24+ // This file houses test classes and functions relating to the code generator (protocols, serializers, etc)
25+ // Items contained here should be relatively high-level, utilizing all members of codegen classes, Smithy, and
26+ // anything else necessary for test functionality.
3027
3128/* *
3229 * Container for type instances necessary for tests
@@ -37,8 +34,8 @@ data class TestContext(
3734 val generator : ProtocolGenerator ,
3835)
3936
40- // Execute the codegen and return the generated output
41- internal fun testRender (
37+ /* * Execute the codegen and return the generated output */
38+ fun testRender (
4239 members : List <MemberShape >,
4340 renderFn : (List <MemberShape >, KotlinWriter ) -> Unit ,
4441): String {
@@ -47,8 +44,8 @@ internal fun testRender(
4744 return writer.toString()
4845}
4946
50- // Drive codegen for serialization of a given shape
51- internal fun codegenSerializerForShape (model : Model , shapeId : String , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): String {
47+ /* * Drive codegen for serialization of a given shape */
48+ fun codegenSerializerForShape (model : Model , shapeId : String , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): String {
5249 val ctx = model.newTestContext()
5350
5451 val op = ctx.generationCtx.model.expectShape(ShapeId .from(shapeId))
@@ -62,8 +59,8 @@ internal fun codegenSerializerForShape(model: Model, shapeId: String, location:
6259 }
6360}
6461
65- // Drive codegen for deserialization of a given shape
66- internal fun codegenDeserializerForShape (model : Model , shapeId : String , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): String {
62+ /* * Drive codegen for deserialization of a given shape */
63+ fun codegenDeserializerForShape (model : Model , shapeId : String , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): String {
6764 val ctx = model.newTestContext()
6865 val op = ctx.generationCtx.model.expectShape(ShapeId .from(shapeId))
6966
@@ -77,8 +74,8 @@ internal fun codegenDeserializerForShape(model: Model, shapeId: String, location
7774 }
7875}
7976
80- // Drive codegen for serializer of a union of a given shape
81- internal fun codegenUnionSerializerForShape (model : Model , shapeId : String ): String {
77+ /* * Drive codegen for serializer of a union of a given shape */
78+ fun codegenUnionSerializerForShape (model : Model , shapeId : String ): String {
8279 val ctx = model.newTestContext()
8380
8481 val bindingIndex = HttpBindingIndex .of(ctx.generationCtx.model)
@@ -98,8 +95,8 @@ internal fun codegenUnionSerializerForShape(model: Model, shapeId: String): Stri
9895 }
9996}
10097
101- // Retrieves Response Document members for HttpTrait-enabled protocols
102- internal fun TestContext.responseMembers (shape : Shape , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): List <MemberShape > {
98+ /* * Retrieves response document members for HttpTrait-enabled protocols */
99+ fun TestContext.responseMembers (shape : Shape , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): List <MemberShape > {
103100 val bindingIndex = HttpBindingIndex .of(this .generationCtx.model)
104101 val responseBindings = bindingIndex.getResponseBindings(shape)
105102
@@ -109,8 +106,8 @@ internal fun TestContext.responseMembers(shape: Shape, location: HttpBinding.Loc
109106 .map { it.member }
110107}
111108
112- // Retrieves Request Document members for HttpTrait-enabled protocols
113- internal fun TestContext.requestMembers (shape : Shape , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): List <MemberShape > {
109+ /* * Retrieves Request Document members for HttpTrait-enabled protocols */
110+ fun TestContext.requestMembers (shape : Shape , location : HttpBinding .Location = HttpBinding .Location .DOCUMENT ): List <MemberShape > {
114111 val bindingIndex = HttpBindingIndex .of(this .generationCtx.model)
115112 val responseBindings = bindingIndex.getRequestBindings(shape)
116113
@@ -120,21 +117,21 @@ internal fun TestContext.requestMembers(shape: Shape, location: HttpBinding.Loca
120117 .map { it.member }
121118}
122119
123- internal fun TestContext.toGenerationContext (): GenerationContext =
120+ fun TestContext.toGenerationContext (): GenerationContext =
124121 GenerationContext (generationCtx.model, generationCtx.symbolProvider, generationCtx.settings, generator)
125122
126123fun <T : Shape > TestContext.toRenderingContext (writer : KotlinWriter , forShape : T ? = null): RenderingContext <T > =
127124 toGenerationContext().toRenderingContext(writer, forShape)
128125
129- // A HttpProtocolClientGenerator for testing
130- internal class TestProtocolClientGenerator (
126+ /* * An HttpProtocolClientGenerator for testing */
127+ class TestProtocolClientGenerator (
131128 ctx : ProtocolGenerator .GenerationContext ,
132129 features : List <ProtocolMiddleware >,
133130 httpBindingResolver : HttpBindingResolver ,
134131) : HttpProtocolClientGenerator(ctx, features, httpBindingResolver)
135132
136- // A HttpBindingProtocolGenerator for testing (nothing is rendered for serializing/deserializing payload bodies)
137- internal class MockHttpProtocolGenerator : HttpBindingProtocolGenerator () {
133+ /* * An HttpBindingProtocolGenerator for testing (nothing is rendered for serializing/deserializing payload bodies) */
134+ class MockHttpProtocolGenerator : HttpBindingProtocolGenerator () {
138135 override val defaultTimestampFormat: TimestampFormatTrait .Format = TimestampFormatTrait .Format .EPOCH_SECONDS
139136 override fun getProtocolHttpBindingResolver (model : Model , serviceShape : ServiceShape ): HttpBindingResolver =
140137 HttpTraitResolver (model, serviceShape, ProtocolContentTypes .consistent(" application/json" ))
@@ -192,7 +189,7 @@ internal class MockHttpProtocolGenerator : HttpBindingProtocolGenerator() {
192189 }
193190}
194191
195- // Create a test harness with all necessary codegen types
192+ /* * Create a test harness with all necessary codegen types */
196193fun codegenTestHarnessForModelSnippet (
197194 generator : ProtocolGenerator ,
198195 namespace : String = TestModelDefault .NAMESPACE ,
@@ -219,8 +216,10 @@ data class CodegenTestHarness(
219216 val protocol : String ,
220217)
221218
222- // Create and use a writer to drive codegen from a function taking a writer.
223- // Strip off comment and package preamble.
219+ /* *
220+ * Create and use a writer to drive codegen from a function taking a writer.
221+ * Strip off comment and package preamble.
222+ */
224223fun generateCode (generator : (KotlinWriter ) -> Unit ): String {
225224 val packageDeclaration = " some-unique-thing-that-will-never-be-codegened"
226225 val writer = KotlinWriter (packageDeclaration)
0 commit comments