aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/music/main/CachingUtil.java
diff options
context:
space:
mode:
authorThomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>2018-03-04 03:28:07 -0500
committerThomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>2018-03-04 03:28:07 -0500
commitf327e0cb4a14ff8d4f85e5ae9da5986b8c87ab8c (patch)
treec5fc16c846c3e4b1c894c359e91cf68baa4af088 /src/main/java/org/onap/music/main/CachingUtil.java
parent168c54c6e774563910a3ed5a7480ea63cd3fe572 (diff)
Sonar Fixes to increate Coverage on Unit tests
Including bug fix that added proper Exception handling on REST Calls. Change-Id: I618faa69ab549e76c148bb7c664a5ffe0eae84ca Issue-ID: MUSIC-44, MUSIC-45 Signed-off-by: Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/main/CachingUtil.java')
-rwxr-xr-xsrc/main/java/org/onap/music/main/CachingUtil.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/org/onap/music/main/CachingUtil.java b/src/main/java/org/onap/music/main/CachingUtil.java
index 4b2b4824..aef261f0 100755
--- a/src/main/java/org/onap/music/main/CachingUtil.java
+++ b/src/main/java/org/onap/music/main/CachingUtil.java
@@ -378,8 +378,7 @@ public class CachingUtil implements Runnable {
}
- public static Map<String, Object> verifyOnboarding(String ns, String userId, String password)
- throws Exception {
+ public static Map<String, Object> verifyOnboarding(String ns, String userId, String password) {
Map<String, Object> resultMap = new HashMap<>();
if (ns == null || userId == null || password == null) {
logger.error(EELFLoggerDelegate.errorLogger,"One or more required headers is missing. userId: "+userId+" :: password: "+password);
@@ -390,10 +389,24 @@ public class CachingUtil implements Runnable {
PreparedQueryObject queryObject = new PreparedQueryObject();
queryObject.appendQueryString(
"select * from admin.keyspace_master where application_name = ? and username = ? and password = ? allow filtering");
- queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), ns));
- queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
- queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), password));
- Row rs = MusicCore.get(queryObject).one();
+ try {
+ queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), ns));
+ queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), userId));
+ queryObject.addValue(MusicUtil.convertToActualDataType(DataType.text(), password));
+ } catch(Exception e) {
+ resultMap.put("Exception",
+ "Unable to process input data. Invalid input data type. Please check ns, userId and password values. "+e.getMessage());
+ return resultMap;
+ }
+ Row rs = null;
+ try {
+ rs = MusicCore.get(queryObject).one();
+ } catch (MusicServiceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ resultMap.put("Exception", "Unable to process operation. Error is "+e.getMessage());
+ return resultMap;
+ }
if (rs == null) {
logger.error(EELFLoggerDelegate.errorLogger,"Namespace, UserId and password doesn't match. namespace: "+ns+" and userId: "+userId);