diff options
author | Dan Timoney <dtimoney@att.com> | 2018-12-28 02:45:54 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-12-28 02:45:54 +0000 |
commit | f5e7b450adf2392f5748ad0a95b1243527e65bee (patch) | |
tree | aea924a729d3fbcf1e31696fadfa19ffb4b9b80d /ms/controllerblueprints/modules/service/src/test | |
parent | d35235fd2ec0c9108594150c4f710622d59efc8a (diff) | |
parent | beb4b741c0093384bd39e8e4b1a917bf198ff953 (diff) |
Merge "Applied comments from review: Change 74622 - Draft"
Diffstat (limited to 'ms/controllerblueprints/modules/service/src/test')
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 00000000..e3cea380 --- /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 718616bb..4e1bedf2 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 |