52be29ec5c1ada0ae5aa413b79bbe733e96ff7bb
[aai/test-config.git] / testsuite / robot / resources / aai / csit-customer.robot
1 *** Settings ***
2 Documentation     Operations on customers in AAI for BBS use case,
3 ...               using earliest API version where it is implemented
4 ...               and latest API version where it is not implemented
5
6 Resource    ../json_templater.robot
7 Resource    aai_interface.robot
8 Resource    csit-api-version-properties.robot
9 Resource    csit-relationship-list.robot
10 Resource    csit-subobject.robot
11 Library    OperatingSystem
12 Library    Collections
13
14
15 *** Variables ***
16 ${AAI_CUST_CONTAINER_PATH}=  /customers
17 ${AAI_CUST_SUBOBJECT_PATH}=  /customer
18 ${AAI_CUST_UNIQUE_KEY}=      global-customer-id
19 ${AAI_CUST_CSIT_BODY}=       robot/assets/templates/aai/csit-customer.template
20 ${AAI_CUST_ROOT_PATH}=       ${AAI_BUSINESS_PATH}${AAI_CUST_CONTAINER_PATH}${AAI_CUST_SUBOBJECT_PATH}
21 ${AAI_CUST_API_NA_INDEX_PATH}=    ${AAI_UNSUPPORTED_INDEX_PATH}
22 ${AAI_CUST_API_IMPL_INDEX_PATH}=  ${AAI_DUBLIN_INDEX_PATH}
23 # ${AAI_CUST_API_IMPL_INDEX_PATH}=  ${AAI_CASABLANCA_INDEX_PATH}
24
25 *** Keywords ***
26 Create Customer If Not Exists
27     [Documentation]    Creates Customer in AAI if it doesn't exist
28     [Arguments]    ${global_customer_id}  ${subscriber_name}  ${subscriber_type}
29     ${get_resp}=    Get SubObject  ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${AAI_CUST_UNIQUE_KEY}  ${global_customer_id}
30     Return From Keyword If    '${get_resp.status_code}' == '200'
31     Create Customer  ${global_customer_id}  ${subscriber_name}  ${subscriber_type}
32
33 Create Customer
34     [Documentation]    Creates Customer in AAI
35     [Arguments]    ${global_customer_id}  ${subscriber_name}  ${subscriber_type}
36     ${arguments}=    Create Dictionary     global_customer_id=${global_customer_id}  subscriber_name=${subscriber_name}  subscriber_type=${subscriber_type}
37     ${put_resp}=    Create SubObject  ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${global_customer_id}  ${AAI_CUST_CSIT_BODY}  ${arguments}
38
39 Delete Customer If Exists
40     [Documentation]    Removes Customer from AAI if it exists
41     [Arguments]    ${global_customer_id}
42     ${get_resp}=    Get SubObject  ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${AAI_CUST_UNIQUE_KEY}  ${global_customer_id}
43     Run Keyword If    '${get_resp.status_code}' == '200'    Delete Customer     ${global_customer_id}   ${get_resp.json()}
44
45 Delete Customer
46     [Documentation]    Removes Customer from AAI
47     [Arguments]    ${global_customer_id}  ${json}
48     ${del_resp}=    Delete SubObject  ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${global_customer_id}  ${json}
49
50 Get Customer
51     [Documentation]   Return Customer
52     [Arguments]    ${global_customer_id}
53     ${get_resp}=    Get SubObject  ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${AAI_CUST_UNIQUE_KEY}  ${global_customer_id}
54     Should Be Equal As Strings  ${get_resp.status_code}     200
55     [Return]  ${get_resp.json()}
56
57 Get Valid Customer URL
58     [Documentation]   Return Valid Customer URL
59     [Arguments]    ${global_customer_id}
60     ${resp}=    Get Valid SubObject URL  ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${global_customer_id}
61     [Return]  ${resp}
62
63 Get Nodes Query Customer
64     [Documentation]   Return Nodes query Customer
65     [Arguments]    ${global_customer_id}
66     ${get_resp}=    Confirm Nodes Query SubObjects  ${AAI_CUST_API_IMPL_INDEX_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_UNIQUE_KEY}  ${global_customer_id}
67     [Return]  ${get_resp.json()}
68
69 Get Example Customer
70     [Documentation]   Return Example Customer
71     ${get_resp}=    Confirm Examples Query SubObjects  ${AAI_CUST_API_IMPL_INDEX_PATH}  ${AAI_CUST_CONTAINER_PATH}
72     [Return]  ${get_resp.json()}
73
74 Confirm No Customer
75     [Documentation]   Confirm No Customer
76     [Arguments]    ${global_customer_id}
77     ${get_resp}=    Get SubObject  ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${AAI_CUST_UNIQUE_KEY}  ${global_customer_id}
78     Should Be Equal As Strings  ${get_resp.status_code}     404
79
80 Confirm API Not Implemented Customer
81     [Documentation]   Confirm latest API version where Customer is not implemented
82     [Arguments]    ${global_customer_id}
83     ${resp}=    Confirm API Not Implemented SubObject  ${AAI_CUST_API_NA_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_CUST_CONTAINER_PATH}  ${AAI_CUST_SUBOBJECT_PATH}  ${global_customer_id}
84
85 Add Customer Relationship
86     [Documentation]    Adds Relationship to existing Customer in AAI
87     [Arguments]    ${global_customer_id}  ${related_class_name}  ${related_object_url}
88     ${put_resp}=    Add Relationship     ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_CUST_ROOT_PATH}/${global_customer_id}  ${related_class_name}  ${related_object_url}
89
90 Get Customer RelationshipList
91     [Documentation]   Return relationship-list from Customer
92     [Arguments]    ${global_customer_id}
93     ${resp}=    Get RelationshipList     ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_CUST_ROOT_PATH}/${global_customer_id}
94     [Return]  ${resp}
95
96 Get Customer With RelationshipList
97     [Documentation]   Return Customer with relationship-list
98     [Arguments]    ${global_customer_id}
99     ${resp}=    Get Object With Depth     ${AAI_CUST_API_IMPL_INDEX_PATH}${AAI_CUST_ROOT_PATH}/${global_customer_id}
100     [Return]  ${resp}
101