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