test(jolt-demo): 添加新功能测试用例和规格说明

- 新增 cardinality、default、modify、remove、shift、sort等操作的测试用例
- 添加相应的规格说明文件,详细描述每种操作的使用方法和示例
- 为 shift 操作提供了多种不同场景的测试用例和说明
This commit is contained in:
liuy 2025-07-01 08:50:08 +08:00
parent f9eb0bdea3
commit 9ace3f6737
51 changed files with 625 additions and 1 deletions

View File

@ -0,0 +1,5 @@
{
"review" : {
"rating" : [ 5, 4 ]
}
}

View File

@ -0,0 +1,10 @@
{
"views": [
{
"count": 1024
},
{
"count": 2048
}
]
}

View File

@ -0,0 +1,10 @@
[
{
"operation": "cardinality",
"spec": {
"review": {
"rating": "ONE"//rating{"review":{"rating":5}}
}
}
}
]

View File

@ -0,0 +1,13 @@
[
{
"operation": "cardinality",
"spec": {
"views": {
"@": "ONE",
"count": "MANY"
}
}
}
]
//cardinality@
//"@""ONE""MANY"

View File

@ -0,0 +1,14 @@
{
"Rating": 3,
"SecondaryRatings": {
"quality": {
"Range": 7,
"Value": 3,
"Id": "quality"
},
"sharpness": {
"Value": 4,
"Id": "sharpness"
}
}
}

View File

@ -0,0 +1,7 @@
{
"name": "Alice",
"age": null,
"contact": {
"phone": "12345"
}
}

View File

@ -0,0 +1,15 @@
{
"photos": [
{
"id": "327704",
"url": "http://bob.com/0001/327704/photo.jpg"
},
{
"id": "327705",
"url": "http://bob.com/0002/327704/photo.jpg"
},
{
"id": "327706"
}
]
}

View File

@ -0,0 +1,11 @@
[
{
"operation": "default",
"spec": {
"Range": 5,
"data": {
"default": 12345
}
}
}
]

View File

@ -0,0 +1,10 @@
[
{
"operation": "default",
"spec": {
"age": 18, // age null 18
"gender": "female", // gender
"active": true // active
}
}
]

View File

@ -0,0 +1,13 @@
[
{
"operation": "default",
"spec": {
"photos[]": {
"2": {
"url": "http://www.bazaarvoice.com",
"caption": ""
}
}
}
}
]

View File

@ -0,0 +1,23 @@
{
"x": [
3,
2,
1,
"go"
],
"small": "small",
"BIG": "BIG",
"people": [
{
"firstName": "Bob",
"lastName": "Smith",
"address": {
"state": null
}
},
{
"firstName": "Sterling",
"lastName": "Archer"
}
]
}

View File

@ -0,0 +1,19 @@
[
{
"operation": "modify-default-beta",
"spec": {
"y": "=join(',',@(1,x))",
"z": "=join(' ',@(1,x))",
"small_toUpper": "=toUpper(@(1,small))",
"BIG_toLower": "=toLower(@(1,BIG))",
"people": {
"*": {
"fullName": "=concat(@(1,firstName),' ',@(1,lastName))",
"address?": {
"state": "Texas"
}
}
}
}
}
]

View File

@ -0,0 +1,11 @@
{
"~emVersion": "2",
"id": "123124",
"productId": "31231231",
"submissionId": "34343",
"this": "stays",
"configured": {
"a": "b",
"c": "d"
}
}

View File

@ -0,0 +1,12 @@
{
"ratings": {
"Set1": {
"a": "a",
"b": "b"
},
"Set2": {
"c": "c",
"b": "b"
}
}
}

View File

@ -0,0 +1,22 @@
{
"ratings_legacy": {
"Set1": {
"a": "a",
"b": "b"
},
"Set2": {
"a": "a",
"b": "b"
}
},
"ratings_new": {
"Set1": {
"a": "a",
"b": "b"
},
"Set2": {
"a": "a",
"b": "b"
}
}
}

View File

@ -0,0 +1,13 @@
[
{
"operation": "remove",
"spec": {
"~emVersion": "",
"productId": "",
"submissionId": "",
"configured": {
"c": ""
}
}
}
]

View File

@ -0,0 +1,12 @@
[
{
"operation": "remove",
"spec": {
"ratings": {
"*": {
"b": ""
}
}
}
}
]

View File

@ -0,0 +1,10 @@
[
{
"operation": "remove",
"spec": {
"ratings_*": {
"Set1": ""
}
}
}
]

View File

@ -0,0 +1,14 @@
{
"orderId": 1212,
"orderNo": "202223434343",
"goods": {
"goodsId": 123,
"goodsName": "test_goods"
},
"orderItem": [
{
"orderItemId": 1324,
"orderItemNo": "34535345"
}
]
}

View File

@ -0,0 +1,3 @@
{
"foo": "1"
}

