blob: 55e57ecd485325932606f1f16b7d5abba46cb9ec [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** Settings ***
2Suite Setup
3Suite Teardown Delete All Sessions
4Test Timeout
5Library demjson
6Resource Rule-Keywords.robot
7
8*** Test Cases ***
9add_valid_rule
10 [Documentation] Add a valid rule.
11 ${dict2} create dictionary ruleName=youbowu0314 description=create a new rule! content=package ruleqwertasd;\n\nimport java.util.Locale; enabled=1 loopControlName=closedControlLoop
12 ${jsonParams} encode ${dict2}
13 ${response} createRule ${jsonParams}
14 ${respJson} to json ${response.content}
15 ${RULEID} get from dictionary ${respJson} ruleId
16 set global variable ${RULEID}
17 log ${RULEID}
18
19add_invalid_content_rule
20 [Documentation] Add an invalid rule of which the content is incorrect!!
21 ${dict1} create dictionary ruleName=gy0307001 description=create a new rule! content=123123123 enabled=1
22 ${jsonParams} encode ${dict1}
23 ${response} createRule ${jsonParams} -1
24 log ${response.content}
25
26add_deficient_rule
27 [Documentation] Add an invalid rule of which some mandatory fields are missing.(rulename)
28 ${dict3} create dictionary description=create a valid rule! content=package rule2017 enabled=1
29 ${jsonParams} encode ${dict3}
30 ${response} createRule ${jsonParams} -1
31
32query_rule_with_existing_id
33 [Documentation] Query a rule with an existing ID.
34 should not be empty ${RULEID}
35 ${response} queryConditionRule {"ruleid":"${RULEID}"}
36 ${respJson} to json ${response.content}
37 ${count} get from dictionary ${respJson} totalCount
38 run keyword if ${count}!=1 fail Can't find the rule with the specified ruleid.
39
40query_rule_with_non_existing_id
41 [Documentation] Query a rule with a non-existing ID.
42 ${response} queryConditionRule {"ruleId":"invalidid"}
43 ${respJson} to json ${response.content}
44 ${count} get from dictionary ${respJson} totalCount
45 run keyword if ${count}!=0 fail
46
47query_rule_with_partial_existing_name
48 [Documentation] Query rules with (a part of) an existing name.
49 ${response} queryConditionRule {"ruleName":"youbowu"}
50 ${respJson} to json ${response.content}
51 ${count} get from dictionary ${respJson} totalCount
52 run keyword if ${count}<1 fail Can't find the rule with (a part of) an existing name
53
54query_rule_with_partial_non_existing_name
55 [Documentation] Query rules with (a part of) a non-existing name.
56 ${response} queryConditionRule {"ruleName":"zte2017"}
57 ${respJson} to json ${response.content}
58 ${count} get from dictionary ${respJson} totalCount
59 run keyword if ${count}!=0 fail
60
61query_rule_with_vaild_status
62 [Documentation] Query rules with a valid status.
63 ${response} queryConditionRule {"enabled":1}
64 ${respJson} to json ${response.content}
65 ${count} get from dictionary ${respJson} totalCount
66 run keyword if ${count}<0 fail Can't find the rule with the status valued 1.
67
68query_rule_with_invalid_status
69 [Documentation] Query rules with an invalid status.
70 ${response} queryConditionRule {"enabled":99}
71 ${respJson} to json ${response.content}
72 ${count} get from dictionary ${respJson} totalCount
73 run keyword if ${count}!=0 fail
74
75query_rule_with_empty_status
76 [Documentation] Query rules with the status left empty.
77 ${response} queryConditionRule {"enabled":null}
78 ${respJson} to json ${response.content}
79 ${count} get from dictionary ${respJson} totalCount
80 run keyword if ${count}!=0 fail
81
82query_rule_with_combinational_fields
83 [Documentation] Query rules using the combination of different fields.
84 ${dic} create dictionary ruleName=youbowu0314 enabled=1
85 ${paramJson} encode ${dic}
86 ${response} queryConditionRule ${paramJson}
87 ${respJson} to json ${response.content}
88 ${count} get from dictionary ${respJson} totalCount
89 run keyword if ${count}<1 fail Can't find the rules with the combination of different fields. ELSE traversalRuleAttribute ${respJson}
90 ... ${dic}
91
92modify_rule_with_status
93 [Documentation] modify the rule with a valid status.
94 ${dic} create dictionary ruleId=${RULEID} enabled=0 content=package rule03140002 loopControlName=closedControlLoop
95 ${modifyParam} encode ${dic}
96 ${modifyResp} modifyRule ${modifyParam}
97 ${response} queryConditionRule {"ruleId":"${RULEID}"}
98 ${respJson} to json ${response.content}
99 ${count} get from dictionary ${respJson} totalCount
100 run keyword if ${count}!=1 fail query rule fails! (can't find the rule modified!) ELSE traversalRuleAttribute ${respJson}
101 ... ${dic}
102
103modify_rule_with_invalid_status
104 [Documentation] modify the rule with an invalid status.
105 ${dic} create dictionary ruleId=${RULEID} enabled=88 content=package rule03140002
106 ${modifyParam} encode ${dic}
107 ${modifyResponse} modifyRule ${modifyParam} -1
108
109modify_rule_with_description
110 [Documentation] modify the description of the rule with the new string.
111 ${dic} create dictionary ruleId=${RULEID} description=now, i modifying the description of the rule. content=package rule03140002 loopControlName=closedControlLoop
112 ${modifyParam} encode ${dic}
113 ${modifyResp} modifyRule ${modifyParam}
114 ${response} queryConditionRule {"ruleId":'${RULEID}'} 1
115 ${respJson} to json ${response.content}
116 ${count} get from dictionary ${respJson} totalCount
117 run keyword if ${count}!=1 fail query rule fails! ELSE traversalRuleAttribute ${respJson}
118 ... ${dic}
119
120delete_existing_rule
121 [Documentation] Delete an existing rule.
122 should not be empty ${RULEID}
123 deleteRule ${RULEID}
124
125delete_non_existing_rule
126 [Documentation] Delete a non-existing rule.
127 deleteRule ${RULEID} -1