2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.adapters.catalogdb.catalogrest;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import static org.junit.Assert.assertTrue;
28 import static org.junit.Assert.fail;
29 import java.util.List;
30 import javax.transaction.Transactional;
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.onap.so.adapters.catalogdb.CatalogDbAdapterBaseTest;
34 import org.onap.so.db.catalog.beans.BuildingBlockDetail;
35 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
36 import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
37 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
38 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
39 import org.onap.so.db.catalog.beans.InstanceGroup;
40 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
41 import org.onap.so.db.catalog.client.CatalogDbClientPortChanger;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
44 import org.springframework.beans.factory.annotation.Autowired;
45 import org.springframework.boot.web.server.LocalServerPort;
47 public class NetworkCollectionCatalogDbQueryTest extends CatalogDbAdapterBaseTest {
49 private static final Logger logger = LoggerFactory.getLogger(NetworkCollectionCatalogDbQueryTest.class);
50 private static final String NETWORKCOLLECTION = "NetworkCollection";
52 private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671";
56 boolean isInitialized;
59 CatalogDbClientPortChanger client;
62 public void initialize() {
63 client.wiremockPort = String.valueOf(port);
68 public void networkCollectionTest() {
69 logger.debug("TEST IS STARTING UP...");
70 String modelUUID = "4694a55f-58b3-4f17-92a5-796d6f5ffd0d";
71 boolean found = false;
72 logger.debug(Integer.toString(port));
73 InstanceGroup instanceGroup = null;
74 List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupList = null;
75 org.onap.so.db.catalog.beans.Service service = client.getServiceByID(modelUUID);
76 if (service == null) {
79 List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations();
80 if (customizations.isEmpty()) {
81 logger.debug("No Network Collection found. CollectionResourceCustomizations is empty");
83 for (CollectionResourceCustomization crc : customizations) {
84 if (client.getNetworkCollectionResourceCustomizationByID(
85 crc.getModelCustomizationUUID()) instanceof NetworkCollectionResourceCustomization) {
86 if (crc.getCollectionResource() != null) {
87 if (crc.getCollectionResource().getToscaNodeType() != null) {
88 String toscaNodeType = crc.getCollectionResource().getToscaNodeType();
89 if (toscaNodeType.contains(NETWORKCOLLECTION)) {
90 logger.debug("Found a network collection");
91 instanceGroup = crc.getCollectionResource().getInstanceGroup();
92 collectionInstanceGroupList = instanceGroup.getCollectionInstanceGroupCustomizations();
93 CollectionNetworkResourceCustomization collectionNetworkCust =
94 instanceGroup.getCollectionNetworkResourceCustomizations().get(0);
95 logger.debug("Found Collection Network Resource Customization: "
96 + collectionNetworkCust.getModelCustomizationUUID());
99 "No Network Collection found. toscaNodeType does not contain NetworkCollection");
102 logger.debug("No Network Collection found. toscaNodeType is null");
105 logger.debug("No Network Collection found. collectionResource is null");
109 logger.debug("Not a Network Collection Resource Customization Instance");
113 assertEquals("Number of CollectionResourceInstanceGroupCustomization in list", 2,
114 collectionInstanceGroupList.size());
115 assertNotNull(instanceGroup);
120 public void buildingBlockDetailTest() {
121 logger.debug("TEST IS STARTING UP...");
122 logger.debug(Integer.toString(port));
123 String buildingBlockFlowName = "CreateNetworkCollectionBB";
124 BuildingBlockDetail buildingBlockDetail = client.getBuildingBlockDetail(buildingBlockFlowName);
125 logger.debug("" + buildingBlockDetail.getResourceType());
126 assertNotNull(buildingBlockDetail);
130 public void fetchServiceTopology_Test() {
131 org.onap.so.db.catalog.beans.Service service = client.getServiceByID(serviceUUID);
133 if (service == null) {
134 fail("Service is null");
136 assertEquals(serviceUUID, service.getModelUUID());
137 assertEquals("MSOTADevInfra_vSAMP10a_Service", service.getModelName());
141 public void CollectionNetworkResourceCustomizationTest() {
142 String modelCustId = "1a61be4b-3378-4c9a-91c8-c919519b2d01";
143 CollectionNetworkResourceCustomization collectionNetworkCust =
144 client.getCollectionNetworkResourceCustomizationByID(modelCustId);
145 assertNotNull(collectionNetworkCust);
146 logger.debug(collectionNetworkCust.getModelCustomizationUUID());
150 public void getCvnfcCustomization() {
151 client.getServiceByID(serviceUUID);
152 String vfId = "cb82ffd8-252a-11e7-93ae-92361f002671";
153 String vnfId = "68dc9a92-214c-11e7-93ae-92361f002671";
155 CvnfcConfigurationCustomization fabricConfig =
156 client.getCvnfcCustomization(serviceUUID, vnfId, vfId, "dadc2c8c-2bab-11e9-b210-d663bd873d95");
157 assertEquals("386c9aa7-9318-48ee-a6d1-1bf0f85de385", fabricConfig.getModelCustomizationUUID());