aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src/test/java
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-04-30 21:00:08 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-30 21:00:20 -0400
commitacb8997a69725a39270a6527b33995f51c1e4586 (patch)
tree44984771fe8b939093982ef049f0aa393336136e /adapters/mso-catalog-db-adapter/src/test/java
parentd26574fe0e44f43bfbf507adbf91a28c1b53c63a (diff)
Add Model Version Query
Fix the sql migration version numbering to be proper Fix marking test as private, mark public Clean up public declarations to private Fix schema.sql to have new column for unit test Revert POM Change, add License, clean up comments Fix bad spelling of method name issue Update catalog db to support new rest endpoint Update local query service and mappers Localstaging of potential catalog db changes Update logic to write overall distro status Change-Id: I84d53b972ede3176c5af32d13444583a36606efa Issue-ID: SO-1820 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src/test/java')
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java134
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java1
2 files changed, 134 insertions, 1 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
new file mode 100644
index 0000000000..b8161de6b2
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/ServiceMapperTest.java
@@ -0,0 +1,134 @@
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import static com.shazam.shazamcrest.MatcherAssert.assertThat;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.junit.Test;
+import org.onap.so.adapters.catalogdb.rest.ServiceMapper;
+import org.onap.so.db.catalog.beans.HeatTemplate;
+import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.rest.catalog.beans.Service;
+import wiremock.com.fasterxml.jackson.core.JsonParseException;
+import wiremock.com.fasterxml.jackson.databind.JsonMappingException;
+import wiremock.com.fasterxml.jackson.databind.ObjectMapper;
+
+public class ServiceMapperTest {
+
+ private ServiceMapper serviceMapper = new ServiceMapper();
+
+ @Test
+ public void service_map_test() throws JsonParseException, JsonMappingException, IOException {
+ Service actual = serviceMapper.mapService(getTestService(), 2);
+ assertThat(actual, sameBeanAs(getExpectedService()));
+ }
+
+ private Service getExpectedService() throws JsonParseException, JsonMappingException, IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ return mapper.readValue(getJson("ExpectedService.json"), Service.class);
+ }
+
+
+ private org.onap.so.db.catalog.beans.Service getTestService() {
+ org.onap.so.db.catalog.beans.Service testService = new org.onap.so.db.catalog.beans.Service();
+ testService.setCategory("category");
+ testService.setDescription("description");
+ testService.setDistrobutionStatus("distrobutionStatus");
+ testService.setEnvironmentContext("environmentContext");
+ testService.setModelInvariantUUID("modelInvariantUUID");
+ testService.setModelName("modelName");
+ testService.setModelUUID("modelUUID");
+ testService.setModelVersion("modelVersion");
+ testService.setServiceType("serviceType");
+ testService.setServiceRole("serviceRole");
+ testService.getVnfCustomizations().add(getTestVnfCustomization());
+ return testService;
+ }
+
+ private org.onap.so.db.catalog.beans.VnfResourceCustomization getTestVnfCustomization() {
+ org.onap.so.db.catalog.beans.VnfResourceCustomization test =
+ new org.onap.so.db.catalog.beans.VnfResourceCustomization();
+ test.setId(1);
+ test.setAvailabilityZoneMaxCount(11);
+ test.setMaxInstances(3);
+ test.setMinInstances(1);
+ test.setModelCustomizationUUID("modelCustomizationUUID");
+ test.setModelInstanceName("modelInstanceName");
+ test.setMultiStageDesign("multiStageDesign");
+ test.setNfFunction("nfFunction");
+ test.setNfNamingCode("nfNamingCode");
+ test.setNfRole("nfRole");
+ test.setNfType("nfType");
+ test.setService(new org.onap.so.db.catalog.beans.Service());
+ test.setVnfResources(getTestVnfResource());
+ test.setVfModuleCustomizations(getTestVfModuleCust());
+ return test;
+ }
+
+ private List<VfModuleCustomization> getTestVfModuleCust() {
+ List<VfModuleCustomization> test = new ArrayList<>();
+ VfModuleCustomization testVfMod = new VfModuleCustomization();
+ testVfMod.setAvailabilityZoneCount(10);
+ testVfMod.setInitialCount(1);
+ testVfMod.setLabel("label");
+ testVfMod.setMaxInstances(3);
+ testVfMod.setMinInstances(1);
+ testVfMod.setModelCustomizationUUID("modelCustomizationUUID");
+ org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
+ vfModule.setDescription("description");
+ vfModule.setIsBase(false);
+ vfModule.setModelInvariantUUID("modelInvariantUUID");
+ vfModule.setModelName("modelName");
+ vfModule.setModelUUID("modelUUID");
+ vfModule.setModelVersion("modelVersion");
+ HeatTemplate moduleHeatTemplate = new HeatTemplate();
+ moduleHeatTemplate.setArtifactChecksum("artifactChecksum");
+ moduleHeatTemplate.setArtifactUuid("artifactUuid");
+ List<HeatTemplate> childTemplates;
+ // moduleHeatTemplate.setChildTemplates(childTemplates);
+ moduleHeatTemplate.setDescription("description");
+ Set<HeatTemplateParam> parameters = new HashSet<>();
+ HeatTemplateParam heatParam = new HeatTemplateParam();
+ heatParam.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid");
+ heatParam.setParamAlias("paramAlias");
+ heatParam.setParamName("paramName");
+ heatParam.setParamType("paramType");
+ heatParam.setRequired(false);
+ parameters.add(heatParam);
+ moduleHeatTemplate.setParameters(parameters);
+ moduleHeatTemplate.setTemplateBody("templateBody");
+ moduleHeatTemplate.setTemplateName("templateName");
+ moduleHeatTemplate.setTimeoutMinutes(1000);
+ moduleHeatTemplate.setVersion("version");
+ vfModule.setModuleHeatTemplate(moduleHeatTemplate);
+ testVfMod.setVfModule(vfModule);
+ test.add(testVfMod);
+ return test;
+ }
+
+ private org.onap.so.db.catalog.beans.VnfResource getTestVnfResource() {
+ org.onap.so.db.catalog.beans.VnfResource test = new org.onap.so.db.catalog.beans.VnfResource();
+ test.setCategory("category");
+ test.setDescription("description");
+ test.setModelInvariantUUID("modelInvariantUUID");
+ test.setModelName("modelName");
+ test.setModelUUID("modelUUID");
+ test.setModelVersion("modelVersion");
+ test.setAicVersionMax("cloudVersionMax");
+ test.setAicVersionMin("cloudVersionMin");
+ test.setOrchestrationMode("orchestrationMode");
+ test.setSubCategory("subCategory");
+ test.setToscaNodeType("toscaNodeType");
+ return test;
+ }
+
+ private String getJson(String filename) throws IOException {
+ return new String(Files.readAllBytes(Paths.get("src/test/resources/" + filename)));
+ }
+}
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 51b44b0d3a..4127d07c5f 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
@@ -289,7 +289,6 @@ public class CatalogDbClientTest extends CatalogDbAdapterBaseTest {
Assert.assertNotNull(vnfResource.getModelInvariantId());
Assert.assertNotNull(vnfResource.getModelVersion());
Assert.assertNotNull(vnfResource.getHeatTemplates());
- Assert.assertNotNull(vnfResource.getVnfResourceCustomizations());
Assert.assertEquals("vSAMP10a", vnfResource.getModelName());
}