Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX add new push cases in doc and test #4627

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions doc/manuals/orion-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,31 @@ PUT /v2/entities/E/attrs/A

would change the value of attribute A to `[1, 2, 3, 3]`

If after the previous result the following request is done:

```
PUT /v2/entities/E/attrs/A
{
"value": { "$push": { "$each": [4, 5]} },
"type": "Array"
}
```

would change the value of attribute A to `[1, 2, 3, 3, 4, 5]`.

If after the previous result the following request is done:

```
PUT /v2/entities/E/attrs/A
{
"value": { "$push": { "$each": [ -1, 0 ], "$position": 0} },
"type": "Array"
}
```

would change the value of attribute A to `[-1, 0, 1, 2, 3, 3, 4, 5]`


#### `$addToSet`

Similar to push but avoids duplications.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ accumulatorStart --pretty-print
# 02. Create sub for entity E
# 03. Update A with $push: $each: [2, 3, 4]
# 04. Get entity, see E-A=[1,2,3,4]
# 05. Dump accumulator, see E-A=[1,2,3,4]
# 05. Update A with $push: $each: [-1, 0], $position: 0
# 06. Get entity, see E-A=[-1,0,1,2,3,4]
# 07. Dump accumulator, see E-A=[1,2,3,4] and E-A=[-1,0,1,2,3,4]
#


Expand Down Expand Up @@ -96,8 +98,28 @@ echo
echo


echo '05. Dump accumulator, see E-A=[1,2,3,4]'
echo '======================================='
echo '05. Update A with $push: $each: [-1, 0], $position: 0'
echo '====================================================='
payload='{
"A": {
"value": { "$push": { "$each": [-1, 0], "$position": 0} },
"type": "StructuredValue"
}
}'
orionCurl --url /v2/entities/E/attrs --payload "$payload"
echo
echo


echo '06. Get entity, see E-A=[-1,0,1,2,3,4]'
echo '======================================'
orionCurl --url /v2/entities/E
echo
echo


echo '07. Dump accumulator, see E-A=[1,2,3,4] and E-A=[-1,0,1,2,3,4]'
echo '=============================================================='
accumulatorDump
echo
echo
Expand Down Expand Up @@ -156,8 +178,42 @@ Content-Length: 84
}


05. Dump accumulator, see E-A=[1,2,3,4]
=======================================
05. Update A with $push: $each: [-1, 0], $position: 0
=====================================================
HTTP/1.1 204 No Content
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})



06. Get entity, see E-A=[-1,0,1,2,3,4]
======================================
HTTP/1.1 200 OK
Date: REGEX(.*)
Fiware-Correlator: REGEX([0-9a-f\-]{36})
Content-Type: application/json
Content-Length: 89

{
"A": {
"metadata": {},
"type": "StructuredValue",
"value": [
-1,
0,
1,
2,
3,
4
]
},
"id": "E",
"type": "T"
}


07. Dump accumulator, see E-A=[1,2,3,4] and E-A=[-1,0,1,2,3,4]
==============================================================
POST http://localhost:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 139
Expand Down Expand Up @@ -188,6 +244,38 @@ Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1
"subscriptionId": "REGEX([0-9a-f\-]{24})"
}
=======================================
POST http://localhost:REGEX(\d+)/notify
Fiware-Servicepath: /
Content-Length: 144
User-Agent: orion/REGEX(\d+\.\d+\.\d+.*)
Ngsiv2-Attrsformat: normalized
Host: localhost:REGEX(\d+)
Accept: application/json
Content-Type: application/json; charset=utf-8
Fiware-Correlator: REGEX([0-9a-f\-]{36}); cbnotif=1

{
"data": [
{
"A": {
"metadata": {},
"type": "StructuredValue",
"value": [
-1,
0,
1,
2,
3,
4
]
},
"id": "E",
"type": "T"
}
],
"subscriptionId": "REGEX([0-9a-f\-]{24})"
}
=======================================


--TEARDOWN--
Expand Down
Loading