diff options
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test/java')
13 files changed, 1011 insertions, 1061 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java index 3c05f8164b..4ffa38dd96 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/AllTestsTestSuite.java @@ -19,14 +19,14 @@ */ package org.onap.so.adapters.catalogdb; -import org.junit.runner.RunWith; +import org.junit.runner.RunWith; import com.googlecode.junittoolbox.SuiteClasses; import com.googlecode.junittoolbox.WildcardPatternSuite; @RunWith(WildcardPatternSuite.class) @SuiteClasses("**/*Test.class") public class AllTestsTestSuite { - // the class remains empty, - // used only as a holder for the above annotations + // the class remains empty, + // used only as a holder for the above annotations } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java index b2a20681d9..3fb156d68a 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/CatalogDbAdapterBaseTest.java @@ -12,10 +12,10 @@ import org.springframework.test.context.junit4.SpringRunner; @ActiveProfiles("test") public class CatalogDbAdapterBaseTest { - @LocalServerPort - protected int port; - - - @Test - public void testNothing(){} + @LocalServerPort + protected int port; + + + @Test + public void testNothing() {} } 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 index 5d9eedb20f..eaf1bb3e4b 100644 --- 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 @@ -19,6 +19,7 @@ */ package org.onap.so.adapters.catalogdb; + import ch.vorburger.exec.ManagedProcessException; import ch.vorburger.mariadb4j.DBConfigurationBuilder; import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; @@ -30,7 +31,7 @@ import org.springframework.context.annotation.Profile; import javax.sql.DataSource; @Configuration -@Profile({"test","local"}) +@Profile({"test", "local"}) public class EmbeddedMariaDbConfig { @Bean @@ -40,21 +41,16 @@ public class EmbeddedMariaDbConfig { @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 + @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(); + 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 index bd8c5bc3e3..145ba50583 100644 --- 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 @@ -29,13 +29,10 @@ import static org.onap.so.logger.MdcConstants.RESPONSECODE; import static org.onap.so.logger.MdcConstants.RESPONSEDESC; import static org.onap.so.logger.MdcConstants.SERVICE_NAME; import static org.onap.so.logger.MdcConstants.STATUSCODE; - 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.Test; import org.onap.logging.ref.slf4j.ONAPLogConstants; @@ -48,799 +45,801 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; - import ch.qos.logback.classic.spi.ILoggingEvent; public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { - private static final String ECOMP_MSO_CATALOG_V2_VF_MODULES = "ecomp/mso/catalog/v2/vfModules"; + 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_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe"; + + 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"; + + TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); + + HttpHeaders headers = new HttpHeaders(); - private static final String ECOMP_MSO_CATALOG_V2_SERVICE_ALLOTTED_RESOURCES = "ecomp/mso/catalog/v2/serviceAllottedResources"; + 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 static final String ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE = "ecomp/mso/catalog/v2/resourceRecipe"; + 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 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 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 static final String ECOMP_MSO_CATALOG_V2_SERVICE_RESOURCES = "ecomp/mso/catalog/v2/serviceResources"; + 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}"; - TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); + 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}"; - 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 badQueryParamResponse = + "{\"messageId\":null,\"message\":\"no matching parameters\",\"category\":\"INTERNAL\",\"rolledBack\":false}\""; - 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 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 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 serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; - 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 arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df"; - private final String arResourceUUID = "25e2d69b-3b22-47b8-b4c9-7b14fd4a80df"; - - private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671"; - - /* Health Check Resources Endpoint */ - - @Test - public void testHealthcheck() throws JSONException { + private final String serviceInvariantUUID = "9647dfc4-2083-11e7-93ae-92361f002671"; - HttpEntity<String> entity = new HttpEntity<String>(null, headers); + /* Health Check Resources Endpoint */ - ResponseEntity<String> response = restTemplate.exchange( - createURLWithPort("/manage/health"), - HttpMethod.GET, entity, String.class); - - assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); - for(ILoggingEvent logEvent : TestAppender.events) - if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY") - ){ - Map<String,String> mdc = logEvent.getMDCPropertyMap(); + @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()); + for (ILoggingEvent logEvent : TestAppender.events) + if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") + && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("ENTRY")) { + Map<String, String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INSTANCE_UUID)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("INPROGRESS",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); - }else if(logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") && - logEvent.getMarker()!= null && logEvent.getMarker().getName().equals("EXIT")){ - Map<String,String> mdc = logEvent.getMDCPropertyMap(); + assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); + assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); + assertEquals("INPROGRESS", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); + } else if (logEvent.getLoggerName().equals("org.onap.so.logging.spring.interceptor.LoggingInterceptor") + && logEvent.getMarker() != null && logEvent.getMarker().getName().equals("EXIT")) { + Map<String, String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.INVOCATION_ID)); - assertEquals("200",mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE)); - assertEquals("",mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); - assertEquals("/manage/health",mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); - assertEquals("COMPLETED",mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); + assertEquals("200", mdc.get(ONAPLogConstants.MDCs.RESPONSE_CODE)); + assertEquals("", mdc.get(ONAPLogConstants.MDCs.PARTNER_NAME)); + assertEquals("/manage/health", mdc.get(ONAPLogConstants.MDCs.SERVICE_NAME)); + assertEquals("COMPLETED", mdc.get(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE)); } - } - - /* 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); - - - } - - - + } + + /* 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 testResourceReceipe() throws JSONException { - String expectedResourceRecipe = "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}"; - - HttpEntity<String> entity = new HttpEntity<String>(null, headers); - headers.set("Accept", MediaType.APPLICATION_JSON); - - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE)) - .queryParam("resourceModelUuid", arResourceUUID) - .queryParam("action", "createInstance"); - - ResponseEntity<String> response = restTemplate.exchange( - builder.toUriString(), - HttpMethod.GET, entity, String.class); - - assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value()); - JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false); - } - - @Test - public void testResourceReceipeNotMatched() 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_RESOURCE_RECEIPE)) - .queryParam("resourceModelUuid", arResourceUUID) - .queryParam("action", "invalid_action"); - - ResponseEntity<String> response = restTemplate.exchange( - builder.toUriString(), - HttpMethod.GET, entity, String.class); - - assertEquals(Response.Status.NOT_FOUND.getStatusCode(),response.getStatusCode().value()); - } - - @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); - - - for(ILoggingEvent logEvent : TestAppender.events) - if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && - logEvent.getMarker().getName().equals("ENTRY") - ){ - Map<String,String> mdc = logEvent.getMDCPropertyMap(); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); - assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); - assertNotNull(mdc.get(INVOCATION_ID)); - assertEquals("UNKNOWN",mdc.get(PARTNERNAME)); - assertEquals("v2/vfModules",mdc.get(SERVICE_NAME)); - assertEquals("INPROGRESS",mdc.get(STATUSCODE)); - }else if(logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") && - logEvent.getMarker().getName().equals("EXIT")){ - Map<String,String> mdc = logEvent.getMDCPropertyMap(); + + @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 testResourceReceipe() throws JSONException { + String expectedResourceRecipe = + "{\"orchestrationUri\":\"/mso/async/services/CreateSDNCNetworkResource\",\"action\":\"createInstance\",\"description\":\"sotnvpnattachmentvF\",\"id\":\"1\",\"recipeTimeout\":\"180\",\"paramXSD\":\"\"}"; + + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_V2_RESOURCE_RECEIPE)) + .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "createInstance"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + JSONAssert.assertEquals(expectedResourceRecipe, response.getBody().toString(), false); + } + + @Test + public void testResourceReceipeNotMatched() 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_RESOURCE_RECEIPE)) + .queryParam("resourceModelUuid", arResourceUUID).queryParam("action", "invalid_action"); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatusCode().value()); + } + + @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); + + + for (ILoggingEvent logEvent : TestAppender.events) + if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") + && logEvent.getMarker().getName().equals("ENTRY")) { + Map<String, String> mdc = logEvent.getMDCPropertyMap(); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); + assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); + assertNotNull(mdc.get(INVOCATION_ID)); + assertEquals("UNKNOWN", mdc.get(PARTNERNAME)); + assertEquals("v2/vfModules", mdc.get(SERVICE_NAME)); + assertEquals("INPROGRESS", mdc.get(STATUSCODE)); + } else if (logEvent.getLoggerName().equals("org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging") + && logEvent.getMarker().getName().equals("EXIT")) { + Map<String, String> mdc = logEvent.getMDCPropertyMap(); assertNotNull(mdc.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP)); assertNotNull(mdc.get(ENDTIME)); assertNotNull(mdc.get(ONAPLogConstants.MDCs.REQUEST_ID)); assertNotNull(mdc.get(INVOCATION_ID)); - assertEquals("500",mdc.get(RESPONSECODE)); - assertEquals("UNKNOWN",mdc.get(PARTNERNAME)); - assertEquals("v2/vfModules",mdc.get(SERVICE_NAME)); - assertEquals("ERROR",mdc.get(STATUSCODE)); + assertEquals("500", mdc.get(RESPONSECODE)); + assertEquals("UNKNOWN", mdc.get(PARTNERNAME)); + assertEquals("v2/vfModules", mdc.get(SERVICE_NAME)); + assertEquals("ERROR", mdc.get(STATUSCODE)); assertNotNull(mdc.get(RESPONSEDESC)); - } - } - - private String createURLWithPort(String uri) { - return "http://localhost:" + port + uri; - } + } + } + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + uri; + } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java index 3e30dcc3b2..15e986505e 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogQueryExceptionTest.java @@ -26,12 +26,13 @@ import static org.junit.Assert.assertEquals; public class CatalogQueryExceptionTest { @Test - public void catalogQueryExceptionConstructor(){ + public void catalogQueryExceptionConstructor() { CatalogQueryException messageCatalogQueryException = new CatalogQueryException("TestMessage"); assertNotNull(messageCatalogQueryException.getMessage()); - assertEquals("TestMessage",messageCatalogQueryException.getMessage()); + assertEquals("TestMessage", messageCatalogQueryException.getMessage()); - CatalogQueryException paramsCatalogQueryException = new CatalogQueryException("TestMessage",CatalogQueryExceptionCategory.INTERNAL,true,"messageID"); + CatalogQueryException paramsCatalogQueryException = + new CatalogQueryException("TestMessage", CatalogQueryExceptionCategory.INTERNAL, true, "messageID"); assertParams(paramsCatalogQueryException); CatalogQueryException defaultCatalogQueryException = new CatalogQueryException(); @@ -44,12 +45,12 @@ public class CatalogQueryExceptionTest { private void assertParams(CatalogQueryException paramsCatalogQueryException) { assertNotNull(paramsCatalogQueryException.getMessage()); - assertEquals("TestMessage",paramsCatalogQueryException.getMessage()); + assertEquals("TestMessage", paramsCatalogQueryException.getMessage()); assertNotNull(paramsCatalogQueryException.getCategory()); - assertEquals(CatalogQueryExceptionCategory.INTERNAL,paramsCatalogQueryException.getCategory()); + assertEquals(CatalogQueryExceptionCategory.INTERNAL, paramsCatalogQueryException.getCategory()); assertNotNull(paramsCatalogQueryException.getRolledBack()); - assertEquals(true,paramsCatalogQueryException.getRolledBack()); + assertEquals(true, paramsCatalogQueryException.getRolledBack()); assertNotNull(paramsCatalogQueryException.getMessageId()); - assertEquals("messageID",paramsCatalogQueryException.getMessageId()); + assertEquals("messageID", paramsCatalogQueryException.getMessageId()); } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java index f2f06d7f3d..bf5a742661 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CloudConfigTest.java @@ -58,7 +58,7 @@ public class CloudConfigTest extends CatalogDbAdapterBaseTest { @Transactional public void createCloudSiteRest_TEST() { headers.set("Accept", MediaType.APPLICATION_JSON); - headers.set("Content-Type",MediaType.APPLICATION_JSON); + headers.set("Content-Type", MediaType.APPLICATION_JSON); CloudSite cloudSite = new CloudSite(); cloudSite.setId("MTN7"); @@ -78,17 +78,19 @@ public class CloudConfigTest extends CatalogDbAdapterBaseTest { cloudIdentity.setIdentityAuthenticationType(AuthenticationType.RACKSPACE_APIKEY); cloudSite.setIdentityService(cloudIdentity); String uri = "/cloudSite"; - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:"+ port + uri); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri); HttpEntity<CloudSite> request = new HttpEntity<CloudSite>(cloudSite, headers); - ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), - HttpMethod.POST, request, String.class); + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.POST, request, String.class); assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatusCode().value()); - builder = UriComponentsBuilder.fromHttpUrl("http://localhost:"+ port + uri +"/" + cloudSite.getId()); + builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri + "/" + cloudSite.getId()); HttpEntity<String> entity = new HttpEntity<String>(null, headers); - ResponseEntity<CloudSite> actualCloudSite = restTemplate.exchange(builder.toUriString(),HttpMethod.GET, entity, CloudSite.class); - builder = UriComponentsBuilder.fromHttpUrl("http://localhost:"+ port + uri); - ResponseEntity<String> cloudSiteString = restTemplate.exchange(builder.toUriString(),HttpMethod.GET, entity, String.class); + ResponseEntity<CloudSite> actualCloudSite = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, CloudSite.class); + builder = UriComponentsBuilder.fromHttpUrl("http://localhost:" + port + uri); + ResponseEntity<String> cloudSiteString = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); System.out.println(cloudSiteString.getBody()); assertEquals(Response.Status.OK.getStatusCode(), actualCloudSite.getStatusCode().value()); assertThat(actualCloudSite.getBody(), sameBeanAs(cloudSite).ignoring("created").ignoring("updated") 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 index e6a281a375..440270e047 100644 --- 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 @@ -26,11 +26,8 @@ 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; @@ -53,102 +50,103 @@ import org.springframework.test.context.junit4.SpringRunner; public class NetworkCollectionCatalogDbQueryTest extends CatalogDbAdapterBaseTest { - private static final Logger logger = LoggerFactory.getLogger(NetworkCollectionCatalogDbQueryTest.class); - private static final String NETWORKCOLLECTION = "NetworkCollection"; - - private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; + private static final Logger logger = LoggerFactory.getLogger(NetworkCollectionCatalogDbQueryTest.class); + private static final String NETWORKCOLLECTION = "NetworkCollection"; + + private final String serviceUUID = "5df8b6de-2083-11e7-93ae-92361f002671"; + + @LocalServerPort + private int port; + boolean isInitialized; + + @Autowired + CatalogDbClientPortChanger client; + + @Before + public void initialize() { + client.wiremockPort = String.valueOf(port); + } + + @Test + @Transactional + public void networkCollectionTest() { + logger.debug("TEST IS STARTING UP..."); + String modelUUID = "4694a55f-58b3-4f17-92a5-796d6f5ffd0d"; + boolean found = false; + logger.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) { + logger.debug("null"); + } else { + List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); + if (customizations.isEmpty()) { + logger.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)) { + logger.debug("Found a network collection"); + instanceGroup = crc.getCollectionResource().getInstanceGroup(); + collectionInstanceGroupList = instanceGroup.getCollectionInstanceGroupCustomizations(); + CollectionNetworkResourceCustomization collectionNetworkCust = + instanceGroup.getCollectionNetworkResourceCustomizations().get(0); + logger.debug("Found Collection Network Resource Customization: " + + collectionNetworkCust.getModelCustomizationUUID()); + } else { + logger.debug( + "No Network Collection found. toscaNodeType does not contain NetworkCollection"); + } + } else { + logger.debug("No Network Collection found. toscaNodeType is null"); + } + } else { + logger.debug("No Network Collection found. collectionResource is null"); + } + found = true; + } else { + logger.debug("Not a Network Collection Resource Customization Instance"); + } + } + } + assertEquals("Number of CollectionResourceInstanceGroupCustomization in list", 2, + collectionInstanceGroupList.size()); + assertNotNull(instanceGroup); + assertTrue(found); + } - @LocalServerPort - private int port; - boolean isInitialized; + @Test + public void buildingBlockDetailTest() { + logger.debug("TEST IS STARTING UP..."); + logger.debug(Integer.toString(port)); + String buildingBlockFlowName = "CreateNetworkCollectionBB"; + BuildingBlockDetail buildingBlockDetail = client.getBuildingBlockDetail(buildingBlockFlowName); + logger.debug("" + buildingBlockDetail.getResourceType()); + assertNotNull(buildingBlockDetail); + } - @Autowired - CatalogDbClientPortChanger client; + @Test + public void fetchServiceTopology_Test() { + org.onap.so.db.catalog.beans.Service service = client.getServiceByID(serviceUUID); - @Before - public void initialize(){ - client.wiremockPort= String.valueOf(port); - } - - @Test - @Transactional - public void networkCollectionTest() { - logger.debug("TEST IS STARTING UP..."); - String modelUUID = "4694a55f-58b3-4f17-92a5-796d6f5ffd0d"; - boolean found = false; - logger.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) { - logger.debug("null"); - } else { - List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); - if (customizations.isEmpty()) { - logger.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)) { - logger.debug("Found a network collection"); - instanceGroup = crc.getCollectionResource().getInstanceGroup(); - collectionInstanceGroupList = - instanceGroup.getCollectionInstanceGroupCustomizations(); - CollectionNetworkResourceCustomization collectionNetworkCust = instanceGroup.getCollectionNetworkResourceCustomizations().get(0); - logger.debug("Found Collection Network Resource Customization: " + collectionNetworkCust.getModelCustomizationUUID()); - } else { - logger.debug( - "No Network Collection found. toscaNodeType does not contain NetworkCollection"); - } - } else { - logger.debug("No Network Collection found. toscaNodeType is null"); - } - } else { - logger.debug("No Network Collection found. collectionResource is null"); - } - found = true; - } else { - logger.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() { - logger.debug("TEST IS STARTING UP..."); - logger.debug(Integer.toString(port)); - String buildingBlockFlowName = "CreateNetworkCollectionBB"; - BuildingBlockDetail buildingBlockDetail = client.getBuildingBlockDetail(buildingBlockFlowName); - logger.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()); + } - 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); - logger.debug(collectionNetworkCust.getModelCustomizationUUID()); - } + @Test + public void CollectionNetworkResourceCustomizationTest() { + String modelCustId = "1a61be4b-3378-4c9a-91c8-c919519b2d01"; + CollectionNetworkResourceCustomization collectionNetworkCust = + client.getCollectionNetworkResourceCustomizationByID(modelCustId); + assertNotNull(collectionNetworkCust); + logger.debug(collectionNetworkCust.getModelCustomizationUUID()); + } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java index e403867c42..8fae1c2900 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryResourceRecipeTest.java @@ -22,7 +22,6 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; - import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -62,7 +61,7 @@ public class QueryResourceRecipeTest { } private Recipe createRecipe() { - ServiceRecipe recipe = new ServiceRecipe(); + ServiceRecipe recipe = new ServiceRecipe(); recipe.setId(RECIPE_ID); recipe.setAction(RECIPE_ACTION); recipe.setOrchestrationUri(RECIPE_URI); @@ -76,8 +75,9 @@ public class QueryResourceRecipeTest { public void convertToJson() { Recipe recipe = createRecipe(); QueryResourceRecipe queryResourceRecipe = new QueryResourceRecipe(recipe); - assertEquals("{\"orchestrationUri\":\"uriTest\",\"action\":\"actionTest\",\"description\":\"descrTest\",\"id\":\"123\",\"recipeTimeout\":\"100\",\"paramXSD\":\"paramsXsdTest\"}", - queryResourceRecipe.JSON2(false,false)); + assertEquals( + "{\"orchestrationUri\":\"uriTest\",\"action\":\"actionTest\",\"description\":\"descrTest\",\"id\":\"123\",\"recipeTimeout\":\"100\",\"paramXSD\":\"paramsXsdTest\"}", + queryResourceRecipe.JSON2(false, false)); } @Test @@ -86,10 +86,11 @@ public class QueryResourceRecipeTest { QueryResourceRecipe networkQueryRR = new QueryResourceRecipe(new NetworkRecipe()); QueryResourceRecipe arQueryRR = new QueryResourceRecipe(new ArRecipe()); - String expected = "{\"orchestrationUri\":\"\",\"action\":\"\",\"description\":\"\",\"id\":\"\",\"recipeTimeout\":\"\",\"paramXSD\":\"\"}"; + String expected = + "{\"orchestrationUri\":\"\",\"action\":\"\",\"description\":\"\",\"id\":\"\",\"recipeTimeout\":\"\",\"paramXSD\":\"\"}"; assertEquals(expected, vnfQueryRR.JSON2(false, false)); - assertEquals(expected, networkQueryRR.JSON2(false,false)); - assertEquals(expected, arQueryRR.JSON2(false,false)); + assertEquals(expected, networkQueryRR.JSON2(false, false)); + assertEquals(expected, arQueryRR.JSON2(false, false)); } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java index 32cc2946db..44e5998404 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceCsarTest.java @@ -21,7 +21,6 @@ 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.onap.so.db.catalog.beans.ToscaCsar; diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModuleTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModuleTest.java index 98e90c828c..cf0a06e8b0 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModuleTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVfModuleTest.java @@ -21,10 +21,8 @@ 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.onap.so.db.catalog.beans.HeatEnvironment; import org.onap.so.db.catalog.beans.VfModule; @@ -52,8 +50,7 @@ public class QueryVfModuleTest { .contains(VF_MODEL_UUID); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].modelInfo.modelInvariantUuid")) .contains(VF_MODULE_INVARIANT_UUID); - assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].isBase")) - .contains("true"); + assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].isBase")).contains("true"); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].vfModuleLabel")) .contains(VF_MODEL_CUSTOMIZATION_LABEL); assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vfModules[0].initialCount")) 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 index c5772d9883..0fcb73beab 100644 --- 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 @@ -27,11 +27,11 @@ import ch.qos.logback.core.AppenderBase; -public class TestAppender extends AppenderBase<ILoggingEvent> { +public class TestAppender extends AppenderBase<ILoggingEvent> { static List<ILoggingEvent> events = new ArrayList<>(); - - @Override - protected void append(ILoggingEvent loggingEvent) { - events.add(loggingEvent); - } + + @Override + protected void append(ILoggingEvent loggingEvent) { + events.add(loggingEvent); + } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java index e38bd02069..14498b6617 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientPortChanger.java @@ -21,7 +21,6 @@ package org.onap.so.db.catalog.client; import org.springframework.stereotype.Component; - import java.net.URI; @Component() @@ -29,7 +28,7 @@ public class CatalogDbClientPortChanger extends CatalogDbClient { public String wiremockPort; - CatalogDbClientPortChanger(){ + CatalogDbClientPortChanger() { } @@ -44,6 +43,6 @@ public class CatalogDbClientPortChanger extends CatalogDbClient { String prefix = "http://localhost:" + wiremockPort; String query = uri.getQuery(); - return URI.create(prefix + path + (query == null || query.isEmpty()?"":"?"+query)); + return URI.create(prefix + path + (query == null || query.isEmpty() ? "" : "?" + query)); } } diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java index 763b3441fb..e1152bad4a 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java @@ -24,7 +24,6 @@ package org.onap.so.db.catalog.client; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; - import java.util.List; import java.util.UUID; import org.junit.Assert; @@ -82,17 +81,17 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep() { - RainyDayHandlerStatus rainyDayHandlerStatus = client - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - "AssignServiceInstanceBB", "*", "*", "*", "*"); + RainyDayHandlerStatus rainyDayHandlerStatus = + client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( + "AssignServiceInstanceBB", "*", "*", "*", "*"); Assert.assertEquals("Rollback", rainyDayHandlerStatus.getPolicy()); } @Test public void testGetRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStepRecordNotFound() { - RainyDayHandlerStatus rainyDayHandlerStatus = client - .getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( - UUID.randomUUID().toString(), "*", "*", "*", "*"); + RainyDayHandlerStatus rainyDayHandlerStatus = + client.getRainyDayHandlerStatusByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep( + UUID.randomUUID().toString(), "*", "*", "*", "*"); Assert.assertNull(rainyDayHandlerStatus); } @@ -184,8 +183,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetVnfResourceCustomizationByModelCustomizationUUID() { - VnfResourceCustomization vnfResourceCustomization = client - .getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671"); + VnfResourceCustomization vnfResourceCustomization = + client.getVnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002671"); Assert.assertNotNull(vnfResourceCustomization); Assert.assertEquals("vSAMP", vnfResourceCustomization.getNfRole()); Assert.assertNotNull(vnfResourceCustomization.getModelCustomizationUUID()); @@ -197,8 +196,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetVnfResourceCustomizationByModelCustomizationUUINotFound() { - VnfResourceCustomization vnfResourceCustomization = client - .getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); + VnfResourceCustomization vnfResourceCustomization = + client.getVnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); Assert.assertNull(vnfResourceCustomization); } @@ -208,13 +207,13 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { Assert.assertNotNull(instanceGroup); Assert.assertEquals("network_collection_resource_1806..NetworkCollection..0", instanceGroup.getModelName()); Assert.assertEquals("org.openecomp.resource.cr.NetworkCollectionResource1806", - instanceGroup.getToscaNodeType().toString()); + instanceGroup.getToscaNodeType().toString()); } @Test public void testGetVfModuleCustomizationByModelCuztomizationUUID() { - VfModuleCustomization vfModuleCustomization = client - .getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); + VfModuleCustomization vfModuleCustomization = + client.getVfModuleCustomizationByModelCuztomizationUUID("cb82ffd8-252a-11e7-93ae-92361f002671"); Assert.assertNotNull(vfModuleCustomization); Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); Assert.assertEquals("base", vfModuleCustomization.getLabel()); @@ -222,15 +221,15 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetVfModuleCustomizationByModelCuztomizationUUIDNotFound() { - VfModuleCustomization vfModuleCustomization = client - .getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString()); + VfModuleCustomization vfModuleCustomization = + client.getVfModuleCustomizationByModelCuztomizationUUID(UUID.randomUUID().toString()); Assert.assertNull(vfModuleCustomization); } @Test public void testGetNetworkResourceCustomizationByModelCustomizationUUID() { - NetworkResourceCustomization networkResourceCustomization = client - .getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac"); + NetworkResourceCustomization networkResourceCustomization = + client.getNetworkResourceCustomizationByModelCustomizationUUID("3bdbb104-476c-483e-9f8b-c095b3d308ac"); Assert.assertNotNull(networkResourceCustomization); Assert.assertNotNull(networkResourceCustomization.getModelCustomizationUUID()); Assert.assertEquals("CONTRAIL30_GNDIRECT 9", networkResourceCustomization.getModelInstanceName()); @@ -239,16 +238,16 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetNetworkResourceCustomizationByModelCustomizationUUIDNotFound() { - NetworkResourceCustomization networkResourceCustomization = client - .getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); + NetworkResourceCustomization networkResourceCustomization = + client.getNetworkResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); Assert.assertNull(networkResourceCustomization); } @Test public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID() { - VfModuleCustomization vfModuleCustomization = client - .getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( - "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672"); + VfModuleCustomization vfModuleCustomization = + client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( + "cb82ffd8-252a-11e7-93ae-92361f002672", "20c4431c-246d-11e7-93ae-92361f002672"); Assert.assertNotNull(vfModuleCustomization); Assert.assertNotNull(vfModuleCustomization.getModelCustomizationUUID()); Assert.assertNotNull(vfModuleCustomization.getVfModule()); @@ -257,35 +256,35 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGgetVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUIDNotFound() { - VfModuleCustomization vfModuleCustomization = client - .getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( - "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString()); + VfModuleCustomization vfModuleCustomization = + client.getVfModuleCustomizationByModelCustomizationUUIDAndVfModuleModelUUID( + "cb82ffd8-252a-11e7-93ae-92361f002672", UUID.randomUUID().toString()); Assert.assertNull(vfModuleCustomization); } @Test public void testGetFirstByServiceModelUUIDAndAction() { - ServiceRecipe serviceRecipe = client - .getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance"); + ServiceRecipe serviceRecipe = + client.getFirstByServiceModelUUIDAndAction("4694a55f-58b3-4f17-92a5-796d6f5ffd0d", "createInstance"); Assert.assertNotNull(serviceRecipe); Assert.assertNotNull(serviceRecipe.getServiceModelUUID()); Assert.assertNotNull(serviceRecipe.getAction()); Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", - serviceRecipe.getOrchestrationUri()); + serviceRecipe.getOrchestrationUri()); Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); } @Test public void testGetFirstByServiceModelUUIDAndActionNotFound() { - ServiceRecipe serviceRecipe = client - .getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671", UUID.randomUUID().toString()); + ServiceRecipe serviceRecipe = client.getFirstByServiceModelUUIDAndAction("5df8b6de-2083-11e7-93ae-92361f002671", + UUID.randomUUID().toString()); Assert.assertNull(serviceRecipe); } @Test public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersion() { VnfResource vnfResource = client - .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0"); + .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", "2.0"); Assert.assertNotNull(vnfResource); Assert.assertNotNull(vnfResource.getModelInvariantId()); Assert.assertNotNull(vnfResource.getModelVersion()); @@ -296,9 +295,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetFirstVnfResourceByModelInvariantUUIDAndModelVersionNotFound() { - VnfResource vnfResource = client - .getFirstVnfResourceByModelInvariantUUIDAndModelVersion("2fff5b20-214b-11e7-93ae-92361f002671", - UUID.randomUUID().toString()); + VnfResource vnfResource = client.getFirstVnfResourceByModelInvariantUUIDAndModelVersion( + "2fff5b20-214b-11e7-93ae-92361f002671", UUID.randomUUID().toString()); Assert.assertNull(vnfResource); } @@ -306,15 +304,15 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { public void testGetFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources() { VnfResource vnfr = new VnfResource(); vnfr.setModelUUID("ff2ae348-214a-11e7-93ae-92361f002671"); - VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = client - .getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr); + VnfResourceCustomization firstVnfResourceCustomizationByModelInstanceNameAndVnfResources = + client.getFirstVnfResourceCustomizationByModelInstanceNameAndVnfResources("vSAMP10a 1", vnfr); Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources); Assert.assertEquals("vSAMP", firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getNfRole()); Assert.assertEquals("vSAMP10a 1", - firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName()); + firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getModelInstanceName()); Assert.assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVnfResources()); - Assert - .assertNotNull(firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations()); + Assert.assertNotNull( + firstVnfResourceCustomizationByModelInstanceNameAndVnfResources.getVfModuleCustomizations()); } @Test @@ -335,9 +333,9 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction() { - VnfComponentsRecipe vnfComponentsRecipe = client - .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( - "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance"); + VnfComponentsRecipe vnfComponentsRecipe = + client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( + "20c4431c-246d-11e7-93ae-92361f002671", "volumeGroup", "createInstance"); Assert.assertNotNull(vnfComponentsRecipe); Assert.assertNotNull(vnfComponentsRecipe.getAction()); Assert.assertNotNull(vnfComponentsRecipe.getVfModuleModelUUID()); @@ -350,28 +348,28 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndActionNotFound() { - VnfComponentsRecipe vnfComponentsRecipe = client - .getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction(UUID.randomUUID().toString(), - "volumeGroup", "createInstance"); + VnfComponentsRecipe vnfComponentsRecipe = + client.getFirstVnfComponentsRecipeByVfModuleModelUUIDAndVnfComponentTypeAndAction( + UUID.randomUUID().toString(), "volumeGroup", "createInstance"); Assert.assertNull(vnfComponentsRecipe); } @Test public void testGetFirstVnfComponentsRecipeByVnfComponentTypeAndAction() { - VnfComponentsRecipe vnfComponentsRecipe = client - .getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance"); + VnfComponentsRecipe vnfComponentsRecipe = + client.getFirstVnfComponentsRecipeByVnfComponentTypeAndAction("volumeGroup", "createInstance"); Assert.assertNotNull(vnfComponentsRecipe); Assert.assertNotNull(vnfComponentsRecipe.getAction()); Assert.assertNotNull(vnfComponentsRecipe.getVnfComponentType()); Assert.assertEquals("VID_DEFAULT recipe t", vnfComponentsRecipe.getDescription()); - Assert - .assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", vnfComponentsRecipe.getOrchestrationUri()); + Assert.assertEquals("/mso/async/services/CreateVfModuleVolumeInfraV1", + vnfComponentsRecipe.getOrchestrationUri()); } @Test public void testGetServiceByModelVersionAndModelInvariantUUID() { - Service service = client - .getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671"); + Service service = + client.getServiceByModelVersionAndModelInvariantUUID("2.0", "9647dfc4-2083-11e7-93ae-92361f002671"); Assert.assertNotNull(service); Assert.assertNotNull(service.getModelVersion()); Assert.assertNotNull(service.getModelInvariantUUID()); @@ -387,8 +385,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetVfModuleByModelInvariantUUIDAndModelVersion() { - VfModule vfModule = client - .getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2"); + VfModule vfModule = + client.getVfModuleByModelInvariantUUIDAndModelVersion("78ca26d0-246d-11e7-93ae-92361f002671", "2"); Assert.assertNotNull(vfModule); Assert.assertNotNull(vfModule.getModelVersion()); Assert.assertNotNull(vfModule.getModelInvariantUUID()); @@ -404,8 +402,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetServiceByModelInvariantUUIDOrderByModelVersionDesc() { - List<Service> serviceList = client - .getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); + List<Service> serviceList = + client.getServiceByModelInvariantUUIDOrderByModelVersionDesc("9647dfc4-2083-11e7-93ae-92361f002671"); Assert.assertFalse(serviceList.isEmpty()); Assert.assertEquals(2, serviceList.size()); Service service = serviceList.get(0); @@ -414,15 +412,15 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testGetServiceByModelInvariantUUIDOrderByModelVersionDescNotFound() { - List<Service> serviceList = client - .getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString()); + List<Service> serviceList = + client.getServiceByModelInvariantUUIDOrderByModelVersionDesc(UUID.randomUUID().toString()); Assert.assertTrue(serviceList.isEmpty()); } @Test public void testGetVfModuleByModelInvariantUUIDOrderByModelVersionDesc() { - List<VfModule> moduleList = client - .getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671"); + List<VfModule> moduleList = + client.getVfModuleByModelInvariantUUIDOrderByModelVersionDesc("78ca26d0-246d-11e7-93ae-92361f002671"); Assert.assertFalse(moduleList.isEmpty()); Assert.assertEquals(2, moduleList.size()); VfModule module = moduleList.get(0); @@ -432,7 +430,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testPostCloudSite() { CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger( - "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort); + "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort); CloudSite cloudSite = new CloudSite(); cloudSite.setId("MTN6"); cloudSite.setClli("TESTCLLI"); @@ -471,60 +469,22 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testPostHomingInstance() { CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger( - "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort); + "http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort); HomingInstance homingInstance = new HomingInstance(); homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671"); homingInstance.setCloudOwner("CloudOwner-1"); homingInstance.setCloudRegionId("CloudRegionOne"); - homingInstance.setOofDirectives("{\n" + - "\"directives\": [\n" + - "{\n" + - "\"directives\": [\n" + - "{\n" + - "\"attributes\": [\n" + - "{\n" + - "\"attribute_value\": \"onap.hpa.flavor31\",\n" + - "\"attribute_name\": \"firewall_flavor_name\"\n" + - "}\n" + - "],\n" + - "\"type\": \"flavor_directives\"\n" + - "}\n" + - "],\n" + - "\"type\": \"vnfc\",\n" + - "\"id\": \"vfw\"\n" + - "},\n" + - "{\n" + - "\"directives\": [\n" + - "{\n" + - "\"attributes\": [\n" + - "{\n" + - "\"attribute_value\": \"onap.hpa.flavor32\",\n" + - "\"attribute_name\": \"packetgen_flavor_name\"\n" + - "}\n" + - "],\n" + - "\"type\": \"flavor_directives\"\n" + - "}\n" + - "],\n" + - "\"type\": \"vnfc\",\n" + - "\"id\": \"vgenerator\"\n" + - "},\n" + - "{\n" + - "\"directives\": [\n" + - "{\n" + - "\"attributes\": [\n" + - "{\n" + - "\"attribute_value\": \"onap.hpa.flavor31\",\n" + - "\"attribute_name\": \"sink_flavor_name\"\n" + - "}\n" + - "],\n" + - "\"type\": \"flavor_directives\"\n" + - "}\n" + - "],\n" + - "\"type\": \"vnfc\",\n" + - "\"id\": \"vsink\"\n" + - "}\n" + - "]\n" + - "}"); + homingInstance.setOofDirectives("{\n" + "\"directives\": [\n" + "{\n" + "\"directives\": [\n" + "{\n" + + "\"attributes\": [\n" + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + + "\"attribute_name\": \"firewall_flavor_name\"\n" + "}\n" + "],\n" + + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n" + "\"id\": \"vfw\"\n" + + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n" + "{\n" + + "\"attribute_value\": \"onap.hpa.flavor32\",\n" + "\"attribute_name\": \"packetgen_flavor_name\"\n" + + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n" + + "\"id\": \"vgenerator\"\n" + "},\n" + "{\n" + "\"directives\": [\n" + "{\n" + "\"attributes\": [\n" + + "{\n" + "\"attribute_value\": \"onap.hpa.flavor31\",\n" + "\"attribute_name\": \"sink_flavor_name\"\n" + + "}\n" + "],\n" + "\"type\": \"flavor_directives\"\n" + "}\n" + "],\n" + "\"type\": \"vnfc\",\n" + + "\"id\": \"vsink\"\n" + "}\n" + "]\n" + "}"); localClient.postHomingInstance(homingInstance); HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671"); Assert.assertNotNull(getHomingInstance); @@ -574,7 +534,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { northBoundRequest.setIsAlacarte(true); northBoundRequest.setCloudOwner("my-custom-cloud-owner"); client.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner("createService", "service", true, - "my-custom-cloud-owner"); + "my-custom-cloud-owner"); Assert.assertNotNull(northBoundRequest); Assert.assertEquals("createService", northBoundRequest.getAction()); Assert.assertEquals("service", northBoundRequest.getRequestScope()); @@ -584,27 +544,27 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testFindServiceRecipeByActionAndServiceModelUUID() { - ServiceRecipe serviceRecipe = client - .findServiceRecipeByActionAndServiceModelUUID("createInstance", "4694a55f-58b3-4f17-92a5-796d6f5ffd0d"); + ServiceRecipe serviceRecipe = client.findServiceRecipeByActionAndServiceModelUUID("createInstance", + "4694a55f-58b3-4f17-92a5-796d6f5ffd0d"); Assert.assertNotNull(serviceRecipe); Assert.assertNotNull(serviceRecipe.getServiceModelUUID()); Assert.assertNotNull(serviceRecipe.getAction()); Assert.assertEquals("/mso/async/services/CreateGenericALaCarteServiceInstance", - serviceRecipe.getOrchestrationUri()); + serviceRecipe.getOrchestrationUri()); Assert.assertEquals("MSOTADevInfra aLaCarte", serviceRecipe.getDescription()); } @Test public void testFindServiceRecipeByActionAndServiceModelUUIDNotFound() { - ServiceRecipe serviceRecipe = client - .findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test"); + ServiceRecipe serviceRecipe = + client.findServiceRecipeByActionAndServiceModelUUID("not_found", "5df8b6de-2083-11e7-93ae-test"); Assert.assertNull(serviceRecipe); } @Test public void testFindExternalToInternalServiceByServiceName() { - ExternalServiceToInternalService externalServiceToInternalService = client - .findExternalToInternalServiceByServiceName("MySpecialServiceName"); + ExternalServiceToInternalService externalServiceToInternalService = + client.findExternalToInternalServiceByServiceName("MySpecialServiceName"); Assert.assertNotNull(externalServiceToInternalService); Assert.assertNotNull(externalServiceToInternalService.getServiceName()); Assert.assertNotNull(externalServiceToInternalService.getServiceModelUUID()); @@ -613,8 +573,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void testFindExternalToInternalServiceByServiceNameNotFound() { - ExternalServiceToInternalService externalServiceToInternalService = client - .findExternalToInternalServiceByServiceName("Not_Found"); + ExternalServiceToInternalService externalServiceToInternalService = + client.findExternalToInternalServiceByServiceName("Not_Found"); Assert.assertNull(externalServiceToInternalService); } @@ -624,7 +584,7 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { Assert.assertNotNull(pnfResource); assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID()); assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680", - pnfResource.getModelInvariantUUID()); + pnfResource.getModelInvariantUUID()); assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion()); assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode()); } @@ -637,8 +597,8 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { @Test public void getPnfResourceCustomizationByModelCustomizationUUID_validUuid_expectedOutput() { - PnfResourceCustomization pnfResourceCustomization = client - .getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680"); + PnfResourceCustomization pnfResourceCustomization = + client.getPnfResourceCustomizationByModelCustomizationUUID("68dc9a92-214c-11e7-93ae-92361f002680"); assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName()); assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName()); assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion()); @@ -647,25 +607,25 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { assertNotNull(pnfResource); assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID()); assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680", - pnfResource.getModelInvariantUUID()); + pnfResource.getModelInvariantUUID()); assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion()); assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode()); } @Test public void getPnfResourceCustomizationByModelCustomizationUUID_invalidUuid_nullOutput() { - PnfResourceCustomization pnfResourceCustomization = client - .getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); + PnfResourceCustomization pnfResourceCustomization = + client.getPnfResourceCustomizationByModelCustomizationUUID(UUID.randomUUID().toString()); Assert.assertNull(pnfResourceCustomization); } @Test public void getPnfResourceCustomizationFromJoinTable_validServiceUuid_expectedOutput() { - List<PnfResourceCustomization> pnfResourceCustomizationList = client - .getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676"); + List<PnfResourceCustomization> pnfResourceCustomizationList = + client.getPnfResourceCustomizationByModelUuid("5df8b6de-2083-11e7-93ae-92361f002676"); assertEquals(1, pnfResourceCustomizationList.size()); - PnfResourceCustomization pnfResourceCustomization= pnfResourceCustomizationList.get(0); + PnfResourceCustomization pnfResourceCustomization = pnfResourceCustomizationList.get(0); assertEquals("modelInstanceName", "PNF routing", pnfResourceCustomization.getModelInstanceName()); assertEquals("blueprintName", "test_configuration_restconf", pnfResourceCustomization.getBlueprintName()); assertEquals("blueprintVersion", "1.0.0", pnfResourceCustomization.getBlueprintVersion()); @@ -674,29 +634,27 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest { assertEquals("PNFResource modelUUID", "ff2ae348-214a-11e7-93ae-92361f002680", pnfResource.getModelUUID()); assertEquals("PNFResource modelInvariantUUID", "2fff5b20-214b-11e7-93ae-92361f002680", - pnfResource.getModelInvariantUUID()); + pnfResource.getModelInvariantUUID()); assertEquals("PNFResource modelVersion", "1.0", pnfResource.getModelVersion()); assertEquals("PNFResource orchestration mode", "", pnfResource.getOrchestrationMode()); } @Test public void getPnfResourceCustomizationFromJoinTable_invalidServiceUuid_nullOutput() { - List<PnfResourceCustomization> pnfResourceCustomizationList = client - .getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString()); + List<PnfResourceCustomization> pnfResourceCustomizationList = + client.getPnfResourceCustomizationByModelUuid(UUID.randomUUID().toString()); assertEquals(0, pnfResourceCustomizationList.size()); } - + @Test public void getWorkflowByArtifactUUID_validUuid_expectedOutput() { - Workflow workflow = client - .findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1"); + Workflow workflow = client.findWorkflowByArtifactUUID("5b0c4322-643d-4c9f-b184-4516049e99b1"); assertEquals("artifactName", "testingWorkflow", workflow.getArtifactName()); } @Test public void getWorkflowByArtifactUUID_invalidUuid_nullOutput() { - Workflow workflow = client - .findWorkflowByArtifactUUID(UUID.randomUUID().toString()); + Workflow workflow = client.findWorkflowByArtifactUUID(UUID.randomUUID().toString()); Assert.assertNull(workflow); } |