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