AAI-2184 Robot testcases for BBS use case Dublin
[aai/test-config.git] / testsuite / robot / resources / aai / csit-service-subscription.robot
1 *** Settings ***
2 Documentation     Operations on service-subscriptions 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 ...               Note that service-subscription is always a sub-object!
6
7 Resource    ../json_templater.robot
8 Resource    aai_interface.robot
9 Resource    csit-api-version-properties.robot
10 Resource    csit-relationship-list.robot
11 Resource    csit-subobject.robot
12 Library    OperatingSystem
13 Library    Collections
14
15
16 *** Variables ***
17 ${AAI_SSUBS_CONTAINER_PATH}=  /service-subscriptions
18 ${AAI_SSUBS_SUBOBJECT_PATH}=  /service-subscription
19 ${AAI_SSUBS_UNIQUE_KEY}=      service-type
20 ${AAI_SSUBS_CSIT_BODY}=       robot/assets/templates/aai/csit-service-subscription.template
21 ${AAI_SSUBS_ROOT_PATH}=       ${AAI_BUSINESS_PATH}${AAI_SSUBS_CONTAINER_PATH}${AAI_SSUBS_SUBOBJECT_PATH}
22 ${AAI_SSUBS_API_NA_INDEX_PATH}=    ${AAI_UNSUPPORTED_INDEX_PATH}
23 ${AAI_SSUBS_API_IMPL_INDEX_PATH}=  ${AAI_DUBLIN_INDEX_PATH}
24 # ${AAI_SSUBS_API_IMPL_INDEX_PATH}=  ${AAI_CASABLANCA_INDEX_PATH}
25
26 *** Keywords ***
27 Create Service Subscription If Not Exists
28     [Documentation]    Creates Service Subscription in AAI if it doesn't exist
29     [Arguments]    ${api_version_base_object_url}  ${service_type}
30     ${get_resp}=    Get SubObject  ${api_version_base_object_url}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${AAI_SSUBS_UNIQUE_KEY}  ${service_type}
31     Return From Keyword If    '${get_resp.status_code}' == '200'
32     Create Service Subscription  ${api_version_base_object_url}  ${service_type}
33
34 Create Service Subscription
35     [Documentation]    Creates Service Subscription in AAI
36     [Arguments]    ${api_version_base_object_url}  ${service_type}
37     ${arguments}=    Create Dictionary     service_type=${service_type}
38     ${put_resp}=    Create SubObject  ${api_version_base_object_url}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${service_type}  ${AAI_SSUBS_CSIT_BODY}  ${arguments}
39
40 Delete Service Subscription If Exists
41     [Documentation]    Removes Service Subscription from AAI if it exists
42     [Arguments]    ${api_version_base_object_url}  ${service_type}
43     ${get_resp}=    Get SubObject  ${api_version_base_object_url}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${AAI_SSUBS_UNIQUE_KEY}  ${service_type}
44     Run Keyword If    '${get_resp.status_code}' == '200'    Delete Service Subscription     ${api_version_base_object_url}  ${service_type}   ${get_resp.json()}
45
46 Delete Service Subscription
47     [Documentation]    Removes Service Subscription from AAI
48     [Arguments]    ${api_version_base_object_url}  ${service_type}  ${json}
49     ${del_resp}=    Delete SubObject  ${api_version_base_object_url}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${service_type}  ${json}
50
51 Get Service Subscription
52     [Documentation]   Return Service Subscription
53     [Arguments]    ${api_version_base_object_url}  ${service_type}
54     ${get_resp}=    Get SubObject  ${api_version_base_object_url}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${AAI_SSUBS_UNIQUE_KEY}  ${service_type}
55     Should Be Equal As Strings  ${get_resp.status_code}     200
56     [Return]  ${get_resp.json()}
57
58 Get Valid Service Subscription URL
59     [Documentation]   Return Valid Service Subscription URL
60     [Arguments]    ${api_version_base_object_url}  ${service_type}
61     ${resp}=    Get Valid SubObject URL  ${api_version_base_object_url}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${service_type}
62     [Return]  ${resp}
63
64 Get Nodes Query Service Subscription
65     [Documentation]   Return Nodes query Service Subscription
66     [Arguments]    ${service_type}
67     ${get_resp}=    Confirm Nodes Query SubObjects  ${AAI_SSUBS_API_IMPL_INDEX_PATH}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_UNIQUE_KEY}  ${service_type}
68     [Return]  ${get_resp.json()}
69
70 Get Example Service Subscription
71     [Documentation]   Return Example Service Subscription
72     ${get_resp}=    Confirm Examples Query SubObjects  ${AAI_SSUBS_API_IMPL_INDEX_PATH}  ${AAI_SSUBS_CONTAINER_PATH}
73     [Return]  ${get_resp.json()}
74
75 Confirm No Service Subscription
76     [Documentation]   Confirm No Service Subscription
77     [Arguments]    ${api_version_base_object_url}  ${service_type}
78     ${get_resp}=    Get SubObject  ${api_version_base_object_url}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${AAI_SSUBS_UNIQUE_KEY}  ${service_type}
79     Should Be Equal As Strings  ${get_resp.status_code}     404
80
81 Confirm API Not Implemented Service Subscription
82     [Documentation]   Confirm latest API version where Service Subscription is not implemented
83     [Arguments]    ${service_type}
84     ${resp}=    Confirm API Not Implemented SubObject  ${AAI_SSUBS_API_NA_INDEX_PATH}${AAI_BUSINESS_PATH}  ${AAI_SSUBS_CONTAINER_PATH}  ${AAI_SSUBS_SUBOBJECT_PATH}  ${service_type}
85
86 Add Service Subscription Relationship
87     [Documentation]    Adds Relationship to existing Service Subscription in AAI
88     [Arguments]    ${api_version_base_object_url}  ${service_type}  ${related_class_name}  ${related_object_url}
89     ${put_resp}=    Add Relationship     ${api_version_base_object_url}${AAI_SSUBS_ROOT_PATH}/${service_type}  ${related_class_name}  ${related_object_url}
90
91 Get Service Subscription RelationshipList
92     [Documentation]   Return relationship-list from Service Subscription
93     [Arguments]    ${api_version_base_object_url}  ${service_type}
94     ${resp}=    Get RelationshipList     ${api_version_base_object_url}${AAI_SSUBS_ROOT_PATH}/${service_type}
95     [Return]  ${resp}
96
97 Get Service Subscription With RelationshipList
98     [Documentation]   Return Service Subscription with relationship-list
99     [Arguments]    ${api_version_base_object_url}  ${service_type}
100     ${resp}=    Get Object With Depth     ${api_version_base_object_url}${AAI_SSUBS_ROOT_PATH}/${service_type}
101     [Return]  ${resp}
102