aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/main/java/org/onap
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-18 11:38:10 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2017-09-18 11:38:10 +0530
commitdfeb8e23c04bc94050f95c95458605fb4c3cb6d5 (patch)
tree84bfa4840d29fcb08afbb1fc1bc4e72f0fdf1bf6 /framework/src/main/java/org/onap
parent1a4b4030e10b53ffc80d977908cd6097d843f7a8 (diff)
Improve the UT of profile
CLI-43 Change-Id: If2f1040a93d18d8f4375c459db3e7250f4dba99f Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main/java/org/onap')
-rw-r--r--framework/src/main/java/org/onap/cli/fw/error/OnapCommandLoadProfileFailed.java5
-rw-r--r--framework/src/main/java/org/onap/cli/fw/error/OnapCommandPersistProfileFailed.java6
-rw-r--r--framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java8
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java5
4 files changed, 17 insertions, 7 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandLoadProfileFailed.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandLoadProfileFailed.java
index 62fd84fa..0e3846a0 100644
--- a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandLoadProfileFailed.java
+++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandLoadProfileFailed.java
@@ -30,4 +30,9 @@ public class OnapCommandLoadProfileFailed extends OnapCommandException {
public OnapCommandLoadProfileFailed(String error) {
super("0x1301", "Failed to load profile details, " + error);
}
+
+ public OnapCommandLoadProfileFailed(Throwable error) {
+ this(error.getMessage());
+ }
+
}
diff --git a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandPersistProfileFailed.java b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandPersistProfileFailed.java
index f49e35c6..4e563d51 100644
--- a/framework/src/main/java/org/onap/cli/fw/error/OnapCommandPersistProfileFailed.java
+++ b/framework/src/main/java/org/onap/cli/fw/error/OnapCommandPersistProfileFailed.java
@@ -16,6 +16,8 @@
package org.onap.cli.fw.error;
+import java.io.IOException;
+
/**
* Command profile persistence failed.
*
@@ -30,4 +32,8 @@ public class OnapCommandPersistProfileFailed extends OnapCommandException {
public OnapCommandPersistProfileFailed(String error) {
super("0x1302", "Failed to persist profile details, " + error);
}
+
+ public OnapCommandPersistProfileFailed(Throwable e1) {
+ this(e1.getMessage());
+ }
}
diff --git a/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java b/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
index 6f043665..f8afd549 100644
--- a/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
+++ b/framework/src/main/java/org/onap/cli/fw/input/cache/OnapCommandParameterCache.java
@@ -34,8 +34,6 @@ public class OnapCommandParameterCache {
private String profileName = Constants.PARAM_CACHE_FILE_NAME;
- private boolean isLastPersistFailed = false;
-
private OnapCommandParameterCache() {
}
@@ -97,16 +95,16 @@ public class OnapCommandParameterCache {
try {
OnapCommandUtils.persistParams(params, this.profileName);
} catch (OnapCommandPersistProfileFailed e) {
- isLastPersistFailed = true;
+ throw new RuntimeException(e);
}
}
private void load() {
- List<Param> params;
+ List<Param> params= new ArrayList<>();
try {
params = OnapCommandUtils.loadParamFromCache(this.profileName);
} catch (OnapCommandLoadProfileFailed e) {
- params = new ArrayList<>();
+ throw new RuntimeException(e);
}
for (Param p : params) {
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
index 639e9636..2404a899 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/OnapCommandUtils.java
@@ -138,6 +138,7 @@ import org.onap.cli.fw.http.HttpResult;
import org.onap.cli.fw.input.OnapCommandParameter;
import org.onap.cli.fw.input.ParameterType;
import org.onap.cli.fw.input.cache.Param;
+import org.onap.cli.fw.log.OnapCommandLogger;
import org.onap.cli.fw.output.OnapCommandResult;
import org.onap.cli.fw.output.OnapCommandResultAttribute;
import org.onap.cli.fw.output.OnapCommandResultAttributeScope;
@@ -1639,7 +1640,7 @@ public class OnapCommandUtils {
mapper.writerWithDefaultPrettyPrinter().writeValue(file, params);
}
} catch (IOException e1) {
- throw new OnapCommandPersistProfileFailed(e1.getMessage());
+ throw new OnapCommandPersistProfileFailed(e1);
}
}
}
@@ -1715,7 +1716,7 @@ public class OnapCommandUtils {
params.addAll(Arrays.asList(list));
}
} catch (IOException e) {
- throw new OnapCommandLoadProfileFailed(e.getMessage());
+ throw new OnapCommandLoadProfileFailed(e);
}
return params;