@@ -53,7 +53,7 @@ import java.util.regex.Pattern
53
53
*/
54
54
@Suppress(" LargeClass" , " TooManyFunctions" , " SpreadOperator" )
55
55
open class PactDslJsonBody : DslPart {
56
- override var body: JsonValue
56
+ override var body: JsonValue = JsonValue . Object ()
57
57
58
58
/* *
59
59
* Constructs a new body as a root
@@ -624,7 +624,7 @@ open class PactDslJsonBody : DslPart {
624
624
else -> {}
625
625
}
626
626
627
- matchers.addRules(constructValidPath(name, rootPath), listOf (
627
+ matchers.addRules(constructValidPath(name, rootPath, false ), listOf (
628
628
NumberTypeMatcher (NumberTypeMatcher .NumberType .NUMBER ),
629
629
RegexMatcher (regex, example.toString())
630
630
))
@@ -654,7 +654,7 @@ open class PactDslJsonBody : DslPart {
654
654
else -> {}
655
655
}
656
656
657
- matchers.addRules(constructValidPath(name, rootPath), listOf (
657
+ matchers.addRules(constructValidPath(name, rootPath, false ), listOf (
658
658
NumberTypeMatcher (NumberTypeMatcher .NumberType .DECIMAL ),
659
659
RegexMatcher (regex, example.toString())
660
660
))
@@ -683,7 +683,7 @@ open class PactDslJsonBody : DslPart {
683
683
else -> {}
684
684
}
685
685
686
- matchers.addRules(constructValidPath(name, rootPath), listOf (
686
+ matchers.addRules(constructValidPath(name, rootPath, false ), listOf (
687
687
NumberTypeMatcher (NumberTypeMatcher .NumberType .INTEGER ),
688
688
RegexMatcher (regex, example.toString())
689
689
))
@@ -828,7 +828,7 @@ open class PactDslJsonBody : DslPart {
828
828
* @param format datetime format
829
829
*/
830
830
fun datetime (name : String , format : String ): PactDslJsonBody {
831
- val path = constructValidPath(name, rootPath)
831
+ val path = constructValidPath(name, rootPath, false )
832
832
generators.addGenerator(Category .BODY , path, DateTimeGenerator (format, null ))
833
833
val formatter = DateTimeFormatter .ofPattern(format).withZone(ZoneId .systemDefault())
834
834
matchers.addRule(path, matchTimestamp(format))
@@ -887,7 +887,7 @@ open class PactDslJsonBody : DslPart {
887
887
}
888
888
889
889
val formatter = DateTimeFormatter .ofPattern(format).withZone(timeZone.toZoneId())
890
- matchers.addRule(constructValidPath(name, rootPath), matchTimestamp(format))
890
+ matchers.addRule(constructValidPath(name, rootPath, false ), matchTimestamp(format))
891
891
892
892
when (val body = body) {
893
893
is JsonValue .Object -> body.add(name,
@@ -943,7 +943,7 @@ open class PactDslJsonBody : DslPart {
943
943
}
944
944
945
945
val formatter = DateTimeFormatter .ofPattern(format).withZone(timeZone.toZoneId())
946
- matchers.addRule(constructValidPath(name, rootPath), matchTimestamp(format))
946
+ matchers.addRule(constructValidPath(name, rootPath, false ), matchTimestamp(format))
947
947
948
948
when (val body = body) {
949
949
is JsonValue .Object -> body.add(name,
@@ -966,7 +966,7 @@ open class PactDslJsonBody : DslPart {
966
966
@JvmOverloads
967
967
fun date (name : String = "date"): PactDslJsonBody {
968
968
val pattern = DateFormatUtils .ISO_DATE_FORMAT .pattern
969
- val path = constructValidPath(name, rootPath)
969
+ val path = constructValidPath(name, rootPath, false )
970
970
generators.addGenerator(Category .BODY , path, DateGenerator (pattern, null ))
971
971
matchers.addRule(path, matchDate(pattern))
972
972
@@ -990,7 +990,7 @@ open class PactDslJsonBody : DslPart {
990
990
* @param format date format to match
991
991
*/
992
992
fun date (name : String , format : String ): PactDslJsonBody {
993
- val path = constructValidPath(name, rootPath)
993
+ val path = constructValidPath(name, rootPath, false )
994
994
generators.addGenerator(Category .BODY , path, DateGenerator (format, null ))
995
995
val instance = FastDateFormat .getInstance(format)
996
996
matchers.addRule(path, matchDate(format))
@@ -1045,7 +1045,7 @@ open class PactDslJsonBody : DslPart {
1045
1045
}
1046
1046
1047
1047
val instance = FastDateFormat .getInstance(format, timeZone)
1048
- matchers.addRule(constructValidPath(name, rootPath), matchDate(format))
1048
+ matchers.addRule(constructValidPath(name, rootPath, false ), matchDate(format))
1049
1049
1050
1050
when (val body = body) {
1051
1051
is JsonValue .Object -> body.add(name, JsonValue .StringValue (instance.format(examples[0 ]).toCharArray()))
@@ -1077,7 +1077,7 @@ open class PactDslJsonBody : DslPart {
1077
1077
}
1078
1078
1079
1079
val formatter = DateTimeFormatter .ofPattern(format)
1080
- matchers.addRule(constructValidPath(name, rootPath), matchDate(format))
1080
+ matchers.addRule(constructValidPath(name, rootPath, false ), matchDate(format))
1081
1081
1082
1082
when (val body = body) {
1083
1083
is JsonValue .Object -> body.add(name, JsonValue .StringValue (formatter.format(examples[0 ]).toCharArray()))
@@ -1102,7 +1102,7 @@ open class PactDslJsonBody : DslPart {
1102
1102
@JvmOverloads
1103
1103
fun time (name : String = "time"): PactDslJsonBody {
1104
1104
val pattern = DateFormatUtils .ISO_TIME_FORMAT .pattern
1105
- val path = constructValidPath(name, rootPath)
1105
+ val path = constructValidPath(name, rootPath, false )
1106
1106
generators.addGenerator(Category .BODY , path, TimeGenerator (pattern, null ))
1107
1107
matchers.addRule(path, matchTime(pattern))
1108
1108
@@ -1126,7 +1126,7 @@ open class PactDslJsonBody : DslPart {
1126
1126
* @param format time format to match
1127
1127
*/
1128
1128
fun time (name : String , format : String ): PactDslJsonBody {
1129
- val path = constructValidPath(name, rootPath)
1129
+ val path = constructValidPath(name, rootPath, false )
1130
1130
generators.addGenerator(Category .BODY , path, TimeGenerator (format, null ))
1131
1131
matchers.addRule(path, matchTime(format))
1132
1132
@@ -1183,7 +1183,7 @@ open class PactDslJsonBody : DslPart {
1183
1183
}
1184
1184
1185
1185
val instance = FastDateFormat .getInstance(format, timeZone)
1186
- matchers.addRule(constructValidPath(name, rootPath), matchTime(format))
1186
+ matchers.addRule(constructValidPath(name, rootPath, false ), matchTime(format))
1187
1187
1188
1188
when (val body = body) {
1189
1189
is JsonValue .Object -> body.add(name, JsonValue .StringValue (instance.format(examples[0 ]).toCharArray()))
@@ -1203,7 +1203,7 @@ open class PactDslJsonBody : DslPart {
1203
1203
* @param name attribute name
1204
1204
*/
1205
1205
fun ipAddress (name : String ): PactDslJsonBody {
1206
- matchers.addRule(constructValidPath(name, rootPath), regexp(" (\\ d{1,3}\\ .)+\\ d{1,3}" ))
1206
+ matchers.addRule(constructValidPath(name, rootPath, false ), regexp(" (\\ d{1,3}\\ .)+\\ d{1,3}" ))
1207
1207
1208
1208
when (val body = body) {
1209
1209
is JsonValue .Object -> body.add(name, JsonValue .StringValue (" 127.0.0.1" .toCharArray()))
@@ -1223,7 +1223,7 @@ open class PactDslJsonBody : DslPart {
1223
1223
* @param name field name
1224
1224
*/
1225
1225
override fun `object` (name : String ): PactDslJsonBody {
1226
- return PactDslJsonBody (constructValidPath(name, rootPath) + " ." , name, this )
1226
+ return PactDslJsonBody (constructValidPath(name, rootPath, false ) + " ." , name, this )
1227
1227
}
1228
1228
1229
1229
override fun `object` (): PactDslJsonBody {
@@ -1236,7 +1236,7 @@ open class PactDslJsonBody : DslPart {
1236
1236
* @param value DSL Part to set the value as
1237
1237
*/
1238
1238
fun `object` (name : String , value : DslPart ): PactDslJsonBody {
1239
- val base = constructValidPath(name, rootPath)
1239
+ val base = constructValidPath(name, rootPath, false )
1240
1240
if (value is PactDslJsonBody ) {
1241
1241
val obj = PactDslJsonBody (base, name, this , value)
1242
1242
putObjectPrivate(obj)
@@ -1350,7 +1350,7 @@ open class PactDslJsonBody : DslPart {
1350
1350
}
1351
1351
1352
1352
override fun eachLike (name : String , obj : DslPart ): PactDslJsonBody {
1353
- val base = constructValidPath(name, rootPath)
1353
+ val base = constructValidPath(name, rootPath, false )
1354
1354
matchers.addRule(base, TypeMatcher )
1355
1355
val parent = PactDslJsonArray (base, name, this , true )
1356
1356
if (obj is PactDslJsonBody ) {
@@ -1375,7 +1375,7 @@ open class PactDslJsonBody : DslPart {
1375
1375
* @param numberExamples number of examples to generate
1376
1376
*/
1377
1377
override fun eachLike (name : String , numberExamples : Int ): PactDslJsonBody {
1378
- val path = constructValidPath(name, rootPath)
1378
+ val path = constructValidPath(name, rootPath, false )
1379
1379
matchers.addRule(path, TypeMatcher )
1380
1380
val parent = PactDslJsonArray (path, name, this , true )
1381
1381
parent.numberExamples = numberExamples
@@ -1394,7 +1394,7 @@ open class PactDslJsonBody : DslPart {
1394
1394
*/
1395
1395
@JvmOverloads
1396
1396
fun eachLike (name : String , value : PactDslJsonRootValue , numberExamples : Int = 1): PactDslJsonBody {
1397
- val path = constructValidPath(name, rootPath)
1397
+ val path = constructValidPath(name, rootPath, false )
1398
1398
matchers.addRule(path, TypeMatcher )
1399
1399
val parent = PactDslJsonArray (path, name, this , true )
1400
1400
parent.numberExamples = numberExamples
@@ -1416,7 +1416,7 @@ open class PactDslJsonBody : DslPart {
1416
1416
}
1417
1417
1418
1418
override fun minArrayLike (name : String , size : Int , obj : DslPart ): PactDslJsonBody {
1419
- val base = constructValidPath(name, rootPath)
1419
+ val base = constructValidPath(name, rootPath, false )
1420
1420
matchers.addRule(base, matchMin(size))
1421
1421
val parent = PactDslJsonArray (base, name, this , true )
1422
1422
if (obj is PactDslJsonBody ) {
@@ -1442,7 +1442,7 @@ open class PactDslJsonBody : DslPart {
1442
1442
String .format(" Number of example %d is less than the minimum size of %d" ,
1443
1443
numberExamples, size)
1444
1444
}
1445
- val path = constructValidPath(name, rootPath)
1445
+ val path = constructValidPath(name, rootPath, false )
1446
1446
matchers.addRule(path, matchMin(size))
1447
1447
val parent = PactDslJsonArray (path, name, this , true )
1448
1448
parent.numberExamples = numberExamples
@@ -1479,7 +1479,7 @@ open class PactDslJsonBody : DslPart {
1479
1479
String .format(" Number of example %d is less than the minimum size of %d" ,
1480
1480
numberExamples, size)
1481
1481
}
1482
- val path = constructValidPath(name, rootPath)
1482
+ val path = constructValidPath(name, rootPath, false )
1483
1483
matchers.addRule(path, matchMin(size))
1484
1484
val parent = PactDslJsonArray (path, name, this , true )
1485
1485
parent.numberExamples = numberExamples
@@ -1501,7 +1501,7 @@ open class PactDslJsonBody : DslPart {
1501
1501
}
1502
1502
1503
1503
override fun maxArrayLike (name : String , size : Int , obj : DslPart ): PactDslJsonBody {
1504
- val base = constructValidPath(name, rootPath)
1504
+ val base = constructValidPath(name, rootPath, false )
1505
1505
matchers.addRule(base, matchMax(size))
1506
1506
val parent = PactDslJsonArray (base, name, this , true )
1507
1507
if (obj is PactDslJsonBody ) {
@@ -1527,7 +1527,7 @@ open class PactDslJsonBody : DslPart {
1527
1527
String .format(" Number of example %d is more than the maximum size of %d" ,
1528
1528
numberExamples, size)
1529
1529
}
1530
- val path = constructValidPath(name, rootPath)
1530
+ val path = constructValidPath(name, rootPath, false )
1531
1531
matchers.addRule(path, matchMax(size))
1532
1532
val parent = PactDslJsonArray (path, name, this , true )
1533
1533
parent.numberExamples = numberExamples
@@ -1564,7 +1564,7 @@ open class PactDslJsonBody : DslPart {
1564
1564
String .format(" Number of example %d is more than the maximum size of %d" ,
1565
1565
numberExamples, size)
1566
1566
}
1567
- val path = constructValidPath(name, rootPath)
1567
+ val path = constructValidPath(name, rootPath, false )
1568
1568
matchers.addRule(path, matchMax(size))
1569
1569
val parent = PactDslJsonArray (path, name, this , true )
1570
1570
parent.numberExamples = numberExamples
@@ -1578,7 +1578,7 @@ open class PactDslJsonBody : DslPart {
1578
1578
*/
1579
1579
@JvmOverloads
1580
1580
fun id (name : String = "id"): PactDslJsonBody {
1581
- val path = constructValidPath(name, rootPath)
1581
+ val path = constructValidPath(name, rootPath, false )
1582
1582
generators.addGenerator(Category .BODY , path, RandomIntGenerator (0 , Int .MAX_VALUE ))
1583
1583
matchers.addRule(path, TypeMatcher )
1584
1584
@@ -1757,7 +1757,7 @@ open class PactDslJsonBody : DslPart {
1757
1757
}
1758
1758
1759
1759
override fun eachArrayLike (name : String , numberExamples : Int ): PactDslJsonArray {
1760
- val path = constructValidPath(name, rootPath)
1760
+ val path = constructValidPath(name, rootPath, false )
1761
1761
matchers.addRule(path, TypeMatcher )
1762
1762
val parent = PactDslJsonArray (path, name, this , true )
1763
1763
parent.numberExamples = numberExamples
@@ -1781,7 +1781,7 @@ open class PactDslJsonBody : DslPart {
1781
1781
String .format(" Number of example %d is more than the maximum size of %d" ,
1782
1782
numberExamples, size)
1783
1783
}
1784
- val path = constructValidPath(name, rootPath)
1784
+ val path = constructValidPath(name, rootPath, false )
1785
1785
matchers.addRule(path, matchMax(size))
1786
1786
val parent = PactDslJsonArray (path, name, this , true )
1787
1787
parent.numberExamples = numberExamples
@@ -1806,7 +1806,7 @@ open class PactDslJsonBody : DslPart {
1806
1806
String .format(" Number of example %d is less than the minimum size of %d" ,
1807
1807
numberExamples, size)
1808
1808
}
1809
- val path = constructValidPath(name, rootPath)
1809
+ val path = constructValidPath(name, rootPath, false )
1810
1810
matchers.addRule(path, matchMin(size))
1811
1811
val parent = PactDslJsonArray (path, name, this , true )
1812
1812
parent.numberExamples = numberExamples
@@ -2027,7 +2027,7 @@ open class PactDslJsonBody : DslPart {
2027
2027
2028
2028
override fun minMaxArrayLike (name : String , minSize : Int , maxSize : Int , obj : DslPart ): PactDslJsonBody {
2029
2029
validateMinAndMaxAndExamples(minSize, maxSize, minSize)
2030
- val base = constructValidPath(name, rootPath)
2030
+ val base = constructValidPath(name, rootPath, false )
2031
2031
matchers.addRule(base, matchMinMax(minSize, maxSize))
2032
2032
val parent = PactDslJsonArray (base, name, this , true )
2033
2033
if (obj is PactDslJsonBody ) {
@@ -2049,7 +2049,7 @@ open class PactDslJsonBody : DslPart {
2049
2049
2050
2050
override fun minMaxArrayLike (name : String , minSize : Int , maxSize : Int , numberExamples : Int ): PactDslJsonBody {
2051
2051
validateMinAndMaxAndExamples(minSize, maxSize, numberExamples)
2052
- val path = constructValidPath(name, rootPath)
2052
+ val path = constructValidPath(name, rootPath, false )
2053
2053
matchers.addRule(path, matchMinMax(minSize, maxSize))
2054
2054
val parent = PactDslJsonArray (path, name, this , true )
2055
2055
parent.numberExamples = numberExamples
@@ -2092,7 +2092,7 @@ open class PactDslJsonBody : DslPart {
2092
2092
maxSize : Int
2093
2093
): PactDslJsonArray {
2094
2094
validateMinAndMaxAndExamples(minSize, maxSize, numberExamples)
2095
- val path = constructValidPath(name, rootPath)
2095
+ val path = constructValidPath(name, rootPath, false )
2096
2096
matchers.addRule(path, matchMinMax(minSize, maxSize))
2097
2097
val parent = PactDslJsonArray (path, name, this , true )
2098
2098
parent.numberExamples = numberExamples
@@ -2140,7 +2140,7 @@ open class PactDslJsonBody : DslPart {
2140
2140
numberExamples : Int
2141
2141
): PactDslJsonBody {
2142
2142
validateMinAndMaxAndExamples(minSize, maxSize, numberExamples)
2143
- val path = constructValidPath(name, rootPath)
2143
+ val path = constructValidPath(name, rootPath, false )
2144
2144
matchers.addRule(path, matchMinMax(minSize, maxSize))
2145
2145
val parent = PactDslJsonArray (path, name, this , true )
2146
2146
parent.numberExamples = numberExamples
0 commit comments