View File

@ -0,0 +1,4 @@
{
"author": "Stephen Hawking",
"book": "A Brief History of Time"
}

View File

@ -0,0 +1,6 @@
{
"Photos": [
"AAA.jpg",
"BBB.jpg"
]
}

View File

@ -0,0 +1,4 @@
{
"photo-1-id": "327704",
"photo-1-url": "http://bob.com/0001/327704/photo.jpg"
}

View File

@ -0,0 +1,3 @@
{
"foo": 3
}

View File

@ -0,0 +1,4 @@
{
"foo" : "bar",
"tuna" : "marlin"
}

View File

@ -0,0 +1,8 @@
{
"rating": {
"quality": {
"value": 3,
"max": 5
}
}
}

View File

@ -0,0 +1,16 @@
{
"rating": {
"primary": {
"value": 3, // "Rating"
"max": 5 // "RatingRange"
},
"quality": { // "SecondaryRatings.quality.Id" = "quality",使key
"value": 3, // SecondaryRatings.quality.value
"max": 5 // SecondaryRatings.quality.Range
},
"sharpness": { // SecondaryRatings.sharpty.Id=sharpture
"value": 7, // SecondaryRatings.sharps.value
"max": 10 // SecondaryRatings.sharps.Range
}
}
}

View File

@ -0,0 +1,12 @@
{
"rating" : {
"quality": {
"value": 3,
"max": 5
},
"sharpness" : {
"value" : 7,
"max" : 10
}
}
}

View File

@ -0,0 +1,4 @@
{
"tag-Pro-a": "Awesome",
"tag-Con-b": "Bogus"
}

View File

@ -0,0 +1,12 @@
{
"rating": {
"primary": {
"value": 3,
"max": 5
},
"quality": {
"value": 3,
"max": 7
}
}
}

View File

@ -0,0 +1,7 @@
{
"ratings": {
"primary": 5,
"quality": 4,
"design": 5
}
}

View File

@ -0,0 +1,3 @@
{
"hidden": true
}

View File

@ -0,0 +1,3 @@
{
"rating": "1"
}

24
jolt-demo/shift/spec.json Normal file
View File

@ -0,0 +1,24 @@
[
{
"operation": "shift",
"spec": {
"orderId": "data.order_id",
"orderNo": "data.order_no",
"orderItem": {
"*": {
"orderItemId": "data.order_item.[#2].order_item_id",
"orderItemNo": "data.order_item.[#2].order_item_no"
}
}
}
},
{
"operation": "default",
"spec": {
"Range": 5,
"data": {
"default": 12345
}
}
}
]

View File

@ -0,0 +1,28 @@
[
{
"operation": "shift",
"spec": {
"foo": {
"$": "place.to.put.key",//$keyplace.to.put.keyplace.to.put.key=foo
"@": "place.to.put.value"//@keyvalueplace.to.put.valueplace.to.put.value=1
}
}
}
]
//LHS@
//LHS@(jsonroot)
//@value1"2""xxxx""foo":{"xx":"1"}
//@
// { "address": { ... } }@&*
//{
// "place": {
// "to": {
// "put": {
// "key": "foo",
// "value": "1"
// }
// }
// }
//}

View File

@ -0,0 +1,11 @@
[
{
"operation": "shift",
"spec": {
"@author": "@book"
}
}
]
//@authorauthorvalue(Stephen Hawking)@book=Stephen Hawking
//@bookbookvaluekeyA Brief History of Time=Stephen Hawking

View File

@ -0,0 +1,12 @@
[
{
"operation": "shift",
"spec": {
"Photos": {
"1": "photo-&-url"
// 1
}
}
}
]
// & key

View File

@ -0,0 +1,9 @@
[
{
"operation": "shift",
"spec": {
"photo-1-id": "Photos[1].Id",//Photos[1].Id1
"photo-1-url": "Photos[1].Url"//Photos[1].Url
}
}
]

View File

@ -0,0 +1,11 @@
[
{
"operation": "shift",
"spec": {
"foo": [
"bar",
"baz"
]
}
}
]

View File

@ -0,0 +1,9 @@
[
{
"operation": "shift",
"spec": {
"foo": "baz",
"tuna": "baz"
}
}
]

View File

@ -0,0 +1,14 @@
[
{
"operation": "shift",
"spec": {
"rating": {
"quality": {
"value": "SecondaryRatings.quality.Value", // SecondaryRatings.quality.Value3
"max": "SecondaryRatings.quality.RatingRange" // SecondaryRatings.quality.RatingRange5
}
}
}
}
]
//"SecondaryRatings.quality.RatingRange"

View File

