f93ee8bbd3933aa93f5201745050162d1450da69
[integration/test.git] / test / csit / suites / iotdm / basic / 080_FilterCriteriaTest.robot
1 *** Settings ***
2 Suite Setup       Connect And Create The Tree
3 Suite Teardown    Kill The Tree    ${CONTROLLER}    InCSE1    admin    admin
4 Library           ../../../libraries/criotdm.py
5 Library           Collections
6
7 *** Variables ***
8 ${httphost}       ${CONTROLLER}
9 ${httpuser}       admin
10 ${httppass}       admin
11 ${rt_ae}          2
12 ${rt_container}    3
13 ${rt_contentInstance}    4
14
15 *** Test Cases ***
16 Set Suite Variable
17     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
18     Set Suite Variable    ${iserver}
19     #==================================================
20     #    ResultContent(rcn) Test
21     #==================================================
22
23 1.1 rcn is legal in create
24     [Documentation]    rcn=1, 2, 3, 0 is legal
25     ${attr} =    Set Variable    "aei":"ODL","api":"jb","apn":"jb2","or":"http://hey/you"
26     : FOR    ${rcn}    IN    \    1    2    3
27     ...    0
28     \    ${r} =    Create Resource With Command    ${iserver}    InCSE1    ${rt_ae}    rcn=${rcn}
29     \    ...    ${attr}
30     #add check reponse here in the next step, seperate them
31
32 1.2 rcn is illegal in create
33     [Documentation]    rcn=4, 5, 6, 7 is illegal
34     ${attr} =    Set Variable    "aei":"ODL","api":"jb","apn":"jb2","or":"http://hey/you"
35     : FOR    ${rcn}    IN    4    5    6    7
36     \    ${error} =    Run Keyword And Expect Error    *    Create Resource With Command    ${iserver}    InCSE1
37     \    ...    ${rt_ae}    rcn=${rcn}    ${attr}
38     \    Should Start with    ${error}    Cannot create this resource [400]
39     \    Should Contain    ${error}    rcn
40
41 2.1 rcn is legal in update
42     [Documentation]    rcn=1, 4, 0/ null is legal
43     ${attr} =    Set Variable    "or":"http://hey/you"
44     : FOR    ${rcn}    IN    \    0    1    4
45     \    ${r} =    Update Resource With Command    ${iserver}    InCSE1/AE1    ${rt_ae}    rcn=${rcn}
46     \    ...    ${attr}
47
48 2.2 rcn is illegal in update
49     [Documentation]    rcn=2, 3, 5, 6, 7 is illegal
50     ${attr} =    Set Variable    "or":"http://hey/you"
51     : FOR    ${rcn}    IN    2    3    4    7
52     \    ${error} =    Run Keyword And Expect Error    *    Update Resource With Command    ${iserver}    InCSE1/AE1
53     \    ...    ${rt_ae}    rcn=${rcn}    ${attr}
54     \    Should Start with    ${error}    Cannot update this resource [400]
55     \    Should Contain    ${error}    rcn
56
57 3.1 rcn is legal in retrieve
58     [Documentation]    rcn=1, 4, 5, 6 null is legal
59     : FOR    ${rcn}    IN    \    1    4    5
60     ...    6
61     \    ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=${rcn}
62     # when rcn=7 can be retrieved
63
64 3.2 rcn is illegal in retrieve
65     [Documentation]    rcn=0, 2, 3 is illegal
66     : FOR    ${rcn}    IN    0    2    3
67     \    ${error} =    Run Keyword And Expect Error    *    Retrieve Resource With Command    ${iserver}    InCSE1/AE1
68     \    ...    rcn=${rcn}
69     \    Should Start with    ${error}    Cannot retrieve this resource [400]
70     \    Should Contain    ${error}    rcn
71
72 4.2 rcn is illegal in delete
73     [Documentation]    rcn=4, 5, 6, 7 is illegal
74     ${attr} =    Set Variable    "or":"http://hey/you"
75     : FOR    ${rcn}    IN    2    3    4    5
76     ...    6    7
77     \    ${error} =    Run Keyword And Expect Error    *    Delete Resource With Command    ${iserver}    InCSE1/AE1
78     \    ...    rcn=${rcn}
79     \    Should Start with    ${error}    Cannot delete this resource [400]
80     \    Should Contain    ${error}    rcn
81
82 Delete the tree
83     Kill The Tree    ${CONTROLLER}    InCSE1    admin    admin
84     #==================================================
85     #    FilterCriteria Test
86     #==================================================
87
88 Create the tree
89     Connect And Create The Tree
90
91 1. createdBefore
92     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&crb=20160612T033748Z
93     ${count} =    Get Length    ${r.json()['ch']}
94     Should Be Equal As Integers    ${count}    2
95
96 2. createdAfter
97     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&cra=20150612T033748Z
98     ${count} =    Get Length    ${r.json()['ch']}
99     Should Be Equal As Integers    ${count}    2
100
101 3. modifiedSince
102     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&ms=20150612T033748Z
103     ${count} =    Get Length    ${r.json()['ch']}
104     Should Be Equal As Integers    ${count}    2
105
106 4. unmodifiedSince
107     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/AE1    rcn=4&us=20160612T033748Z
108     ${count} =    Get Length    ${r.json()['ch']}
109     Should Be Equal As Integers    ${count}    2
110
111 5. stateTagSmaller
112     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/Container3    rcn=4&sts=3
113     ${count} =    Get Length    ${r.json()['ch']}
114     ${s} =    Set Variable    ${r.json()['ch']}
115     Should Be Equal As Integers    ${count}    5
116
117 6. stateTagBigger
118     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/Container3    rcn=4&stb=1
119     ${count} =    Get Length    ${r.json()['ch']}
120     Should Be Equal As Integers    ${count}    2
121     # 7. expireBefore
122     # 8. expireAfter
123
124 9. labels
125     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1/Container3    rcn=4&sts=3&lbl=contentInstanceUnderContainerContainer
126     ${count} =    Get Length    ${r.json()['ch']}
127     Should Be Equal As Integers    ${count}    2
128     # 2 labels test
129
130 10. resourceType
131     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3
132     ${count} =    Get Length    ${r.json()['ch']}
133     Should Be Equal As Integers    ${count}    3
134
135 11. sizeAbove
136     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3&sza=5
137     ${count} =    Get Length    ${r.json()['ch']}
138     Should Be Equal As Integers    ${count}    2
139
140 12. sizeBelow
141     ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3&szb=5
142     ${count} =    Get Length    ${r.json()['ch']}
143     Should Be Equal As Integers    ${count}    1
144     # 13. contentType
145     # 14. limit
146     #    ${r} =    Retrieve Resource With Command    ${iserver}    InCSE1    rcn=4&rty=3&lim=2
147     #    ${count} =    Get Length    ${r.json()['ch']}
148     #    Should Be Equal As Integers    ${count}    2
149     #15. attribute
150     #16. filterUsage
151     # different conditions shall use the "AND" logical operation;
152     # same conditions shall use the "OR" logical operation.
153
154 *** Keywords ***
155 Connect And Create The Tree
156     [Documentation]    Create a tree that contain AE/ container / contentInstance in different layers
157     ${iserver} =    Connect To Iotdm    ${httphost}    ${httpuser}    ${httppass}    http
158     ${attr} =    Set Variable    "aei":"ODL","api":"jb","apn":"jb2","or":"http://hey/you"
159     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}    AE1
160     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}    AE2
161     Create Resource    ${iserver}    InCSE1    ${rt_ae}    ${attr}    AE3
162     ${attr} =    Set Variable
163     Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    ${attr}    Container1
164     Create Resource    ${iserver}    InCSE1/AE1    ${rt_container}    ${attr}    Container2
165     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underCSE"]
166     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container3
167     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container4
168     Create Resource    ${iserver}    InCSE1    ${rt_container}    ${attr}    Container5
169     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underAEContainer"]
170     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_container}    ${attr}    Container6
171     ${attr} =    Set Variable    "cr":null,"mni":5,"mbs":150,"or":"http://hey/you","lbl":["underCSEContainer"]
172     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr}    Container7
173     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr}    Container8
174     Create Resource    ${iserver}    InCSE1/Container3    ${rt_container}    ${attr}    Container9
175     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderAEContainer"]
176     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_contentInstance}    ${attr}    conIn1
177     Create Resource    ${iserver}    InCSE1/AE1/Container1    ${rt_contentInstance}    ${attr}    conIn2
178     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderContainerContainer"]
179     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr}    conIn3
180     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr}    conIn4
181     Create Resource    ${iserver}    InCSE1/Container3    ${rt_contentInstance}    ${attr}    conIn5
182     ${attr} =    Set Variable    "cnf": "1","or": "http://hey/you","con":"102","lbl":["contentInstanceUnderContainer"]
183     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr}    conIn6
184     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr}    conIn7
185     Create Resource    ${iserver}    InCSE1/Container4    ${rt_contentInstance}    ${attr}    conIn8