diff options
author | 2016-08-24 17:55:22 +0800 | |
---|---|---|
committer | 2016-08-24 17:55:22 +0800 | |
commit | 5c16ff58fc795440b76c7bf724deba6e78366b86 (patch) | |
tree | 2c3018c63120d1475a4bbee7bfcca0e4fc4c67b1 /catalog-core/catalog-mgr/src/main | |
parent | 49302058ca6f43eb04d5cd5287aba012d489ebff (diff) |
Fix unit test issue
Change-Id: If42d15f2572c9005e61ca108ea7cdd0525771a31
Signed-off-by: huangjian <huang.jian12@zte.com.cn>
Diffstat (limited to 'catalog-core/catalog-mgr/src/main')
4 files changed, 48 insertions, 6 deletions
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java index 60a08583..34159585 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/common/ToolUtil.java @@ -87,12 +87,10 @@ public class ToolUtil { InputStream uploadedInputStream) throws IOException { File tmpDir = new File(dirName); LOG.info("tmpdir = " + File.separator + dirName); - LOG.info("tmpDir.getAbsolutePath() = " + tmpDir.getAbsolutePath()); if (!tmpDir.exists()) { tmpDir.mkdirs(); } - - File file = new File(tmpDir.getAbsolutePath() + File.separator + fileName); + File file = new File(tmpDir + File.separator + fileName); OutputStream os = null; try { int read = 0; @@ -112,7 +110,7 @@ public class ToolUtil { public static String getTempDir(String dirName, String fileName) { // File tmpDir = new File(File.separator + dirName); - return dirName + File.separator + fileName.replace(".csar", ""); + return Class.class.getClass().getResource("/").getPath() + dirName + File.separator + fileName.replace(".csar", ""); } public static String getUnzipDir(String dirName) { diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java new file mode 100644 index 00000000..c4cab536 --- /dev/null +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/entity/EnumOnboardState.java @@ -0,0 +1,34 @@ +/**
+ * Copyright 2016 [ZTE] and others.
+ *
+ * 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.openo.commontosca.catalog.entity;
+
+/**
+ * @author 00164331
+ *
+ */
+public enum EnumOnboardState {
+ onBoarded("onBoarded"), nonOnBoarded("non-onBoarded");
+
+ String value;
+
+ EnumOnboardState(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+}
diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java index c323f11a..f0a68d59 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/filemanage/http/HttpFileManagerImpl.java @@ -38,8 +38,9 @@ public class HttpFileManagerImpl implements FileManager { } // File dstFile = new File(ToolUtil.getHttpServerPath() + dstPath); // LOGGER.info("dstFile AbsolutePath:" + dstFile.getAbsolutePath()); + String targetDir = Class.class.getClass().getResource("/").getPath() + ToolUtil.getHttpServerPath() + dstPath; try { - ToolUtil.copyDirectory(srcPath, ToolUtil.getHttpServerPath() + dstPath, true); + ToolUtil.copyDirectory(srcPath, targetDir, true); } catch (IOException e) { flag = false; LOGGER.error("copy file failed.errorMsg:" + e.getMessage()); diff --git a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java index 7395ed16..ed20c14c 100644 --- a/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java +++ b/catalog-core/catalog-mgr/src/main/java/org/openo/commontosca/catalog/wrapper/PackageWrapperUtil.java @@ -42,6 +42,7 @@ import org.openo.commontosca.catalog.model.externalservice.lifecycle.LifeCycleSe import org.openo.commontosca.catalog.common.ToolUtil;
import org.openo.commontosca.catalog.db.entity.PackageData;
import org.openo.commontosca.catalog.entity.CSARPackage;
+import org.openo.commontosca.catalog.entity.EnumOnboardState;
import org.openo.commontosca.catalog.entity.EnumOperationalState;
import org.openo.commontosca.catalog.entity.EnumUsageState;
import org.openo.commontosca.catalog.entity.response.PackageMeta;
@@ -146,7 +147,7 @@ public class PackageWrapperUtil { packageMeta.setModifyTime(currentTime);
packageMeta.setOperationalState(EnumOperationalState.Disabled);
packageMeta.setUsageState(EnumUsageState.NotInUse);
- packageMeta.setOnBoardState("false");
+ packageMeta.setOnBoardState(EnumOnboardState.nonOnBoarded.getValue());
packageMeta.setProcessState(EnumProcessState.normal);
return packageMeta;
}
@@ -292,6 +293,14 @@ public class PackageWrapperUtil { }
return metas;
}
+
+ public static EnumOnboardState getEnumByValue(String value) {
+ if(value == "non-onBoarded") {
+ return EnumOnboardState.nonOnBoarded;
+ } else {
+ return EnumOnboardState.onBoarded;
+ }
+ }
private static PackageMeta packageData2PackageMeta(PackageData packageData) {
PackageMeta meta = new PackageMeta();
|