Merge "AaiController tests"
[vid.git] / vid-app-common / src / test / java / org / onap / vid / controller / AaiControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nokia.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.vid.controller;
23
24 import static org.hamcrest.MatcherAssert.assertThat;
25 import static org.hamcrest.core.Is.is;
26 import static org.mockito.ArgumentMatchers.anyString;
27 import static org.mockito.ArgumentMatchers.eq;
28 import static org.mockito.ArgumentMatchers.isA;
29 import static org.mockito.BDDMockito.given;
30 import static org.mockito.Mockito.mock;
31 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
32 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
33 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
34 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
35
36 import com.fasterxml.jackson.databind.ObjectMapper;
37 import com.google.common.collect.ImmutableList;
38 import com.google.common.collect.ImmutableMap;
39 import com.google.common.collect.ImmutableMultimap;
40 import com.google.common.collect.Lists;
41 import com.google.common.collect.Multimap;
42 import java.util.List;
43 import java.util.Map;
44 import java.util.UUID;
45 import javax.ws.rs.core.Response;
46 import org.junit.Before;
47 import org.junit.Test;
48 import org.junit.runner.RunWith;
49 import org.mockito.Answers;
50 import org.mockito.Mock;
51 import org.mockito.Mockito;
52 import org.mockito.junit.MockitoJUnitRunner;
53 import org.onap.vid.aai.AaiResponse;
54 import org.onap.vid.aai.AaiResponseTranslator;
55 import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigData;
56 import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataError;
57 import org.onap.vid.aai.AaiResponseTranslator.PortMirroringConfigDataOk;
58 import org.onap.vid.aai.model.AaiGetAicZone.AicZones;
59 import org.onap.vid.aai.model.AaiGetAicZone.Zone;
60 import org.onap.vid.aai.model.AaiGetPnfs.Pnf;
61 import org.onap.vid.aai.model.PortDetailsTranslator.PortDetails;
62 import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsError;
63 import org.onap.vid.aai.model.PortDetailsTranslator.PortDetailsOk;
64 import org.onap.vid.aai.util.AAIRestInterface;
65 import org.onap.vid.model.VersionByInvariantIdsRequest;
66 import org.onap.vid.properties.Features;
67 import org.onap.vid.roles.RoleProvider;
68 import org.onap.vid.roles.RoleValidatorByRoles;
69 import org.onap.vid.services.AaiService;
70 import org.onap.vid.utils.SystemPropertiesWrapper;
71 import org.onap.vid.utils.Unchecked;
72 import org.springframework.http.HttpStatus;
73 import org.springframework.http.MediaType;
74 import org.springframework.test.web.servlet.MockMvc;
75 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
76 import org.togglz.core.manager.FeatureManager;
77
78 @RunWith(MockitoJUnitRunner.class)
79 public class AaiControllerTest {
80
81     private static final String ID_1 = "id1";
82     private static final String ID_2 = "id2";
83     private final ObjectMapper objectMapper = new ObjectMapper();
84     @Mock
85     private AaiService aaiService;
86     @Mock(answer = Answers.RETURNS_DEEP_STUBS)
87     private AAIRestInterface aaiRestInterface;
88     @Mock
89     private RoleProvider roleProvider;
90     @Mock
91     private SystemPropertiesWrapper systemPropertiesWrapper;
92     @Mock
93     private FeatureManager featureManager;
94
95     private MockMvc mockMvc;
96     private AaiController aaiController;
97
98     @Before
99     public void setUp() {
100         aaiController = new AaiController(aaiService, aaiRestInterface, roleProvider, systemPropertiesWrapper,
101             featureManager);
102         mockMvc = MockMvcBuilders.standaloneSetup(aaiController).build();
103     }
104
105     @Test
106     public void getAicZoneForPnf_shouldReturnOKResponse() throws Exception {
107         String globalCustomerId = "testCustomerId";
108         String serviceType = "testServiceType";
109         String serviceId = "testServiceId";
110         String expectedResponseBody = "OK_RESPONSE";
111         AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, null, HttpStatus.OK.value());
112         given(aaiService.getAicZoneForPnf(globalCustomerId, serviceType, serviceId)).willReturn(aaiResponse);
113
114         mockMvc.perform(
115             get("/aai_get_aic_zone_for_pnf/{globalCustomerId}/{serviceType}/{serviceId}", globalCustomerId, serviceType,
116                 serviceId)
117                 .contentType(MediaType.APPLICATION_JSON)
118                 .accept(MediaType.APPLICATION_JSON))
119             .andExpect(status().isOk())
120             .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody)));
121     }
122
123     @Test
124     public void getInstanceGroupsByVnfInstanceId_shouldReturnOKResponse() throws Exception {
125         String vnfInstanceId = "testVndInstanceId";
126         String expectedResponseBody = "OK_RESPONSE";
127         AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, null, HttpStatus.OK.value());
128         given(aaiService.getInstanceGroupsByVnfInstanceId(vnfInstanceId)).willReturn(aaiResponse);
129
130         mockMvc.perform(get("/aai_get_instance_groups_by_vnf_instance_id/{vnfInstanceId}", vnfInstanceId)
131             .contentType(MediaType.APPLICATION_JSON)
132             .accept(MediaType.APPLICATION_JSON))
133             .andExpect(status().isOk())
134             .andExpect(content().string(objectMapper.writeValueAsString(expectedResponseBody)));
135     }
136
137     @Test
138     public void doGetServiceInstance_shouldFetchServiceInstance_byServiceInstanceId() throws Exception {
139         String serviceInstanceId = "testServiceInstanceId";
140         String serviceInstanceType = "Service Instance Id";
141         String expectedResponseBody = "OK_RESPONSE";
142         Response response = mock(Response.class);
143         given(response.readEntity(String.class)).willReturn(expectedResponseBody);
144         given(response.getStatus()).willReturn(HttpStatus.OK.value());
145
146         given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI(
147             "search/nodes-query?search-node-type=service-instance&filter=service-instance-id:EQUALS:"
148                 + serviceInstanceId)),
149             eq(false)).getResponse()).willReturn(response);
150
151         mockMvc
152             .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId,
153                 serviceInstanceType)
154                 .contentType(MediaType.APPLICATION_JSON)
155                 .accept(MediaType.APPLICATION_JSON))
156             .andExpect(status().isOk())
157             .andExpect(content().string(expectedResponseBody));
158     }
159
160     @Test
161     public void doGetServiceInstance_shouldFetchServiceInstance_byServiceInstanceName() throws Exception {
162         String serviceInstanceId = "testServiceInstanceId";
163         String serviceInstanceType = "testServiceInstanceType";
164         String expectedResponseBody = "OK_RESPONSE";
165         Response response = mock(Response.class);
166         given(response.readEntity(String.class)).willReturn(expectedResponseBody);
167         given(response.getStatus()).willReturn(HttpStatus.OK.value());
168
169         given(aaiRestInterface.RestGet(eq("VidAaiController"), anyString(), eq(Unchecked.toURI(
170             "search/nodes-query?search-node-type=service-instance&filter=service-instance-name:EQUALS:"
171                 + serviceInstanceId)),
172             eq(false)).getResponse()).willReturn(response);
173
174         mockMvc
175             .perform(get("/aai_get_service_instance/{service-instance-id}/{service-instance-type}", serviceInstanceId,
176                 serviceInstanceType)
177                 .contentType(MediaType.APPLICATION_JSON)
178                 .accept(MediaType.APPLICATION_JSON))
179             .andExpect(status().isOk())
180             .andExpect(content().string(expectedResponseBody));
181     }
182
183     @Test
184     public void doGetServices_shouldReturnOkResponse() throws Exception {
185         String globalCustomerId = "testGlobalCustomerId";
186         String serviceSubscriptionId = "testServiceSubscriptionId";
187         String expectedResponseBody = "OK_RESPONSE";
188         Response response = mock(Response.class);
189         given(response.readEntity(String.class)).willReturn(expectedResponseBody);
190         given(response.getStatus()).willReturn(HttpStatus.OK.value());
191
192         given(aaiRestInterface.RestGet(
193             eq("VidAaiController"),
194             anyString(),
195             eq(Unchecked.toURI(
196                 "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
197                     + serviceSubscriptionId + "?depth=0")),
198             eq(false)).getResponse()).willReturn(response);
199
200         mockMvc
201             .perform(
202                 get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId,
203                     serviceSubscriptionId)
204                     .contentType(MediaType.APPLICATION_JSON)
205                     .accept(MediaType.APPLICATION_JSON))
206             .andExpect(status().isOk())
207             .andExpect(content().string(expectedResponseBody));
208     }
209
210     @Test
211     public void doGetServices_shouldReturnInternalServerError_forEmptyResponse() throws Exception {
212         String globalCustomerId = "testGlobalCustomerId";
213         String serviceSubscriptionId = "testServiceSubscriptionId";
214         String expectedResponseBody = "Failed to fetch data from A&AI, check server logs for details.";
215         given(aaiRestInterface.RestGet(
216             eq("VidAaiController"),
217             anyString(),
218             eq(Unchecked.toURI(
219                 "business/customers/customer/" + globalCustomerId + "/service-subscriptions/service-subscription/"
220                     + serviceSubscriptionId + "?depth=0")),
221             eq(false)).getResponse()).willReturn(null);
222
223         mockMvc
224             .perform(
225                 get("/aai_get_service_subscription/{global-customer-id}/{service-subscription-id}", globalCustomerId,
226                     serviceSubscriptionId)
227                     .contentType(MediaType.APPLICATION_JSON)
228                     .accept(MediaType.APPLICATION_JSON))
229             .andExpect(status().isInternalServerError())
230             .andExpect(content().string(expectedResponseBody));
231     }
232
233     @Test
234     public void getPortMirroringConfigData_givenIds_shouldReturnConfigDataMappedById() throws Exception {
235         PortMirroringConfigDataOk okConfigData = new PortMirroringConfigDataOk("foo");
236         PortMirroringConfigDataError errorConfigData = new PortMirroringConfigDataError("bar", "{ baz: qux }");
237         Map<String, PortMirroringConfigData> expectedJson = ImmutableMap.of(
238             ID_1, okConfigData,
239             ID_2, errorConfigData);
240         given(aaiService.getPortMirroringConfigData(ID_1)).willReturn(okConfigData);
241         given(aaiService.getPortMirroringConfigData(ID_2)).willReturn(errorConfigData);
242
243         mockMvc
244             .perform(get("/aai_getPortMirroringConfigsData")
245                 .param("configurationIds", ID_1, ID_2)
246                 .contentType(MediaType.APPLICATION_JSON)
247                 .accept(MediaType.APPLICATION_JSON))
248             .andExpect(status().isOk())
249             .andExpect(content().json(objectMapper.writeValueAsString(expectedJson)));
250     }
251
252     @Test
253     public void getPortMirroringSourcePorts_givenIds_shouldReturnPortDetailsMappedById() throws Exception {
254         PortDetailsOk portDetailsOk = new PortDetailsOk("foo", "testInterface", true);
255         PortDetailsError portDetailsError = new PortDetailsError("bar", "{ baz: qux }");
256         Multimap<String, PortDetails> expectedJson = ImmutableMultimap.of(
257             ID_1, portDetailsOk,
258             ID_2, portDetailsError);
259         given(aaiService.getPortMirroringSourcePorts(ID_1)).willReturn(Lists.newArrayList(portDetailsOk));
260         given(aaiService.getPortMirroringSourcePorts(ID_2)).willReturn(Lists.newArrayList(portDetailsError));
261
262         mockMvc
263             .perform(get("/aai_getPortMirroringSourcePorts")
264                 .param("configurationIds", ID_1, ID_2)
265                 .contentType(MediaType.APPLICATION_JSON)
266                 .accept(MediaType.APPLICATION_JSON))
267             .andExpect(status().isOk())
268             .andExpect(content().json(objectMapper.writeValueAsString(expectedJson.asMap())));
269     }
270
271     @Test
272     public void getNodeTemplateInstances_givenParams_shouldReturnCorrectResponse() throws Exception {
273         String globalCustomerId = "testCustomerId";
274         String serviceType = "testServiceType";
275         String modelVersionId = UUID.nameUUIDFromBytes("modelVersionId".getBytes()).toString();
276         String modelInvariantId = UUID.nameUUIDFromBytes("modelInvariantId".getBytes()).toString();
277         String cloudRegion = "testRegion";
278         String urlTemplate = "/aai_get_vnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}";
279         String expectedResponseBody = "myResponse";
280         AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value());
281         given(aaiService
282             .getNodeTemplateInstances(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion))
283             .willReturn(aaiResponse);
284
285         mockMvc
286             .perform(get(urlTemplate, globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion)
287                 .contentType(MediaType.APPLICATION_JSON)
288                 .accept(MediaType.APPLICATION_JSON))
289             .andExpect(status().isOk())
290             .andExpect(content().string(expectedResponseBody));
291     }
292
293     @Test
294     public void getAicZones_shouldReturnAaiZones_whenAaiHttpStatusIsOK() throws Exception {
295         AicZones aicZones = new AicZones(ImmutableList.of(new Zone("TEST_ZONE_ID", "TEST_ZONE_NAME")));
296         given(aaiService.getAaiZones()).willReturn(new AaiResponse(aicZones, "", HttpStatus.OK.value()));
297
298         mockMvc.perform(get("/aai_get_aic_zones")
299             .contentType(MediaType.APPLICATION_JSON)
300             .accept(MediaType.APPLICATION_JSON))
301             .andExpect(status().isOk())
302             .andExpect(content().json(objectMapper.writeValueAsString(aicZones)));
303     }
304
305     @Test
306     public void getAicZones_shouldReturnErrorResponse_whenAaiHttpStatusOtherThanOK() throws Exception {
307         String expectedErrorMessage = "Calling AAI Failed";
308         given(aaiService.getAaiZones())
309             .willReturn(new AaiResponse(null, expectedErrorMessage, HttpStatus.INTERNAL_SERVER_ERROR.value()));
310
311         mockMvc.perform(get("/aai_get_aic_zones")
312             .contentType(MediaType.APPLICATION_JSON)
313             .accept(MediaType.APPLICATION_JSON))
314             .andExpect(status().isInternalServerError())
315             .andExpect(content().string(expectedErrorMessage));
316     }
317
318     @Test
319     public void getSpecificPnf_shouldReturnPnfObjectForPnfId() throws Exception {
320         String pnfId = "MyPnfId";
321         Pnf pnf = Pnf.builder()
322             .withPnfId(pnfId)
323             .withPnfName("TestPnf")
324             .withPnfName2("pnfName2")
325             .withPnfName2Source("pnfNameSource")
326             .withEquipModel("model")
327             .withEquipType("type")
328             .withEquipVendor("vendor")
329             .build();
330         AaiResponse<Pnf> aaiResponse = new AaiResponse<>(pnf, "", HttpStatus.OK.value());
331         given(aaiService.getSpecificPnf(pnfId)).willReturn(aaiResponse);
332
333         mockMvc.perform(get("/aai_get_pnfs/pnf/{pnf_id}", pnfId)
334             .contentType(MediaType.APPLICATION_JSON)
335             .accept(MediaType.APPLICATION_JSON))
336             .andExpect(status().isOk())
337             .andExpect(content().json(objectMapper.writeValueAsString(pnf)));
338     }
339
340     @Test
341     public void getSpecificPnf_shouldHandleAAIServiceException() throws Exception {
342         String pnfId = "MyPnfId";
343         String expectedErrorMessage = "AAI Service Error";
344         given(aaiService.getSpecificPnf(pnfId)).willThrow(new RuntimeException(expectedErrorMessage));
345
346         mockMvc.perform(get("/aai_get_pnfs/pnf/{pnf_id}", pnfId)
347             .contentType(MediaType.APPLICATION_JSON)
348             .accept(MediaType.APPLICATION_JSON))
349             .andExpect(status().isInternalServerError())
350             .andExpect(content().string(expectedErrorMessage));
351     }
352
353     public void getPNFInstances_shouldReturnOKResponseFromAAIService() throws Exception {
354         String globalCustomerId = "testCustomerId";
355         String serviceType = "testServiceType";
356         String modelVersionId = UUID.nameUUIDFromBytes("modelVersionId".getBytes()).toString();
357         String modelInvariantId = UUID.nameUUIDFromBytes("modelInvariantId".getBytes()).toString();
358         String cloudRegion = "testRegion";
359         String equipVendor = "testVendor";
360         String equipModel = "model123";
361         String urlTemplate = "/aai_get_pnf_instances/{globalCustomerId}/{serviceType}/{modelVersionId}/{modelInvariantId}/{cloudRegion}/{equipVendor}/{equipModel}";
362         String expectedResponseBody = "myResponse";
363         AaiResponse<String> aaiResponse = new AaiResponse<>(expectedResponseBody, "", HttpStatus.OK.value());
364
365         given(aaiService
366             .getPNFData(globalCustomerId, serviceType, modelVersionId, modelInvariantId, cloudRegion, equipVendor,
367                 equipModel)).willReturn(aaiResponse);
368
369         mockMvc.perform(
370             get(urlTemplate, globalCustomerId, serviceType, modelVersionId,
371                 modelInvariantId, cloudRegion, equipVendor, equipModel)
372                 .contentType(MediaType.APPLICATION_JSON)
373                 .accept(MediaType.APPLICATION_JSON))
374             .andExpect(status().isOk())
375             .andExpect(content().string(expectedResponseBody));
376     }
377
378     @Test
379     public void getVersionByInvariantId_shouldReturnOKResponse() throws Exception {
380         String expectedResponse = "OKResponse";
381         VersionByInvariantIdsRequest request = new VersionByInvariantIdsRequest();
382         request.versions = ImmutableList.of("ver1", "ver2");
383         Response response = mock(Response.class);
384         given(response.readEntity(String.class)).willReturn(expectedResponse);
385         given(aaiService
386             .getVersionByInvariantId(request.versions)).willReturn(response);
387
388         mockMvc.perform(
389             post("/aai_get_version_by_invariant_id")
390                 .content(objectMapper.writeValueAsString(request))
391                 .contentType(MediaType.APPLICATION_JSON)
392                 .accept(MediaType.APPLICATION_JSON))
393             .andExpect(status().isOk())
394             .andExpect(content().string(expectedResponse));
395     }
396
397     @Test
398     public void getSubscriberDetails_shouldOmitServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsTrue()
399         throws Exception {
400         boolean isFeatureActive = true;
401         boolean omitServiceInstances = true;
402
403         String subscriberId = "subscriberId";
404         String okResponseBody = "OK_RESPONSE";
405         AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value());
406         given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive);
407         given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class),
408             eq(isFeatureActive && omitServiceInstances)))
409             .willReturn(aaiResponse);
410
411         mockMvc.perform(
412             get("/aai_sub_details/{subscriberId}", subscriberId)
413                 .param("omitServiceInstances", Boolean.toString(omitServiceInstances))
414                 .contentType(MediaType.APPLICATION_JSON)
415                 .accept(MediaType.APPLICATION_JSON))
416             .andExpect(status().isOk())
417             .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody)));
418     }
419
420     @Test
421     public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureEnabled_andOmitFlagIsFalse()
422         throws Exception {
423         boolean isFeatureActive = true;
424         boolean omitServiceInstances = false;
425
426         getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances);
427     }
428
429     @Test
430     public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsTrue()
431         throws Exception {
432         boolean isFeatureActive = false;
433         boolean omitServiceInstances = true;
434
435         getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances);
436     }
437
438     @Test
439     public void getPortMirroringConfigData_givenThreeIds_ReturnsThreeResults() {
440
441         final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForA = new AaiResponseTranslator.PortMirroringConfigDataOk(
442             "foobar");
443         final AaiResponseTranslator.PortMirroringConfigDataError toBeReturnedForB = new AaiResponseTranslator.PortMirroringConfigDataError(
444             "foo", "{ baz: qux }");
445         final AaiResponseTranslator.PortMirroringConfigDataOk toBeReturnedForC = new AaiResponseTranslator.PortMirroringConfigDataOk(
446             "corge");
447
448         Mockito
449             .doReturn(toBeReturnedForA)
450             .doReturn(toBeReturnedForB)
451             .doReturn(toBeReturnedForC)
452             .when(aaiService).getPortMirroringConfigData(Mockito.anyString());
453
454         final Map<String, AaiResponseTranslator.PortMirroringConfigData> result = aaiController
455             .getPortMirroringConfigsData(ImmutableList.of("a", "b", "c"));
456
457         assertThat(result, is(ImmutableMap.of(
458             "a", toBeReturnedForA,
459             "b", toBeReturnedForB,
460             "c", toBeReturnedForC
461         )));
462     }
463
464     @Test
465     public void getSubscriberDetails_shouldIncludeServiceInstancesFromSubscriberData_whenFeatureDisabled_andOmitFlagIsFalse()
466         throws Exception {
467         boolean isFeatureActive = false;
468         boolean omitServiceInstances = false;
469         getSubscriberDetails_assertServiceInstancesInclusion(isFeatureActive, omitServiceInstances);
470     }
471
472     private void getSubscriberDetails_assertServiceInstancesInclusion(boolean isFeatureActive,
473         boolean omitServiceInstances) throws Exception {
474         String subscriberId = "subscriberId";
475         String okResponseBody = "OK_RESPONSE";
476         AaiResponse<String> aaiResponse = new AaiResponse<>(okResponseBody, "", HttpStatus.OK.value());
477         given(featureManager.isActive(Features.FLAG_1906_AAI_SUB_DETAILS_REDUCE_DEPTH)).willReturn(isFeatureActive);
478         given(aaiService.getSubscriberData(eq(subscriberId), isA(RoleValidatorByRoles.class),
479             eq(isFeatureActive && omitServiceInstances)))
480             .willReturn(aaiResponse);
481
482         mockMvc.perform(
483             get("/aai_sub_details/{subscriberId}", subscriberId)
484                 .param("omitServiceInstances", Boolean.toString(omitServiceInstances))
485                 .contentType(MediaType.APPLICATION_JSON)
486                 .accept(MediaType.APPLICATION_JSON))
487             .andExpect(status().isOk())
488             .andExpect(content().string(objectMapper.writeValueAsString(okResponseBody)));
489     }
490
491     @Test
492     public void getSpecificConfiguration_shouldReturnOkResponse() throws Exception {
493         String configurationId = "testGlobalCustomerId";
494         String expectedResponseBody = "OK_RESPONSE";
495         Response response = mock(Response.class);
496         given(response.readEntity(String.class)).willReturn(expectedResponseBody);
497         given(response.getStatus()).willReturn(HttpStatus.OK.value());
498
499         given(aaiRestInterface.RestGet(
500             eq("VidAaiController"),
501             anyString(),
502             eq(Unchecked.toURI("network/configurations/configuration/" + configurationId)),
503             eq(false)).getResponse()).willReturn(response);
504
505         mockMvc
506             .perform(
507                 get("/aai_get_configuration/{configuration_id}", configurationId)
508                     .contentType(MediaType.APPLICATION_JSON)
509                     .accept(MediaType.APPLICATION_JSON))
510             .andExpect(status().isOk())
511             .andExpect(content().string(expectedResponseBody));
512     }
513
514     @Test
515     public void getServiceInstanceAssociatedPnfs_shouldReturnPnfs() throws Exception {
516         String globalCustomerId = "testCustomerId";
517         String serviceType = "testServiceType";
518         String serviceInstanceId = "testServiceInstanceId";
519         List<String> expectedPnfs = ImmutableList.of("pnf1", "pnf2", "pnf3");
520
521         given(aaiService.getServiceInstanceAssociatedPnfs(globalCustomerId, serviceType, serviceInstanceId))
522             .willReturn(expectedPnfs);
523
524         mockMvc
525             .perform(
526                 get("/aai_get_service_instance_pnfs/{globalCustomerId}/{serviceType}/{serviceInstanceId}",
527                     globalCustomerId, serviceType, serviceInstanceId)
528                     .contentType(MediaType.APPLICATION_JSON)
529                     .accept(MediaType.APPLICATION_JSON))
530             .andExpect(status().isOk())
531             .andExpect(content().json(objectMapper.writeValueAsString(expectedPnfs)));
532     }
533
534 }
535