@ -0,0 +1,20 @@
[
{
"operation": "shift",
"spec": {
"rating": {
"primary": {
"value": "Rating",//Rating3
"max": "RatingRange"//RatingRange5
},
"*": {//ratingqualitysharpnessprimary
"value": "SecondaryRatings.&1.Value",//rating.*.value SecondaryRatings.*.Value
"max": "SecondaryRatings.&1.Range",//rating.*.max SecondaryRatings.*.Range
"$": "SecondaryRatings.&1.Id" //使 rating.*.quality or sharpness SecondaryRatings.*.Id
}
}
}
}
]
// * LHS使* keyuser-* userkey
// &1 * "quality"

View File

@ -0,0 +1,15 @@
[
{
"operation": "shift",
"spec": {
"rating": {
"*": {
"max": "Rating.[#2].amx",//rating.*.max Rating[{max:5}]
"value": "Rating.[#2].value"//rating.*.valueRating[{value:3}]
}
}
}
}
]
//[#2]

View File

@ -0,0 +1,35 @@
[
{
"operation": "shift",
"spec": {
"tag-*-*": "&(0,0)"//* tag- & Jolt
}
}
]
//&LHSRHS使&
//(0,1) 0 tag-Pro1 *
//&(0,1) tag-
// Jolt shift & (a,b)
//a**0 1
//b使** 1
//0 1
//Jolt a
//**&(0,1)** * Pro
//**&(1,1)** /
//**&(2,1)**
//&
//{
// "foo" : {
// "bar": {
// "baz": // &0 = baz, &1 = bar, &2 = foo
// }
// }
//}
//使"tag-*-*""tag-Foo-Bar":
// &(0,0) = "tag-Foo-Bar"
// &(0,1) = "Foo"
// &(0,2) = "Bar"

View File

@ -0,0 +1,15 @@
[
{
"operation": "shift",
"spec": {
"rating": {
"*": { // ratingkey
"$": "ratings" // keyrating
}
}
}
}
]
//JSONvalueJSONvalueJSONkey
//$
//$

View File

@ -0,0 +1,28 @@
[
{
"operation": "shift",
"spec": {
"ratings": {
"*": {
"$": "Ratings[#2].Name",//"Ratings[#2].Name": "primary") Ratings[#2].Name $
"@": "Ratings[#2].Value"//"Ratings[#2].Value": 5) Ratings[#2].Value @
}
}
}
}
]
//#2 0
//#number
//#2
//root(0) ratings(1) *(2) (3)
//#2321ratings
//Joltratings0
//JSONratings3primary0quality1design2
//primary#2ratings0design2
//LHS RHS使
//RHS, # [#2]
//LSH#
//LSH#

View File

@ -0,0 +1,12 @@
[
{
"operation": "shift",
"spec": {
"hidden" : {
"true" : { // "hidden" true
"#disabled" : "clients.clientId" // "disabled" "clients.clientId", #(disabled) #disabled#(disabled)
}
}
}
}
]

View File

@ -0,0 +1,9 @@
[
{
"operation": "shift",
"spec": {
"rating|Rating" : "rating-primary" // "rating" or "Rating" rating-primary
}
}
]
//|

View File

@ -0,0 +1,6 @@
{
"a": "0",
"b": "-1",
"r": "9",
"d": "2"
}

5
jolt-demo/sort/spec.json Normal file
View File

@ -0,0 +1,5 @@
[
{
"operation": "sort"
}
]

30
pom.xml
View File

@ -78,6 +78,8 @@
<dingtalk-stream-sdk.version>1.3.7</dingtalk-stream-sdk.version> <dingtalk-stream-sdk.version>1.3.7</dingtalk-stream-sdk.version>
<dingtalk-sdk.version>2.1.46</dingtalk-sdk.version> <dingtalk-sdk.version>2.1.46</dingtalk-sdk.version>
<!-- <groovy.version>4.0.15</groovy.version>--> <!-- <groovy.version>4.0.15</groovy.version>-->
<dingtalk-sdk.version>2.1.46</dingtalk-sdk.version>
<latest.jolt.version>0.1.8</latest.jolt.version>
</properties> </properties>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
@ -422,6 +424,33 @@
<artifactId>jsch</artifactId> <artifactId>jsch</artifactId>
<version>0.1.53</version> <version>0.1.53</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>com.bazaarvoice.jolt</groupId>-->
<!-- <artifactId>jolt-core</artifactId>-->
<!-- <version>0.1.7</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.bazaarvoice.jolt</groupId>-->
<!-- <artifactId>json-utils</artifactId>-->
<!-- <version>0.1.7</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.fasterxml.jackson.core</groupId>-->
<!-- <artifactId>jackson-databind</artifactId>-->
<!-- <version>2.13.3</version>-->
<!-- </dependency>-->
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>jolt-core</artifactId>
<version>${latest.jolt.version}</version>
</dependency>
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>json-utils</artifactId>
<version>${latest.jolt.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -572,7 +601,6 @@
<enabled>false</enabled> <enabled>false</enabled>
</snapshots> </snapshots>
</repository> </repository>
</repositories> </repositories>
</project> </project>