summaryrefslogtreecommitdiffstats
path: root/mso-catalog-db/src/test/java
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2017-10-04 07:08:52 +0000
committerGerrit Code Review <gerrit@onap.org>2017-10-04 07:08:52 +0000
commita6f1f00a9ddc9af2dd57dd4257e353f2901d1881 (patch)
tree57fe5ffb0695a0972a4f5637638a641a20df6084 /mso-catalog-db/src/test/java
parent474b7c329c1ca7b7c0dbf933d556e3417fdc2940 (diff)
parent7b2eead87658554c14bd1333a2cae9f68df3e62f (diff)
Merge "Adding UT for MsoCatalog POJO"
Diffstat (limited to 'mso-catalog-db/src/test/java')
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java87
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java59
-rw-r--r--mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java69
3 files changed, 215 insertions, 0 deletions
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java
new file mode 100644
index 0000000000..da4e87806c
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.db.catalog.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.UUID;
+
+import org.junit.Test;
+import org.openecomp.mso.db.catalog.beans.HeatFiles;
+
+/**
+ */
+
+public class HeatFilesTest {
+
+ @Test
+ public final void heatFilesTest() {
+
+ HeatFiles heatFiles = new HeatFiles();
+ heatFiles.setFileBody("testBody");
+ heatFiles.setArtifactUuid(UUID.randomUUID().toString());
+ assertTrue(heatFiles.getFileBody().equals("testBody"));
+ assertTrue(!heatFiles.toString().contains("8 chars"));
+ heatFiles.setFileBody(null);
+ assertTrue(!heatFiles.toString().contains("Not defined"));
+ heatFiles.setVersion("12");
+ assertTrue(heatFiles.getVersion().equals("12"));
+
+ heatFiles.setFileName("File");
+ assertTrue(heatFiles.getFileName().equalsIgnoreCase("File"));
+
+ heatFiles.setCreated(null);
+ assertTrue(heatFiles.getCreated() == null);
+ heatFiles.setAsdcUuid("asdc");
+
+ assertTrue(heatFiles.getAsdcUuid().equalsIgnoreCase("asdc"));
+
+ heatFiles.setDescription("desc");
+ assertTrue(heatFiles.getDescription().equalsIgnoreCase("desc"));
+
+
+ heatFiles.setArtifactChecksum("artifactChecksum");
+ assertTrue(heatFiles.getArtifactChecksum().equalsIgnoreCase("artifactChecksum"));
+ File tempFile;
+ try {
+ tempFile = File.createTempFile("heatFiles", "test");
+ tempFile.deleteOnExit();
+ try (Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile), "utf-8"))) {
+ writer.write("something\n");
+ writer.write("something2\n");
+ }
+ heatFiles.setFileBody(tempFile.getAbsolutePath());
+ assertTrue(heatFiles.getFileBody().contains("test"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("Exception caught");
+ }
+
+ }
+
+}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java
new file mode 100644
index 0000000000..d70f267cc1
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.db.catalog.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Timestamp;
+
+import org.junit.Test;
+import org.openecomp.mso.db.catalog.beans.ModelRecipe;
+
+/**
+ */
+
+public class ModelRecipeTest {
+
+ @Test
+ public final void modelRecipeDataTest() {
+ ModelRecipe modelRecipe = new ModelRecipe();
+ modelRecipe.setAction("action");
+ assertTrue(modelRecipe.getAction().equalsIgnoreCase("action"));
+ modelRecipe.setCreated(new Timestamp(System.currentTimeMillis()));
+ assertTrue(modelRecipe.getCreated() != null);
+ modelRecipe.setDescription("description");
+ assertTrue(modelRecipe.getDescription().equalsIgnoreCase("description"));
+ modelRecipe.setId(1);
+ assertTrue(modelRecipe.getId() == 1);
+ modelRecipe.setModelId(1);
+ assertTrue(modelRecipe.getModelId() == 1);
+ modelRecipe.setModelParamXSD("modelParamXSD");
+ assertTrue(modelRecipe.getModelParamXSD().equalsIgnoreCase("modelParamXSD"));
+ modelRecipe.setOrchestrationUri("orchestrationUri");
+ assertTrue(modelRecipe.getOrchestrationUri().equalsIgnoreCase("orchestrationUri"));
+ modelRecipe.setRecipeTimeout(1);
+ assertTrue(modelRecipe.getRecipeTimeout() == 1);
+ modelRecipe.setSchemaVersion("schemaVersion");
+ assertTrue(modelRecipe.getSchemaVersion().equalsIgnoreCase("schemaVersion"));
+// assertTrue(modelRecipe.toString() != null);
+ }
+
+}
diff --git a/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java
new file mode 100644
index 0000000000..dcc9810042
--- /dev/null
+++ b/mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.db.catalog.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.sql.Timestamp;
+
+import org.junit.Test;
+import org.openecomp.mso.db.catalog.beans.Model;
+
+/**
+ */
+
+public class ModelTest {
+
+ @Test
+ public final void modelDataTest() {
+ Model model = new Model();
+ model.setId(1);
+ assertTrue(model.getId() == 1);
+
+ model.setCreated(new Timestamp(System.currentTimeMillis()));
+ assertTrue(model.getCreated() != null);
+ model.setModelCustomizationId("modelCustomizationId");
+
+ assertTrue(model.getModelCustomizationId().equalsIgnoreCase("modelCustomizationId"));
+ model.setModelCustomizationName("modelCustomizationName");
+ assertTrue(model.getModelCustomizationName().equalsIgnoreCase("modelCustomizationName"));
+
+ model.setModelInvariantId("modelInvariantId");
+ assertTrue(model.getModelInvariantId().equalsIgnoreCase("modelInvariantId"));
+ model.setModelName("modelName");
+ assertTrue(model.getModelName().equalsIgnoreCase("modelName"));
+
+ model.setModelType("modelType");
+ assertTrue(model.getModelType().equalsIgnoreCase("modelType"));
+ model.setModelVersion("modelVersion");
+ assertTrue(model.getModelVersion().equalsIgnoreCase("modelVersion"));
+ model.setModelVersionId("modelVersionId");
+ assertTrue(model.getModelVersionId().equalsIgnoreCase("modelVersionId"));
+ model.setVersion("1");
+ assertTrue(model.getVersion().equalsIgnoreCase("1"));
+ model.setRecipes(null);
+
+ assertTrue(model.getRecipes() == null);
+// assertTrue(model.toString() != null);
+
+ }
+
+}