-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing inner enum import on operations
Previously inner types of complex types were not imported properly on operations. This resulted in Retrofit interfaces missing some imports. This commit introduces methods to inspect and import the inner types used as result types of operations. Fixes #76
- Loading branch information
Showing
8 changed files
with
249 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
plugin/src/test/java/com/yelp/codegen/KotlinGenerator_TypeMappersTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package com.yelp.codegen | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Test | ||
|
||
class KotlinGenerator_TypeMappersTest { | ||
|
||
@Test | ||
fun listTypeWrapper_withSimpleType() { | ||
assertEquals("List<String>", KotlinGenerator().listTypeWrapper("List", "String")) | ||
} | ||
|
||
@Test | ||
fun listTypeWrapper_withMultipleNesting() { | ||
assertEquals("List<List<String>>", KotlinGenerator().listTypeWrapper("List", "List<String>")) | ||
} | ||
|
||
@Test | ||
fun listTypeUnwrapper_withSimpleType() { | ||
assertEquals("String", KotlinGenerator().listTypeUnwrapper("String")) | ||
} | ||
|
||
@Test | ||
fun listTypeUnwrapper_withListType() { | ||
assertEquals("String", KotlinGenerator().listTypeUnwrapper("List<String>")) | ||
} | ||
|
||
@Test | ||
fun isListTypeWrapped_withSimpleType() { | ||
assertFalse(KotlinGenerator().isListTypeWrapped("String")) | ||
} | ||
|
||
@Test | ||
fun isListTypeWrapped_withListType() { | ||
assertTrue(KotlinGenerator().isListTypeWrapped("List<String>")) | ||
} | ||
|
||
@Test | ||
fun isListTypeWrapped_withMapType() { | ||
assertFalse(KotlinGenerator().isListTypeWrapped("Map<String, Int>")) | ||
} | ||
|
||
@Test | ||
fun mapTypeWrapper_withSimpleType() { | ||
assertEquals("Map<String, Any>", KotlinGenerator().mapTypeWrapper("Map", "Any")) | ||
} | ||
|
||
@Test | ||
fun mapTypeWrapper_withMultipleNesting() { | ||
assertEquals("HashMap<String, List<Any?>?>", KotlinGenerator().mapTypeWrapper("HashMap", "List<Any?>?")) | ||
} | ||
|
||
@Test | ||
fun mapTypeUnwrapper_withSimpleType() { | ||
assertEquals("String", KotlinGenerator().mapTypeUnwrapper("String")) | ||
} | ||
|
||
@Test | ||
fun mapTypeUnwrapper_withMapType() { | ||
assertEquals("Int", KotlinGenerator().mapTypeUnwrapper("Map<String, Int>")) | ||
} | ||
|
||
@Test | ||
fun isMapTypeWrapped_withSimpleType() { | ||
assertFalse(KotlinGenerator().isMapTypeWrapped("String")) | ||
} | ||
|
||
@Test | ||
fun isMapTypeWrapped_withListType() { | ||
assertFalse(KotlinGenerator().isMapTypeWrapped("List<String>")) | ||
} | ||
|
||
@Test | ||
fun isMapTypeWrapped_withMapType() { | ||
assertTrue(KotlinGenerator().isMapTypeWrapped("Map<String, Int>")) | ||
} | ||
|
||
@Test | ||
fun nullableTypeWrapper_withSimpleType() { | ||
assertEquals("String?", KotlinGenerator().nullableTypeWrapper("String")) | ||
} | ||
|
||
@Test | ||
fun resolveInnerType_withSimpleType() { | ||
assertEquals("String", KotlinGenerator().resolveInnerType("String")) | ||
} | ||
|
||
@Test | ||
fun resolveInnerType_withListType() { | ||
assertEquals("String", KotlinGenerator().resolveInnerType("List<String>")) | ||
} | ||
|
||
@Test | ||
fun resolveInnerType_withMapType() { | ||
assertEquals("Int", KotlinGenerator().resolveInnerType("Map<String, Int>")) | ||
} | ||
|
||
@Test | ||
fun resolveInnerType_withComplexType() { | ||
assertEquals("Int", KotlinGenerator().resolveInnerType("Map<String, Map<String, List<Map<String, Int>>>>")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters