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