@@ -37,7 +37,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
3737 val df = mkDataFrame(spark, defData)
3838 val sut = StringLengthCheck (" item" , None , None , None )
3939 assert(sut.configCheck(df))
40- assert(sut.getEvents contains ValidatorError (" Must define minValue or maxValue or both." ))
40+ assert(sut.getEvents contains ValidatorError (" Must define minLength or maxLength or both." ))
4141 assert(sut.failed)
4242 }
4343
@@ -80,14 +80,14 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
8080 assert(sut.failed)
8181 }
8282
83- it(" minValue less than maxValue fails configCheck" ) {
84- val maxValue = Math .abs(Random .nextInt(1000 )) // scalastyle:ignore
85- val minValue = maxValue + 10
86- val sut = StringLengthCheck (" item" , Some (Json .fromInt(minValue )), Some (Json .fromInt(maxValue )), None )
83+ it(" minLength less than maxLength fails configCheck" ) {
84+ val maxLength = Math .abs(Random .nextInt(1000 )) // scalastyle:ignore
85+ val minLength = maxLength + 10
86+ val sut = StringLengthCheck (" item" , Some (Json .fromInt(minLength )), Some (Json .fromInt(maxLength )), None )
8787 val df = mkDataFrame(spark, defData)
8888 assert(sut.configCheck(df))
8989 assert(sut.failed)
90- assert(sut.getEvents contains ValidatorError (s " min: $minValue must be less than or equal to max: $maxValue " ))
90+ assert(sut.getEvents contains ValidatorError (s " min: $minLength must be less than or equal to max: $maxLength " ))
9191 }
9292
9393 }
@@ -104,72 +104,72 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
104104 it(" variable column name is good." ) {
105105 val dict = new VarSubstitution
106106 dict.addString(" column" , " item" )
107- val minValue = Json .fromDouble(0.0 )
108- val sut = StringLengthCheck (" $column" , minValue , None , None )
109- assert(sut.substituteVariables(dict) == StringLengthCheck (" item" , minValue , None , None ))
107+ val minLength = Json .fromDouble(0.0 )
108+ val sut = StringLengthCheck (" $column" , minLength , None , None )
109+ assert(sut.substituteVariables(dict) == StringLengthCheck (" item" , minLength , None , None ))
110110 assert(! sut.failed)
111111 }
112112
113- it(" substitutes minValue " ) {
113+ it(" substitutes minLength " ) {
114114 val dict = new VarSubstitution
115- dict.addString(" minValue " , " 0" )
116- val sut = StringLengthCheck (" item" , Some (Json .fromString(" ${minValue }" )), None , None )
115+ dict.addString(" minLength " , " 0" )
116+ val sut = StringLengthCheck (" item" , Some (Json .fromString(" ${minLength }" )), None , None )
117117 assert(sut.substituteVariables(dict) == StringLengthCheck (" item" , Some (Json .fromInt(0 )), None , None ))
118118 assert(! sut.failed)
119119 }
120120
121- it(" substitutes maxValue " ) {
121+ it(" substitutes maxLength " ) {
122122 val dict = new VarSubstitution
123- dict.addString(" maxValue " , " 10" )
124- val sut = StringLengthCheck (" item" , None , Some (Json .fromString(" ${maxValue }" )), None )
123+ dict.addString(" maxLength " , " 10" )
124+ val sut = StringLengthCheck (" item" , None , Some (Json .fromString(" ${maxLength }" )), None )
125125 assert(sut.substituteVariables(dict) ==
126126 StringLengthCheck (" item" , None , Some (Json .fromInt(10 )), None )) // scalastyle:ignore
127127 assert(! sut.failed)
128128 }
129129
130- it(" substitutes minValue and maxValue " ) {
130+ it(" substitutes minLength and maxLength " ) {
131131 val dict = new VarSubstitution
132- dict.addString(" minValue " , " 1" )
133- dict.addString(" maxValue " , " 10" )
134- val sut = StringLengthCheck (" item" , Some (Json .fromString(" ${minValue }" )),
135- Some (Json .fromString(" ${maxValue }" )), None )
132+ dict.addString(" minLength " , " 1" )
133+ dict.addString(" maxLength " , " 10" )
134+ val sut = StringLengthCheck (" item" , Some (Json .fromString(" ${minLength }" )),
135+ Some (Json .fromString(" ${maxLength }" )), None )
136136 assert(sut.substituteVariables(dict) == StringLengthCheck (" item" , Some (Json .fromInt(1 )),
137- Some (Json .fromInt(10 )), None )) // scalastyle: ignore
137+ Some (Json .fromInt(10 )), None )) // scalastyle:ignore
138138 assert(! sut.failed)
139139 }
140140
141141 it(" substitutes threshold" ) {
142142 val dict = new VarSubstitution
143143 // scalastyle:off
144144 val threshold = Json .fromInt(100 )
145- val minValue = Some (Json .fromInt(1 ))
146- val maxValue = Some (Json .fromInt(10 ))
145+ val minLength = Some (Json .fromInt(1 ))
146+ val maxLength = Some (Json .fromInt(10 ))
147147 // scalastyle:on
148148 dict.add(" threshold" , threshold)
149- val sut = StringLengthCheck (" item" , minValue, maxValue , Some (" ${threshold}" ))
150- assert(sut.substituteVariables(dict) == StringLengthCheck (" item" , minValue, maxValue ,
149+ val sut = StringLengthCheck (" item" , minLength, maxLength , Some (" ${threshold}" ))
150+ assert(sut.substituteVariables(dict) == StringLengthCheck (" item" , minLength, maxLength ,
151151 Some (" 100" ))) // scalastyle: ignore
152152 assert(! sut.failed)
153153 }
154154 }
155155
156156 describe(" colTest" ) {
157157
158- it(" minValue " ) {
158+ it(" minLength " ) {
159159 val dict = new VarSubstitution
160160 val sut = StringLengthCheck (" item" , Some (Json .fromInt(2 )), None , None )
161161 assert(sut.colTest(schema, dict).sql ==
162162 LessThan (Length (UnresolvedAttribute (" item" )), Literal .create(2 , IntegerType )).sql)
163163 }
164164
165- it(" maxValue " ) {
165+ it(" maxLength " ) {
166166 val dict = new VarSubstitution
167167 val sut = StringLengthCheck (" item" , None , Some (Json .fromInt(2 )), None )
168168 assert(sut.colTest(schema, dict).sql ==
169169 GreaterThan (Length (UnresolvedAttribute (" item" )), Literal .create(2 , IntegerType )).sql)
170170 }
171171
172- it(" minValue and maxValue " ) {
172+ it(" minLength and maxLength " ) {
173173 val dict = new VarSubstitution
174174 val sut = StringLengthCheck (" item" , Some (Json .fromInt(1 )), Some (Json .fromInt(10 )), None ) // scalastyle:ignore
175175 assert(sut.colTest(schema, dict).sql ==
@@ -187,8 +187,8 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
187187 """ ---
188188 |- type: stringLengthCheck
189189 | column: item
190- | minValue : 0
191- | maxValue : 100
190+ | minLength : 0
191+ | maxLength : 100
192192 |
193193 """ .stripMargin
194194 val json = io.circe.yaml.parser.parse(yaml).right.getOrElse(Json .Null )
@@ -208,7 +208,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
208208 """ ---
209209 |- type: stringLengthCheck
210210 | column: item
211- | minValue : 0
211+ | minLength : 0
212212 |
213213 """ .stripMargin
214214 val json = io.circe.yaml.parser.parse(yaml).right.getOrElse(Json .Null )
@@ -228,7 +228,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
228228 """ ---
229229 |- type: stringLengthCheck
230230 | column: item
231- | maxValue : 100
231+ | maxLength : 100
232232 |
233233 """ .stripMargin
234234 val json = io.circe.yaml.parser.parse(yaml).right.getOrElse(Json .Null )
@@ -308,7 +308,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
308308 " StringLengthCheck failed! item = and ((length('item) < 5) || (length('item) > 6))" ))
309309 }
310310
311- it(" String length check fails for minValue = maxValue and numErrorsToReport:3" ) {
311+ it(" String length check fails for minLength = maxLength and numErrorsToReport:3" ) {
312312 val dict = new VarSubstitution
313313 val df = mkDataFrame(spark, defData)
314314 val sut = StringLengthCheck (" item" , Some (Json .fromInt(5 )), Some (Json .fromInt(5 )), None ) // scalastyle:ignore
@@ -333,7 +333,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
333333 " StringLengthCheck failed! item = Item23 and ((length('item) < 5) || (length('item) > 5))" ))
334334 }
335335
336- it(" String length check fails for only minValue specified and numErrorsToReport:2" ) {
336+ it(" String length check fails for only minLength specified and numErrorsToReport:2" ) {
337337 val dict = new VarSubstitution
338338 val df = mkDataFrame(spark, defData)
339339 val sut = StringLengthCheck (" item" , Some (Json .fromInt(5 )), None , None ) // scalastyle:ignore
@@ -354,7 +354,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
354354 " StringLengthCheck failed! item = and (length('item) < 5)" ))
355355 }
356356
357- it(" String length check fails for only maxValue specified and numErrorsToReport:2" ) {
357+ it(" String length check fails for only maxLength specified and numErrorsToReport:2" ) {
358358 val dict = new VarSubstitution
359359 val df = mkDataFrame(spark, defData)
360360 val sut = StringLengthCheck (" item" , None , Some (Json .fromInt(2 )), None ) // scalastyle:ignore
@@ -375,7 +375,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
375375 " StringLengthCheck failed! item = Item23 and (length('item) > 2)" ))
376376 }
377377
378- it(" String length check passes for minValue and maxValue specified" ) {
378+ it(" String length check passes for minLength and maxLength specified" ) {
379379 val dict = new VarSubstitution
380380 val df = mkDataFrame(spark, defData)
381381 val sut = StringLengthCheck (" item" , Some (Json .fromInt(0 )), Some (Json .fromInt(6 )), None ) // scalastyle:ignore
@@ -388,7 +388,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
388388 ValidatorCheckEvent (failure = false , " StringLengthCheck on column 'item'" , 4 , 0 )) // scalastyle:ignore
389389 }
390390
391- it(" String length check passes for only minValue specified" ) {
391+ it(" String length check passes for only minLength specified" ) {
392392 val dict = new VarSubstitution
393393 val df = mkDataFrame(spark, defData)
394394 val sut = StringLengthCheck (" item" , Some (Json .fromInt(0 )), None , None ) // scalastyle:ignore
@@ -401,7 +401,7 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
401401 ValidatorCheckEvent (failure = false , " StringLengthCheck on column 'item'" , 4 , 0 )) // scalastyle:ignore
402402 }
403403
404- it(" String length check passes for only maxValue specified" ) {
404+ it(" String length check passes for only maxLength specified" ) {
405405 val dict = new VarSubstitution
406406 val df = mkDataFrame(spark, defData)
407407 val sut = StringLengthCheck (" item" , None , Some (Json .fromInt(6 )), None ) // scalastyle:ignore
@@ -415,14 +415,14 @@ class StringLengthCheckSpec extends FunSpec with Matchers with TestingSparkSessi
415415 }
416416
417417 it(" toJson works" ) {
418- val minValue = Random .nextInt(1000 ) // scalastyle:ignore
419- val minJson = Json .fromInt(minValue )
420- val maxJson = Json .fromInt(minValue + Random .nextInt(1000 ) + 1 ) // scalastyle:ignore
418+ val minLength = Random .nextInt(1000 ) // scalastyle:ignore
419+ val minJson = Json .fromInt(minLength )
420+ val maxJson = Json .fromInt(minLength + Random .nextInt(1000 ) + 1 ) // scalastyle:ignore
421421 val sut = StringLengthCheck (" item" , Some (minJson), Some (maxJson), None ) // scalastyle:ignore
422422 assert(sut.toJson == Json .obj((" type" , Json .fromString(" stringLengthCheck" )),
423423 (" column" , Json .fromString(" item" )),
424- (" minValue " , minJson),
425- (" maxValue " , maxJson),
424+ (" minLength " , minJson),
425+ (" maxLength " , maxJson),
426426 (" events" , Json .arr())
427427 ))
428428 }
0 commit comments