Step 1: Move vm scripts to the right place
[integration/test.git] / test / csit / suites / iotdm / basic / 050_ContainerAttributeTest.robot
1 *** Settings ***
2 Suite Teardown    Kill The Tree    ${CONTROLLER}    InCSE1    admin    admin
3 Library           ../../../libraries/criotdm.py
4 Library           Collections
5
6 *** Variables ***
7 ${httphost}       ${CONTROLLER}
8 ${httpuser}       admin
9 ${httppass}       admin
10 ${rt_ae}          2
11 ${rt_container}    3
12 ${rt_contentInstance}    4
13
14 *** Test Cases ***
15 Set Suite Variable
16     [Documentation]    set a suite variable ${iserver}
17     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
18     Set Suite Variable    ${iserver}
19     #==================================================
20     #    Container Mandatory Attribute Test
21     #==================================================
22     # For Creation, there are no mandatory input attribute
23
24 1.1 After Created, test whether all the mandatory attribtues are exist.
25     [Documentation]    After Created, test whether all the mandatory attribtues are exist.
26     ${attr} =    Set Variable
27     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container1
28     ${container} =    Name    ${r}
29     ${status_code} =    Status Code    ${r}
30     Should Be Equal As Integers    ${status_code}    201
31     ${text} =    Text    ${r}
32     Should Contain    ${text}    "ri":    "rn":    "cni"
33     Should Contain    ${text}    "lt":    "pi":    "st":
34     Should Contain    ${text}    "ct":    "rty":3    "cbs"
35     Should Not Contain    S{text}    "lbl"    "creator"    "or"
36     #==================================================
37     #    Container Optional Attribute Test (Allowed)
38     #==================================================
39     #    create--> delete
40     #    update(create)--> update(modified)-->update (delete)
41
42 2.11 maxNumberofInstance (mni) can be added when create
43     [Documentation]    maxNumberofInstance (mni) can be added when create
44     ${attr} =    Set Variable    "mni":3
45     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
46     ${text} =    Check Response and Retrieve Resource    ${r}
47     Should Contain    ${text}    "mni"
48
49 Delete the Container2-2.1
50     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
51
52 2.12 maxNumberofInstance (mni) can be added through update (0-1)
53     [Documentation]    maxNumberofInstance (mni) can be added through update (0-1)
54     ${attr} =    Set Variable    "mni":3
55     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
56     ${text} =    Check Response and Retrieve Resource    ${r}
57     Should Contain    ${text}    "mni"
58
59 2.13 maxNumberofInstance (mni) can be modified through update (1-1)
60     [Documentation]    maxNumberofInstance (mni) can be modified through update (1-1)
61     ${attr} =    Set Variable    "mni":5
62     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
63     ${text} =    Check Response and Retrieve Resource    ${r}
64     Should Contain    ${text}    "mni":5
65     Should Not Contain    ${text}    "mni":3
66
67 2.14 if set to null, maxnumberofInstance (mni) can be deleted through delete(1-0)
68     [Documentation]    if set to null, maxnumberofInstance (mni) can be deleted through delete(1-0)
69     ${attr} =    Set Variable    "mni":null
70     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
71     ${text} =    Check Response and Retrieve Resource    ${r}
72     Should Not Contain    ${text}    "mni"
73
74 2.21 maxByteSize (mbs) can be added when create
75     [Documentation]    maxByteSize (mbs) can be added when create
76     ${attr} =    Set Variable    "mbs":20
77     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
78     ${text} =    Check Response and Retrieve Resource    ${r}
79     Should Contain    ${text}    "mbs"
80
81 Delete the Container2-2.2
82     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
83
84 2.22 maxByteSize (mbs) can be added through update (0-1)
85     [Documentation]    maxByteSize (mbs) can be added through update (0-1)
86     ${attr} =    Set Variable    "mbs":20
87     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
88     ${text} =    Check Response and Retrieve Resource    ${r}
89     Should Contain    ${text}    "mbs"
90
91 2.23 maxByteSize (mbs) can be modified through update (1-1)
92     [Documentation]    maxByteSize (mbs) can be modified through update (1-1)
93     ${attr} =    Set Variable    "mbs":25
94     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
95     ${text} =    Check Response and Retrieve Resource    ${r}
96     Should Contain    ${text}    "mbs":25
97     Should Not Contain    ${text}    "mbs":20
98
99 2.24 if set to null, maxByteSize (mbs) can be deleted through delete(1-0)
100     [Documentation]    if set to null, maxByteSize (mbs) can be deleted through delete(1-0)
101     ${attr} =    Set Variable    "mbs":null
102     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
103     ${text} =    Check Response and Retrieve Resource    ${r}
104     Should Not Contain    ${text}    "mbs"
105
106 2.31 ontologyRef(or) can be added when create
107     [Documentation]    ontologyRef(or) can be added when create
108     ${attr} =    Set Variable    "or":"http://cisco.com"
109     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
110     ${text} =    Check Response and Retrieve Resource    ${r}
111     Should Contain    ${text}    "or"
112
113 Delete the Container2-2.3
114     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
115
116 2.32 ontologyRef(or) can be added through update (0-1)
117     [Documentation]    ontologyRef(or) can be added through update (0-1)
118     ${attr} =    Set Variable    "or":"http://cisco.com"
119     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
120     ${text} =    Check Response and Retrieve Resource    ${r}
121     Should Contain    ${text}    "or"
122
123 2.33 ontologyRef(or) can be modified through update (1-1)
124     [Documentation]    ontologyRef(or) can be modified through update (1-1)
125     ${attr} =    Set Variable    "or":"http://iotdm.com"
126     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
127     ${text} =    Check Response and Retrieve Resource    ${r}
128     Should Contain    ${text}    "or":"http://iotdm.com"
129     Should Not Contain    ${text}    "or":"http://cisco.com"
130
131 2.34 if set to null, ontologyRef(or) can be deleted through delete(1-0)
132     [Documentation]    if set to null, ontologyRef(or) can be deleted through delete(1-0)
133     ${attr} =    Set Variable    "or":null
134     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
135     ${text} =    Check Response and Retrieve Resource    ${r}
136     Should Not Contain    ${text}    "or"
137
138 2.41 labels can be created through update (0-1)
139     [Documentation]    labels can be created through update (0-1)
140     ${attr} =    Set Variable    "lbl":["label1"]
141     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
142     ${text} =    Check Response and Retrieve Resource    ${r}
143     Should Contain    ${text}    lbl    label1
144
145 2.42 labels can be modified (1-1)
146     [Documentation]    labels can be modified (1-1)
147     ${attr} =    Set Variable    "lbl":["label2"]
148     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
149     ${text} =    Check Response and Retrieve Resource    ${r}
150     Should Not Contain    ${text}    label1
151     Should Contain    ${text}    lbl    label2
152
153 2.43 if set to null, labels should be deleted(1-0)
154     [Documentation]    if set to null, labels should be deleted(1-0)
155     ${attr} =    Set Variable    "lbl":null
156     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
157     ${text} =    Check Response and Retrieve Resource    ${r}
158     Should Not Contain    ${text}    lbl    label1    label2
159
160 2.44 labels can be created through update (0-n)
161     [Documentation]    labels can be created through update (0-n)
162     ${attr} =    Set Variable    "lbl":["label3","label4","label5"]
163     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
164     ${text} =    Check Response and Retrieve Resource    ${r}
165     Should Contain    ${text}    lbl    label3    label4
166     Should Contain    ${text}    label5
167
168 2.45 labels can be modified (n-n)(across)
169     [Documentation]    labels can be modified (n-n)(across)
170     ${attr} =    Set Variable    "lbl":["label4","label5","label6"]
171     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
172     ${text} =    Check Response and Retrieve Resource    ${r}
173     Should Not Contain    ${text}    label1    label2    label3
174     Should Contain    ${text}    lbl    label4    label5
175     Should Contain    ${text}    label6
176
177 2.46 labels can be modified (n-n)(not across)
178     [Documentation]    labels can be modified (n-n)(not across)
179     ${attr} =    Set Variable    "lbl":["label7","label8","label9"]
180     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
181     ${text} =    Check Response and Retrieve Resource    ${r}
182     Should Not Contain    ${text}    label1    label2    label3
183     Should Not Contain    ${text}    label6    label4    label5
184     Should Contain    ${text}    lbl    label7    label8
185     Should Contain    ${text}    label9
186
187 2.47 if set to null, labels should be deleted(n-0)
188     [Documentation]    if set to null, labels should be deleted(n-0)
189     ${attr} =    Set Variable    "lbl":null
190     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
191     ${text} =    Check Response and Retrieve Resource    ${r}
192     Should Not Contain    ${text}    label1    label2    label3
193     Should Not Contain    ${text}    label6    label4    label5
194     Should Not Contain    ${text}    label7    label8    label9
195     Should Not Contain    ${text}    lbl
196     #======================================================
197     #    Container Disturbing Attribute Test, Not Allowed Update
198     #======================================================
199     # using non-valid attribtue to create then expext error
200
201 3.11 Mulitiple maxNrofInstance should return error
202     [Documentation]    Mulitiple maxNrofInstance should return error
203     ${attr} =    Set Variable    "mni":33,"mni":33
204     ${error} =    Cannot Create Container Error    ${attr}
205     Should Contain    ${error}    Duplicate key    mni
206
207 3.12 Mulitiple maxByteSize should return error
208     [Documentation]    Mulitiple maxByteSize should return error
209     ${attr} =    Set Variable    "mbs":44,"mbs":44
210     ${error} =    Cannot Create Container Error    ${attr}
211     Should Contain    ${error}    Duplicate key    mbs
212
213 3.13 Multiple creator should return error
214     [Documentation]    Multiple creator should return error
215     ${attr} =    Set Variable    "cr":null,"cr":null
216     ${error} =    Cannot Create Container Error    ${attr}
217     Should Contain    ${error}    Duplicate key    cr
218
219 3.14 Multiple ontologyRef should return error
220     [Documentation]    Multiple ontologyRef should return error
221     ${attr} =    Set Variable    "or":"http://cisco.com","or":"http://cisco.com"
222     ${error} =    Cannot Create Container Error    ${attr}
223     Should Contain    ${error}    Duplicate key    or
224
225 3.14 Multiple label attribute should return error(multiple array)
226     [Documentation]    Multiple label attribute should return error(multiple array)
227     ${attr} =    Set Variable    "lbl":["ODL1"], "lbl":["dsdsd"]
228     ${error} =    Cannot Create Container Error    ${attr}
229     Should Contain    ${error}    Duplicate key    lbl
230     #    3.2 Input of Integer using String should return error    [Should checked by wenxin]
231     #------------------------------------------------------
232     # using non-valid attribute to update then expect error
233
234 3.31 resourceType cannot be update.
235     [Documentation]    when update resourceType, expect error
236     ${attr} =    Set Variable    "ty":2
237     ${error} =    Cannot Update Container Error    ${attr}
238     Should Contain    ${error}    error
239
240 3.32 resoureceID cannot be update.
241     [Documentation]    update resoureceID then expect error
242     ${attr} =    Set Variable    "ri":"aaa"
243     ${error} =    Cannot Update Container Error    ${attr}
244     Should Contain    ${error}    error    ri
245
246 3.33 resouceNme cannot be update.(write once)
247     [Documentation]    update resourceName and expect error
248     ${attr} =    Set Variable    "rn":"aaa"
249     ${error} =    Cannot Update Container Error    ${attr}
250     Should Contain    ${error}    error    rn
251
252 3.34 parentID cannot be update.
253     [Documentation]    update parentID and expect error
254     ${attr} =    Set Variable    "pi":"aaa"
255     ${error} =    Cannot Update Container Error    ${attr}
256     Should Contain    ${error}    error    pi
257
258 3.35 createTime cannot be update.
259     [Documentation]    update createTime and expect error
260     ${attr} =    Set Variable    "ct":"aaa"
261     ${error} =    Cannot Update Container Error    ${attr}
262     Should Contain    ${error}    error    ct
263
264 3.36 curerntByteSize cannot be update --- Special, cannot be modified by the user
265     [Documentation]    update currentByteSize and expect error
266     ${attr} =    Set Variable    "cbs":123
267     ${error} =    Cannot Update Container Error    ${attr}
268     Should Contain    ${error}    error    api
269
270 3.37 currentNrofInstance cannot be updated --- Special, cannot be modified by the user
271     [Documentation]    update cni and expect error
272     ${attr} =    Set Variable    "cni":3
273     ${error} =    Cannot Update Container Error    ${attr}
274     Should Contain    ${error}    error    aei
275
276 3.38 LastMoifiedTime --- Special, cannot be modified by the user
277     [Documentation]    update lt and expect error
278     ${attr} =    Set Variable    "lt":"aaa"
279     ${error} =    Cannot Update Container Error    ${attr}
280     Should Contain    ${error}    error    lt
281
282 3.39 stateTag --- Special, cannot be modified by the user
283     [Documentation]    update st and expect error
284     ${attr} =    Set Variable    "st":3
285     ${error} =    Cannot Update Container Error    ${attr}
286     Should Contain    ${error}    error    st
287
288 3.310 creator -- cannot be modified
289     [Documentation]    update cr and expect error
290     ${attr} =    Set Variable    "cr":null
291     ${error} =    Cannot Update Container Error    ${attr}
292     Should Contain    ${error}    error    cr
293
294 3.41 Using AE's M attribute to create
295     [Documentation]    use AE attribtue to create Container then expect error
296     ${attr} =    Set Variable    "api":"ODL","aei":"ODL"
297     ${error} =    Cannot Update Container Error    ${attr}
298     Should Contain    ${error}    CONTENT(pc)
299
300 3.42 Using ContentInstance's M attribute to create
301     [Documentation]    use contentInstance attribtue to create Container then expect error
302     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"101"
303     ${error} =    Cannot Update Container Error    ${attr}
304     Should Contain    ${error}    CONTENT(pc)
305     #==================================================
306     #    Functional Attribute Test
307     #==================================================
308     # 1. lastModifiedTime
309     # 2. parentID
310     # 3. stateTag
311     # 4. currentNrOfInstances
312     # 5. currentByteSize
313     # 6. maxNrOfInstances
314     # 7. maxByteSize
315     # 8. creator
316     # 9. contentSize
317     # 10. childresource
318     #-------------- 1.    lastModifiedTime    -----------
319
320 4.11 if updated seccessfully, lastModifiedTime must be modified.
321     [Documentation]    if updated seccessfully, lastModifiedTime must be modified.
322     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container1
323     ${text} =    Text    ${oldr}
324     LOG    ${text}
325     ${lt1} =    LastModifiedTime    ${oldr}
326     ${attr} =    Set Variable    "lbl":["aaa"]
327     Sleep    1s
328     # We know Beryllium is going to be get rid of all sleep.
329     # But as lastModifiedTime has precision in seconds,
330     # we need to wait 1 second to see different value on update.
331     ${r} =    update Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}
332     ${lt2} =    LastModifiedTime    ${r}
333     Should Not Be Equal    ${oldr.json()['lt']}    ${lt2}
334
335 4.12 childResources create , parent's lastmodifiedTime update
336     [Documentation]    childResources create , parent's lastmodifiedTime update
337     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container1
338     ${text} =    Text    ${oldr}
339     LOG    ${text}
340     ${lt1} =    LastModifiedTime    ${oldr}
341     Sleep    1s
342     # We know Beryllium is going to be get rid of all sleep.
343     # But as lastModifiedTime has precision in seconds,
344     # we need to wait 1 second to see different value on update.
345     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
346     ${r} =    Create Resource    ${iserver}    InCSE1/Container1    ${rt_contentInstance}    ${attr}    conIn1
347     ${lt2} =    LastModifiedTime    ${r}
348     Should Not Be Equal    ${oldr.json()['lt']}    ${lt2}
349     #-------------- 2 parentID ------------
350
351 4.21 Check parentID(cse-container)
352     [Documentation]    parentID should be InCSE1
353     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1
354     ${CSEID} =    Set Variable    ${oldr.json()['ri']}
355     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container1
356     Should Be Equal    ${oldr.json()['ri']}    ${r.json()['pi']}
357
358 4.22 Check parentID(cse-container-container)
359     [Documentation]    parentID should be correct
360     # CSE
361     #    |--Contianer1
362     #    |--Container2
363     ${attr} =    Set Variable
364     ${r}=    Create Resource    ${iserver}    InCSE1/Container1    ${rt_container}    ${attr}    Container2
365     ${container} =    Name    ${r}
366     ${status_code} =    Status Code    ${r}
367     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container1
368     ${CSEID} =    Set Variable    ${oldr.json()['ri']}
369     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container1/Container2
370     Should Be Equal    ${oldr.json()['ri']}    ${r.json()['pi']}
371
372 4.23 Check parentID(cse-AE-container)
373     [Documentation]    parentID should be correct
374     # CSE
375     #    |--AE1
376     #    |--Container2
377     ${attr} =    Set Variable    "api":"ODL","aei":"ODL"
378     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}    AE1
379     ${attr} =    Set Variable
380     ${r}=    Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    ${attr}    Container2
381     ${container} =    Name    ${r}
382     ${status_code} =    Status Code    ${r}
383     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/AE1
384     ${CSEID} =    Set Variable    ${oldr.json()['ri']}
385     ${r} =    Retrieve Resource    ${iserver}    InCSE1/AE1/Container2
386     Should Be Equal    ${oldr.json()['ri']}    ${r.json()['pi']}
387
388 4.24 Check parentID(cse-AE-container-container)
389     [Documentation]    parentID should be correct
390     # CSE
391     #    |--AE1
392     #    |--Container2
393     #    |--- Container3
394     ${attr} =    Set Variable
395     ${r}=    Create Resource    ${iserver}    InCSE1/AE1/Container2    ${rt_container}    ${attr}    Container3
396     ${container} =    Name    ${r}
397     ${status_code} =    Status Code    ${r}
398     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/AE1/Container2
399     ${CSEID} =    Set Variable    ${oldr.json()['ri']}
400     ${r} =    Retrieve Resource    ${iserver}    InCSE1/AE1/Container2/Container3
401     Should Be Equal    ${oldr.json()['ri']}    ${r.json()['pi']}
402
403 Delete the test AE-4.2
404     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/AE1
405     #--------------3. stateTag------------
406
407 4.31 stateTag (when create, check if 0)
408     [Documentation]    when create, st should be 0
409     # CSE
410     #    |--Container2
411     ${attr} =    Set Variable
412     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
413     ${container} =    Name    ${r}
414     ${status_code} =    Status Code    ${r}
415     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
416     ${st} =    Set Variable    ${oldr.json()['st']}
417     Should Be Equal As Integers    0    ${st}
418     # 4.32 stateTag (when update expirationTime)
419     # 4.33 stateTag (when update accessControlPolicyIDs)
420
421 4.34 stateTag (when update labels) + lastModifiedTime
422     [Documentation]    st and lt should be changed
423     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
424     ${oldst} =    Set Variable    ${oldr.json()['st']}
425     ${attr} =    Set Variable    "lbl":["label1"]
426     Sleep    1s
427     # We know Beryllium is going to be get rid of all sleep.
428     # But as lastModifiedTime has precision in seconds,
429     # we need to wait 1 second to see different value on update.
430     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
431     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
432     Should Be Equal As Integers    ${oldst+1}    ${r.json()['st']}
433     Should Not Be Equal    ${oldr.json()['lt']}    ${r.json()['lt']}
434     # 4.35 stateTag (when update announceTo)
435     # 4.36 stateTag (when update announceAttribute)
436
437 4.37 stateTag (when update MaxNrOfInstances) + lastModifiedTime
438     [Documentation]    st and lt should be changed
439     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
440     ${oldst} =    Set Variable    ${oldr.json()['st']}
441     ${attr} =    Set Variable    "mni":5
442     Sleep    1s
443     # We know Beryllium is going to be get rid of all sleep.
444     # But as lastModifiedTime has precision in seconds,
445     # we need to wait 1 second to see different value on update.
446     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
447     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
448     Should Be Equal As Integers    ${oldst+1}    ${r.json()['st']}
449     Should Not Be Equal    ${oldr.json()['lt']}    ${r.json()['lt']}
450
451 4.38 stateTag (when update MaxByteSize) + lastModifiedTime
452     [Documentation]    st and lt should be changed
453     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
454     ${oldst} =    Set Variable    ${oldr.json()['st']}
455     ${attr} =    Set Variable    "mbs":30
456     Sleep    1s
457     # We know Beryllium is going to be get rid of all sleep.
458     # But as lastModifiedTime has precision in seconds,
459     # we need to wait 1 second to see different value on update.
460     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
461     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
462     Should Be Equal As Integers    ${oldst+1}    ${r.json()['st']}
463     Should Not Be Equal    ${oldr.json()['lt']}    ${r.json()['lt']}
464     # 4.39 stateTag (when update maxInstanceAge)
465     # 4.310 stateTag (when update locationID)
466
467 4.311 stateTag (when update ontologyRef) + lastModifiedTime
468     [Documentation]    st and lt should be changed
469     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
470     ${oldst} =    Set Variable    ${oldr.json()['st']}
471     ${attr} =    Set Variable    "or":"http://google.com"
472     Sleep    1s
473     # We know Beryllium is going to be get rid of all sleep.
474     # But as lastModifiedTime has precision in seconds,
475     # we need to wait 1 second to see different value on update.
476     Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
477     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
478     Should Be Equal As Integers    ${oldst+1}    ${r.json()['st']}
479     Should Not Be Equal    ${oldr.json()['lt']}    ${r.json()['lt']}
480
481 4.312 when create child container, stateTag will not increase + lastModifiedTime should change
482     [Documentation]    when create child container, stateTag will not increase + lastModifiedTime should not change
483     # CSE
484     #    |--Contianer2
485     #    |--Container3
486     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
487     ${oldst} =    Set Variable    ${oldr.json()['st']}
488     ${attr} =    Set Variable    "lbl":["label1"]
489     Sleep    1s
490     # We know Beryllium is going to be get rid of all sleep.
491     # But as lastModifiedTime has precision in seconds,
492     # we need to wait 1 second to see different value on update.
493     Create Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}    Container3
494     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
495     ${text} =    Text    ${r}
496     LOG    ${text}
497     Should Be Equal As Integers    ${oldst}    ${r.json()['st']}
498     Should Not Be Equal    ${oldr.json()['lt']}    ${r.json()['lt']}
499
500 4.313 * when create child contentInsntance, state should increase + lastModifiedTime shold change
501     [Documentation]    when create child contentInsntance, state should increase + lastModifiedTime shold not change
502     # CSE
503     #    |--Contianer2
504     #    |--ContentInstance
505     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
506     ${oldst} =    Set Variable    ${oldr.json()['st']}
507     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
508     Sleep    1s
509     # We know Beryllium is going to be get rid of all sleep.
510     # But as lastModifiedTime has precision in seconds,
511     # we need to wait 1 second to see different value on update.
512     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
513     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
514     ${text} =    Text    ${r}
515     LOG    ${text}
516     Should Be Equal As Integers    ${oldst+1}    ${r.json()['st']}
517     Should Not Be Equal    ${oldr.json()['lt']}    ${r.json()['lt']}
518
519 4.314 stateTag should not be updated when update child container
520     [Documentation]    stateTag should not be updated when update child container
521     # CSE
522     #    |--Contianer2
523     #    |--Container3
524     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
525     ${oldst} =    Set Variable    ${oldr.json()['st']}
526     ${attr} =    Set Variable    "lbl":["label45"]
527     Sleep    1s
528     # We know Beryllium is going to be get rid of all sleep.
529     # But as lastModifiedTime has precision in seconds,
530     # we need to wait 1 second to see different value on update.
531     Update Resource    ${iserver}    InCSE1/Container2/Container3    ${rt_container}    ${attr}
532     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
533     ${text} =    Text    ${r}
534     LOG    ${text}
535     Should Be Equal As Integers    ${oldst}    ${r.json()['st']}
536     ${lt2} =    LastModifiedTime    ${r}
537     Should Be Equal    ${oldr.json()['lt']}    ${r.json()['lt']}
538
539 Delete the Container2-4.3
540     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
541     #------------    4.    currentNrofInstance ------
542
543 4.41 when container create, cni should be 0
544     [Documentation]    when container create, cni should be 0
545     ${attr} =    Set Variable
546     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
547     ${container} =    Name    ${r}
548     ${status_code} =    Status Code    ${r}
549     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
550     ${cni} =    Set Variable    ${oldr.json()['cni']}
551     Should Be Equal As Integers    0    ${cni}
552
553 4.42 when conInstance create, parent container's cni should + 1
554     [Documentation]    when conInstance create, parent container's cni should + 1
555     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
556     ${oldcni} =    Set Variable    ${oldr.json()['cni']}
557     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
558     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
559     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
560     ${text} =    Text    ${r}
561     LOG    ${text}
562     Should Be Equal As Integers    ${oldcni+1}    ${r.json()['cni']}
563     # Test again
564     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
565     ${oldcni} =    Set Variable    ${oldr.json()['cni']}
566     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
567     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    contentIn1
568     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
569     ${text} =    Text    ${r}
570     LOG    ${text}
571     Should Be Equal As Integers    ${oldcni+1}    ${r.json()['cni']}
572
573 4.43 when conInstance delete, parent container's cni should - 1
574     [Documentation]    Delete the conIn created in 4.42, when conInstance delete, parent container's cni should - 1
575     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
576     ${oldcni} =    Set Variable    ${oldr.json()['cni']}
577     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
578     Delete Resource    ${iserver}    InCSE1/Container2/contentIn1
579     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
580     ${text} =    Text    ${r}
581     LOG    ${text}
582     Should Be Equal As Integers    ${oldcni-1}    ${r.json()['cni']}
583
584 Delete the Container2-4.4
585     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
586     # -------------    5. currentByteSize    -----------
587
588 4.51 when container create, cbs should be 0
589     [Documentation]    when container create, cbs should be 0
590     ${attr} =    Set Variable
591     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
592     ${container} =    Name    ${r}
593     ${status_code} =    Status Code    ${r}
594     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
595     ${cbs} =    Set Variable    ${oldr.json()['cbs']}
596     Should Be Equal As Integers    0    ${cbs}
597
598 4.52 when conInstance create, parent container's cbs should + cs
599     [Documentation]    when conInstance create, parent container's cbs should + cs
600     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
601     ${oldcbs} =    Set Variable    ${oldr.json()['cbs']}
602     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
603     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
604     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
605     ${text} =    Text    ${r}
606     LOG    ${text}
607     Should Be Equal As Integers    ${oldcbs+6}    ${r.json()['cbs']}
608     # Test again
609     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
610     ${oldcbs} =    Set Variable    ${oldr.json()['cbs']}
611     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"xxx%%!@"
612     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    contentIn1
613     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
614     ${text} =    Text    ${r}
615     LOG    ${text}
616     Should Be Equal As Integers    ${oldcbs+7}    ${r.json()['cbs']}
617
618 4.53 when conInstance delete, parent container's cbs should - cs
619     [Documentation]    Delete the conIn created in 4.52, when conInstance delete, parent container's cbs should - cs
620     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
621     ${oldcbs} =    Set Variable    ${oldr.json()['cbs']}
622     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102"
623     Delete Resource    ${iserver}    InCSE1/Container2/contentIn1
624     ${r} =    Retrieve Resource    ${iserver}    InCSE1/Container2
625     ${text} =    Text    ${r}
626     LOG    ${text}
627     Should Be Equal As Integers    ${oldcbs-7}    ${r.json()['cbs']}
628
629 Delete the Container2-4.5
630     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
631     # -------------    6. maxNrOfInstances    ----------
632
633 4.61 if maxNrOfInstance = 1 , can create 1 contentInstance
634     [Documentation]    if maxNrOfInstance = 1 , can create 1 contentInstance
635     ${attr} =    Set Variable    "mni":1
636     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
637     ${container} =    Name    ${r}
638     ${status_code} =    Status Code    ${r}
639     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
640     ${mni} =    Set Variable    ${oldr.json()['mni']}
641     Should Be Equal As Integers    1    ${mni}
642     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
643     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
644
645 4.62 if maxNrOfInstance = 1 , cannot create 2 contentInstance
646     [Documentation]    if maxNrOfInstance = 1 , cannot create 2 contentInstance
647     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
648     # cannot create 2
649     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}
650     ...    ${attr}
651     Should Start with    ${error}    Cannot create this resource [400]
652
653 4.63 if update to 3 , cannot create 4 contentInstance
654     [Documentation]    if update to 3 , cannot create 4 contentInstance
655     ${attr} =    Set Variable    "mni":3
656     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
657     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CSS"
658     # create 3
659     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    cin1
660     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    cin2
661     #Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
662     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
663     ${mni} =    Set Variable    ${rr.json()['mni']}
664     ${chr} =    Set Variable    ${rr.json()['ch']}
665     ${text} =    Text    ${rr}
666     LOG    ${text}
667     # cannot create 4
668     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}
669     ...    ${attr}
670     Should Start with    ${error}    Cannot create this resource [400]
671
672 4.64 what if alread have 4, then set mni to 1 ?
673     [Documentation]    what if alread have 4, then set mni to 1 ?
674     ${attr} =    Set Variable    "mni":1
675     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
676     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
677     ${chr} =    Set Variable    ${rr.json()['ch']}
678     ${mni} =    Set Variable    ${rr.json()['mni']}
679     Should Be Equal As Integers    ${rr.json()['cni']}    1
680
681 Delete the Container2-4.6
682     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
683     # -------------    7. maxByteSize -------
684
685 4.71 if maxByteSize = 5 , can create contentInstance with contentSize 5
686     [Documentation]    if maxByteSize = 5 , can create contentInstance with contentSize 5
687     ${attr} =    Set Variable    "mbs":5
688     ${r}=    Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container2
689     ${container} =    Name    ${r}
690     ${status_code} =    Status Code    ${r}
691     ${oldr} =    Retrieve Resource    ${iserver}    InCSE1/Container2
692     ${mbs} =    Set Variable    ${oldr.json()['mbs']}
693     Should Be Equal As Integers    5    ${mbs}
694
695 4.72 if maxByteSize = 5 , cannot create contentInstance with contenSize 8
696     [Documentation]    if maxByteSize = 5 , cannot create contentInstance with contenSize 8
697     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102C"
698     # create 1 (6 bytes)
699     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}
700     # cannot create 2
701     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}
702     ...    ${attr}
703     Should Start with    ${error}    Cannot create this resource [400]
704
705 4.73 if update to 20 , cannot create another contentInstance
706     [Documentation]    if update to 20 , cannot create another contentInstance
707     ${attr} =    Set Variable    "mbs":20
708     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
709     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102CS"
710     # create 3
711     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    cin1
712     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    cin2
713     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    cin3
714     Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}    ${attr}    cin4
715     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
716     ${cbs} =    Set Variable    ${rr.json()['cbs']}
717     ${chr} =    Set Variable    ${rr.json()['ch']}
718     ${text} =    Text    ${rr}
719     LOG    ${text}
720     # cannot create 4
721     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container2    ${rt_contentInstance}
722     ...    ${attr}
723     Should Start with    ${error}    Cannot create this resource [400]
724
725 4.74 what if alread have 20, then set mbs to 5 ?
726     [Documentation]    what if alread have 20, then set mbs to 5 ?
727     ${attr} =    Set Variable    "mbs":5
728     ${r}=    Update Resource    ${iserver}    InCSE1/Container2    ${rt_container}    ${attr}
729     ${rr}=    Retrieve resource    ${iserver}    InCSE1/Container2
730     ${chr} =    Set Variable    ${rr.json()['ch']}
731     ${cbs} =    Set Variable    ${rr.json()['cbs']}
732     Should Be Equal As Integers    ${rr.json()['cni']}    1
733
734 Delete the Container2-4.7
735     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container2
736
737 4.81 creator -- value must be null
738     [Documentation]    creator -- value must be null
739     ${attr} =    Set Variable    "cr":"VALUE"
740     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1/Container1    ${rt_container}
741     ...    ${attr}
742     Should Start with    ${error}    Cannot create this resource [400]
743     Should Contain    ${error}    error    cr
744     #==================================================
745     #    Finish
746     #==================================================
747
748 Delete the test Container1
749     [Documentation]    Delete the test Container1
750     ${deleteRes} =    Delete Resource    ${iserver}    InCSE1/Container1
751
752 *** Keywords ***
753 Check Response and Retrieve Resource
754     [Arguments]    ${r}
755     ${con} =    Name    ${r}
756     ${status_code} =    Status Code    ${r}
757     Should Be True    199 < ${status_code} < 299
758     ${rr} =    Retrieve Resource    ${iserver}    ${con}
759     ${text} =    Text    ${rr}
760     [Return]    ${text}
761
762 Cannot Create Container Error
763     [Arguments]    ${attr}
764     [Documentation]    create Container Under InCSE1 and expect error
765     ${error} =    Run Keyword And Expect Error    *    Create Resource    ${iserver}    InCSE1    ${rt_container}
766     ...    ${attr}
767     Should Start with    ${error}    Cannot create this resource [400]
768     [Return]    ${error}
769
770 Cannot Update Container Error
771     [Arguments]    ${attr}
772     [Documentation]    update Container Under InCSE1 and expect error
773     ${error} =    Run Keyword And Expect Error    *    Update Resource    ${iserver}    InCSE1/Container1    ${rt_container}
774     ...    ${attr}
775     Should Start with    ${error}    Cannot update this resource [400]
776     [Return]    ${error}