diff options
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test')
22 files changed, 1609 insertions, 1445 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/EmbeddedMariaDbConfig.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..7f0c07bdf6 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/EmbeddedMariaDbConfig.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb; +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import javax.sql.DataSource; + +@Configuration +@Profile({"test","local"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + return new MariaDB4jSpringService(); + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java new file mode 100644 index 0000000000..f3315b57eb --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -0,0 +1,782 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb.catalogrest; + +import static org.junit.Assert.*; + + +import java.io.IOException; +import java.util.Map; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + + +import org.json.JSONException; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.catalogdb.CatalogDBApplication; + +import org.onap.so.logger.MsoLogger; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.util.UriComponentsBuilder; + +import ch.qos.logback.classic.spi.ILoggingEvent; + + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") + +public class CatalogDBRestTest { + + private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules"; + + private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources"; + + private static final String ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS = "ecomp/mso/catalog/v2/serviceNetworks"; + + private static final String ECOMP_MSO_CATALOG_V2_SERVICE_VNFS = "ecomp/mso/catalog/v2/serviceVnfs"; + + private static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources"; + + @LocalServerPort + private int port; + + TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); + + HttpHeaders headers = new HttpHeaders(); + + private final String expectedServiceResourceResponse = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}"; + + private final String expectedServiceResourceResponsev2 = "{\r\n\"serviceResources\": {\r\n\"modelInfo\": {\r\n\"modelName\": \"MSOTADevInfra_vSAMP10a_Service\",\r\n\"modelUuid\": \"5df8b6de-2083-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"9647dfc4-2083-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\"\r\n},\r\n\"serviceType\": \"NA\",\r\n\"serviceRole\": \"NA\",\r\n\"environmentContext\": \"Luna\",\r\n\"workloadContext\": \"Oxygen\",\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n],\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n],\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}\r\n}"; + + + private final String expectedServiceVnfResponse = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}"; + + private final String expectedServiceVnfResponseV3 = "{\r\n\"serviceVnfs\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002672\",\r\n\"modelInstanceName\": \"vSAMP10a 2\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002672\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002672\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}\r\n]\r\n}"; + + private final String expectedServiceNetworkResourceResponse = "{\r\n\"serviceNetworks\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}\r\n]\r\n}"; + + private final String badQueryParamResponse = "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\""; + + private final String expectedAllottedResponse = "{\r\n\"serviceAllottedResources\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}\r\n]\r\n}"; + + private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; + + private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671"; + + /* Health Check Resources Endpoint */ + + @Test + public void testHealthcheck() throws JSONException { + + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + + ResponseEntity<String> response = restTemplate.exchange( + createURLWithPort("/manage/health"), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + } + + /* Service Resources Endpoint */ + + @Test + public void testGetServiceModelUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) + .queryParam("serviceModelUuid", serviceUUID); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), JSONCompareMode.LENIENT); + } + + @Test + public void testGetServiceInvariantUUIDAndVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) + .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "1.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceResourceResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceInvariantUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) + .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false); + } + + @Test + public void testGetServiceInvariantUUIDEmtpyModelVer() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) + .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671").queryParam("serviceModelVersion", "");; + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceResourceResponsev2, response.getBody().toString(), false); + } + + @Test + public void testGetServiceModelUUID404() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + String expectedResponse = "\"serviceResources\": null"; + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) + .queryParam("serviceModelUuid", "5df8b6de-2083-11e7-93"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceBadQueryParams() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES)) + .queryParam("BadQueryParam", "5df8b6de-2083-11e7-93"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); + } + + /* VNF Resources Endpoint */ + + @Test + public void testGetVNFResourcesByCustomizationUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10a\",\r\n\"modelUuid\": \"ff2ae348-214a-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"2fff5b20-214b-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"68dc9a92-214c-11e7-93ae-92361f002671\",\r\n\"modelInstanceName\": \"vSAMP10a 1\"\r\n},\r\n\"toscaNodeType\": \"VF\",\r\n\"nfFunction\": \"vSAMP\",\r\n\"nfType\": \"vSAMP\",\r\n\"nfRole\": \"vSAMP\",\r\n\"nfNamingCode\": \"vSAMP\",\r\n\"multiStageDesign\": null,\r\n\"vfModules\": [\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n},\r\n{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::PCM::module-1\",\r\n\"modelUuid\": \"066de97e-253e-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"64efd51a-2544-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"b4ea86b4-253f-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": false,\r\n\"vfModuleLabel\": \"PCM\",\r\n\"initialCount\": 0,\r\n\"hasVolumeGroup\": false\r\n}\r\n]\r\n}"; + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc9a92-214c-11e7-93ae-92361f002671")) + ; + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false); + } + + + + @Test + public void testGetVNFResources404() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/vnfResources/68dc-11e7-93ae-92361f002671")) + ; + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + + } + + @Test + public void testGetServiceVNFResourcesByCustomizationUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("vnfModelCustomizationUuid", "68dc9a92-214c-11e7-93ae-92361f002671"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceVNFResourcesByServiceModelUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelUuid", serviceUUID); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceVNFResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671") + .queryParam("serviceModelVersion", "1.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceVNFResourcesByServiceModelInvariantUUIDEmptyVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671") + .queryParam("serviceModelVersion", ""); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false); + } + + + @Test + public void testGetServiceVNFResourcesByServiceModelInvariantUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelInvariantUuid", "9647dfc4-2083-11e7-93ae-92361f002671"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false); + } + + @Test + public void testGetServiceVNFResourcesByServiceModelName() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false); + } + + @Test + public void testGetServiceVNFResourcesByServiceModelNameEmptyVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", ""); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponseV3, response.getBody().toString(), false); + } + + @Test + public void testGetServiceVNFResourcesByServiceModelNameAndVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelName", "MSOTADevInfra_vSAMP10a_Service").queryParam("serviceModelVersion", "1.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceVnfResponse, response.getBody().toString(), false); + } + + @Test + public void testSerfviceVNFResources404() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("serviceModelName", "BADNAME").queryParam("serviceModelVersion", "1.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + + } + + + @Test + public void testSerfviceVNFBadParams() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_VNFS)) + .queryParam("BadParamName", "BADNAME"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); + + + } + + + + /* Network Resources Endpoint */ + + @Test + public void testGetNetworkResourcesByCustomizationUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"CONTRAIL30_GNDIRECT\",\r\n\"modelUuid\": \"10b36f65-f4e6-4be6-ae49-9596dc1c47fc\",\r\n\"modelInvariantUuid\": \"ce4ff476-9641-4e60-b4d5-b4abbec1271d\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"3bdbb104-476c-483e-9f8b-c095b3d308ac\",\r\n\"modelInstanceName\": \"CONTRAIL30_GNDIRECT 9\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"networkType\": \"\",\r\n\"networkTechnology\": \"\",\r\n\"networkRole\": \"\",\r\n\"networkScope\": \"\"\r\n}"; + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-476c-483e-9f8b-c095b3d308ac")) + ; + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false); + } + + + + @Test + public void testGetNetworkResources404() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/networkResources/3bdbb104-4asdf")) + ; + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + + } + + /* Service Network Resources Endpoints */ + + @Test + public void testGetServiceNetworkResourcesByUnknownQueryParam() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("serviceModelName", "PROVIDER NETWORK").queryParam("serviceModelVersion", "2.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceNetworkResourcesByServiceModelUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("serviceModelUuid", serviceUUID); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceNetworkResourcesByServiceModelUUIDNotExist() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("serviceModelUuid", "doesNotExist"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + + } + + @Test + public void testGetServiceNetworkResourcesByNetworkCustomizationUUIDNotExist() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("networkModelCustomizationUuid", "06b8966e-097c-4d63-afda-e0d"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + + } + + @Test + public void testGetServiceNetworkResourcesByServiceModelInvariantUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("serviceModelInvariantUuid", serviceInvariantUUID); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceNetworkResourcesByServiceModelInvariantUUIDAndVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("serviceModelInvariantUuid", serviceInvariantUUID) + .queryParam("serviceModelVersion", "2.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceNetworkResourcesByServiceModelInvariantAndEmptyVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("serviceModelInvariantUuid", serviceInvariantUUID) + .queryParam("serviceModelVersion", ""); + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false); + } + + + @Test + public void testGetServiceNetworkResourcesByNetworkCustomizationUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("networkModelCustomizationUuid", "3bdbb104-476c-483e-9f8b-c095b3d308ac"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceNetworkResourcesByNetworkModelName() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_NETWORKS)) + .queryParam("networkModelName", "CONTRAIL30_GNDIRECT"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedServiceNetworkResourceResponse, response.getBody().toString(), false); + } + + /* Allotted endpoints */ + + @Test + public void testGetAllottedResourcesByCustomizationUUID() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"Tunnel_Xconn\",\r\n\"modelUuid\": \"f6b7d4c6-e8a4-46e2-81bc-31cad5072842\",\r\n\"modelInvariantUuid\": \"b7a1b78e-6b6b-4b36-9698-8c9530da14af\",\r\n\"modelVersion\": \"1.0\",\r\n\"modelCustomizationUuid\": \"367a8ba9-057a-4506-b106-fbae818597c6\",\r\n\"modelInstanceName\": \"Sec_Tunnel_Xconn 11\"\r\n},\r\n\"toscaNodeType\": \"\",\r\n\"allottedResourceType\": \"\",\r\n\"allottedResourceRole\": null,\r\n\"providingServiceModelName\": null,\r\n\"providingServiceModelInvariantUuid\": null,\r\n\"providingServiceModelUuid\": null,\r\n\"nfFunction\": null,\r\n\"nfType\": null,\r\n\"nfRole\": null,\r\n\"nfNamingCode\": null\r\n}"; + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort("ecomp/mso/catalog/v2/allottedResources/367a8ba9-057a-4506-b106-fbae818597c6")); + + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false); + } + + + @Test + public void testGetAllottedResourcesByServiceModelUuuid() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES)) + .queryParam("serviceModelUuid",serviceUUID); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceAllottedResourcesByServiceModelInvariantUuid() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES)) + .queryParam("serviceModelInvariantUuid", serviceInvariantUUID); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersion() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES)) + .queryParam("serviceModelInvariantUuid", serviceInvariantUUID) + .queryParam("serviceModelVersion", "1.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false); + } + + @Test + public void testGetServiceAllottedResourcesByServiceModelInvariantUuidModelVersionEmpty() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES)) + .queryParam("serviceModelInvariantUuid", serviceInvariantUUID) + .queryParam("serviceModelVersion", "1.0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false); + } + + @Test + public void testGetAllottedResourcesByAllottedCustomizationId() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES)) + .queryParam("arModelCustomizationUuid", "367a8ba9-057a-4506-b106-fbae818597c6"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedAllottedResponse, response.getBody().toString(), false); + } + + + @Test + public void testGetAllottedResourcesResourcesNonExistResource() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES)) + .queryParam("arModelCustomizationUuid", "NOTEXIST"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + + } + + /* VF Modules Endpoint */ + + @Test + public void testGetVFModulesNonExistResource() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)) + .queryParam("vfModuleModelName", "NEUTRON_BASIC"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); + + } + + @Test + public void testGetVFModulesByVfModuleModelName() throws JSONException { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + String expectedResponse = "{\r\n\"modelInfo\": {\r\n\"modelName\": \"vSAMP10aDEV::base::module-0\",\r\n\"modelUuid\": \"20c4431c-246d-11e7-93ae-92361f002671\",\r\n\"modelInvariantUuid\": \"78ca26d0-246d-11e7-93ae-92361f002671\",\r\n\"modelVersion\": \"2\",\r\n\"modelCustomizationUuid\": \"cb82ffd8-252a-11e7-93ae-92361f002671\"\r\n},\r\n\"isBase\": true,\r\n\"vfModuleLabel\": \"base\",\r\n\"initialCount\": 1,\r\n\"hasVolumeGroup\": false\r\n}"; + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)) + .queryParam("vfModuleModelName", "vSAMP10aDEV::base::module-0"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResponse, response.getBody().toString(), false); + + } + + @Test + public void testGetVFModulesBadQueryParam() throws JSONException, IOException { + TestAppender.events.clear(); + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_VF_MODULES)) + .queryParam("ADASD", "NEUTRON_BASIC"); + + ResponseEntity<String> response = restTemplate.exchange( + builder.toUriString(), + HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),response.getStatusCode().value()); + JSONAssert.assertEquals(badQueryParamResponse, response.getBody().toString(), false); + + + ILoggingEvent logEvent = TestAppender.events.get(0); + Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(MsoLogger.BEGINTIME)); + assertNotNull(mdc.get(MsoLogger.ENDTIME)); + assertNotNull(mdc.get(MsoLogger.REQUEST_ID)); + assertNotNull(mdc.get(MsoLogger.TIMER)); + assertEquals("500",mdc.get(MsoLogger.RESPONSECODE)); + assertEquals("UNKNOWN",mdc.get(MsoLogger.PARTNERNAME)); + assertEquals("v2/vfModules",mdc.get(MsoLogger.SERVICE_NAME)); + assertEquals("ERROR",mdc.get(MsoLogger.STATUSCODE)); + assertNotNull(mdc.get(MsoLogger.RESPONSEDESC)); + } + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + uri; + } +} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java index 365c9abcf5..3e30dcc3b2 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.catalogdb.catalogrest; +package org.onap.so.adapters.catalogdb.catalogrest; import org.junit.Test; import static org.junit.Assert.assertNotNull; diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java new file mode 100644 index 0000000000..f09df8823c --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/NetworkCollectionCatalogDbQueryTest.java @@ -0,0 +1,153 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb.catalogrest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.List; + +import javax.transaction.Transactional; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.adapters.catalogdb.CatalogDBApplication; +import org.onap.so.db.catalog.beans.BuildingBlockDetail; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; +import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.logger.MsoLogger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = CatalogDBApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class NetworkCollectionCatalogDbQueryTest { + + private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, NetworkCollectionCatalogDbQueryTest.class); + private static final String NETWORKCOLLECTION = "NetworkCollection"; + + private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; + + @LocalServerPort + private int port; + + @Autowired + private CatalogDbClient client; + + @Before + public void setPort() { + client.removePortFromEndpoint(); + client.setPortToEndpoint(Integer.toString(port)); + } + + @Test + @Transactional + public void networkCollectionTest() { + msoLogger.debug("TEST IS STARTING UP..."); + String modelUUID = "4694a55f-58b3-4f17-92a5-796d6f5ffd0d"; + boolean found = false; + msoLogger.debug(Integer.toString(port)); + InstanceGroup instanceGroup = null; + List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupList = null; + org.onap.so.db.catalog.beans.Service service = client.getServiceByID(modelUUID); + if (service == null) { + msoLogger.debug("null"); + } else { + List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); + if (customizations.isEmpty()) { + msoLogger.debug("No Network Collection found. CollectionResourceCustomizations is empty"); + } + for (CollectionResourceCustomization crc : customizations) { + if(client.getNetworkCollectionResourceCustomizationByID(crc.getModelCustomizationUUID()) + instanceof NetworkCollectionResourceCustomization) { + if (crc.getCollectionResource() != null) { + if (crc.getCollectionResource() + .getToscaNodeType() != null) { + String toscaNodeType = crc.getCollectionResource() + .getToscaNodeType(); + if (toscaNodeType.contains(NETWORKCOLLECTION)) { + msoLogger.debug("Found a network collection"); + instanceGroup = crc.getCollectionResource().getInstanceGroup(); + collectionInstanceGroupList = + instanceGroup.getCollectionInstanceGroupCustomizations(); + CollectionNetworkResourceCustomization collectionNetworkCust = instanceGroup.getCollectionNetworkResourceCustomizations().get(0); + msoLogger.debug("Found Collection Network Resource Customization: " + collectionNetworkCust.getModelCustomizationUUID()); + } else { + msoLogger.debug( + "No Network Collection found. toscaNodeType does not contain NetworkCollection"); + } + } else { + msoLogger.debug("No Network Collection found. toscaNodeType is null"); + } + } else { + msoLogger.debug("No Network Collection found. collectionResource is null"); + } + found = true; + } else { + msoLogger.debug("Not a Network Collection Resource Customization Instance"); + } + } + } + assertEquals("Number of CollectionResourceInstanceGroupCustomization in list", 2, collectionInstanceGroupList.size()); + assertNotNull(instanceGroup); + assertTrue(found); + } + + @Test + public void buildingBlockDetailTest() { + msoLogger.debug("TEST IS STARTING UP..."); + msoLogger.debug(Integer.toString(port)); + String buildingBlockFlowName = "CreateNetworkCollectionBB"; + BuildingBlockDetail buildingBlockDetail = client.getBuildingBlockDetail(buildingBlockFlowName); + msoLogger.debug("" + buildingBlockDetail.getResourceType()); + assertNotNull(buildingBlockDetail); + } + + @Test + public void fetchServiceTopology_Test() { + org.onap.so.db.catalog.beans.Service service = client.getServiceByID(serviceUUID); + + if (service == null) { + fail("Service is null"); + } + assertEquals(serviceUUID, service.getModelUUID()); + assertEquals("MSOTADevInfra_vSAMP10a_Service",service.getModelName()); + } + + @Test + public void CollectionNetworkResourceCustomizationTest() { + String modelCustId = "1a61be4b-3378-4c9a-91c8-c919519b2d01"; + CollectionNetworkResourceCustomization collectionNetworkCust = client.getCollectionNetworkResourceCustomizationByID(modelCustId); + assertNotNull(collectionNetworkCust); + msoLogger.debug(collectionNetworkCust.getModelCustomizationUUID()); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java index fa1a1fc94e..645714cc80 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java @@ -18,14 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.catalogdb.catalogrest; +package org.onap.so.adapters.catalogdb.catalogrest; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Before; import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.Recipe; -import org.openecomp.mso.jsonpath.JsonPathUtil; +import org.onap.so.db.catalog.beans.Recipe; +import org.onap.so.db.catalog.beans.ServiceRecipe; +import org.onap.so.jsonpath.JsonPathUtil; public class QueryResourceRecipeTest { @@ -55,18 +56,13 @@ public class QueryResourceRecipeTest { assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.description")).contains(RECIPE_DESCRIPTION); } - @Test - public void toString_properContent() { - assertThat(testedObject.toString()).contains("RECIPE: actionTest,uri=uriTest"); - } - private Recipe createRecipe() { - Recipe recipe = new Recipe(); + ServiceRecipe recipe = new ServiceRecipe(); recipe.setId(RECIPE_ID); recipe.setAction(RECIPE_ACTION); recipe.setOrchestrationUri(RECIPE_URI); recipe.setRecipeTimeout(RECIPE_TIMEOUT); - recipe.setParamXSD(RECIPE_PARAMS_XSD); + recipe.setParamXsd(RECIPE_PARAMS_XSD); recipe.setDescription(RECIPE_DESCRIPTION); return recipe; } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java index e9c947d50e..32cc2946db 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.catalogdb.catalogrest; +package org.onap.so.adapters.catalogdb.catalogrest; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Before; import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.ToscaCsar; -import org.openecomp.mso.jsonpath.JsonPathUtil; +import org.onap.so.db.catalog.beans.ToscaCsar; +import org.onap.so.jsonpath.JsonPathUtil; public class QueryServiceCsarTest { @@ -55,12 +55,6 @@ public class QueryServiceCsarTest { assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.description")).contains(TOSCA_DESCRIPTION); } - @Test - public void toString_properContent() { - assertThat(testedObject.toString()).contains( - "TOSCACSAR: artifactUUID=artUuidTest,name=toscaNameTest,version=v12,description=toscaDescr,artifactChecksum=tosArtCheck,url=tosUrl"); - } - private ToscaCsar createToscaCsar() { ToscaCsar toscaCsar = new ToscaCsar(); toscaCsar.setArtifactUUID(TOSCA_ARTIFACT_UUID); diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModuleTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModuleTest.java index b00b5b7ca8..98e90c828c 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryVfModuleTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModuleTest.java @@ -18,16 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.openecomp.mso.adapters.catalogdb.catalogrest; +package org.onap.so.adapters.catalogdb.catalogrest; import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; + import org.junit.Test; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; -import org.openecomp.mso.jsonpath.JsonPathUtil; +import org.onap.so.db.catalog.beans.HeatEnvironment; +import org.onap.so.db.catalog.beans.VfModule; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.jsonpath.JsonPathUtil; public class QueryVfModuleTest { @@ -74,13 +76,13 @@ public class QueryVfModuleTest { VfModule vfModule = new VfModule(); vfModule.setModelName(VF_MODULE_MODEL_NAME); vfModule.setModelUUID(VF_MODEL_UUID); - vfModule.setModelInvariantUuid(VF_MODULE_INVARIANT_UUID); - vfModule.setVersion(VF_MODULE_VERSION); - vfModule.setIsBase(1); + vfModule.setModelInvariantUUID(VF_MODULE_INVARIANT_UUID); + vfModule.setModelVersion(VF_MODULE_VERSION); + vfModule.setIsBase(true); VfModuleCustomization vfModuleCustomization = new VfModuleCustomization(); vfModuleCustomization.setVfModule(vfModule); - vfModuleCustomization.setModelCustomizationUuid(VF_MODEL_CUSTOMIZATION_UUID); + vfModuleCustomization.setModelCustomizationUUID(VF_MODEL_CUSTOMIZATION_UUID); vfModuleCustomization.setLabel(VF_MODEL_CUSTOMIZATION_LABEL); vfModuleCustomization.setInitialCount(VF_MODEL_CUSTOMIZATION_INITIAL_COUNT); list.add(vfModuleCustomization); @@ -89,7 +91,9 @@ public class QueryVfModuleTest { private List<VfModuleCustomization> createListWithHeatEnvironmentArtifactUuid() { List<VfModuleCustomization> list = createList(); - list.get(0).setHeatEnvironmentArtifactUuid("heatEnvTest"); + HeatEnvironment he = new HeatEnvironment(); + he.setArtifactUuid("heatEnvTest"); + list.get(0).setVolumeHeatEnv(he); return list; } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/TestAppender.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/TestAppender.java new file mode 100644 index 0000000000..c5772d9883 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/TestAppender.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.catalogdb.catalogrest; + +import java.util.ArrayList; +import java.util.List; +import ch.qos.logback.classic.spi.ILoggingEvent; +import ch.qos.logback.core.AppenderBase; + + + +public class TestAppender extends AppenderBase<ILoggingEvent> { + static List<ILoggingEvent> events = new ArrayList<>(); + + @Override + protected void append(ILoggingEvent loggingEvent) { + events.add(loggingEvent); + } +} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java deleted file mode 100644 index 31594905fd..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestClassTest.java +++ /dev/null @@ -1,380 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.catalogdb; - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.apache.http.HttpStatus; -import javax.json.*; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.openecomp.mso.adapters.catalogdb.CatalogDbAdapterRest; -import org.openecomp.mso.adapters.catalogdb.catalogrest.CatalogQueryException; -import org.openecomp.mso.adapters.catalogdb.catalogrest.QueryServiceVnfs; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.junit.Before; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.verifyStatic; -import static org.hamcrest.CoreMatchers.instanceOf; - -@RunWith(PowerMockRunner.class) -@PrepareForTest({CatalogDbAdapterRest.class, CatalogDatabase.class}) -public class CatalogDbAdapterRestClassTest { - @Mock - private static CatalogDatabase dbMock; - - private static List<VnfResourceCustomization> paramList; - - @Before - public void prepare () { - /* - * 1. for non routing related methods/classes, use mockito - * 2. for routing methods, use TJWSEmbeddedJaxrsServer - */ - - /* - * in the setup portion, create a mock db object - * - */ - // set up mock return value - paramList = new ArrayList<>(); - VnfResourceCustomization d1 = new VnfResourceCustomization(); - d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - d1.setModelInstanceName("ciVFOnboarded-FNAT-aab06c41 1"); - paramList.add(d1); - // end - - PowerMockito.mockStatic(CatalogDatabase.class); - dbMock = PowerMockito.mock(CatalogDatabase.class); - PowerMockito.when(CatalogDatabase.getInstance()).thenReturn(dbMock); - try { - - PowerMockito.whenNew(CatalogDatabase.class).withAnyArguments().thenReturn(dbMock); - PowerMockito.spy (dbMock); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void respond_Test(){ - QueryServiceVnfs qryResp = new QueryServiceVnfs(paramList); - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - CatalogDbAdapterRest spyAdapter = Mockito.spy(adapter); - - Response resp = spyAdapter.respond("v1", HttpStatus.SC_OK, false, qryResp); - Mockito.verify(spyAdapter,Mockito.times(1)).respond("v1", HttpStatus.SC_OK, false, qryResp); - - String s = resp.getEntity().toString(); - // System.out.println(s); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - } - - - @Test - public void serviceVnfsImpl_vnfUuid_ver_Test() - { - PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList); - - try { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - - // Run - Response resp = adapter.serviceVnfsImpl("v1", true, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null, null); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - // - Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByVnfModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceVnfsImpl_smiUuid_NoVer_Test() - { - PowerMockito.when(dbMock.getAllVnfsByServiceModelInvariantUuid(Mockito.anyString())).thenReturn (paramList); - - try { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - - // Run - Response resp = adapter.serviceVnfsImpl("v1", true, null, null, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceModelInvariantUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceVnfsImpl_smUuid_ver_Test() - { - PowerMockito.when(dbMock.getAllVnfsByServiceModelUuid(Mockito.anyString())).thenReturn (paramList); - - try { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - - // Run - Response resp = adapter.serviceVnfsImpl("v1", true, null,"16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceModelUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceVnfsImpl_smiUuid_ver_Test() - { - PowerMockito.when(dbMock.getAllVnfsByServiceModelInvariantUuid(Mockito.anyString(),Mockito.anyString())).thenReturn (paramList); - - try { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - - // Run - Response resp = adapter.serviceVnfsImpl("v1", true, null, null, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", "v1", null); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - // end - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceModelInvariantUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391","v1"); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceVnfsImpl_smName_ver_Test() - { - PowerMockito.when(dbMock.getAllVnfsByServiceName(Mockito.anyString(),Mockito.anyString())).thenReturn (paramList); - - try { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - - // Run - Response resp = adapter.serviceVnfsImpl("v1", true, null, null, null, "v1", "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceName("16ea3e56-a8ce-4ad7-8edd-4d2eae095391","v1"); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceVnfsImpl_smName_NoVer_Test() - { - PowerMockito.when(dbMock.getAllVnfsByServiceName(Mockito.anyString())).thenReturn (paramList); - - try { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - - // Run - Response resp = adapter.serviceVnfsImpl("v1", true, null, null, null, null, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - Mockito.verify(dbMock, Mockito.times(1)).getAllVnfsByServiceName("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceVnfsImpl_Exception_Test() - { - PowerMockito.when(dbMock.getAllVnfsByServiceName(Mockito.anyString())).thenReturn (null); - - try { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - - // Run - Response resp = adapter.serviceVnfsImpl("v1", true, null, null, null, null, null); - - assertEquals(resp.getStatus(), HttpStatus.SC_INTERNAL_SERVER_ERROR); - assertThat(resp.getEntity(), instanceOf(CatalogQueryException.class)); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceNetworksImpl_nUuid_ver_Test(){ - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - CatalogDbAdapterRest spyAdapter = Mockito.spy(adapter); - - Response resp = Response - .status(HttpStatus.SC_OK) - .entity("{\"serviceVnfs\":[{\"version\":\"v1\",\"modelCustomizationUuid\":\"16ea3e56-a8ce-4ad7-8edd-4d2eae095391\",\"modelInstanceName\":\"ciVFOnboarded-FNAT-aab06c41 1\",\"created\":null,\"vnfResourceModelUuid\":null,\"vnfResourceModelUUID\":null,\"minInstances\":null,\"maxInstances\":null,\"availabilityZoneMaxCount\":null,\"vnfResource\":null,\"nfFunction\":null,\"nfType\":null,\"nfRole\":null,\"nfNamingCode\":null,\"multiStageDesign\":null,\"vfModuleCustomizations\":null,\"serviceResourceCustomizations\":null,\"creationTimestamp\":null}]}") - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); - - Mockito.doReturn(resp).when(spyAdapter).serviceNetworksImpl(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString()); - - // Run - - Response ret = spyAdapter.serviceNetworksImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391",null, null, null, null); - Mockito.verify(spyAdapter).serviceNetworksImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null, null); - - assertTrue(ret.getStatus() == HttpStatus.SC_OK); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - - } - - @Test - public void serviceAllottedResourcesImpl_Test() - { - CatalogDbAdapterRest adapter = new CatalogDbAdapterRest(); - CatalogDbAdapterRest spyAdapter = Mockito.spy(adapter); - - Response resp = Response - .status(HttpStatus.SC_OK) - .entity("{\"serviceVnfs\":[{\"version\":\"v1\",\"modelCustomizationUuid\":\"16ea3e56-a8ce-4ad7-8edd-4d2eae095391\",\"modelInstanceName\":\"ciVFOnboarded-FNAT-aab06c41 1\",\"created\":null,\"vnfResourceModelUuid\":null,\"vnfResourceModelUUID\":null,\"minInstances\":null,\"maxInstances\":null,\"availabilityZoneMaxCount\":null,\"vnfResource\":null,\"nfFunction\":null,\"nfType\":null,\"nfRole\":null,\"nfNamingCode\":null,\"multiStageDesign\":null,\"vfModuleCustomizations\":null,\"serviceResourceCustomizations\":null,\"creationTimestamp\":null}]}") - .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) - .build(); - - Mockito.doReturn(resp).when(spyAdapter).serviceAllottedResourcesImpl(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString()); - - // Run - - Response ret = spyAdapter.serviceAllottedResourcesImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391",null, null, null); - Mockito.verify(spyAdapter).serviceAllottedResourcesImpl("v1", false, "16ea3e56-a8ce-4ad7-8edd-4d2eae095391", null, null, null); - - assertTrue(ret.getStatus() == HttpStatus.SC_OK); - String s = resp.getEntity().toString(); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - // end - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - - assertEquals(resp.getStatus(), HttpStatus.SC_OK); - assertEquals(jArray.size(), 1); - assertEquals(jArray.getJsonObject(0).getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - - } - -} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java deleted file mode 100644 index ae5e663777..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestHttpTest.java +++ /dev/null @@ -1,490 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.catalogdb; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -import org.jboss.resteasy.plugins.server.tjws.TJWSEmbeddedJaxrsServer; -import static org.junit.Assert.*; - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -import org.jboss.resteasy.spi.Registry; -import org.jboss.resteasy.spi.ResteasyProviderFactory; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.openecomp.mso.adapters.catalogdb.CatalogDbAdapterRest; -import org.openecomp.mso.db.catalog.CatalogDatabase; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; -import org.openecomp.mso.db.catalog.beans.VfModule; -import org.openecomp.mso.db.catalog.beans.VfModuleCustomization; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.apache.http.HttpStatus; -import org.jboss.resteasy.client.jaxrs.ResteasyClient; -import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; -import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; -import org.powermock.modules.junit4.PowerMockRunner; - - -@RunWith(PowerMockRunner.class) -@PrepareForTest({CatalogDatabase.class}) -@PowerMockIgnore("javax.net.ssl.*") -public class CatalogDbAdapterRestHttpTest { - @Mock - private static CatalogDatabase dbMock; - private static TJWSEmbeddedJaxrsServer server; - private static final int PORT = 3099; - private static Registry registry; - private static ResteasyProviderFactory factory; - - @BeforeClass - public static void beforeClass() throws Exception { - server = new TJWSEmbeddedJaxrsServer(); - server.setPort(PORT); - server.start(); - registry = server.getDeployment().getRegistry(); - factory = server.getDeployment().getDispatcher().getProviderFactory(); - registry.addPerRequestResource(CatalogDbAdapterRest.class); - factory.registerProvider(CatalogDbAdapterRest.class); - } - - @Before - public void before(){ - PowerMockito.mockStatic(CatalogDatabase.class); - dbMock = PowerMockito.mock(CatalogDatabase.class); - PowerMockito.when(CatalogDatabase.getInstance()).thenReturn(dbMock); - - try { - PowerMockito.whenNew(CatalogDatabase.class).withAnyArguments().thenReturn(dbMock); - - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void healthCheck_Test(){ - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/healthcheck"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - assertTrue(value.contains("Application v1 ready")); - } - - @Test - public void vnfResourcesUrl_Test() - { - try { - List<VnfResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - VnfResourceCustomization d1 = new VnfResourceCustomization(); - d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - d1.setModelInstanceName("RG_6-26_mog11 0"); - d1.setVersion("v1"); - paramList.add(d1); - PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/vnfResources/16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - assertTrue(jArray.size() == 1); - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String version = rec.getString("version"); - String uuid = rec.getString("modelCustomizationUuid"); - - assertTrue(version.equals("v1")); - assertTrue(uuid.equals("16ea3e56-a8ce-4ad7-8edd-4d2eae095391")); - } - // end - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Test - public void serviceVnfsUrl_smiUuid_smVer_Test(){ - try { - List<VnfResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - VnfResourceCustomization d1 = new VnfResourceCustomization(); - d1.setVnfResourceModelUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - d1.setModelInstanceName("RG_6-26_mog11 0"); - d1.setVersion("v1"); - d1.setMaxInstances(50); - paramList.add(d1); - PowerMockito.when(dbMock.getAllVnfsByServiceModelInvariantUuid(Mockito.anyString(),Mockito.anyString())).thenReturn (paramList); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceVnfs?serviceModelInvariantUuid=16ea3e56-a8ce-4ad7-8edd-4d2eae095391&serviceModelVersion=ver1"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - assertTrue(jArray.size() == 1); - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String version = rec.getString("version"); - String uuid = rec.getString("vnfResourceModelUuid"); - int maxInstance = rec.getInt("maxInstances"); - - assertTrue(version.equals("v1")); - assertTrue(uuid.equals("16ea3e56-a8ce-4ad7-8edd-4d2eae095391")); - assertTrue(maxInstance == 50); - } - // end - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void serviceVnfsUrl_vnfUuid_Test(){ - try { - List<VnfResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - VnfResourceCustomization d1 = new VnfResourceCustomization(); - d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - d1.setModelInstanceName("RG_6-26_mog11 0"); - d1.setVersion("v1"); - paramList.add(d1); - PowerMockito.when(dbMock.getAllVnfsByVnfModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceVnfs?vnfModelCustomizationUuid=16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // System.out.println(value); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceVnfs"); - assertTrue(jArray.size() == 1); - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String version = rec.getString("version"); - String uuid = rec.getString("modelCustomizationUuid"); - - assertTrue(version.equals("v1")); - assertTrue(uuid.equals("16ea3e56-a8ce-4ad7-8edd-4d2eae095391")); - } - // end - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void networkResourcesUrl_nUuid_Ver_Test(){ - try { - List<NetworkResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - NetworkResourceCustomization d1 = new NetworkResourceCustomization(); - d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - PowerMockito.when(dbMock.getAllNetworksByNetworkModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/networkResources/0cb9b26a-9820-48a7-86e5-16c510e993d9"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // System.out.println(value); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceNetworks"); - assertTrue(jArray.size() == 1); - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String uuid = rec.getString("networkResourceModelUuid"); - - assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - } - // end - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void serviceNetworksUrl_nType_Test(){ - try { - List<NetworkResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - NetworkResourceCustomization d1 = new NetworkResourceCustomization(); - d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - PowerMockito.when(dbMock.getAllNetworksByNetworkType(Mockito.anyString())).thenReturn (paramList); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceNetworks?networkModelName=0cb9b26a-9820-48a7-86e5-16c510e993d9"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // System.out.println(value); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceNetworks"); - assertTrue(jArray.size() == 1); - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String uuid = rec.getString("networkResourceModelUuid"); - - assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - } - // end - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void serviceResourcesUrl_smiUuid_Ver_Test(){ - try { - ArrayList<NetworkResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - NetworkResourceCustomization d1 = new NetworkResourceCustomization(); - d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - ServiceMacroHolder ret = new ServiceMacroHolder(); - ret.setNetworkResourceCustomization(paramList); - PowerMockito.when(dbMock.getAllResourcesByServiceModelInvariantUuid(Mockito.anyString(),Mockito.anyString())).thenReturn (ret); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceResources?serviceModelInvariantUuid=0cb9b26a-9820-48a7-86e5-16c510e993d9&serviceModelVersion=ver1"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // System.out.println(value); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonObject obj = respObj.getJsonObject("serviceResources"); - JsonArray jArray = obj.getJsonArray("networkResourceCustomization"); - assertTrue(jArray.size() == 1); - - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String uuid = rec.getString("networkResourceModelUuid"); - - assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - } - // end - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void allottedResourcesUrl_aUuid_Test() - { - try { - List<AllottedResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - AllottedResourceCustomization d1 = new AllottedResourceCustomization(); - d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - PowerMockito.when(dbMock.getAllAllottedResourcesByArModelCustomizationUuid(Mockito.anyString())).thenReturn (paramList); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/allottedResources/0cb9b26a-9820-48a7-86e5-16c510e993d9"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // System.out.println(value); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceAllottedResources"); - assertTrue(jArray.size() == 1); - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String uuid = rec.getString("arModelUuid"); - - assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - } - // end - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - - } - - @Test - public void serviceAllottedResourcesUrl_smiUuid_Test() - { - try { - List<AllottedResourceCustomization> paramList; - // set up mock return value - paramList = new ArrayList<>(); - AllottedResourceCustomization d1 = new AllottedResourceCustomization(); - d1.setArModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - PowerMockito.when(dbMock.getAllAllottedResourcesByServiceModelInvariantUuid(Mockito.anyString(), Mockito.anyString())).thenReturn (paramList); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/serviceAllottedResources?serviceModelInvariantUuid=0cb9b26a-9820-48a7-86e5-16c510e993d9&serviceModelVersion=ver1"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // System.out.println(value); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceAllottedResources"); - assertTrue(jArray.size() == 1); - if(jArray.size() == 1){ - JsonObject rec = jArray.getJsonObject(0); - String uuid = rec.getString("arModelUuid"); - - assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - } - // end - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test - public void vfModulesUrl_modelName_Test() - { - try { - // set up mock return value - VfModule vfm = new VfModule(); - vfm.setModelName("test Model"); - vfm.setModelUUID("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - - VfModuleCustomization ret = new VfModuleCustomization(); - ret.setVfModule(vfm); - PowerMockito.when(dbMock.getVfModuleCustomizationByModelName(Mockito.anyString())).thenReturn (ret); - // end - - // Run - ResteasyClient client = new ResteasyClientBuilder().build(); - ResteasyWebTarget target = client.target("http://localhost:3099/v1/vfModules?vfModuleModelName=0cb9b26a-9820-48a7-86e5-16c510e993d9"); - Response response = target.request().get(); - String value = response.readEntity(String.class); - - // System.out.println(value); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(value.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonObject jObj = respObj.getJsonObject("modelInfo"); - String uuid = jObj.getString("modelUuid"); - String name = jObj.getString("modelName"); - assertTrue(uuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - assertTrue(name.equals("test Model")); - // end - - } catch (Exception e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @AfterClass - public static void afterClass() throws Exception { - server.stop(); - } -} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestTest.java deleted file mode 100644 index 2e22e97a81..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/CatalogDbAdapterRestTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.openecomp.mso.adapters.catalogdb; - -import org.junit.Test; - -public class CatalogDbAdapterRestTest { - - CatalogDbAdapterRest catalogDbAdapterRest = new CatalogDbAdapterRest(); - - @Test(expected = NullPointerException.class) - public void respond() throws Exception { - catalogDbAdapterRest.respond(null, 0, true, null); - } - - @Test - public void healthcheck() throws Exception { - catalogDbAdapterRest.healthcheck("test"); - } - - @Test - public void serviceVnfs() throws Exception { - catalogDbAdapterRest.serviceVnfs("test", "test"); - } - - @Test - public void serviceVnfs1() throws Exception { - catalogDbAdapterRest.serviceVnfs("test", "test", "test", "test", "test", "test"); - } - - @Test - public void serviceVnfsImpl() throws Exception { - catalogDbAdapterRest.serviceVnfsImpl("test", false, "test", "test", "test", "test", "test"); - } - - @Test - public void serviceNetworks() throws Exception { - catalogDbAdapterRest.serviceNetworks("test", "test"); - } - - @Test - public void serviceNetworks1() throws Exception { - catalogDbAdapterRest.serviceNetworks("test", "test", "test", "test", "test", "test", "test", "test"); - } - - @Test - public void serviceNetworksImpl() throws Exception { - catalogDbAdapterRest.serviceNetworksImpl("test", false, "test", "test", "test", "test", "test"); - } - - @Test - public void serviceResources() throws Exception { - catalogDbAdapterRest.serviceResources("test", "test", "test", "test"); - } - - @Test - public void serviceAllottedResources() throws Exception { - catalogDbAdapterRest.serviceAllottedResources("test", "test"); - } - - @Test - public void serviceAllottedResources1() throws Exception { - catalogDbAdapterRest.serviceAllottedResources("test", "test", "test", "test", "test"); - } - - @Test - public void serviceAllottedResourcesImpl() throws Exception { - catalogDbAdapterRest.serviceAllottedResourcesImpl("test", false, "test", "test", "test", "test"); - } - - @Test - public void vfModules() throws Exception { - catalogDbAdapterRest.vfModules("test"); - } - - @Test - public void serviceToscaCsar() throws Exception { - catalogDbAdapterRest.serviceToscaCsar("test"); - } - - @Test - public void resourceRecipe() throws Exception { - catalogDbAdapterRest.resourceRecipe("test", "test"); - } - -}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java deleted file mode 100644 index a4a5df7536..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/CatalogQueryTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.catalogdb.catalogrest; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; - -public class CatalogQueryTest { - private static final String MAP_KEY = "keyTest"; - private static final String VALUE_MAP = "valueTest"; - private CatalogQuery testedObject; - - @Before - public void init() { - testedObject = new CatalogQueryForTesting(); - } - - @Test - public void putStringValueToMap() { - Map<String, String> valueMap = new HashMap<>(); - testedObject.put(valueMap, MAP_KEY, VALUE_MAP); - assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "\"valueTest\""); - } - - @Test - public void putNullStringValueToMap() { - Map<String, String> valueMap = new HashMap<>(); - String value = null; - testedObject.put(valueMap, MAP_KEY, value); - assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "null"); - } - - @Test - public void putIntegerValueToMap() { - Map<String, String> valueMap = new HashMap<>(); - testedObject.put(valueMap, MAP_KEY, 1); - assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "1"); - } - - @Test - public void putNullIntegerValueToMap() { - Map<String, String> valueMap = new HashMap<>(); - Integer value = null; - testedObject.put(valueMap, MAP_KEY, value); - assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "null"); - } - - @Test - public void putTrueBooleanValueToMap() { - Map<String, String> valueMap = new HashMap<>(); - testedObject.put(valueMap, MAP_KEY, true); - assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "true"); - } - - @Test - public void putFalseBooleanValueToMap() { - Map<String, String> valueMap = new HashMap<>(); - testedObject.put(valueMap, MAP_KEY, false); - assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "false"); - } - - @Test - public void putNullBooleanValueToMap() { - Map<String, String> valueMap = new HashMap<>(); - Boolean value = null; - testedObject.put(valueMap, MAP_KEY, value); - assertThat(valueMap).hasSize(1).containsEntry(MAP_KEY, "null"); - } - - @Test - public void setTemplate_keyFindInMap() { - Map<String, String> valueMap = new HashMap<>(); - valueMap.put(MAP_KEY, VALUE_MAP); - String template = "<keyTest>"; - String result = testedObject.setTemplate(template, valueMap); - assertThat(result).isEqualTo(VALUE_MAP); - } - - @Test - public void setTemplate_keyNotFindInMap() { - Map<String, String> valueMap = new HashMap<>(); - String template = "<keyTest>"; - String result = testedObject.setTemplate(template, valueMap); - assertThat(result).isEqualTo("\"TBD\""); - } - - @Test - public void setTemplate_templateDoesNotMatch() { - Map<String, String> valueMap = new HashMap<>(); - String template = "key"; - String result = testedObject.setTemplate(template, valueMap); - assertThat(result).isEqualTo("key"); - } - - @Test - public void smartToJson(){ - String expectedResult = "{\"s\":\"s1\"}"; - assertThat(testedObject.smartToJSON()).isEqualTo(expectedResult); - } - - @Test - public void toJsonString_withVersion1() { - String expectedResult = "{\"s\":\"s1\"}"; - assertThat(testedObject.toJsonString("v1",true)).isEqualTo(expectedResult); - } - - @Test - public void toJsonString_withVersion2() { - assertThat(testedObject.toJsonString("v2",true)).isEqualTo("json2"); - } - - @Test - public void toJsonString_withInvalidVersion() { - assertThat(testedObject.toJsonString("ver77",true)).isEqualTo("invalid version: ver77"); - } - - private class CatalogQueryForTesting extends CatalogQuery { - - private String s = "s1"; - - public String getS() { - return s; - } - - @Override - public String JSON2(boolean isArray, boolean isEmbed) { - return "json2"; - } - } - -} - - diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java deleted file mode 100644 index 0d86a6cf10..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryAllottedResourceCustomizationTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.catalogdb.catalogrest; - -import static org.junit.Assert.assertEquals; - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.openecomp.mso.db.catalog.beans.AllottedResourceCustomization; - -@RunWith(MockitoJUnitRunner.class) -public class QueryAllottedResourceCustomizationTest { - - @Test - public void JSON2_Test() - { - List<AllottedResourceCustomization> paramList; - paramList = new ArrayList<>(); - AllottedResourceCustomization d1 = new AllottedResourceCustomization(); - d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - d1.setModelCustomizationUuid("16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - paramList.add(d1); - - QueryAllottedResourceCustomization qarcObj = new QueryAllottedResourceCustomization(paramList); - String ret = qarcObj.JSON2(true, true); - System.out.println(ret); - ret = "{" + ret + "}"; - - JsonReader reader = Json.createReader(new StringReader(ret.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray jArray = respObj.getJsonArray("serviceAllottedResources"); - assertEquals(jArray.size(), 1); - - assertEquals(jArray.getJsonObject(0).getJsonObject("modelInfo").getString("modelInstanceName"), "0cb9b26a-9820-48a7-86e5-16c510e993d9"); - assertEquals(jArray.getJsonObject(0).getJsonObject("modelInfo").getString("modelCustomizationUuid"), "16ea3e56-a8ce-4ad7-8edd-4d2eae095391"); - } - -} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java deleted file mode 100644 index 3a767a8609..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceMarcoHolderTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.catalogdb.catalogrest; - -import static org.junit.Assert.assertTrue; - -import java.io.StringReader; -import java.util.ArrayList; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; - -@RunWith(MockitoJUnitRunner.class) -public class QueryServiceMarcoHolderTest { - - @Test - public void JSON2_Test() - { - Service svc = new Service(); - svc.setModelUUID("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - svc.setModelName("Testing Model One"); - ArrayList<NetworkResourceCustomization> paramList; - paramList = new ArrayList<>(); - NetworkResourceCustomization d1 = new NetworkResourceCustomization(); - d1.setNetworkResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - ServiceMacroHolder ret = new ServiceMacroHolder(svc); - ret.setNetworkResourceCustomization(paramList); - QueryServiceMacroHolder holder = new QueryServiceMacroHolder(ret); - String s = holder.JSON2(true, true); - - // System.out.println(s); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonObject obj = respObj.getJsonObject("serviceResources"); - JsonObject obj2 = obj.getJsonObject("modelInfo"); - String modelName = obj2.getString("modelName"); - String modelUuid = obj2.getString("modelUuid"); - - assertTrue(modelName.equals("Testing Model One")); - assertTrue(modelUuid.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - // end - } -} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java deleted file mode 100644 index 1c855eaa72..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceNetworksTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.catalogdb.catalogrest; - -import static org.junit.Assert.assertTrue; - -import java.io.StringReader; -import java.util.ArrayList; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.Service; -import org.openecomp.mso.db.catalog.beans.ServiceMacroHolder; - -@RunWith(MockitoJUnitRunner.class) -public class QueryServiceNetworksTest { - - - @Test - public void JSON2_Test() - { - ArrayList<NetworkResourceCustomization> paramList; - paramList = new ArrayList<>(); - NetworkResourceCustomization d1 = new NetworkResourceCustomization(); - d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - QueryServiceNetworks qsn = new QueryServiceNetworks(paramList); - - String s = qsn.JSON2(true, true); - s = "{" + s + "}"; - System.out.println(s); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray objArr = respObj.getJsonArray("serviceNetworks"); - - assertTrue(objArr.size() == 1); - - JsonObject obj2 = objArr.getJsonObject(0).getJsonObject("modelInfo"); - String modelName = obj2.getString("modelInstanceName"); - - assertTrue(modelName.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - // end - } -} diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java deleted file mode 100644 index 8c8fc967da..0000000000 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/openecomp/mso/adapters/catalogdb/catalogrest/QueryServiceVnfsTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.adapters.catalogdb.catalogrest; - -import static org.junit.Assert.assertTrue; - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -import javax.json.Json; -import javax.json.JsonArray; -import javax.json.JsonObject; -import javax.json.JsonReader; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.runners.MockitoJUnitRunner; -import org.openecomp.mso.db.catalog.beans.NetworkResourceCustomization; -import org.openecomp.mso.db.catalog.beans.VnfResourceCustomization; - -@RunWith(MockitoJUnitRunner.class) -public class QueryServiceVnfsTest { - - @Test - public void JSON2_Test() - { - List<VnfResourceCustomization> paramList; - paramList = new ArrayList<>(); - VnfResourceCustomization d1 = new VnfResourceCustomization(); - d1.setModelInstanceName("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - d1.setVnfResourceModelUuid("0cb9b26a-9820-48a7-86e5-16c510e993d9"); - paramList.add(d1); - QueryServiceVnfs qsn = new QueryServiceVnfs(paramList); - - String s = qsn.JSON2(true, true); - s = "{" + s + "}"; - System.out.println(s); - - // prepare to inspect response - JsonReader reader = Json.createReader(new StringReader(s.replaceAll("\r?\n", ""))); - JsonObject respObj = reader.readObject(); - reader.close(); - JsonArray objArr = respObj.getJsonArray("serviceVnfs"); - - assertTrue(objArr.size() == 1); - - JsonObject obj2 = objArr.getJsonObject(0).getJsonObject("modelInfo"); - String modelName = obj2.getString("modelInstanceName"); - - assertTrue(modelName.equals("0cb9b26a-9820-48a7-86e5-16c510e993d9")); - // end - - } -} diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml new file mode 100644 index 0000000000..a1e62f5e85 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/resources/application-test.yaml @@ -0,0 +1,70 @@ +# TEST FILE +catalog.db.endpoint: "http://localhost:" + +ssl-enable: false +mso: + site-name: localDevEnv + logPath: logs + catalog: + db: + spring: + endpoint: "http://localhost:" + db: + auth: Basic YnBlbDptc28tZGItMTUwNyE= + +spring: + datasource: + url: jdbc:mariadb://localhost:3307/catalogdb + username: root + password: password + driver-class-name: org.mariadb.jdbc.Driver + initialize: true + data: classpath*:data.sql + jpa: + generate-ddl: false + show-sql: false + hibernate: + dialect: org.hibernate.dialect.MySQL5Dialect + storage_engine: innodb + naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy + enable-lazy-load-no-trans: true + database-platform: org.hibernate.dialect.MySQL5Dialect + ddl-auto: validate + security: + usercredentials: + - + username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client + - + username: bpel + password: '$2a$12$1xyutEZNfjGewIZRfKaE8eZE99f5sYFUmmM80BobI65KNjmcK0JuO' + role: BPEL-Client + - + username: mso_admin + password: '$2a$12$tidKuu.h88E2nuL95pTVY.ZOYMN/1dp29A9b1o.0GFDsVVSYlMkHa' + role: ACTUATOR +mariaDB4j: + dataDir: + port: 3307 + databaseName: catalogdb + +server: + port: 8080 + tomcat: + max-threads: 50 + + +#Actuator +management: + endpoints: + enabled-by-default: false + endpoint: + info: + enabled: true + +flyway: + baseline-on-migrate: false + url: jdbc:mariadb://localhost:3307/catalogdb + user: root + password: password diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql new file mode 100644 index 0000000000..1b71d16e57 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql @@ -0,0 +1,198 @@ + +insert into heat_files(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values +('00535bdd-0878-4478-b95a-c575c742bfb0', 'nimbus-ethernet-gw', '1', 'created from csar', 'DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n', 'MANUAL RECORD', '2017-01-21 23:56:43'); + + +insert into tosca_csar(artifact_uuid, name, version, description, artifact_checksum, url, creation_timestamp) values +('0513f839-459d-46b6-aa3d-2edfef89a079', 'service-Ciservicee3756aea561a-csar.csar', '1', 'TOSCA definition package of the asset', 'YTk1MmY2MGVlNzVhYTU4YjgzYjliMjNjMmM3NzU1NDc=', '/sdc/v1/catalog/services/Ciservicee3756aea561a/1.0/artifacts/service-Ciservicee3756aea561a-csar.csar', '2017-11-27 11:38:27'); + + +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002671', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '1.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', '0513f839-459d-46b6-aa3d-2edfef89a079', 'NA', 'NA', 'Luna', 'Oxygen'); + +insert into tosca_csar(ARTIFACT_UUID,NAME,VERSION,DESCRIPTION,ARTIFACT_CHECKSUM,URL,CREATION_TIMESTAMP) values +('266eaf78-af74-45cd-83ec-9c477f189dc1','service-NetworkCollectionSvc0106-csar.csar','1','TOSCA definition package of the asset','OGQ1M2QyYjU0OWMzZTY4MWVlYTNhOWIxNmQ2NjEyZDQ=','/sdc/v1/catalog/services/NetworkCollectionSvc0106/1.0/artifacts/service-NetworkCollectionSvc0106-csar.csar','2018-06-01 16:06:52'); +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('4694a55f-58b3-4f17-92a5-796d6f5ffd0d', 'Network_Collection_SVC_0106', 'afa5911f-87a7-4e99-a6dc-8e6cd7b86573', '1.0','tbd','2018-06-01 16:06:52', '266eaf78-af74-45cd-83ec-9c477f189dc1', 'INFRASTRUCTURE', '', 'General_Revenue-Bearing', 'Production'); +insert into collection_resource(MODEL_UUID,MODEL_NAME,MODEL_INVARIANT_UUID,MODEL_VERSION,TOSCA_NODE_TYPE,DESCRIPTION,CREATION_TIMESTAMP) values +('e083bdcd-449d-433d-9699-1bbc2d363f06','Network_Collection_Resource_1806','38273494-f61a-4645-bfe2-d971994bc3e5','1.0','org.openecomp.resource.cr.NetworkCollectionResource1806','tbd','2018-06-20 12:53:34'); +insert into collection_resource_customization(MODEL_CUSTOMIZATION_UUID,MODEL_INSTANCE_NAME,role,object_type,function,collection_resource_type,CREATION_TIMESTAMP,CR_MODEL_UUID) values +('a07a5826-3281-485c-8f40-6988011ef3f2','Network_Collection_Resource_1806','','NetworkCollection','','','2018-06-01 16:06:52','e083bdcd-449d-433d-9699-1bbc2d363f06'), +('a07a5826-3281-485c-8f40-6988011ef3f3','Network_Collection_Resource_1806','','NetworkCollection','','','2018-06-01 16:06:52','e083bdcd-449d-433d-9699-1bbc2d363f06'); +insert into collection_resource_customization_to_service(SERVICE_MODEL_UUID,RESOURCE_MODEL_CUSTOMIZATION_UUID) values +('4694a55f-58b3-4f17-92a5-796d6f5ffd0d', 'a07a5826-3281-485c-8f40-6988011ef3f2'); +insert into instance_group(MODEL_UUID, MODEL_NAME, MODEL_INVARIANT_UUID, MODEL_VERSION, TOSCA_NODE_TYPE, ROLE, OBJECT_TYPE, CREATION_TIMESTAMP, CR_MODEL_UUID, INSTANCE_GROUP_TYPE) values +("0c8692ef-b9c0-435d-a738-edf31e71f38b", "network_collection_resource_1806..NetworkCollection..0", "c675f5f6-c017-40cb-807a-cb806ad24c0f", "1", "org.openecomp.resource.cr.NetworkCollectionResource1806", "SUB_INTERFACE", "L3_NETWORK", "2018-05-25 14:33:28", "e083bdcd-449d-433d-9699-1bbc2d363f06", "L3_NETWORK"); +insert into collection_resource_instance_group_customization(COLLECTION_RESOURCE_CUSTOMIZATION_MODEL_UUID,INSTANCE_GROUP_MODEL_UUID,FUNCTION,DESCRIPTION,SUBINTERFACE_NETWORK_QUANTITY,CREATION_TIMESTAMP) values +('a07a5826-3281-485c-8f40-6988011ef3f2','0c8692ef-b9c0-435d-a738-edf31e71f38b','ncfunction','ncdescription',5,'2018-06-01 16:06:52'), +('a07a5826-3281-485c-8f40-6988011ef3f3','0c8692ef-b9c0-435d-a738-edf31e71f38b','ncfunction','ncdescription',5,'2018-06-01 16:06:52'); +insert into service(model_uuid, model_name, model_invariant_uuid, model_version, description, creation_timestamp, tosca_csar_artifact_uuid, service_type, service_role, environment_context, workload_context) values +('5df8b6de-2083-11e7-93ae-92361f002672', 'MSOTADevInfra_vSAMP10a_Service', '9647dfc4-2083-11e7-93ae-92361f002671', '2.0', 'MSO aLaCarte Vfmodule with addon', '2017-04-14 13:42:39', null, 'NA', 'NA', 'Luna', 'Oxygen'); + +insert into service_recipe(id, action, version_str, description, orchestration_uri, service_param_xsd, recipe_timeout, service_timeout_interim, creation_timestamp, service_model_uuid) values +('1', 'createInstance', '1', 'MSOTADevInfra aLaCarte', '/mso/async/services/CreateGenericALaCarteServiceInstance', null, '180', '0', '2017-04-14 19:18:20', '5df8b6de-2083-11e7-93ae-92361f002671'); + +insert into heat_template(artifact_uuid, name, version, description, body, timeout_minutes, artifact_checksum, creation_timestamp) values +('ff874603-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'), +('ff87482f-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'), +('aa874603-4222-11e7-9252-005056850d2e', 'module_mns_zrdm3frwl01exn_01_rgvm_1.yml', '1', 'created from csar', 'heat_template_version: 2013-05-23 description: heat template that creates TEST VNF parameters: TEST_server_name: type: string label: TEST server name description: TEST server name TEST_image_name: type: string label: image name description: TEST image name TEST_flavor_name: type: string label: TEST flavor name description: flavor name of TEST instance TEST_Role_net_name: type: string label: TEST network name description: TEST network name TEST_vnf_id: type: string label: TEST VNF Id description: TEST VNF Id resources:TEST: type: OS::Nova::Server properties: name: { get_param: TEST_server_name } image: { get_param: TEST_image_name } flavor: { get_param: TEST_flavor_name } networks: - port: { get_resource: TEST_port_0} metadata: vnf_id: {get_param: TEST_vnf_id} TEST_port_0: type: OS::Neutron::Port properties: network: { get_param: TEST_Role_net_name }', '60', 'MANUAL RECORD', '2017-01-21 23:26:56'); + + +insert into heat_template_params(heat_template_artifact_uuid, param_name, is_required, param_type, param_alias) values +('ff874603-4222-11e7-9252-005056850d2e', 'availability_zone_0', 1, 'string', ''), +('ff874603-4222-11e7-9252-005056850d2e', 'exn_direct_net_fqdn',1, 'string', ''), +('ff874603-4222-11e7-9252-005056850d2e', 'exn_hsl_net_fqdn', 1, 'string', ''); + +insert into heat_environment(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values +('fefb1601-4222-11e7-9252-005056850d2e', 'module_nso.env', '2', 'Auto-generated HEAT Environment deployment artifact', 'parameters:\n availability_zone_0: \"alln-zone-1\"\n nso_flavor_name: \"citeis.1vCPUx2GB\"\n nso_image_name: \"RHEL-6.8-BASE-20160912\"\n nso_name_0: \"zrdm3vamp01nso001\"\n nso_oam_ip_0: \"172.18.25.175\"\n nso_oam_net_gw: \"172.18.25.1\"\n nso_oam_net_mask: \"255.255.255.0\"\n nso_sec_grp_id: \"36f48d82-f099-4437-bfbc-70d9e5d420d1\"\n nso_srv_grp_id: \"e431c477-5bd1-476a-bfa9-e4ce16b8356b\"\n oam_net_id: \"nso_oam\"\n vf_module_id: \"145cd730797234b4a40aa99335abc143\"\n vnf_id: \"730797234b4a40aa99335157b02871cd\"\n vnf_name: \"Mobisupport\"\n', 'MWI2ODY0Yjc1NDJjNWU1NjdkMTAyMjVkNzFmZDU0MzA=', '2017-11-27 08:42:58'), +('fefb1751-4333-11e7-9252-005056850d2e', 'module_nso.env', '2', 'Auto-generated HEAT Environment deployment artifact', 'parameters:\n availability_zone_0: \"alln-zone-1\"\n nso_flavor_name: \"citeis.1vCPUx2GB\"\n nso_image_name: \"RHEL-6.8-BASE-20160912\"\n nso_name_0: \"zrdm3vamp01nso001\"\n nso_oam_ip_0: \"172.18.25.175\"\n nso_oam_net_gw: \"172.18.25.1\"\n nso_oam_net_mask: \"255.255.255.0\"\n nso_sec_grp_id: \"36f48d82-f099-4437-bfbc-70d9e5d420d1\"\n nso_srv_grp_id: \"e431c477-5bd1-476a-bfa9-e4ce16b8356b\"\n oam_net_id: \"nso_oam\"\n vf_module_id: \"145cd730797234b4a40aa99335abc143\"\n vnf_id: \"730797234b4a40aa99335157b02871cd\"\n vnf_name: \"Mobisupport\"\n', 'MWI2ODY0Yjc1NDJjNWU1NjdkMTAyMjVkNzFmZDU0MzA=', '2017-11-27 08:42:58'); + +insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values +('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002671', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '1.0', 'vSAMP10a', 'VF', null); + +insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values +('68dc9a92-214c-11e7-93ae-92361f002671', 'vSAMP10a 1', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002671', null); + + +insert into vf_module(model_uuid, model_invariant_uuid, model_version, model_name, description, is_base, heat_template_artifact_uuid, vol_heat_template_artifact_uuid, creation_timestamp, vnf_resource_model_uuid) values + +('20c4431c-246d-11e7-93ae-92361f002671', '78ca26d0-246d-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::base::module-0', 'vSAMP10a DEV Base', '1', 'ff874603-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'), +('066de97e-253e-11e7-93ae-92361f002671', '64efd51a-2544-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::PCM::module-1', 'vSAMP10a DEV PCM', '0', 'ff87482f-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'); + + +insert into vf_module_customization(model_customization_uuid, label, initial_count, min_instances, max_instances, availability_zone_count, heat_environment_artifact_uuid, vol_environment_artifact_uuid, creation_timestamp, vf_module_model_uuid) values +('cb82ffd8-252a-11e7-93ae-92361f002671', 'base', '1', '0', '0', '0', 'fefb1601-4222-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '20c4431c-246d-11e7-93ae-92361f002671'), +('b4ea86b4-253f-11e7-93ae-92361f002671', 'PCM', '0', '0', '0', '0', 'fefb1751-4333-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '066de97e-253e-11e7-93ae-92361f002671'); + + +insert into vnf_res_custom_to_vf_module_custom(vnf_resource_cust_model_customization_uuid, vf_module_cust_model_customization_uuid, creation_timestamp) values +('68dc9a92-214c-11e7-93ae-92361f002671', 'cb82ffd8-252a-11e7-93ae-92361f002671', '2017-05-26 15:08:24'), +('68dc9a92-214c-11e7-93ae-92361f002671', 'b4ea86b4-253f-11e7-93ae-92361f002671', '2017-05-26 15:08:24'); + +insert into allotted_resource(model_uuid, model_invariant_uuid, model_version, model_name, tosca_node_type, subcategory, description, creation_timestamp) values +('f6b7d4c6-e8a4-46e2-81bc-31cad5072842', 'b7a1b78e-6b6b-4b36-9698-8c9530da14af', '1.0', 'Tunnel_Xconn', '', '', '', '2017-05-26 15:08:24'); + +insert into allotted_resource_customization(model_customization_uuid, model_instance_name, providing_service_model_invariant_uuid, target_network_role, nf_type, nf_role, nf_function, nf_naming_code, min_instances, max_instances, ar_model_uuid, creation_timestamp) values +('367a8ba9-057a-4506-b106-fbae818597c6', 'Sec_Tunnel_Xconn 11', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'f6b7d4c6-e8a4-46e2-81bc-31cad5072842', TIMESTAMP '2017-01-20 16:14:20.0'); + + +insert into temp_network_heat_template_lookup(network_resource_model_name, heat_template_artifact_uuid, aic_version_min, aic_version_max) values +('CONTRAIL30_GNDIRECT', 'ff874603-4222-11e7-9252-005056850d2e', '3', '3'); + +insert into network_resource(model_uuid, model_name, model_invariant_uuid, description, heat_template_artifact_uuid, neutron_network_type, model_version, tosca_node_type, aic_version_min, aic_version_max, orchestration_mode, creation_timestamp) values +('10b36f65-f4e6-4be6-ae49-9596dc1c47fc', 'CONTRAIL30_GNDIRECT', 'ce4ff476-9641-4e60-b4d5-b4abbec1271d', 'Contrail 30 GNDIRECT NW', 'aa874603-4222-11e7-9252-005056850d2e', 'BASIC', '1.0', '', '3.0', '', 'HEAT', '2017-01-17 20:35:05'); + +insert into network_resource_customization(model_customization_uuid, model_instance_name, network_technology, network_type, network_role, network_scope, creation_timestamp, network_resource_model_uuid) values +('3bdbb104-476c-483e-9f8b-c095b3d308ac', 'CONTRAIL30_GNDIRECT 9', '', '', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c47fc'); +insert into collection_network_resource_customization(model_customization_uuid, model_instance_name, network_technology, network_type, network_role, network_scope, creation_timestamp, network_resource_model_uuid, instance_group_model_uuid, crc_model_customization_uuid) values +('1a61be4b-3378-4c9a-91c8-c919519b2d01', 'CONTRAIL30_GNDIRECT 9', '', '', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c47fc', '0c8692ef-b9c0-435d-a738-edf31e71f38b', 'a07a5826-3281-485c-8f40-6988011ef3f2'); + +insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values +('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002672', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '2.0', 'vSAMP10a', 'VF', null); + + +insert into vnf_resource_customization(model_customization_uuid, model_instance_name, min_instances, max_instances, availability_zone_max_count, nf_type, nf_role, nf_function, nf_naming_code, creation_timestamp, vnf_resource_model_uuid, multi_stage_design) values +('68dc9a92-214c-11e7-93ae-92361f002672', 'vSAMP10a 2', '0', '0', '0', 'vSAMP', 'vSAMP', 'vSAMP', 'vSAMP', '2017-05-26 15:08:24', 'ff2ae348-214a-11e7-93ae-92361f002672', null); + + + + + +insert into vf_module(model_uuid, model_invariant_uuid, model_version, model_name, description, is_base, heat_template_artifact_uuid, vol_heat_template_artifact_uuid, creation_timestamp, vnf_resource_model_uuid) values + +('20c4431c-246d-11e7-93ae-92361f002672', '78ca26d0-246d-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::base::module-0', 'vSAMP10a DEV Base', '1', 'ff874603-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'), +('066de97e-253e-11e7-93ae-92361f002672', '64efd51a-2544-11e7-93ae-92361f002671', '2', 'vSAMP10aDEV::PCM::module-1', 'vSAMP10a DEV PCM', '0', 'ff87482f-4222-11e7-9252-005056850d2e', null, '2016-09-14 18:19:56', 'ff2ae348-214a-11e7-93ae-92361f002671'); + + + +insert into vf_module_customization(model_customization_uuid, label, initial_count, min_instances, max_instances, availability_zone_count, heat_environment_artifact_uuid, vol_environment_artifact_uuid, creation_timestamp, vf_module_model_uuid) values +('cb82ffd8-252a-11e7-93ae-92361f002672', 'base', '1', '0', '0', '0', 'fefb1601-4222-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '20c4431c-246d-11e7-93ae-92361f002672'), +('b4ea86b4-253f-11e7-93ae-92361f002672', 'PCM', '0', '0', '0', '0', 'fefb1751-4333-11e7-9252-005056850d2e', null, '2017-05-26 15:08:23', '066de97e-253e-11e7-93ae-92361f002672'); + + +insert into vnf_res_custom_to_vf_module_custom(vnf_resource_cust_model_customization_uuid, vf_module_cust_model_customization_uuid, creation_timestamp) values +('68dc9a92-214c-11e7-93ae-92361f002672', 'cb82ffd8-252a-11e7-93ae-92361f002672', '2017-05-26 15:08:24'), +('68dc9a92-214c-11e7-93ae-92361f002672', 'b4ea86b4-253f-11e7-93ae-92361f002672', '2017-05-26 15:08:24'); + + + +insert into vf_module_to_heat_files(vf_module_model_uuid, heat_files_artifact_uuid) values +('20c4431c-246d-11e7-93ae-92361f002671', '00535bdd-0878-4478-b95a-c575c742bfb0'), +('066de97e-253e-11e7-93ae-92361f002671', '00535bdd-0878-4478-b95a-c575c742bfb0'); + + +insert into network_resource_customization_to_service(service_model_uuid, resource_model_customization_uuid) values +('5df8b6de-2083-11e7-93ae-92361f002671', '3bdbb104-476c-483e-9f8b-c095b3d308ac'), +('5df8b6de-2083-11e7-93ae-92361f002672', '3bdbb104-476c-483e-9f8b-c095b3d308ac'); + + +insert into vnf_resource_customization_to_service(service_model_uuid, resource_model_customization_uuid) values +('5df8b6de-2083-11e7-93ae-92361f002671', '68dc9a92-214c-11e7-93ae-92361f002671'), +('5df8b6de-2083-11e7-93ae-92361f002672', '68dc9a92-214c-11e7-93ae-92361f002672'); + +insert into allotted_resource_customization_to_service(service_model_uuid, resource_model_customization_uuid) values +('5df8b6de-2083-11e7-93ae-92361f002671', '367a8ba9-057a-4506-b106-fbae818597c6' ), +('5df8b6de-2083-11e7-93ae-92361f002672', '367a8ba9-057a-4506-b106-fbae818597c6'); + + + +insert into vnf_recipe(id, nf_role, action, service_type, version_str, description, orchestration_uri, vnf_param_xsd, recipe_timeout, creation_timestamp, vf_module_id) values +('61', '*', 'CREATE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/workflow/services/CreateGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), +('63', '*', 'DELETE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/deleteGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), +('65', '*', 'UPDATE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/workflow/services/updateGenericVNFV1', '', '180', '2016-06-03 10:14:10', ''), +('67', '*', 'CREATE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/CreateVfModule', '', '180', '2016-06-03 10:14:10', '*'), +('69', '*', 'DELETE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/DeleteVfModule', '', '180', '2016-06-03 10:14:10', '*'), +('71', '*', 'UPDATE_VF_MODULE', '', '1', 'Recipe Match All for VNFs if no custom flow exists', '/mso/async/services/UpdateVfModule', '', '180', '2016-06-03 10:14:10', '*'), +('77', 'VID_DEFAULT', 'createInstance', '', '1', 'VID_DEFAULT recipe to create VNF if no custom BPMN flow is found', '/mso/async/services/CreateVnfInfra', '', '180', '2016-09-14 19:18:20', ''), +('78', 'VID_DEFAULT', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete VNF if no custom BPMN flow is found', '/mso/async/services/DeleteVnfInfra', '', '180', '2016-09-14 19:18:20', ''), +('81', 'VID_DEFAULT', 'updateInstance', '', '1', 'VID_DEFAULT update', '/mso/async/services/UpdateVnfInfra', '', '180', '2017-07-28 18:19:39', ''), +('85', 'VID_DEFAULT', 'replaceInstance', '', '1', 'VID_DEFAULT replace', '/mso/async/services/ReplaceVnfInfra', '', '180', '2017-07-28 18:19:45', ''), +('10000', 'VID_DEFAULT', 'inPlaceSoftwareUpdate', '', '1', 'VID_DEFAULT inPlaceSoftwareUpdate', '/mso/async/services/VnfInPlaceUpdate', '', '180', '2017-10-25 18:19:45', ''), +('10001', 'VID_DEFAULT', 'applyUpdatedConfig', '', '1', 'VID_DEFAULT applyUpdatedConfig', '/mso/async/services/VnfConfigUpdate', '', '180', '2017-10-25 18:19:45', ''); + + +insert into vnf_components(vnf_id, component_type, heat_template_id, heat_environment_id, creation_timestamp) values +('13961', 'VOLUME', '13843', '13961', '2016-05-19 20:22:02'); + +insert into vnf_components_recipe(id, vnf_type, vnf_component_type, action, service_type, version, description, orchestration_uri, vnf_component_param_xsd, recipe_timeout, creation_timestamp, vf_module_model_uuid) values +('5', '*', 'VOLUME_GROUP', 'CREATE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/createCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), +('7', '*', 'VOLUME_GROUP', 'DELETE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/deleteCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), +('9', '*', 'VOLUME_GROUP', 'UPDATE', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/updateCinderVolumeV1', '', '180', '2016-06-03 10:15:11', ''), +('13', '', 'VOLUME_GROUP', 'DELETE_VF_MODULE_VOL', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/DeleteVfModuleVolume', '', '180', '2016-06-03 10:15:11', '*'), +('15', '', 'VOLUME_GROUP', 'UPDATE_VF_MODULE_VOL', '', '1', 'Recipe Match All for VF Modules if no custom flow exists', '/mso/async/services/UpdateVfModuleVolume', '', '180', '2016-06-03 10:15:11', '*'), +('16', '', 'volumeGroup', 'createInstance', '', '1', 'VID_DEFAULT recipe to create volume-group if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('17', '', 'volumeGroup', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete volume-group if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('18', '', 'volumeGroup', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update volume-group if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleVolumeInfraV1', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('19', '', 'vfModule', 'createInstance', '', '1', 'VID_DEFAULT recipe to create vf-module if no custom BPMN flow is found', '/mso/async/services/CreateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('20', '', 'vfModule', 'deleteInstance', '', '1', 'VID_DEFAULT recipe to delete vf-module if no custom BPMN flow is found', '/mso/async/services/DeleteVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('21', '', 'vfModule', 'updateInstance', '', '1', 'VID_DEFAULT recipe to update vf-module if no custom BPMN flow is found', '/mso/async/services/UpdateVfModuleInfra', '', '180', '2016-09-14 19:18:20', 'VID_DEFAULT'), +('25', '', 'vfModule', 'replaceInstance', '', '1', 'VID_DEFAULT vfModule replace', '/mso/async/services/ReplaceVfModuleInfra', '', '180', '2017-07-28 18:25:06', 'VID_DEFAULT'); + +insert into network_recipe(id, model_name, action, description, orchestration_uri, network_param_xsd, recipe_timeout, service_type, creation_timestamp, version_str) values +('1', 'CONTRAIL_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('2', 'CONTRAIL_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('3', 'CONTRAIL_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('4', 'CONTRAIL_SHARED', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('5', 'CONTRAIL_SHARED', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('6', 'CONTRAIL_SHARED', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('7', 'CONTRAIL_EXTERNAL', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('8', 'CONTRAIL_EXTERNAL', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('9', 'CONTRAIL_EXTERNAL', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-09-14 19:00:57', '1'), +('10', 'CONTRAIL30_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), +('11', 'CONTRAIL30_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), +('12', 'CONTRAIL30_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-05-26 14:48:13', '1'), +('13', 'NEUTRON_BASIC', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-06-01 19:54:51', '1'), +('17', 'VID_DEFAULT', 'createInstance', 'VID_DEFAULT recipe to create network if no custom BPMN flow is found', '/mso/async/services/CreateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), +('18', 'VID_DEFAULT', 'updateInstance', 'VID_DEFAULT recipe to update network if no custom BPMN flow is found', '/mso/async/services/UpdateNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), +('19', 'VID_DEFAULT', 'deleteInstance', 'VID_DEFAULT recipe to delete network if no custom BPMN flow is found', '/mso/async/services/DeleteNetworkInstance', '', '180', '', '2016-09-14 19:18:20', '1.0'), +('124', 'CONTRAIL30_MPSCE', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), +('126', 'CONTRAIL30_MPSCE', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), +('128', 'CONTRAIL30_MPSCE', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2016-10-18 18:47:52', '1'), +('141', 'CONTRAIL30_L2NODHCP', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), +('144', 'CONTRAIL30_L2NODHCP', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), +('147', 'CONTRAIL30_L2NODHCP', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-01-03 20:12:46', '1'), +('169', 'CONTRAIL30_GNDIRECT', 'CREATE', '', '/mso/async/services/CreateNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), +('172', 'CONTRAIL30_GNDIRECT', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), +('175', 'CONTRAIL30_GNDIRECT', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-01-17 20:25:34', '1'), +('176', 'NEUTRON_BASIC', 'DELETE', '', '/mso/async/services/DeleteNetworkV2', '', '180', '', '2017-09-22 18:47:31', '1'), +('177', 'NEUTRON_BASIC', 'UPDATE', '', '/mso/async/services/UpdateNetworkV2', '', '180', '', '2017-09-22 18:47:31', '1'); diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml b/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..aceeda408b --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,50 @@ +<configuration> + + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] |%X{RequestId}| %-5level + %logger{1024} - %msg%n + </pattern> + </encoder> + </appender> + + <appender name="test" + class="org.onap.so.adapters.catalogdb.catalogrest.TestAppender" /> + + <logger name="com.att.ecomp.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="WARN" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.onap" level="${so.log.level:-DEBUG}" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="org.flywaydb" level="DEBUG" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + + <logger name="ch.vorburger" level="WARN" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="AUDIT" level="info" additivity="true"> + <appender-ref ref="test" /> + </logger> + + <root level="WARN"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration>
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/response/expectedServiceResponse.json b/adapters/mso-catalog-db-adapter/src/test/resources/response/expectedServiceResponse.json new file mode 100644 index 0000000000..f92ca927ce --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/resources/response/expectedServiceResponse.json @@ -0,0 +1,78 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelUuid": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantUuid": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + }, + "serviceType": "NA", + "serviceRole": "NA", + "environmentContext": "Luna", + "workloadContext": "Oxygen", + "serviceVnfs": [{ + "modelInfo": { + "modelName": "vSAMP10a", + "modelUuid": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInvariantUuid": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationUuid": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelInstanceName": "vSAMP10a 1" + }, + "toscaNodeType": "VF", + "nfFunction": "vSAMP", + "nfType": "vSAMP", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "multiStageDesign": null, + "vfModules": { + "modelInfo": { + "modelName": "vSAMP10aDEV::PCM::module-1", + "modelUuid": "066de97e-253e-11e7-93ae-92361f002671", + "modelInvariantUuid": "64efd51a-2544-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationUuid": "b4ea86b4-253f-11e7-93ae-92361f002671" + }, + "isBase": false, + "vfModuleLabel": "PCM", + "initialCount": 0, + "hasVolumeGroup": false + } + }], + "serviceNetworks": [{ + "modelInfo": { + "modelName": "CONTRAIL30_GNDIRECT", + "modelUuid": "10b36f65-f4e6-4be6-ae49-9596dc1c47fc", + "modelInvariantUuid": "ce4ff476-9641-4e60-b4d5-b4abbec1271d", + "modelVersion": "1.0", + "modelCustomizationUuid": "3bdbb104-476c-483e-9f8b-c095b3d308ac", + "modelInstanceName": "CONTRAIL30_GNDIRECT 9" + }, + "toscaNodeType": "", + "networkType": "", + "networkTechnology": "", + "networkRole": "", + "networkScope": "" + }], + "serviceAllottedResources": { + "modelInfo": { + "modelName": "Tunnel_Xconn", + "modelUuid": "f6b7d4c6-e8a4-46e2-81bc-31cad5072842", + "modelInvariantUuid": "b7a1b78e-6b6b-4b36-9698-8c9530da14af", + "modelVersion": "1.0", + "modelCustomizationUuid": "367a8ba9-057a-4506-b106-fbae818597c6", + "modelInstanceName": "Sec_Tunnel_Xconn 11" + }, + "toscaNodeType": "", + "allottedResourceType": "", + "allottedResourceRole": null, + "providingServiceModelName": null, + "providingServiceModelInvariantUuid": null, + "providingServiceModelUuid": null, + "nfFunction": null, + "nfType": null, + "nfRole": null, + "nfNamingCode": null + } + } +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/response/expectedServiceResponseV2.json b/adapters/mso-catalog-db-adapter/src/test/resources/response/expectedServiceResponseV2.json new file mode 100644 index 0000000000..5026072fc3 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/resources/response/expectedServiceResponseV2.json @@ -0,0 +1,78 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelUuid": "5df8b6de-2083-11e7-93ae-92361f002672", + "modelInvariantUuid": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "2.0" + }, + "serviceType": "NA", + "serviceRole": "NA", + "environmentContext": "Luna", + "workloadContext": "Oxygen", + "serviceVnfs": [{ + "modelInfo": { + "modelName": "vSAMP10a", + "modelUuid": "ff2ae348-214a-11e7-93ae-92361f002672", + "modelInvariantUuid": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "2.0", + "modelCustomizationUuid": "68dc9a92-214c-11e7-93ae-92361f002672", + "modelInstanceName": "vSAMP10a 2" + }, + "toscaNodeType": "VF", + "nfFunction": "vSAMP", + "nfType": "vSAMP", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "multiStageDesign": null, + "vfModules": { + "modelInfo": { + "modelName": "vSAMP10aDEV::PCM::module-1", + "modelUuid": "066de97e-253e-11e7-93ae-92361f002672", + "modelInvariantUuid": "64efd51a-2544-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationUuid": "b4ea86b4-253f-11e7-93ae-92361f002672" + }, + "isBase": false, + "vfModuleLabel": "PCM", + "initialCount": 0, + "hasVolumeGroup": false + } + }], + "serviceNetworks": [{ + "modelInfo": { + "modelName": "CONTRAIL30_GNDIRECT", + "modelUuid": "10b36f65-f4e6-4be6-ae49-9596dc1c47fc", + "modelInvariantUuid": "ce4ff476-9641-4e60-b4d5-b4abbec1271d", + "modelVersion": "1.0", + "modelCustomizationUuid": "3bdbb104-476c-483e-9f8b-c095b3d308ac", + "modelInstanceName": "CONTRAIL30_GNDIRECT 9" + }, + "toscaNodeType": "", + "networkType": "", + "networkTechnology": "", + "networkRole": "", + "networkScope": "" + }], + "serviceAllottedResources": { + "modelInfo": { + "modelName": "Tunnel_Xconn", + "modelUuid": "f6b7d4c6-e8a4-46e2-81bc-31cad5072842", + "modelInvariantUuid": "b7a1b78e-6b6b-4b36-9698-8c9530da14af", + "modelVersion": "1.0", + "modelCustomizationUuid": "367a8ba9-057a-4506-b106-fbae818597c6", + "modelInstanceName": "Sec_Tunnel_Xconn 11" + }, + "toscaNodeType": "", + "allottedResourceType": "", + "allottedResourceRole": null, + "providingServiceModelName": null, + "providingServiceModelInvariantUuid": null, + "providingServiceModelUuid": null, + "nfFunction": null, + "nfType": null, + "nfRole": null, + "nfNamingCode": null + } + } +}
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/response/serviceResponse.json b/adapters/mso-catalog-db-adapter/src/test/resources/response/serviceResponse.json new file mode 100644 index 0000000000..e6862579df --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/test/resources/response/serviceResponse.json @@ -0,0 +1,78 @@ +{ + "serviceResources": { + "modelInfo": { + "modelName": "MSOTADevInfra_vSAMP10a_Service", + "modelUuid": "5df8b6de-2083-11e7-93ae-92361f002671", + "modelInvariantUuid": "9647dfc4-2083-11e7-93ae-92361f002671", + "modelVersion": "1.0" + }, + "serviceType": "NA", + "serviceRole": "NA", + "environmentContext": "Luna", + "workloadContext": "Oxygen", + "serviceVnfs": [{ + "modelInfo": { + "modelName": "vSAMP10a", + "modelUuid": "ff2ae348-214a-11e7-93ae-92361f002671", + "modelInvariantUuid": "2fff5b20-214b-11e7-93ae-92361f002671", + "modelVersion": "1.0", + "modelCustomizationUuid": "68dc9a92-214c-11e7-93ae-92361f002671", + "modelInstanceName": "vSAMP10a 1" + }, + "toscaNodeType": "VF", + "nfFunction": "vSAMP", + "nfType": "vSAMP", + "nfRole": "vSAMP", + "nfNamingCode": "vSAMP", + "multiStageDesign": null, + "vfModules": { + "modelInfo": { + "modelName": "vSAMP10aDEV::PCM::module-1", + "modelUuid": "066de97e-253e-11e7-93ae-92361f002671", + "modelInvariantUuid": "64efd51a-2544-11e7-93ae-92361f002671", + "modelVersion": "2", + "modelCustomizationUuid": "b4ea86b4-253f-11e7-93ae-92361f002671" + }, + "isBase": false, + "vfModuleLabel": "PCM", + "initialCount": 0, + "hasVolumeGroup": false + } + }], + "serviceNetworks": [{ + "modelInfo": { + "modelName": "CONTRAIL30_GNDIRECT", + "modelUuid": "10b36f65-f4e6-4be6-ae49-9596dc1c47fc", + "modelInvariantUuid": "ce4ff476-9641-4e60-b4d5-b4abbec1271d", + "modelVersion": null, + "modelCustomizationUuid": "3bdbb104-476c-483e-9f8b-c095b3d308ac", + "modelInstanceName": "CONTRAIL30_GNDIRECT 9" + }, + "toscaNodeType": "", + "networkType": "", + "networkTechnology": "", + "networkRole": "", + "networkScope": "" + }], + "serviceAllottedResources": [{ + "modelInfo": { + "modelName": "Tunnel_Xconn", + "modelUuid": "f6b7d4c6-e8a4-46e2-81bc-31cad5072842", + "modelInvariantUuid": "b7a1b78e-6b6b-4b36-9698-8c9530da14af", + "modelVersion": "1.0", + "modelCustomizationUuid": "367a8ba9-057a-4506-b106-fbae818597c6", + "modelInstanceName": "Sec_Tunnel_Xconn 11" + }, + "toscaNodeType": "", + "allottedResourceType": "", + "allottedResourceRole": null, + "providingServiceModelName": null, + "providingServiceModelInvariantUuid": null, + "providingServiceModelUuid": null, + "nfFunction": null, + "nfType": null, + "nfRole": null, + "nfNamingCode": null + }] + } +}
\ No newline at end of file |