@@ -19,55 +19,59 @@ abstract class AbstractIT : DescribeSpec {
1919
2020 private constructor () : super ()
2121
22- constructor (body: DescribeSpec .(AbstractIT ) -> Unit ) : super ({ body(this , object : AbstractIT () {}) })
22+ constructor (
23+ body: DescribeSpec .(AbstractIT ) -> Unit
24+ ) : super ({ body(this , object : AbstractIT () {}) })
2325
2426 init {
2527 assertSoftly = true
2628 }
2729
28- val duplicatedValues = listOf (
29- " Tiger! Tiger!" , // book#title
30- " Girls Girls" , // kPop#girlsGroups
31- " Two Two" , // kPop#firstGroups
32- " woof woof" , // creature#dog#sound
33- " Duran Duran" , // rockBand#name
34- " Li Li" , // heroesOfTheStorm#heroes
35- " Dee Dee" , // theFreshPrinceOfBelAir#characters
36- " Lola Lola" , // cannabis#brands
37- " Hail Hail" , // pearlJam#songs
38- " Help Help" , // pearlJam#songs
39- " Mr. Mr." , // kPop#thirdGroups
40- " Chitty Chitty Bang Bang" , // show#adultMusical
41- " etc. etc." , // marketing#buzzwords
42- " Ook Ook" , // ventureBros#character
43- " Mahi Mahi" , // food#ingredients
44- " Cous Cous" , // food#ingredients
45- " Boom Boom" , // superMario#characters
46- " Pom Pom" , // superMario#characters
47- " Min Min" , // superSmashBros#fighter
48- )
49-
50- val valuesWithHashKey = listOf (
51- " A# .NET" , // programmingLanguage#name
52- " A# (Axiom)" , // programmingLanguage#name
53- " C# – ISO/I EC 23270" , // programmingLanguage#name
54- " F#" , // programmingLanguage#name
55- " J#" , // programmingLanguage#name
56- " M#" , // programmingLanguage#name
57- " P#" , // programmingLanguage#name
58- " Q# (Microsoft programming language)" , // programmingLanguage#name
59- " Visual J#" , // programmingLanguage#name
60- " Acoustic #1" , // pearlJam#songs
61- " I am downloading some NP# music." , // michaelScott#quotes
62- " Cooler #6" , // dragonBall#planets
63- " Cooler #98" , // dragonBall#planets
64- " Cooler #256" , // dragonBall#planets
65- " Frieza #17" , // dragonBall#planets
66- " Frieza #79" , // dragonBall#planets
67- " Frieza #448" , // dragonBall#planets
68- " tL&^J@24CVF=zP46Lxixk`_a#=o6c5" , // device#serial
69- " S#arp" , // kPop#firstGroups
70- )
30+ val duplicatedValues =
31+ listOf (
32+ " Tiger! Tiger!" , // book#title
33+ " Girls Girls" , // kPop#girlsGroups
34+ " Two Two" , // kPop#firstGroups
35+ " woof woof" , // creature#dog#sound
36+ " Duran Duran" , // rockBand#name
37+ " Li Li" , // heroesOfTheStorm#heroes
38+ " Dee Dee" , // theFreshPrinceOfBelAir#characters
39+ " Lola Lola" , // cannabis#brands
40+ " Hail Hail" , // pearlJam#songs
41+ " Help Help" , // pearlJam#songs
42+ " Mr. Mr." , // kPop#thirdGroups
43+ " Chitty Chitty Bang Bang" , // show#adultMusical
44+ " etc. etc." , // marketing#buzzwords
45+ " Ook Ook" , // ventureBros#character
46+ " Mahi Mahi" , // food#ingredients
47+ " Cous Cous" , // food#ingredients
48+ " Boom Boom" , // superMario#characters
49+ " Pom Pom" , // superMario#characters
50+ " Min Min" , // superSmashBros#fighter
51+ )
52+
53+ val valuesWithHashKey =
54+ listOf (
55+ " A# .NET" , // programmingLanguage#name
56+ " A# (Axiom)" , // programmingLanguage#name
57+ " C# – ISO/I EC 23270" , // programmingLanguage#name
58+ " F#" , // programmingLanguage#name
59+ " J#" , // programmingLanguage#name
60+ " M#" , // programmingLanguage#name
61+ " P#" , // programmingLanguage#name
62+ " Q# (Microsoft programming language)" , // programmingLanguage#name
63+ " Visual J#" , // programmingLanguage#name
64+ " Acoustic #1" , // pearlJam#songs
65+ " I am downloading some NP# music." , // michaelScott#quotes
66+ " Cooler #6" , // dragonBall#planets
67+ " Cooler #98" , // dragonBall#planets
68+ " Cooler #256" , // dragonBall#planets
69+ " Frieza #17" , // dragonBall#planets
70+ " Frieza #79" , // dragonBall#planets
71+ " Frieza #448" , // dragonBall#planets
72+ " tL&^J@24CVF=zP46Lxixk`_a#=o6c5" , // device#serial
73+ " S#arp" , // kPop#firstGroups
74+ )
7175}
7276
7377@Suppress(" FunctionName" )
@@ -77,20 +81,26 @@ fun DescribeSpec.`describe all public generators`(
7781 val faker = Faker ()
7882
7983 // Get a list of all publicly visible providers
80- val providers: List <KProperty <* >> = faker::class .declaredMemberProperties.filter {
81- it.visibility == KVisibility .PUBLIC
82- && it.returnType.isSubtypeOf(FakeDataProvider ::class .starProjectedType)
83- && it.returnType.classifier != Money ::class // Ignore Money provider as it's a special case
84- && it.returnType.classifier != StringProvider ::class // Ignore String provider
85- && it.returnType.classifier != RandomProvider ::class // Ignore String provider
86- }
84+ val providers: List <KProperty <* >> =
85+ faker::class .declaredMemberProperties.filter {
86+ it.visibility == KVisibility .PUBLIC &&
87+ it.returnType.isSubtypeOf(FakeDataProvider ::class .starProjectedType) &&
88+ it.returnType.classifier !=
89+ Money ::class // Ignore Money provider as it's a special case
90+ &&
91+ it.returnType.classifier != StringProvider ::class // Ignore String provider
92+ &&
93+ it.returnType.classifier != RandomProvider ::class // Ignore String provider
94+ }
8795
8896 // Get a list of all publicly visible functions in each provider
89- val providerFunctions: GeneratorFunctions = providers.associateBy { provider ->
90- provider.getter.call(faker)!! ::class .declaredMemberFunctions.filter {
91- it.visibility == KVisibility .PUBLIC && ! it.annotations.any { ann -> ann is Deprecated }
97+ val providerFunctions: GeneratorFunctions =
98+ providers.associateBy { provider ->
99+ provider.getter.call(faker)!! ::class .declaredMemberFunctions.filter {
100+ it.visibility == KVisibility .PUBLIC &&
101+ ! it.annotations.any { ann -> ann is Deprecated }
102+ }
92103 }
93- }
94104 describe(" all public functions in each provider" ) {
95105 providerFunctions.forEach { (functions, provider) ->
96106 functions.forEach {
@@ -102,48 +112,59 @@ fun DescribeSpec.`describe all public generators`(
102112 }
103113}
104114
105-
106115@Suppress(" FunctionName" )
107116fun DescribeSpec .`describe all public sub-providers` (
108117 test : suspend DescribeSpecContainerScope .(FakeDataProvider , KProperty <* >, KFunction <* >) -> Unit
109118) {
110119 val faker = Faker ()
111120
112121 // Get a list of all publicly visible providers
113- val providers: List <KProperty <* >> = faker::class .declaredMemberProperties.filter {
114- it.visibility == KVisibility .PUBLIC
115- && it.returnType.isSubtypeOf(FakeDataProvider ::class .starProjectedType)
116- && it.returnType.classifier != Money ::class // Ignore Money provider as it's a special case
117- && it.returnType.classifier != StringProvider ::class // Ignore String provider
118- && it.returnType.classifier != RandomProvider ::class // Ignore String provider
119- }
122+ val providers: List <KProperty <* >> =
123+ faker::class .declaredMemberProperties.filter {
124+ it.visibility == KVisibility .PUBLIC &&
125+ it.returnType.isSubtypeOf(FakeDataProvider ::class .starProjectedType) &&
126+ // Ignore Money provider as it's a special case
127+ it.returnType.classifier != Money ::class &&
128+ // Ignore String provider
129+ it.returnType.classifier != StringProvider ::class &&
130+ // Ignore Random provider
131+ it.returnType.classifier != RandomProvider ::class
132+ }
120133
121134 // Get a list of all publicly visible sub-providers in each provider
122- val subProviders: List <Pair <FakeDataProvider , List <KProperty <* >>>> = providers.mapNotNull { p ->
123- val provider = p.getter.call(faker)!! as FakeDataProvider
124- val subs = provider::class .declaredMemberProperties.filter {
125- it.visibility == KVisibility .PUBLIC
126- && it.returnType.isSubtypeOf(FakeDataProvider ::class .starProjectedType)
127- && it.returnType.classifier as KClass <* > != provider::class // exclude 'unique' properties
135+ val subProviders: List <Pair <FakeDataProvider , List <KProperty <* >>>> =
136+ providers.mapNotNull { p ->
137+ val provider = p.getter.call(faker)!! as FakeDataProvider
138+ val subs =
139+ provider::class .declaredMemberProperties.filter {
140+ it.visibility == KVisibility .PUBLIC &&
141+ it.returnType.isSubtypeOf(FakeDataProvider ::class .starProjectedType) &&
142+ // exclude 'unique' properties
143+ it.returnType.classifier as KClass <* > != provider::class
144+ }
145+ if (subs.isNotEmpty()) provider to subs else null
128146 }
129- if (subs.isNotEmpty()) provider to subs else null
130- }
131147
132148 // Get a list of all publicly visible functions in each provider
133- val providerFunctions: GeneratorFunctions = providers.associateBy { provider ->
134- provider.getter.call(faker)!! ::class .declaredMemberFunctions.filter {
135- it.visibility == KVisibility .PUBLIC && ! it.annotations.any { ann -> ann is Deprecated }
149+ val providerFunctions: GeneratorFunctions =
150+ providers.associateBy { provider ->
151+ provider.getter.call(faker)!! ::class .declaredMemberFunctions.filter {
152+ it.visibility == KVisibility .PUBLIC &&
153+ ! it.annotations.any { ann -> ann is Deprecated }
154+ }
136155 }
137- }
138156
139157 // Get all publicly visible functions in each sub-provider
140- val subProviderFunctions = subProviders.map { (provider, subs) ->
141- provider to subs.associateBy { sub ->
142- sub.getter.call(provider)!! ::class .declaredMemberFunctions.filter {
143- it.visibility == KVisibility .PUBLIC && ! it.annotations.any { ann -> ann is Deprecated }
144- }
158+ val subProviderFunctions =
159+ subProviders.map { (provider, subs) ->
160+ provider to
161+ subs.associateBy { sub ->
162+ sub.getter.call(provider)!! ::class .declaredMemberFunctions.filter {
163+ it.visibility == KVisibility .PUBLIC &&
164+ ! it.annotations.any { ann -> ann is Deprecated }
165+ }
166+ }
145167 }
146- }
147168
148169 describe(" all public functions in each sub-provider" ) {
149170 subProviderFunctions.forEach { (provider, subs) ->
0 commit comments