summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/test
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2018-12-28 02:45:54 +0000
committerGerrit Code Review <gerrit@onap.org>2018-12-28 02:45:54 +0000
commit5a9cc8f332141e2d005ab1f823a8ce311e3b8e84 (patch)
treeea8d59591c5c85f3b9481ab000f36968469fc399 /ms/controllerblueprints/modules/service/src/test
parent8e8bfd22535e03f6c7df847813b5eaadd07c73ef (diff)
parenta19a6d1683689ffcc95f160b0c2ed4718505e7f4 (diff)
Merge "Applied comments from review: Change 74622 - Draft"
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/test')
-rwxr-xr-xms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java89
-rwxr-xr-x[-rw-r--r--]ms/controllerblueprints/modules/service/src/test/resources/application.properties8
2 files changed, 96 insertions, 1 deletions
diff --git a/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java
new file mode 100755
index 000000000..e3cea3800
--- /dev/null
+++ b/ms/controllerblueprints/modules/service/src/test/java/org/onap/ccsdk/apps/controllerblueprints/service/CbaFileManagementServiceTest.java
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2018 IBM Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.controllerblueprints.service;
+import org.junit.*;
+import org.junit.runner.RunWith;
+import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintFileUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.FileSystemUtils;
+import java.nio.file.Path;
+
+
+/**
+ * CbaFileManagementServiceTest.java Purpose: Test the decompressing method of CbaCompressionService
+ *
+ * @author Vinal Patel
+ * @version 1.0
+ */
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@ContextConfiguration(classes = {TestApplication.class})
+public class CbaFileManagementServiceTest {
+
+ @Value("${controllerblueprints.loadBlueprintsExamplesPath}")
+ private String cbaPath;
+ private String zipfile;
+ private String directorypath;
+ private Path zipfilepath;
+
+ @Autowired
+ CbaFileManagementService cbaCompressionService;
+
+
+ /**
+ *
+ */
+ @Before
+ public void setUp() {
+ try {
+ zipfilepath = BluePrintFileUtils.Companion.getCbaStorageDirectory(cbaPath);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ zipfile = "CBA_Zip_Test.zip";
+ directorypath = zipfilepath.resolve(zipfile.substring(0,zipfile.lastIndexOf("."))).toAbsolutePath().toString();
+ }
+ @After
+ public void clenup() throws BluePrintException {
+
+ try {
+ //Delete the Zip file from the repository
+ FileSystemUtils.deleteRecursively(BluePrintFileUtils.Companion.getBluePrintFile(directorypath, zipfilepath));
+ }
+ catch (Exception ex){
+ throw new BluePrintException("Fail while cleaning up CBA saved!", ex);
+ }
+ }
+
+ /**
+ * @throws BluePrintException
+ * Test will get success if it is able to decompress CBA file and returns the folder path
+ */
+ @Test
+ public void testDecompressCBAFile_success() throws BluePrintException {
+ Assert.assertEquals(directorypath,cbaCompressionService.decompressCBAFile(zipfile,zipfilepath));
+ }
+
+}
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/application.properties b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
index 718616bbd..4e1bedf23 100644..100755
--- a/ms/controllerblueprints/modules/service/src/test/resources/application.properties
+++ b/ms/controllerblueprints/modules/service/src/test/resources/application.properties
@@ -32,4 +32,10 @@ controllerblueprints.loadBluePrintPaths=./../../../../components/model-catalog/b
controllerblueprints.loadModelType=false
controllerblueprints.loadModeTypePaths=./../../../../components/model-catalog/definition-type/starter-type
controllerblueprints.loadResourceDictionary=false
-controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary \ No newline at end of file
+controllerblueprints.loadResourceDictionaryPaths=./../../../../components/model-catalog/resource-dictionary/starter-dictionary
+
+# CBA file extension
+controllerblueprints.loadCbaExtension=zip
+
+# CBA examples for tests cases
+controllerblueprints.loadBlueprintsExamplesPath=./../../../../components/model-catalog/blueprint-model/test-blueprints \ No newline at end of file