2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.services;
23 import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
24 import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
25 import static org.hamcrest.MatcherAssert.assertThat;
26 import static org.junit.Assert.assertEquals;
27 import static org.mockito.ArgumentMatchers.any;
28 import static org.mockito.Mockito.mock;
29 import static org.mockito.Mockito.when;
30 import static org.testng.Assert.assertNull;
32 import com.fasterxml.jackson.databind.JsonNode;
33 import com.fasterxml.jackson.databind.ObjectMapper;
34 import com.google.common.collect.ImmutableList;
35 import com.google.common.collect.ImmutableMap;
36 import java.io.IOException;
38 import java.util.Arrays;
39 import java.util.List;
40 import java.util.concurrent.ExecutorService;
41 import java.util.concurrent.Executors;
42 import javax.ws.rs.core.Response;
43 import org.mockito.Mock;
44 import org.onap.vid.aai.AaiClientInterface;
45 import org.onap.vid.aai.ExceptionWithRequestInfo;
46 import org.onap.vid.aai.util.AAITreeConverter;
47 import org.onap.vid.asdc.AsdcCatalogException;
48 import org.onap.vid.asdc.parser.ServiceModelInflator;
49 import org.onap.vid.exceptions.GenericUncheckedException;
50 import org.onap.vid.model.Action;
51 import org.onap.vid.model.ServiceModel;
52 import org.onap.vid.model.aaiTree.AAITreeNode;
53 import org.onap.vid.model.aaiTree.FailureAAITreeNode;
54 import org.onap.vid.model.aaiTree.ServiceInstance;
55 import org.onap.vid.model.aaiTree.Vnf;
56 import org.onap.vid.testUtils.TestUtils;
57 import org.springframework.http.HttpMethod;
58 import org.testng.annotations.BeforeMethod;
59 import org.testng.annotations.Test;
61 public class AAIServiceTreeIntegrativeTest {
64 private AaiClientInterface aaiClient;
67 private Response aaiGetVersionByInvariantIdResponse;
70 ExceptionWithRequestInfo exceptionWithRequestInfo;
73 VidService sdcService;
76 ServiceModelInflator serviceModelInflator;
78 private AAITreeNodeBuilder aaiTreeNodeBuilder;
80 private AAITreeConverter aaiTreeConverter = new AAITreeConverter();
82 private ExecutorService executorService = Executors.newFixedThreadPool(10);
84 private final ObjectMapper mapper = new ObjectMapper();
86 private String globalCustomerID = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
87 private String serviceType = "vWINIFRED";
88 private String serviceInstanceId = "62888f15-6d24-4f7b-92a7-c3f35beeb215";
90 //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
91 private String serviceInstanceRequestUri = "business/customers/customer/" +
93 "/service-subscriptions/service-subscription/" +
95 "/service-instances/service-instance/" +
98 private static String ServiceInstanceResponseString = "{\"service-instance-id\":\"62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
99 "\"service-instance-name\": \"Dror123\"," +
100 "\"environment-context\": \"null\"," +
101 "\"workload-context\": \"null\"," +
102 "\"model-invariant-id\": \"35340388-0b82-4d3a-823d-cbddf842be52\"," +
103 "\"model-version-id\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"," +
104 "\"resource-version\": \"1515515088894\"," +
105 "\"orchestration-status\": \"Active\"," +
106 "\"relationship-list\": {" +
107 "\"relationship\": [{" +
108 "\"related-to\": \"project\"," +
109 "\"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
110 "\"related-link\": \"/aai/v12/business/projects/project/DFW\"," +
111 "\"relationship-data\": [{" +
112 "\"relationship-key\": \"project.project-name\"," +
113 "\"relationship-value\": \"WATKINS\"}]},{" +
114 "\"related-to\": \"generic-vnf\"," +
115 "\"relationship-label\": \"org.onap.relationships.inventory.ComposedOf\"," +
116 "\"related-link\": \"/aai/v12/network/generic-vnfs/generic-vnf/59bde732-9b84-46bd-a59a-3c45fee0538b\"," +
117 "\"relationship-data\": [{" +
118 "\"relationship-key\": \"generic-vnf.vnf-id\"," +
119 "\"relationship-value\": \"59bde732-9b84-46bd-a59a-3c45fee0538b\"}]," +
120 "\"related-to-property\": [{" +
121 "\"property-key\": \"generic-vnf.vnf-name\"," +
122 "\"property-value\": \"DROR_vsp\"}]},{" +
123 "\"related-to\": \"owning-entity\"," +
124 "\"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," +
125 "\"related-link\": \"/aai/v12/business/owning-entities/owning-entity/43b8a85a-0421-4265-9069-117dd6526b8a\"," +
126 "\"relationship-data\": [{" +
127 "\"relationship-key\": \"owning-entity.owning-entity-id\"," +
128 "\"relationship-value\": \"43b8a85a-0421-4265-9069-117dd6526b8a\"}]}]}}";
130 //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
131 private static String genericVnfRequestUri = "/aai/v12/network/generic-vnfs/generic-vnf/59bde732-9b84-46bd-a59a-3c45fee0538b";
133 private String genericVnfResponseString(boolean isDuplicatedKeysInTenantRelation) {
136 "{\"nf-role\":\"\"," +
137 "\"service-id\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," +
138 "\"relationship-list\":{" +
139 "\"relationship\":[{" +
140 "\"related-to\":\"service-instance\"," +
141 "\"relationship-data\":[{" +
142 "\"relationship-value\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," +
143 "\"relationship-key\":\"customer.global-customer-id\"},{" +
144 "\"relationship-value\":\"vWINIFRED\"," +
145 "\"relationship-key\":\"service-subscription.service-type\"},{" +
146 "\"relationship-value\":\"62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
147 "\"relationship-key\":\"service-instance.service-instance-id\"}]," +
148 "\"related-link\":\"/aai/v12/business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/vWINIFRED/service-instances/service-instance/62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
149 "\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\"," +
150 "\"related-to-property\":[{" +
151 "\"property-key\":\"service-instance.service-instance-name\"," +
152 "\"property-value\":\"Dror123\"}]},{" +
153 "\"related-to\":\"platform\"," +
154 "\"relationship-data\":[{" +
155 "\"relationship-value\":\"platformY\"," +
156 "\"relationship-key\":\"platform.platform-name\"}]," +
157 "\"related-link\":\"/aai/v12/business/platforms/platform/platformY\"," +
158 "\"relationship-label\":\"org.onap.relationships.inventory.Uses\"},{" +
159 "\"related-to\":\"line-of-business\"," +
160 "\"relationship-data\":[{" +
161 "\"relationship-value\":\"lob1, lobX\"," +
162 "\"relationship-key\":\"line-of-business.line-of-business-name\"}]," +
163 "\"related-link\":\"/aai/v12/business/lines-of-business/line-of-business/lob1%2C%20lobX\"," +
164 "\"relationship-label\":\"org.onap.relationships.inventory.Uses\"}," +
166 " \"related-to\": \"tenant\"," +
167 " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
168 " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region\"," +
169 " \"relationship-data\": [" +
171 " \"relationship-key\": \"cloud-region.cloud-owner\"," +
172 " \"relationship-value\": \"irma-aic\"" +
175 " \"relationship-key\": \"cloud-region.cloud-region-id\"," +
176 " \"relationship-value\": \"aCloudRegionId\"" +
179 " \"relationship-key\": \"tenant.tenant-id\"," +
180 " \"relationship-value\": \"someTenantId123\"" +
182 (isDuplicatedKeysInTenantRelation ? "{\"relationship-key\": \"tenant.tenant-id\", \"relationship-value\": \"someTenantId456\"}, " : "" ) +
184 " \"relationship-key\": \"vserver.vserver-id\"," +
185 " \"relationship-value\": \"5eef9f6d-9933-4bc6-9a1a-862d61309437\"" +
188 " \"related-to-property\": [" +
190 " \"property-key\": \"vserver.vserver-name\"," +
191 " \"property-value\": \"zolson5bfapn01dns002\"" +
196 "\"vnf-id\":\"59bde732-9b84-46bd-a59a-3c45fee0538b\",\n" +
197 "\"nf-type\":\"\"," +
198 "\"prov-status\":\"PREPROV\"," +
199 "\"vnf-type\":\"Lital--1707097/Lital-VSP-1707097 0\"," +
200 "\"orchestration-status\":\"Created\"," +
201 "\"nf-naming-code\":\"\"," +
202 "\"in-maint\":true," +
203 "\"nf-function\":\"\"," +
204 "\"model-version-id\":\"11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0\"," +
205 "\"resource-version\":\"1522431420767\"," +
206 "\"model-customization-id\":\"14992bf5-d585-4b54-8101-7cf76774337a\"," +
207 "\"model-invariant-id\":\"55628ce3-ed56-40bd-9b27-072698ce02a9\"," +
208 "\"vnf-name\":\"DROR_vsp\"," +
209 "\"is-closed-loop-disabled\":true}";
212 private List<String> invariantIDs = Arrays.asList("35340388-0b82-4d3a-823d-cbddf842be52",
213 "55628ce3-ed56-40bd-9b27-072698ce02a9");
215 private static String getVersionByInvariantIdResponseString = "{" +
217 "\"model-invariant-id\": \"55628ce3-ed56-40bd-9b27-072698ce02a9\"," +
218 "\"model-type\": \"resource\"," +
219 "\"resource-version\": \"1499690926297\"," +
220 "\"model-vers\": {" +
221 "\"model-ver\": [{" +
222 "\"model-version-id\": \"11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0\"," +
223 "\"model-name\": \"Lital-VSP-1707097\"," +
224 "\"model-version\": \"2.0\",\n" +
225 "\"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\"," +
226 "\"model-description\": \"Lital-VSP-1707097-NEW\"," +
227 "\"resource-version\": \"1499690926298\"," +
228 "\"model-elements\": {" +
229 "\"model-element\": [{" +
230 "\"model-element-uuid\": \"a4f14ef7-daa2-4257-9b81-b4558dc4beaa\"," +
231 "\"new-data-del-flag\": \"T\"," +
232 "\"cardinality\": \"unbounded\"," +
233 "\"resource-version\": \"1499690926300\"," +
234 "\"relationship-list\": {" +
235 "\"relationship\": [{" +
236 "\"related-to\": \"model-ver\"," +
237 "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
238 "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," +
239 "\"relationship-data\": [{" +
240 "\"relationship-key\": \"model.model-invariant-id\"," +
241 "\"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"},{" +
242 "\"relationship-key\": \"model-ver.model-version-id\"," +
243 "\"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"}]," +
244 "\"related-to-property\": [{" +
245 "\"property-key\": \"model-ver.model-name\"," +
246 "\"property-value\": \"generic-vnf\"}]}]}}]}," +
247 "\"relationship-list\": {" +
248 "\"relationship\": [{" +
249 "\"related-to\": \"model-element\"," +
250 "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
251 "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/35340388-0b82-4d3a-823d-cbddf842be52/model-vers/model-ver/4e799efd-fd78-444d-bc25-4a3cde2f8cb0/model-elements/model-element/344e8713-f0af-423a-b96d-f45b3a479d11/model-elements/model-element/9e8c8885-601a-4fd6-8424-c233a5333db6\"," +
252 "\"relationship-data\": [{" +
253 "\"relationship-key\": \"model.model-invariant-id\"," +
254 "\"relationship-value\": \"35340388-0b82-4d3a-823d-cbddf842be52\"},{" +
255 "\"relationship-key\": \"model-ver.model-version-id\"," +
256 "\"relationship-value\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"},{" +
257 "\"relationship-key\": \"model-element.model-element-uuid\"," +
258 "\"relationship-value\": \"344e8713-f0af-423a-b96d-f45b3a479d11\"},{" +
259 "\"relationship-key\": \"model-element.model-element-uuid\"," +
260 "\"relationship-value\": \"9e8c8885-601a-4fd6-8424-c233a5333db6\"}]}]}}]}},{" +
261 "\"model-invariant-id\": \"35340388-0b82-4d3a-823d-cbddf842be52\"," +
262 "\"model-type\": \"service\"," +
263 "\"resource-version\": \"1499690928188\"," +
264 "\"model-vers\": {" +
265 "\"model-ver\": [{" +
266 "\"model-version-id\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"," +
267 "\"model-name\": \"Lital--1707097\"," +
268 "\"model-version\": \"1.0\"," +
269 "\"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\"," +
270 "\"model-description\": \"Lital--1707097\"," +
271 "\"resource-version\": \"1499690928190\"," +
272 "\"model-elements\": {" +
273 "\"model-element\": [{" +
274 "\"model-element-uuid\": \"344e8713-f0af-423a-b96d-f45b3a479d11\"," +
275 "\"new-data-del-flag\": \"T\"," +
276 "\"cardinality\": \"unbounded\"," +
277 "\"resource-version\": \"1499690928191\"," +
278 "\"relationship-list\": {" +
279 "\"relationship\": [{" +
280 "\"related-to\": \"model-ver\"," +
281 "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
282 "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9\"," +
283 "\"relationship-data\": [{" +
284 "\"relationship-key\": \"model.model-invariant-id\"," +
285 "\"relationship-value\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\"},{" +
286 "\"relationship-key\": \"model-ver.model-version-id\"," +
287 "\"relationship-value\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"}]," +
288 "\"related-to-property\": [{" +
289 "\"property-key\": \"model-ver.model-name\"," +
290 "\"property-value\": \"service-instance\"}]}]}}]}}]}}]}";
293 public void initMocks() {
294 TestUtils.initMockitoMocks(this);
295 aaiTreeNodeBuilder = new AAITreeNodeBuilder(aaiClient);
298 public void getServiceInstanceTreeAndAssert(boolean isDuplicatedKeysInTenantRelation) throws IOException, AsdcCatalogException {
299 when(aaiClient.typedAaiRest(URI.create(serviceInstanceRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(mapper.readTree(ServiceInstanceResponseString));
300 when(aaiClient.typedAaiRest(URI.create(genericVnfRequestUri), JsonNode.class, null, HttpMethod.GET, false)).
301 thenReturn(mapper.readTree(genericVnfResponseString(isDuplicatedKeysInTenantRelation)));
302 when(aaiClient.getVersionByInvariantId(invariantIDs)).thenReturn(aaiGetVersionByInvariantIdResponse);
304 when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
306 when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
307 when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of(
308 "11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", new ServiceModelInflator.Names("vnf-model-customization-name", "vnf-key-in-model")
311 ServiceInstance root = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
312 .getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
314 assertServiceNode(root, 1);
316 assertEquals(0, root.getExistingNetworksCounterMap().size());
317 assertEquals(1, root.getExistingVNFCounterMap().size());
318 assertEquals((Long)1L, root.getExistingVNFCounterMap().get("14992bf5-d585-4b54-8101-7cf76774337a"));
320 assertVnfNode(root, isDuplicatedKeysInTenantRelation);
324 public void getServiceInstanceTreeTestHappyFlow() throws IOException, AsdcCatalogException {
325 getServiceInstanceTreeAndAssert(false);
329 public void whenDuplicatedKeyInRelationshipData_thenVnfIsParsedButWithoutPlacement() throws IOException, AsdcCatalogException {
330 getServiceInstanceTreeAndAssert(true);
333 private void mockAaiGetCall(String aaiPath, String jsonFilePath) {
335 when(aaiClient.typedAaiRest(URI.create(aaiPath), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(TestUtils.readJsonResourceFileAsObject(jsonFilePath, JsonNode.class));
336 } catch (IOException e) {
337 throw new RuntimeException(e);
342 public void whenGetServiceInstanceWithCR_thenResultAreAsExpected() throws Exception {
344 List<String> modelInvIds = ImmutableList.of(
345 "868b109c-9481-4a18-891b-af974db7705a",
346 "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
347 "f6342be5-d66b-4d03-a1aa-c82c3094c4ea");
349 mockAaiGetCall("business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/a565e6ad-75d1-4493-98f1-33234b5c17e2",
350 "/getTopology/serviceWithCR/serviceWithCR.json");
351 mockAaiGetCall("/aai/v14/network/collections/collection/84a351ae-3601-45e2-98df-878d6c816abc",
352 "/getTopology/serviceWithCR/CR.json");
354 mockAaiGetCall("/aai/v14/network/instance-groups/instance-group/6b3536cf-3a12-457f-abb5-fa2203e0d923",
355 "/getTopology/serviceWithCR/instanceGroup-NCF.json");
357 when(aaiClient.getVersionByInvariantId(modelInvIds)).thenReturn(aaiGetVersionByInvariantIdResponse);
359 when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).
360 thenReturn(TestUtils.readFileAsString("/getTopology/serviceWithCR/service-design-and-creation.json"));
362 when(sdcService.getService(any())).thenReturn(
363 TestUtils.readJsonResourceFileAsObject("/getTopology/serviceWithCR/serviceWithCRModel.json", ServiceModel.class));
365 ServiceInstance serviceInstance = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, new ServiceModelInflator(), executorService)
366 .getServiceInstanceTopology("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", "Emanuel", "a565e6ad-75d1-4493-98f1-33234b5c17e2");
368 String expected = TestUtils.readFileAsString("/getTopology/serviceWithCR/getTopologyWithCR.json");
369 assertThat(serviceInstance, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
372 protected void assertVnfNode(ServiceInstance root, boolean isExpectToPlacement) {
373 Vnf vnf = root.getVnfs().get("59bde732-9b84-46bd-a59a-3c45fee0538b");
374 assertEquals(Action.None, vnf.getAction());
375 assertEquals("Created", vnf.getOrchStatus());
376 assertEquals("PREPROV", vnf.getProvStatus());
377 assertEquals(true, vnf.getInMaint());
378 assertEquals("11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", vnf.getModelInfo().getModelVersionId());
379 assertEquals("14992bf5-d585-4b54-8101-7cf76774337a", vnf.getModelInfo().getModelCustomizationId());
380 assertEquals("55628ce3-ed56-40bd-9b27-072698ce02a9", vnf.getModelInfo().getModelInvariantId());
381 assertEquals("Lital-VSP-1707097", vnf.getModelInfo().getModelName());
382 assertEquals("vnf-model-customization-name", vnf.getModelInfo().getModelCustomizationName());
383 assertEquals("2.0", vnf.getModelInfo().getModelVersion());
384 assertEquals("vnf", vnf.getModelInfo().getModelType());
385 assertEquals("59bde732-9b84-46bd-a59a-3c45fee0538b", vnf.getInstanceId());
386 assertEquals("DROR_vsp", vnf.getInstanceName());
387 assertEquals("Lital--1707097/Lital-VSP-1707097 0", vnf.getInstanceType());
388 assertEquals("11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", vnf.getUuid());
389 assertEquals("59bde732-9b84-46bd-a59a-3c45fee0538b", vnf.getTrackById());
390 assertEquals(0, vnf.getVfModules().size());
391 assertEquals(0, vnf.getNetworks().size());
392 if (!isExpectToPlacement) {
393 assertEquals("aCloudRegionId", vnf.getLcpCloudRegionId());
394 assertEquals("someTenantId123", vnf.getTenantId());
395 assertEquals("irma-aic", vnf.getCloudOwner());
398 assertNull(vnf.getLcpCloudRegionId());
399 assertNull(vnf.getTenantId());
400 assertNull(vnf.getCloudOwner());
404 protected void assertServiceNode(ServiceInstance root, int expectedVnfSize) {
405 assertEquals(Action.None, root.getAction());
406 assertEquals("Active", root.getOrchStatus());
407 assertEquals("4e799efd-fd78-444d-bc25-4a3cde2f8cb0", root.getModelInfo().getModelVersionId());
408 assertEquals(null, root.getModelInfo().getModelCustomizationId());
409 assertEquals("35340388-0b82-4d3a-823d-cbddf842be52", root.getModelInfo().getModelInvariantId());
410 assertEquals("1.0", root.getModelInfo().getModelVersion());
411 assertEquals("Lital--1707097", root.getModelInfo().getModelName());
412 assertEquals("service", root.getModelInfo().getModelType());
413 assertEquals("62888f15-6d24-4f7b-92a7-c3f35beeb215", root.getInstanceId());
414 assertEquals("Dror123", root.getInstanceName());
415 assertEquals(expectedVnfSize, root.getVnfs().size());
416 assertEquals(0, root.getNetworks().size());
417 //future - after add additional properties - assert it
420 @Test(expectedExceptions = GenericUncheckedException.class ,expectedExceptionsMessageRegExp = "AAI node fetching failed.")
421 public void getServiceInstanceTreeTest_errorCreatingVnfNode() throws IOException, AsdcCatalogException {
422 when(aaiClient.typedAaiRest(URI.create(serviceInstanceRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(mapper.readTree(ServiceInstanceResponseString));
423 when(aaiClient.typedAaiRest(URI.create(genericVnfRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenThrow(exceptionWithRequestInfo);
424 when(aaiClient.getVersionByInvariantId(any())).thenReturn(aaiGetVersionByInvariantIdResponse);
425 when(exceptionWithRequestInfo.toString()).thenReturn("this is a fetching node exception");
427 when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
429 when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
430 when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of());
432 new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
433 .getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
436 @Test(expectedExceptions = GenericUncheckedException.class ,expectedExceptionsMessageRegExp = "AAI node fetching failed.")
437 public void testCreateFailureNode() {
438 AAITreeNode failureNode = FailureAAITreeNode.of(new RuntimeException("Failed to retrieve node data."));