From 7fda9bd76272ba4712fa810632ce252dfafe3363 Mon Sep 17 00:00:00 2001 From: "Gadicherla, Shiva" Date: Mon, 2 Mar 2020 21:15:50 +0000 Subject: Junit test case coverage for some classes in music-rest Issue-ID: MUSIC-521 Signed-off-by: Gadicherla, Shiva Change-Id: I3be0da4c0f9e2cb052e9f2dcd3ce5931b8f59d9a --- .../music/eelf/healthcheck/MusicHealthCheck.java | 14 +++++++--- .../eelf/logging/MusicLoggingServletFilter.java | 2 +- .../java/org/onap/music/main/PropertiesLoader.java | 30 +++++++++++++++++++++- 3 files changed, 41 insertions(+), 5 deletions(-) (limited to 'music-rest/src/main/java/org') diff --git a/music-rest/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java b/music-rest/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java index fbfc0de6..acbbdd18 100644 --- a/music-rest/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java +++ b/music-rest/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java @@ -94,10 +94,15 @@ public class MusicHealthCheck { pQuery.appendQueryString("insert into admin.healthcheck (id) values (?)"); pQuery.addValue(randomUUID); ResultType rs = null; - rs = MusicCore.nonKeyRelatedPut(pQuery, consistency); + rs = nonKeyRelatedPut(pQuery, consistency); logger.info(rs.toString()); return null != rs; + } + + /*For unit testing purpose only*/ + public ResultType nonKeyRelatedPut(PreparedQueryObject pQuery, String consistency) throws MusicServiceException, MusicQueryException { + return MusicCore.nonKeyRelatedPut(pQuery, consistency); } private void cleanHealthCheckId(UUID randomUUID) throws MusicServiceException, MusicQueryException { @@ -105,11 +110,14 @@ public class MusicHealthCheck { PreparedQueryObject deleteQueryObject = new PreparedQueryObject(); deleteQueryObject.appendQueryString(cleanQuery); deleteQueryObject.addValue(randomUUID); - MusicDataStoreHandle.getDSHandle().executePut(deleteQueryObject, "eventual"); + executeEventualPut(deleteQueryObject); logger.info(EELFLoggerDelegate.applicationLogger, "Cassandra healthcheck responded and cleaned up."); } - + /*For unit testing purpose only*/ + public void executeEventualPut(PreparedQueryObject deleteQueryObject) throws MusicServiceException, MusicQueryException { + MusicDataStoreHandle.getDSHandle().executePut(deleteQueryObject, "eventual"); + } private boolean createKeyspace() throws MusicServiceException,MusicQueryException { PreparedQueryObject pQuery = new PreparedQueryObject(); diff --git a/music-rest/src/main/java/org/onap/music/eelf/logging/MusicLoggingServletFilter.java b/music-rest/src/main/java/org/onap/music/eelf/logging/MusicLoggingServletFilter.java index c8c6ba65..cda5b659 100644 --- a/music-rest/src/main/java/org/onap/music/eelf/logging/MusicLoggingServletFilter.java +++ b/music-rest/src/main/java/org/onap/music/eelf/logging/MusicLoggingServletFilter.java @@ -82,7 +82,7 @@ public class MusicLoggingServletFilter implements Filter { public void init(FilterConfig filterConfig) throws ServletException { } - + @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { diff --git a/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java b/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java index 9c69b9e2..3017b6d3 100644 --- a/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java +++ b/music-rest/src/main/java/org/onap/music/main/PropertiesLoader.java @@ -90,7 +90,7 @@ public class PropertiesLoader implements InitializingBean { @Value("${create.lock.wait.increment.ms}") private int createLockWaitIncrement; - + @Value("${transId.header.prefix}") private String transIdPrefix; @@ -340,5 +340,33 @@ public class PropertiesLoader implements InitializingBean { // TODO Auto-generated method stub } + + /* For unit testing purpose only*/ + protected void setProperties() { + cassandraHost = "127.0.0.1"; + debug = "true"; + version = "x.x.x"; + build = "y.y"; + musicProperties = "property"; + lockLeasePeriod = "5000"; + cassandraUser = "user"; + cassandraPassword = "password"; + cassandraPort = "8007"; + cassandraConnectTimeOutMS = "1000"; + cassandraReadTimeOutMS = "1000"; + isCadi = "true"; + isKeyspaceActive = "true"; + rertryCount = "20"; + transIdPrefix = "transId-"; + conversationIdPrefix = "conversation-"; + clientIdPrefix = "clientId-"; + messageIdPrefix = "messageId-"; + transIdRequired = true; + conversationIdRequired = true; + clientIdRequired = true; + messageIdRequired = true; + musicAafNs = "ns"; + cipherEncKey = "key"; + } } -- cgit 1.2.3-korg