From 7b2eead87658554c14bd1333a2cae9f68df3e62f Mon Sep 17 00:00:00 2001 From: seshukm Date: Wed, 4 Oct 2017 11:01:39 +0530 Subject: Adding UT for MsoCatalog POJO UT-Step1 IssueId: SO-172 Change-Id: I82c9095d25da5fec5b79360e54a0326b8b86ffc0 Signed-off-by: seshukm --- .../mso/db/catalog/test/HeatFilesTest.java | 87 ++++++++++++++++++++++ .../mso/db/catalog/test/ModelRecipeTest.java | 59 +++++++++++++++ .../openecomp/mso/db/catalog/test/ModelTest.java | 69 +++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/HeatFilesTest.java create mode 100644 mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelRecipeTest.java create mode 100644 mso-catalog-db/src/test/java/org/openecomp/mso/db/catalog/test/ModelTest.java (limited to 'mso-catalog-db') 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); + + } + +} -- cgit 1.2.3-korg