blob: 55e57ecd485325932606f1f16b7d5abba46cb9ec [file] [log] [blame]
Guangrong Fu603b27e2017-09-04 18:26:10 +08001*** 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.
Shiwei Tian1358e552018-03-08 09:30:54 +080011 ${dict2} create dictionary ruleName=youbowu0314 description=create a new rule! content=package ruleqwertasd;\n\nimport java.util.Locale; enabled=1 loopControlName=closedControlLoop
Guangrong Fu603b27e2017-09-04 18:26:10 +080012 ${jsonParams} encode ${dict2}
13 ${response} createRule ${jsonParams}
14 ${respJson} to json ${response.content}
Shiwei Tiane6872862018-03-07 15:19:22 +080015 ${RULEID} get from dictionary ${respJson} ruleId
Guangrong Fu603b27e2017-09-04 18:26:10 +080016 set global variable ${RULEID}
17 log ${RULEID}
18
19add_invalid_content_rule
20 [Documentation] Add an invalid rule of which the content is incorrect!!
Shiwei Tiane6872862018-03-07 15:19:22 +080021 ${dict1} create dictionary ruleName=gy0307001 description=create a new rule! content=123123123 enabled=1
Guangrong Fu603b27e2017-09-04 18:26:10 +080022 ${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}
GuangrongFud570c232018-02-28 09:25:22 +080037 ${count} get from dictionary ${respJson} totalCount
Guangrong Fu603b27e2017-09-04 18:26:10 +080038 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.
GuangrongFu0dbcdac2018-08-15 16:53:54 +080042 ${response} queryConditionRule {"ruleId":"invalidid"}
Guangrong Fu603b27e2017-09-04 18:26:10 +080043 ${respJson} to json ${response.content}
GuangrongFud570c232018-02-28 09:25:22 +080044 ${count} get from dictionary ${respJson} totalCount
Guangrong Fu603b27e2017-09-04 18:26:10 +080045 run keyword if ${count}!=0 fail
46
47query_rule_with_partial_existing_name
48 [Documentation] Query rules with (a part of) an existing name.
Shiwei Tiane6872862018-03-07 15:19:22 +080049 ${response} queryConditionRule {"ruleName":"youbowu"}
Guangrong Fu603b27e2017-09-04 18:26:10 +080050 ${respJson} to json ${response.content}
GuangrongFud570c232018-02-28 09:25:22 +080051 ${count} get from dictionary ${respJson} totalCount
Guangrong Fu603b27e2017-09-04 18:26:10 +080052 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.
GuangrongFu0dbcdac2018-08-15 16:53:54 +080056 ${response} queryConditionRule {"ruleName":"zte2017"}
Guangrong Fu603b27e2017-09-04 18:26:10 +080057 ${respJson} to json ${response.content}
GuangrongFud570c232018-02-28 09:25:22 +080058 ${count} get from dictionary ${respJson} totalCount
Guangrong Fu603b27e2017-09-04 18:26:10 +080059 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}
GuangrongFud570c232018-02-28 09:25:22 +080065 ${count} get from dictionary ${respJson} totalCount
Guangrong Fu603b27e2017-09-04 18:26:10 +080066 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}
GuangrongFud570c232018-02-28 09:25:22 +080072 ${count} get from dictionary ${respJson} totalCount
Guangrong Fu603b27e2017-09-04 18:26:10 +080073 run keyword if ${count}!=0 fail
74
75query_rule_with_empty_status
76 [Documentation] Query rules with the status left empty.
Congcong Peng10d984c2018-03-02 10:46:54 +080077 ${response} queryConditionRule {"enabled":null}
Guangrong Fu603b27e2017-09-04 18:26:10 +080078 ${respJson} to json ${response.content}
GuangrongFud570c232018-02-28 09:25:22 +080079 ${count} get from dictionary ${respJson} totalCount
Guangrong Fu603b27e2017-09-04 18:26:10 +080080 run keyword if ${count}!=0 fail
81
82query_rule_with_combinational_fields
83 [Documentation] Query rules using the combination of different fields.
Shiwei Tiane6872862018-03-07 15:19:22 +080084 ${dic} create dictionary ruleName=youbowu0314 enabled=1
Guangrong Fu603b27e2017-09-04 18:26:10 +080085 ${paramJson} encode ${dic}
86 ${response} queryConditionRule ${paramJson}
87 ${respJson} to json ${response.content}
GuangrongFud570c232018-02-28 09:25:22 +080088 ${count} get from dictionary ${respJson} totalCount
Guangrong Fubc08dfd2017-10-16 11:16:41 +080089 run keyword if ${count}<1 fail Can't find the rules with the combination of different fields. ELSE traversalRuleAttribute ${respJson}
90 ... ${dic}
Guangrong Fu603b27e2017-09-04 18:26:10 +080091
92modify_rule_with_status
93 [Documentation] modify the rule with a valid status.
Shiwei Tiane6872862018-03-07 15:19:22 +080094 ${dic} create dictionary ruleId=${RULEID} enabled=0 content=package rule03140002 loopControlName=closedControlLoop
Guangrong Fu603b27e2017-09-04 18:26:10 +080095 ${modifyParam} encode ${dic}
96 ${modifyResp} modifyRule ${modifyParam}
Shiwei Tiane6872862018-03-07 15:19:22 +080097 ${response} queryConditionRule {"ruleId":"${RULEID}"}
Guangrong Fu603b27e2017-09-04 18:26:10 +080098 ${respJson} to json ${response.content}
GuangrongFud570c232018-02-28 09:25:22 +080099 ${count} get from dictionary ${respJson} totalCount
Guangrong Fubc08dfd2017-10-16 11:16:41 +0800100 run keyword if ${count}!=1 fail query rule fails! (can't find the rule modified!) ELSE traversalRuleAttribute ${respJson}
101 ... ${dic}
Guangrong Fu603b27e2017-09-04 18:26:10 +0800102
103modify_rule_with_invalid_status
104 [Documentation] modify the rule with an invalid status.
Shiwei Tiane6872862018-03-07 15:19:22 +0800105 ${dic} create dictionary ruleId=${RULEID} enabled=88 content=package rule03140002
Guangrong Fu603b27e2017-09-04 18:26:10 +0800106 ${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.
Shiwei Tiane6872862018-03-07 15:19:22 +0800111 ${dic} create dictionary ruleId=${RULEID} description=now, i modifying the description of the rule. content=package rule03140002 loopControlName=closedControlLoop
Guangrong Fu603b27e2017-09-04 18:26:10 +0800112 ${modifyParam} encode ${dic}
113 ${modifyResp} modifyRule ${modifyParam}
Shiwei Tiane6872862018-03-07 15:19:22 +0800114 ${response} queryConditionRule {"ruleId":'${RULEID}'} 1
Guangrong Fu603b27e2017-09-04 18:26:10 +0800115 ${respJson} to json ${response.content}
GuangrongFud570c232018-02-28 09:25:22 +0800116 ${count} get from dictionary ${respJson} totalCount
Guangrong Fubc08dfd2017-10-16 11:16:41 +0800117 run keyword if ${count}!=1 fail query rule fails! ELSE traversalRuleAttribute ${respJson}
118 ... ${dic}
Guangrong Fu603b27e2017-09-04 18:26:10 +0800119
120delete_existing_rule
121 [Documentation] Delete an existing rule.
122 should not be empty ${RULEID}
Guangrong Fu80c347b2017-09-21 10:00:46 +0800123 deleteRule ${RULEID}
Guangrong Fu603b27e2017-09-04 18:26:10 +0800124
125delete_non_existing_rule
126 [Documentation] Delete a non-existing rule.
Guangrong Fu80c347b2017-09-21 10:00:46 +0800127 deleteRule ${RULEID} -1