summaryrefslogtreecommitdiffstats
path: root/ms/controllerblueprints/modules/service/src/test
diff options
context:
space:
mode:
authorSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2018-12-21 10:31:48 -0500
committerSteve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>2018-12-21 15:43:49 -0500
commita19a6d1683689ffcc95f160b0c2ed4718505e7f4 (patch)
treefab6a7918c707696368475e9e8c5e2d04b12970d /ms/controllerblueprints/modules/service/src/test
parent40d739b066bbc44b82e484ec204132c4652552b2 (diff)
Applied comments from review: Change 74622 - Draft
Change-Id: I8ec37a628af98a332f568dc254e499dfdcf886ce Issue-ID: CCSDK-418 Signed-off-by: Steve Alphonse Siani <alphonse.steve.siani.djissitchi@ibm.com>
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