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.mockito.MockitoAnnotations;
45 import org.onap.vid.aai.AaiClientInterface;
46 import org.onap.vid.aai.ExceptionWithRequestInfo;
47 import org.onap.vid.aai.util.AAITreeConverter;
48 import org.onap.vid.asdc.AsdcCatalogException;
49 import org.onap.vid.asdc.parser.ServiceModelInflator;
50 import org.onap.vid.exceptions.GenericUncheckedException;
51 import org.onap.vid.model.Action;
52 import org.onap.vid.model.ServiceModel;
53 import org.onap.vid.model.aaiTree.AAITreeNode;
54 import org.onap.vid.model.aaiTree.FailureAAITreeNode;
55 import org.onap.vid.model.aaiTree.ServiceInstance;
56 import org.onap.vid.model.aaiTree.Vnf;
57 import org.onap.vid.testUtils.TestUtils;
58 import org.springframework.http.HttpMethod;
59 import org.testng.annotations.BeforeMethod;
60 import org.testng.annotations.Test;
62 public class AAIServiceTreeIntegrativeTest {
65 private AaiClientInterface aaiClient;
68 private Response aaiGetVersionByInvariantIdResponse;
71 ExceptionWithRequestInfo exceptionWithRequestInfo;
74 VidService sdcService;
77 ServiceModelInflator serviceModelInflator;
79 private AAITreeNodeBuilder aaiTreeNodeBuilder;
81 private AAITreeConverter aaiTreeConverter = new AAITreeConverter();
83 private ExecutorService executorService = Executors.newFixedThreadPool(10);
85 private final ObjectMapper mapper = new ObjectMapper();
87 private String globalCustomerID = "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb";
88 private String serviceType = "vWINIFRED";
89 private String serviceInstanceId = "62888f15-6d24-4f7b-92a7-c3f35beeb215";
91 //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
92 private String serviceInstanceRequestUri = "business/customers/customer/" +
94 "/service-subscriptions/service-subscription/" +
96 "/service-instances/service-instance/" +
99 private static String ServiceInstanceResponseString = "{\"service-instance-id\":\"62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
100 "\"service-instance-name\": \"Dror123\"," +
101 "\"environment-context\": \"null\"," +
102 "\"workload-context\": \"null\"," +
103 "\"model-invariant-id\": \"35340388-0b82-4d3a-823d-cbddf842be52\"," +
104 "\"model-version-id\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"," +
105 "\"resource-version\": \"1515515088894\"," +
106 "\"orchestration-status\": \"Active\"," +
107 "\"relationship-list\": {" +
108 "\"relationship\": [{" +
109 "\"related-to\": \"project\"," +
110 "\"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
111 "\"related-link\": \"/aai/v12/business/projects/project/DFW\"," +
112 "\"relationship-data\": [{" +
113 "\"relationship-key\": \"project.project-name\"," +
114 "\"relationship-value\": \"WATKINS\"}]},{" +
115 "\"related-to\": \"generic-vnf\"," +
116 "\"relationship-label\": \"org.onap.relationships.inventory.ComposedOf\"," +
117 "\"related-link\": \"/aai/v12/network/generic-vnfs/generic-vnf/59bde732-9b84-46bd-a59a-3c45fee0538b\"," +
118 "\"relationship-data\": [{" +
119 "\"relationship-key\": \"generic-vnf.vnf-id\"," +
120 "\"relationship-value\": \"59bde732-9b84-46bd-a59a-3c45fee0538b\"}]," +
121 "\"related-to-property\": [{" +
122 "\"property-key\": \"generic-vnf.vnf-name\"," +
123 "\"property-value\": \"DROR_vsp\"}]},{" +
124 "\"related-to\": \"owning-entity\"," +
125 "\"relationship-label\": \"org.onap.relationships.inventory.BelongsTo\"," +
126 "\"related-link\": \"/aai/v12/business/owning-entities/owning-entity/43b8a85a-0421-4265-9069-117dd6526b8a\"," +
127 "\"relationship-data\": [{" +
128 "\"relationship-key\": \"owning-entity.owning-entity-id\"," +
129 "\"relationship-value\": \"43b8a85a-0421-4265-9069-117dd6526b8a\"}]}]}}";
131 //TODO Amichai: if in the future it is neede, add here the SUFFIX to the URL: "?format=simple"
132 private static String genericVnfRequestUri = "/aai/v12/network/generic-vnfs/generic-vnf/59bde732-9b84-46bd-a59a-3c45fee0538b";
134 private String genericVnfResponseString(boolean isDuplicatedKeysInTenantRelation) {
137 "{\"nf-role\":\"\"," +
138 "\"service-id\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," +
139 "\"relationship-list\":{" +
140 "\"relationship\":[{" +
141 "\"related-to\":\"service-instance\"," +
142 "\"relationship-data\":[{" +
143 "\"relationship-value\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"," +
144 "\"relationship-key\":\"customer.global-customer-id\"},{" +
145 "\"relationship-value\":\"vWINIFRED\"," +
146 "\"relationship-key\":\"service-subscription.service-type\"},{" +
147 "\"relationship-value\":\"62888f15-6d24-4f7b-92a7-c3f35beeb215\"," +
148 "\"relationship-key\":\"service-instance.service-instance-id\"}]," +
149 "\"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\"," +
150 "\"relationship-label\":\"org.onap.relationships.inventory.ComposedOf\"," +
151 "\"related-to-property\":[{" +
152 "\"property-key\":\"service-instance.service-instance-name\"," +
153 "\"property-value\":\"Dror123\"}]},{" +
154 "\"related-to\":\"platform\"," +
155 "\"relationship-data\":[{" +
156 "\"relationship-value\":\"platformY\"," +
157 "\"relationship-key\":\"platform.platform-name\"}]," +
158 "\"related-link\":\"/aai/v12/business/platforms/platform/platformY\"," +
159 "\"relationship-label\":\"org.onap.relationships.inventory.Uses\"},{" +
160 "\"related-to\":\"line-of-business\"," +
161 "\"relationship-data\":[{" +
162 "\"relationship-value\":\"lob1, lobX\"," +
163 "\"relationship-key\":\"line-of-business.line-of-business-name\"}]," +
164 "\"related-link\":\"/aai/v12/business/lines-of-business/line-of-business/lob1%2C%20lobX\"," +
165 "\"relationship-label\":\"org.onap.relationships.inventory.Uses\"}," +
167 " \"related-to\": \"tenant\"," +
168 " \"relationship-label\": \"org.onap.relationships.inventory.Uses\"," +
169 " \"related-link\": \"/aai/v12/cloud-infrastructure/cloud-regions/cloud-region\"," +
170 " \"relationship-data\": [" +
172 " \"relationship-key\": \"cloud-region.cloud-owner\"," +
173 " \"relationship-value\": \"irma-aic\"" +
176 " \"relationship-key\": \"cloud-region.cloud-region-id\"," +
177 " \"relationship-value\": \"aCloudRegionId\"" +
180 " \"relationship-key\": \"tenant.tenant-id\"," +
181 " \"relationship-value\": \"someTenantId123\"" +
183 (isDuplicatedKeysInTenantRelation ? "{\"relationship-key\": \"tenant.tenant-id\", \"relationship-value\": \"someTenantId456\"}, " : "" ) +
185 " \"relationship-key\": \"vserver.vserver-id\"," +
186 " \"relationship-value\": \"5eef9f6d-9933-4bc6-9a1a-862d61309437\"" +
189 " \"related-to-property\": [" +
191 " \"property-key\": \"vserver.vserver-name\"," +
192 " \"property-value\": \"zolson5bfapn01dns002\"" +
197 "\"vnf-id\":\"59bde732-9b84-46bd-a59a-3c45fee0538b\",\n" +
198 "\"nf-type\":\"\"," +
199 "\"prov-status\":\"PREPROV\"," +
200 "\"vnf-type\":\"Lital--1707097/Lital-VSP-1707097 0\"," +
201 "\"orchestration-status\":\"Created\"," +
202 "\"nf-naming-code\":\"\"," +
203 "\"in-maint\":true," +
204 "\"nf-function\":\"\"," +
205 "\"model-version-id\":\"11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0\"," +
206 "\"resource-version\":\"1522431420767\"," +
207 "\"model-customization-id\":\"14992bf5-d585-4b54-8101-7cf76774337a\"," +
208 "\"model-invariant-id\":\"55628ce3-ed56-40bd-9b27-072698ce02a9\"," +
209 "\"vnf-name\":\"DROR_vsp\"," +
210 "\"is-closed-loop-disabled\":true}";
213 private List<String> invariantIDs = Arrays.asList("35340388-0b82-4d3a-823d-cbddf842be52",
214 "55628ce3-ed56-40bd-9b27-072698ce02a9");
216 private static String getVersionByInvariantIdResponseString = "{" +
218 "\"model-invariant-id\": \"55628ce3-ed56-40bd-9b27-072698ce02a9\"," +
219 "\"model-type\": \"resource\"," +
220 "\"resource-version\": \"1499690926297\"," +
221 "\"model-vers\": {" +
222 "\"model-ver\": [{" +
223 "\"model-version-id\": \"11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0\"," +
224 "\"model-name\": \"Lital-VSP-1707097\"," +
225 "\"model-version\": \"2.0\",\n" +
226 "\"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\"," +
227 "\"model-description\": \"Lital-VSP-1707097-NEW\"," +
228 "\"resource-version\": \"1499690926298\"," +
229 "\"model-elements\": {" +
230 "\"model-element\": [{" +
231 "\"model-element-uuid\": \"a4f14ef7-daa2-4257-9b81-b4558dc4beaa\"," +
232 "\"new-data-del-flag\": \"T\"," +
233 "\"cardinality\": \"unbounded\"," +
234 "\"resource-version\": \"1499690926300\"," +
235 "\"relationship-list\": {" +
236 "\"relationship\": [{" +
237 "\"related-to\": \"model-ver\"," +
238 "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
239 "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/acc6edd8-a8d4-4b93-afaa-0994068be14c/model-vers/model-ver/93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"," +
240 "\"relationship-data\": [{" +
241 "\"relationship-key\": \"model.model-invariant-id\"," +
242 "\"relationship-value\": \"acc6edd8-a8d4-4b93-afaa-0994068be14c\"},{" +
243 "\"relationship-key\": \"model-ver.model-version-id\"," +
244 "\"relationship-value\": \"93a6166f-b3d5-4f06-b4ba-aed48d009ad9\"}]," +
245 "\"related-to-property\": [{" +
246 "\"property-key\": \"model-ver.model-name\"," +
247 "\"property-value\": \"generic-vnf\"}]}]}}]}," +
248 "\"relationship-list\": {" +
249 "\"relationship\": [{" +
250 "\"related-to\": \"model-element\"," +
251 "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
252 "\"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\"," +
253 "\"relationship-data\": [{" +
254 "\"relationship-key\": \"model.model-invariant-id\"," +
255 "\"relationship-value\": \"35340388-0b82-4d3a-823d-cbddf842be52\"},{" +
256 "\"relationship-key\": \"model-ver.model-version-id\"," +
257 "\"relationship-value\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"},{" +
258 "\"relationship-key\": \"model-element.model-element-uuid\"," +
259 "\"relationship-value\": \"344e8713-f0af-423a-b96d-f45b3a479d11\"},{" +
260 "\"relationship-key\": \"model-element.model-element-uuid\"," +
261 "\"relationship-value\": \"9e8c8885-601a-4fd6-8424-c233a5333db6\"}]}]}}]}},{" +
262 "\"model-invariant-id\": \"35340388-0b82-4d3a-823d-cbddf842be52\"," +
263 "\"model-type\": \"service\"," +
264 "\"resource-version\": \"1499690928188\"," +
265 "\"model-vers\": {" +
266 "\"model-ver\": [{" +
267 "\"model-version-id\": \"4e799efd-fd78-444d-bc25-4a3cde2f8cb0\"," +
268 "\"model-name\": \"Lital--1707097\"," +
269 "\"model-version\": \"1.0\"," +
270 "\"distribution-status\": \"DISTRIBUTION_COMPLETE_OK\"," +
271 "\"model-description\": \"Lital--1707097\"," +
272 "\"resource-version\": \"1499690928190\"," +
273 "\"model-elements\": {" +
274 "\"model-element\": [{" +
275 "\"model-element-uuid\": \"344e8713-f0af-423a-b96d-f45b3a479d11\"," +
276 "\"new-data-del-flag\": \"T\"," +
277 "\"cardinality\": \"unbounded\"," +
278 "\"resource-version\": \"1499690928191\"," +
279 "\"relationship-list\": {" +
280 "\"relationship\": [{" +
281 "\"related-to\": \"model-ver\"," +
282 "\"relationship-label\": \"org.onap.relationships.inventory.IsA\"," +
283 "\"related-link\": \"/aai/v12/service-design-and-creation/models/model/82194af1-3c2c-485a-8f44-420e22a9eaa4/model-vers/model-ver/46b92144-923a-4d20-b85a-3cbd847668a9\"," +
284 "\"relationship-data\": [{" +
285 "\"relationship-key\": \"model.model-invariant-id\"," +
286 "\"relationship-value\": \"82194af1-3c2c-485a-8f44-420e22a9eaa4\"},{" +
287 "\"relationship-key\": \"model-ver.model-version-id\"," +
288 "\"relationship-value\": \"46b92144-923a-4d20-b85a-3cbd847668a9\"}]," +
289 "\"related-to-property\": [{" +
290 "\"property-key\": \"model-ver.model-name\"," +
291 "\"property-value\": \"service-instance\"}]}]}}]}}]}}]}";
294 public void initMocks() {
296 aaiGetVersionByInvariantIdResponse = null;
298 serviceModelInflator = null;
299 exceptionWithRequestInfo = null;
301 MockitoAnnotations.initMocks(this);
303 aaiTreeNodeBuilder = new AAITreeNodeBuilder(aaiClient);
306 public void getServiceInstanceTreeAndAssert(boolean isDuplicatedKeysInTenantRelation) throws IOException, AsdcCatalogException {
307 when(aaiClient.typedAaiRest(URI.create(serviceInstanceRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(mapper.readTree(ServiceInstanceResponseString));
308 when(aaiClient.typedAaiRest(URI.create(genericVnfRequestUri), JsonNode.class, null, HttpMethod.GET, false)).
309 thenReturn(mapper.readTree(genericVnfResponseString(isDuplicatedKeysInTenantRelation)));
310 when(aaiClient.getVersionByInvariantId(invariantIDs)).thenReturn(aaiGetVersionByInvariantIdResponse);
312 when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
314 when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
315 when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of(
316 "11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", new ServiceModelInflator.Names("vnf-model-customization-name", "vnf-key-in-model")
319 ServiceInstance root = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
320 .getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
322 assertServiceNode(root, 1);
324 assertEquals(0, root.getExistingNetworksCounterMap().size());
325 assertEquals(1, root.getExistingVNFCounterMap().size());
326 assertEquals((Long)1L, root.getExistingVNFCounterMap().get("14992bf5-d585-4b54-8101-7cf76774337a"));
328 assertVnfNode(root, isDuplicatedKeysInTenantRelation);
332 public void getServiceInstanceTreeTestHappyFlow() throws IOException, AsdcCatalogException {
333 getServiceInstanceTreeAndAssert(false);
337 public void whenDuplicatedKeyInRelationshipData_thenVnfIsParsedButWithoutPlacement() throws IOException, AsdcCatalogException {
338 getServiceInstanceTreeAndAssert(true);
341 private void mockAaiGetCall(String aaiPath, String jsonFilePath) {
343 when(aaiClient.typedAaiRest(URI.create(aaiPath), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(TestUtils.readJsonResourceFileAsObject(jsonFilePath, JsonNode.class));
344 } catch (IOException e) {
345 throw new RuntimeException(e);
350 public void whenGetServiceInstanceWithCR_thenResultAreAsExpected() throws Exception {
352 List<String> modelInvIds = ImmutableList.of(
353 "868b109c-9481-4a18-891b-af974db7705a",
354 "081ceb56-eb71-4566-a72d-3e7cbee5cdf1",
355 "f6342be5-d66b-4d03-a1aa-c82c3094c4ea");
357 mockAaiGetCall("business/customers/customer/a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb/service-subscriptions/service-subscription/Emanuel/service-instances/service-instance/a565e6ad-75d1-4493-98f1-33234b5c17e2",
358 "/getTopology/serviceWithCR/serviceWithCR.json");
359 mockAaiGetCall("/aai/v14/network/collections/collection/84a351ae-3601-45e2-98df-878d6c816abc",
360 "/getTopology/serviceWithCR/CR.json");
362 mockAaiGetCall("/aai/v14/network/instance-groups/instance-group/6b3536cf-3a12-457f-abb5-fa2203e0d923",
363 "/getTopology/serviceWithCR/instanceGroup-NCF.json");
365 when(aaiClient.getVersionByInvariantId(modelInvIds)).thenReturn(aaiGetVersionByInvariantIdResponse);
367 when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).
368 thenReturn(TestUtils.readFileAsString("/getTopology/serviceWithCR/service-design-and-creation.json"));
370 when(sdcService.getService(any())).thenReturn(
371 TestUtils.readJsonResourceFileAsObject("/getTopology/serviceWithCR/serviceWithCRModel.json", ServiceModel.class));
373 ServiceInstance serviceInstance = new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, new ServiceModelInflator(), executorService)
374 .getServiceInstanceTopology("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", "Emanuel", "a565e6ad-75d1-4493-98f1-33234b5c17e2");
376 String expected = TestUtils.readFileAsString("/getTopology/serviceWithCR/getTopologyWithCR.json");
377 assertThat(serviceInstance, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
380 protected void assertVnfNode(ServiceInstance root, boolean isExpectToPlacement) {
381 Vnf vnf = root.getVnfs().get("59bde732-9b84-46bd-a59a-3c45fee0538b");
382 assertEquals(Action.None, vnf.getAction());
383 assertEquals("Created", vnf.getOrchStatus());
384 assertEquals("PREPROV", vnf.getProvStatus());
385 assertEquals(true, vnf.getInMaint());
386 assertEquals("11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", vnf.getModelInfo().getModelVersionId());
387 assertEquals("14992bf5-d585-4b54-8101-7cf76774337a", vnf.getModelInfo().getModelCustomizationId());
388 assertEquals("55628ce3-ed56-40bd-9b27-072698ce02a9", vnf.getModelInfo().getModelInvariantId());
389 assertEquals("Lital-VSP-1707097", vnf.getModelInfo().getModelName());
390 assertEquals("vnf-model-customization-name", vnf.getModelInfo().getModelCustomizationName());
391 assertEquals("2.0", vnf.getModelInfo().getModelVersion());
392 assertEquals("vnf", vnf.getModelInfo().getModelType());
393 assertEquals("59bde732-9b84-46bd-a59a-3c45fee0538b", vnf.getInstanceId());
394 assertEquals("DROR_vsp", vnf.getInstanceName());
395 assertEquals("Lital--1707097/Lital-VSP-1707097 0", vnf.getInstanceType());
396 assertEquals("11c6dc3e-cd6a-41b3-a50e-b5a10f7157d0", vnf.getUuid());
397 assertEquals("59bde732-9b84-46bd-a59a-3c45fee0538b", vnf.getTrackById());
398 assertEquals(0, vnf.getVfModules().size());
399 assertEquals(0, vnf.getNetworks().size());
400 if (!isExpectToPlacement) {
401 assertEquals("aCloudRegionId", vnf.getLcpCloudRegionId());
402 assertEquals("someTenantId123", vnf.getTenantId());
403 assertEquals("irma-aic", vnf.getCloudOwner());
406 assertNull(vnf.getLcpCloudRegionId());
407 assertNull(vnf.getTenantId());
408 assertNull(vnf.getCloudOwner());
412 protected void assertServiceNode(ServiceInstance root, int expectedVnfSize) {
413 assertEquals(Action.None, root.getAction());
414 assertEquals("Active", root.getOrchStatus());
415 assertEquals("4e799efd-fd78-444d-bc25-4a3cde2f8cb0", root.getModelInfo().getModelVersionId());
416 assertEquals(null, root.getModelInfo().getModelCustomizationId());
417 assertEquals("35340388-0b82-4d3a-823d-cbddf842be52", root.getModelInfo().getModelInvariantId());
418 assertEquals("1.0", root.getModelInfo().getModelVersion());
419 assertEquals("Lital--1707097", root.getModelInfo().getModelName());
420 assertEquals("service", root.getModelInfo().getModelType());
421 assertEquals("62888f15-6d24-4f7b-92a7-c3f35beeb215", root.getInstanceId());
422 assertEquals("Dror123", root.getInstanceName());
423 assertEquals(expectedVnfSize, root.getVnfs().size());
424 assertEquals(0, root.getNetworks().size());
425 //future - after add additional properties - assert it
428 @Test(expectedExceptions = GenericUncheckedException.class ,expectedExceptionsMessageRegExp = "AAI node fetching failed.")
429 public void getServiceInstanceTreeTest_errorCreatingVnfNode() throws IOException, AsdcCatalogException {
430 when(aaiClient.typedAaiRest(URI.create(serviceInstanceRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(mapper.readTree(ServiceInstanceResponseString));
431 when(aaiClient.typedAaiRest(URI.create(genericVnfRequestUri), JsonNode.class, null, HttpMethod.GET, false)).thenThrow(exceptionWithRequestInfo);
432 when(aaiClient.getVersionByInvariantId(any())).thenReturn(aaiGetVersionByInvariantIdResponse);
433 when(exceptionWithRequestInfo.toString()).thenReturn("this is a fetching node exception");
435 when(aaiGetVersionByInvariantIdResponse.readEntity(String.class)).thenReturn(getVersionByInvariantIdResponseString);
437 when(sdcService.getService(any())).thenReturn(mock(ServiceModel.class));
438 when(serviceModelInflator.toNamesByVersionId(any())).thenReturn(ImmutableMap.of());
440 new AAIServiceTree(aaiClient, aaiTreeNodeBuilder, aaiTreeConverter, sdcService, serviceModelInflator, executorService)
441 .getServiceInstanceTopology(globalCustomerID, serviceType, serviceInstanceId);
444 @Test(expectedExceptions = GenericUncheckedException.class ,expectedExceptionsMessageRegExp = "AAI node fetching failed.")
445 public void testCreateFailureNode() {
446 AAITreeNode failureNode = FailureAAITreeNode.of(new RuntimeException("Failed to retrieve node data."));