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