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