22
33package com.yelp.codegen
44
5+ import com.google.common.annotations.VisibleForTesting
56import com.yelp.codegen.utils.KotlinLangUtils
67import com.yelp.codegen.utils.safeSuffix
78import com.yelp.codegen.utils.sanitizeKotlinSpecificNames
@@ -62,7 +63,8 @@ class KotlinGenerator : SharedCodegen() {
6263 * ABSTRACT FIELDS AND CONFIG FUNCTIONS
6364 ==================================================== */
6465
65- override val platform = " android"
66+ @VisibleForTesting
67+ public override val platform = " android"
6668
6769 override fun getName () = " kotlin"
6870
@@ -131,13 +133,16 @@ class KotlinGenerator : SharedCodegen() {
131133 /* * No testing files are needed on Kotlin Generator */
132134 override val testingSupportFiles = listOf<SupportingFile >()
133135
134- override fun listTypeWrapper (listType : String , innerType : String ) =
136+ @VisibleForTesting
137+ public override fun listTypeWrapper (listType : String , innerType : String ) =
135138 " $listType <$innerType >"
136139
137- override fun mapTypeWrapper (mapType : String , innerType : String ) =
140+ @VisibleForTesting
141+ public override fun mapTypeWrapper (mapType : String , innerType : String ) =
138142 " $mapType <${typeMapping[" string" ]} , $innerType >"
139143
140- override fun nullableTypeWrapper (baseType : String ) =
144+ @VisibleForTesting
145+ public override fun nullableTypeWrapper (baseType : String ) =
141146 baseType.safeSuffix(" ?" )
142147
143148 /*
@@ -151,7 +156,8 @@ class KotlinGenerator : SharedCodegen() {
151156 specialCharReplacements.remove(" _" )
152157 }
153158
154- override fun isReservedWord (word : String? ) = word in reservedWords
159+ @VisibleForTesting
160+ public override fun isReservedWord (word : String? ) = word in reservedWords
155161
156162 // remove " to avoid code injection
157163 override fun escapeQuotationMark (input : String ) = input.replace(" \" " , " " )
@@ -176,7 +182,8 @@ class KotlinGenerator : SharedCodegen() {
176182 return codegenModel
177183 }
178184
179- private fun addRequiredImports (codegenModel : CodegenModel ) {
185+ @VisibleForTesting
186+ internal fun addRequiredImports (codegenModel : CodegenModel ) {
180187 // If there are any vars, we will mark them with the @Json annotation so we have to make sure to import it
181188 if (codegenModel.vars.isNotEmpty() || codegenModel.isEnum) {
182189 codegenModel.imports.add(" com.squareup.moshi.Json" )
@@ -301,7 +308,8 @@ class KotlinGenerator : SharedCodegen() {
301308 }
302309 }
303310
304- override fun addImport (model : CodegenModel , type : String? ) {
311+ @VisibleForTesting
312+ public override fun addImport (model : CodegenModel , type : String? ) {
305313 if (type != null && needToImport(type) && type in importMapping) {
306314 model.imports.add(type)
307315 }
0 commit comments