Merge "e2e test for instantiation template"
[vid.git] / vid-webpack-master / cypress / support / jsonBuilders / mocks / aai.mock.ts
1 declare namespace Cypress {
2   interface Chainable {
3     initAAIMock: typeof initAAIMock;
4     initAlaCarteService : typeof initAlaCarteService;
5     initZones : typeof initZones;
6     initTenants : typeof initTenants;
7     initSearchVNFMemebers : typeof  initSearchVNFMemebers;
8     initActiveNetworks : typeof  initActiveNetworks;
9     initActiveVPNs : typeof  initActiveVPNs;
10     initGetAAISubDetails : typeof  initGetAAISubDetails;
11     initAAIServices: typeof initAAIServices;
12     initGetModelByServiceType: typeof initGetModelByServiceType;
13   }
14 }
15
16 function initGetSubscribers(response? : JSON) : void {
17   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/subscribers.json').then((res) => {
18     cy.server()
19       .route({
20         method: 'GET',
21         status : 200,
22         url : Cypress.config('baseUrl') + "/aai_get_subscribers**",
23         response : response ? response : res
24       }).as('initGetSubscribers')
25   });
26 }
27
28 function initAaiGetFullSubscribers(response? : JSON) : void {
29   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/subscribers.json').then((res) => {
30     cy.server()
31       .route({
32         method: 'GET',
33         status : 200,
34         url : Cypress.config('baseUrl') + "/aai_get_full_subscribers**",
35         response : response ? response : res
36       }).as('initGetSubscribers')
37   });
38 }
39
40 function initGetAAISubDetails(response? : JSON) : void {
41   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiSubDetails.json').then((res) => {
42     cy.server()
43       .route({
44         method: 'GET',
45         status: 200,
46         url: Cypress.config('baseUrl') + "/aai_sub_details/**",
47         response: response ? response : res
48       }).as('aai-sub-details')
49   });
50 }
51
52 function initGetModelByServiceType(response? : JSON) : void {
53   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiSubDetails.json').then((res) => {
54     cy.server()
55       .route({
56         method: 'GET',
57         status: 200,
58         url: Cypress.config('baseUrl') + "/aai_get_models_by_service_type/**",
59         response: response ? response : res
60       }).as('aai-sub-details')
61   });
62 }
63
64
65 function initAlaCarteService(response? : JSON) : void {
66   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/a-la-carteService.json').then((res) => {
67     cy.server()
68       .route({
69         method: 'GET',
70         status: 200,
71         url: Cypress.config('baseUrl') + "/rest/models/services**",
72         response: response ? response : res
73       }).as('initAlaCarteService')
74   });
75 }
76
77
78
79
80
81 function initTenants(response? : JSON) : void {
82   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/tenants.json').then((res) => {
83     cy.server()
84       .route({
85         method: 'GET',
86         status: 200,
87         url: Cypress.config('baseUrl') + "/aai_get_tenants/**",
88         response: response ? response : res
89       }).as('initTenants')
90   });
91 }
92
93 function initAAIServices(response? : JSON) : void {
94   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiServices.json').then((res) => {
95     cy.server()
96       .route({
97         method: 'GET',
98         status : 200,
99         url : Cypress.config('baseUrl') + "/aai_get_services**",
100         response : response ? response : res
101       }).as(('initAAIServices'));
102   });
103 }
104
105 function initZones(response? : JSON) : void {
106   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/zones.json').then((res) => {
107     cy.server()
108       .route({
109         method: 'GET',
110         status : 200,
111         url : Cypress.config('baseUrl') + "/aai_get_aic_zones**",
112         response : response ? response : res
113       }).as(('zones'));
114   });
115 }
116
117 //Mock of vnf's that members for VNF Group
118 function initSearchVNFMemebers(response? : JSON) : void {
119   cy.readFile('../vid-automation/src/test/resources/VnfGroup/searchMembersResponse.json').then((res) => {
120     cy.server()
121       .route({
122         method: 'GET',
123         status : 200,
124         url : Cypress.config('baseUrl') + "/aai_search_group_members/**",
125         response : response ? response : res
126       }).as(('searchVNFMembers'));
127   });
128 }
129
130 function initActiveNetworks(response? : JSON) : void {
131   cy.readFile('../vid-automation/src/test/resources/viewEdit/aaiGetActiveNetworks.json').then((res) => {
132     cy.server()
133       .route({
134         method: 'GET',
135         status : 200,
136         url : Cypress.config('baseUrl') + "/aai_get_active_networks/**",
137         response : response ? response : res
138       }).as(('getActiveNetworks'));
139   });
140 }
141
142 function initActiveVPNs(response? : JSON) : void {
143   cy.readFile('cypress/support/jsonBuilders/mocks/jsons/aaiActiveVPNs.json').then((res) => {
144     cy.server()
145       .route({
146         method: 'GET',
147         status : 200,
148         url : Cypress.config('baseUrl') + "/aai_get_vpn_list/**",
149         response : response ? response : res
150       }).as(('getVPNs'));
151   });
152 }
153
154 function initAAIMock(): void {
155   initAaiGetFullSubscribers();
156   initGetSubscribers();
157   initAAIServices();
158   initTenants();
159
160 }
161
162
163 Cypress.Commands.add('initAAIMock', initAAIMock);
164 Cypress.Commands.add('initAlaCarteService', initAlaCarteService);
165 Cypress.Commands.add('initZones', initZones);
166 Cypress.Commands.add('initTenants', initTenants);
167 Cypress.Commands.add('initAaiGetFullSubscribers', initAaiGetFullSubscribers);
168 Cypress.Commands.add('initGetAAISubDetails', initGetAAISubDetails);
169 Cypress.Commands.add('initSearchVNFMemebers', initSearchVNFMemebers);
170 Cypress.Commands.add('initActiveNetworks', initActiveNetworks);
171 Cypress.Commands.add('initActiveVPNs', initActiveVPNs);
172 Cypress.Commands.add('initAAIServices', initAAIServices);
173 Cypress.Commands.add('initGetModelByServiceType', initGetModelByServiceType);
174
175
176