diff options
author | Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com> | 2018-03-06 12:13:17 -0500 |
---|---|---|
committer | Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com> | 2018-03-06 12:13:17 -0500 |
commit | 0fec5f6d51014d07449c3b9a3c62d77f6c5d0a57 (patch) | |
tree | ca5a75313c1cabc256b7000c7b8aee065ca48296 /src/main/java/org/onap/music/rest | |
parent | a85726c8f611175a21fb55c139f8430ea82fc39d (diff) |
More Unit tests for Sonar coverage
Change-Id: I5cc3d490bdc70dfa0ed69e1ee6d954ef2846f8e5
Issue-ID: MUSIC-40
Signed-off-by: Thomas Nelson Jr (arthurdent3) tn1381@att.com <tn1381@att.com>
Diffstat (limited to 'src/main/java/org/onap/music/rest')
-rwxr-xr-x | src/main/java/org/onap/music/rest/RestMusicAdminAPI.java | 4 | ||||
-rwxr-xr-x | src/main/java/org/onap/music/rest/RestMusicDataAPI.java | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java index 6d8ac088..849c3a98 100755 --- a/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicAdminAPI.java @@ -39,6 +39,9 @@ import javax.ws.rs.core.MediaType; import org.onap.music.datastore.PreparedQueryObject; import org.onap.music.datastore.jsonobjects.JsonOnboard; import org.onap.music.eelf.logging.EELFLoggerDelegate; +import org.onap.music.eelf.logging.format.AppMessages; +import org.onap.music.eelf.logging.format.ErrorSeverity; +import org.onap.music.eelf.logging.format.ErrorTypes; import org.onap.music.main.CachingUtil; import org.onap.music.main.MusicCore; import org.onap.music.main.MusicUtil; @@ -72,6 +75,7 @@ public class RestMusicAdminAPI { String password = jsonObj.getPassword(); response.addHeader("X-latestVersion", MusicUtil.getVersion()); if (appName == null || userId == null || isAAF == null || password == null) { + logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGINFO ,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR); resultMap.put("Exception", "Please check the request parameters. Some of the required values appName(ns), userId, password, isAAF are missing."); return resultMap; diff --git a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java index 0eedbaa0..ed586d06 100755 --- a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java +++ b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java @@ -44,6 +44,9 @@ import org.onap.music.datastore.jsonobjects.JsonTable; import org.onap.music.datastore.jsonobjects.JsonUpdate; import org.onap.music.eelf.logging.EELFLoggerDelegate; import org.onap.music.exceptions.MusicLockingException; +import org.onap.music.eelf.logging.format.AppMessages; +import org.onap.music.eelf.logging.format.ErrorSeverity; +import org.onap.music.eelf.logging.format.ErrorTypes; import org.onap.music.exceptions.MusicServiceException; import org.onap.music.main.CachingUtil; import org.onap.music.main.MusicCore; @@ -257,7 +260,7 @@ public class RestMusicDataAPI { queryObject.appendQueryString(";"); result = MusicCore.nonKeyRelatedPut(queryObject, consistency); } catch (Exception e) { - logger.error(EELFLoggerDelegate.errorLogger, e.getMessage()); + logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR); } resultMap.remove("uuid"); try { @@ -382,6 +385,7 @@ public class RestMusicDataAPI { @ApiParam(value = "Table Name", required = true) @PathParam("tablename") String tablename, @Context HttpServletResponse response) throws Exception { + Map<String, Object> resultMap = MusicCore.autheticateUser(ns, userId, password, keyspace, aid, "createTable"); response.addHeader(xLatestVersion, MusicUtil.getVersion()); @@ -655,7 +659,7 @@ public class RestMusicDataAPI { : new ReturnType(ResultType.FAILURE, "Null result - Please Contact admin").toMap(); } catch (Exception ex) { - logger.error(EELFLoggerDelegate.applicationLogger, ex.getMessage()); + logger.error(EELFLoggerDelegate.errorLogger,ex.getMessage(), AppMessages.UNKNOWNERROR ,ErrorSeverity.WARN, ErrorTypes.MUSICSERVICEERROR); return new ReturnType(ResultType.FAILURE, ex.getMessage()).toMap(); } } @@ -1150,7 +1154,7 @@ public class RestMusicDataAPI { if (resultMap.containsKey("aid")) resultMap.remove("aid"); if (!resultMap.isEmpty()) { - logger.error("Error while authentication... "); + logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.AUTHENTICATIONERROR ,ErrorSeverity.WARN, ErrorTypes.AUTHENTICATIONERROR); HashMap<String, Object> tempMap = new HashMap<>(); tempMap.putAll(resultMap); Map<String, HashMap<String, Object>> results = new HashMap<>(); @@ -1175,6 +1179,7 @@ public class RestMusicDataAPI { ResultSet results = MusicCore.get(queryObject); return MusicCore.marshallResults(results); } catch (MusicServiceException ex) { + logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.UNKNOWNERROR ,ErrorSeverity.ERROR, ErrorTypes.MUSICSERVICEERROR); return MusicUtil.setErrorResponse(ex); } |