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