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