aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/java/org/onap/music/JerseyConfig.java97
-rw-r--r--src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java10
-rw-r--r--src/main/java/org/onap/music/main/CronJobManager.java22
-rwxr-xr-xsrc/main/java/org/onap/music/rest/RestMusicDataAPI.java7
-rw-r--r--src/main/java/org/onap/music/service/impl/MusicCassaCore.java7
-rw-r--r--src/test/java/org/onap/music/exceptions/MusicLockingExceptionTest.java104
-rw-r--r--src/test/java/org/onap/music/exceptions/MusicPolicyVoilationExceptionTest.java106
-rw-r--r--src/test/java/org/onap/music/exceptions/MusicQueryExceptionTest.java118
-rw-r--r--src/test/java/org/onap/music/exceptions/MusicServiceExceptionTest.java145
9 files changed, 538 insertions, 78 deletions
diff --git a/src/main/java/org/onap/music/JerseyConfig.java b/src/main/java/org/onap/music/JerseyConfig.java
index 74958363..1b5f034a 100755
--- a/src/main/java/org/onap/music/JerseyConfig.java
+++ b/src/main/java/org/onap/music/JerseyConfig.java
@@ -1,64 +1,55 @@
-/*
- * Copyright 2012-2015 the original author or authors.
- *
- * 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.onap.music;
-
-import javax.annotation.PostConstruct;
-import javax.ws.rs.ApplicationPath;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.onap.music.rest.RestMusicAdminAPI;
-import org.onap.music.rest.RestMusicDataAPI;
-import org.onap.music.rest.RestMusicHealthCheckAPI;
-import org.onap.music.rest.RestMusicLocksAPI;
-import org.onap.music.rest.RestMusicQAPI;
-import org.onap.music.rest.RestMusicTestAPI;
-import org.onap.music.rest.RestMusicVersionAPI;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
+/*
+ * Copyright 2012-2015 the original author or authors.
+ *
+ * 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.onap.music;
+
import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.jaxrs.listing.ApiListingResource;
-import io.swagger.jaxrs.listing.SwaggerSerializers;
-
-@Component
-public class JerseyConfig extends ResourceConfig {
-
- @Value("${spring.jersey.application-path:/}")
- private String apiPath;
-
- public JerseyConfig() {
+import io.swagger.jaxrs.listing.SwaggerSerializers;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.onap.music.rest.*;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+
+@Component public class JerseyConfig extends ResourceConfig {
+
+ @Value("${spring.jersey.application-path:/}") private String apiPath;
+
+ public JerseyConfig() {
this.registerEndpoints();
- }
-
- @PostConstruct
- public void init() {
+ }
+
+ @PostConstruct public void init() {
this.configureSwagger();
}
-
+
private void registerEndpoints() {
- register(RestMusicAdminAPI.class);
- register(RestMusicDataAPI.class);
- register(RestMusicLocksAPI.class);
- register(RestMusicQAPI.class);
- register(RestMusicTestAPI.class);
+ register(RestMusicAdminAPI.class);
+ register(RestMusicDataAPI.class);
+ register(RestMusicLocksAPI.class);
+ register(RestMusicQAPI.class);
+ register(RestMusicTestAPI.class);
register(RestMusicVersionAPI.class);
register(RestMusicHealthCheckAPI.class);
}
-
+
private void configureSwagger() {
- // Available at localhost:port/swagger.json
+ //Available at localhost:port/swagger.json
this.register(ApiListingResource.class);
this.register(SwaggerSerializers.class);
@@ -67,11 +58,11 @@ public class JerseyConfig extends ResourceConfig {
config.setTitle("MUSIC");
config.setVersion("v2");
config.setContact("Thomas Nelson");
- config.setSchemes(new String[] { "http", "https" });
+ config.setSchemes(new String[] {"http", "https"});
config.setBasePath("/MUSIC/rest");
config.setResourcePackage("org.onap.music");
config.setPrettyPrint(true);
config.setScan(true);
}
-
+
}
diff --git a/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java b/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java
index 93c44468..3e962a02 100644
--- a/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java
+++ b/src/main/java/org/onap/music/eelf/healthcheck/MusicHealthCheck.java
@@ -3,6 +3,8 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ *
+ * Modifications Copyright (C) 2019 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,9 +67,7 @@ public class MusicHealthCheck {
try {
result = getAdminKeySpace(consistency);
} catch (MusicServiceException e1) {
- // TODO Auto-generated catch block
- logger.error("Error", e);
- e1.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger, e1.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.UNKNOWN);
}
} else {
logger.error("Error", e);
@@ -106,9 +106,7 @@ public class MusicHealthCheck {
try {
rs = MusicCore.nonKeyRelatedPut(pQuery, ConsistencyLevel.ONE.toString());
} catch (MusicServiceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- logger.error("Error", e);
+ logger.error(EELFLoggerDelegate.errorLogger, e.getMessage(),AppMessages.UNKNOWNERROR, ErrorSeverity.ERROR, ErrorTypes.UNKNOWN);
}
if(rs != null && rs.getResult().toLowerCase().contains("success"))
return true;
diff --git a/src/main/java/org/onap/music/main/CronJobManager.java b/src/main/java/org/onap/music/main/CronJobManager.java
index 9cd9f33f..ea2fa685 100644
--- a/src/main/java/org/onap/music/main/CronJobManager.java
+++ b/src/main/java/org/onap/music/main/CronJobManager.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
* 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
@@ -25,12 +27,6 @@ package org.onap.music.main;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Iterator;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.annotation.WebListener;
import org.onap.music.datastore.PreparedQueryObject;
import org.onap.music.eelf.logging.EELFLoggerDelegate;
@@ -52,13 +48,13 @@ public class CronJobManager {
private static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
-
+
@Scheduled(cron = "0 0 0 * * ?")
public void scheduleTaskWithFixedRate() {
logger.info("Executing cronjob to cleanup locks..", dateTimeFormatter.format(LocalDateTime.now()) );
deleteLocksFromDB();
}
-
+
public void deleteLocksFromDB() {
PreparedQueryObject pQuery = new PreparedQueryObject();
String consistency = MusicUtil.EVENTUAL;
@@ -69,10 +65,9 @@ public class CronJobManager {
logger.error(EELFLoggerDelegate.errorLogger,"Error creating Admin.locks table.",AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
}
} catch (MusicServiceException e1) {
- logger.error(EELFLoggerDelegate.errorLogger,e1.getMessage(),AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
- e1.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger,e1,AppMessages.QUERYERROR,ErrorSeverity.CRITICAL, ErrorTypes.QUERYERROR);
}
-
+
pQuery = new PreparedQueryObject();
pQuery.appendQueryString(
"select * from admin.locks");
@@ -82,7 +77,7 @@ public class CronJobManager {
StringBuilder deleteKeys = new StringBuilder();
Boolean expiredKeys = false;
while (it.hasNext()) {
- Row row = (Row) it.next();
+ Row row = it.next();
String id = row.getString("lock_id");
long ctime = Long.parseLong(row.getString("ctime"));
if(System.currentTimeMillis() >= ctime + 24 * 60 * 60 * 1000) {
@@ -102,8 +97,7 @@ public class CronJobManager {
CachingUtil.deleteKeysFromDB(deleteKeys.toString());
}
} catch (MusicServiceException e) {
- logger.error(EELFLoggerDelegate.errorLogger,e.getMessage(),AppMessages.CACHEERROR,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
- e.printStackTrace();
+ logger.error(EELFLoggerDelegate.errorLogger,e,AppMessages.CACHEERROR,ErrorSeverity.CRITICAL, ErrorTypes.DATAERROR);
}
}
}
diff --git a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
index 507bcd40..0010ed1a 100755
--- a/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
+++ b/src/main/java/org/onap/music/rest/RestMusicDataAPI.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ===================================================================
* 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
@@ -404,9 +406,10 @@ public class RestMusicDataAPI {
@ApiParam(value = "Table Name",required = true) @PathParam("tablename") String tablename) throws Exception {
try {
ResponseBuilder response = MusicUtil.buildVersionResponse(VERSION, minorVersion, patchVersion);
- if((keyspace == null || keyspace == null) || (tablename.isEmpty() || tablename.isEmpty())){
+ if(keyspace == null || keyspace.isEmpty() || tablename == null || tablename.isEmpty()){
return response.status(Status.BAD_REQUEST).entity(new JsonResponse(ResultType.FAILURE)
- .setError("one or more path parameters are not set, please check and try again")
+ .setError("One or more path parameters are not set, please check and try again."
+ + "Parameter values: keyspace='" + keyspace + "' tablename='" + tablename + "'")
.toMap()).build();
}
EELFLoggerDelegate.mdcPut("keyspace", "( "+keyspace+" ) ");
diff --git a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
index 8737a060..36d756bb 100644
--- a/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
+++ b/src/main/java/org/onap/music/service/impl/MusicCassaCore.java
@@ -3,6 +3,7 @@
* org.onap.music
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
+ * Modifications Copyright (c) 2018 IBM.
* ===================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -165,7 +166,7 @@ public class MusicCassaCore implements MusicCoreService {
String keyspace = splitString[0].substring(1);//remove '$'
String table = splitString[1];
String primaryKeyValue = splitString[2].substring(0, splitString[2].lastIndexOf("$"));
- fullyQualifiedKey = lockId.substring(1, lockId.lastIndexOf("$"));
+ String localFullyQualifiedKey = lockId.substring(1, lockId.lastIndexOf("$"));
String lockRef = lockId.substring(lockId.lastIndexOf("$")+1); //lockRef is "$" to end
ReturnType result = isTopOfLockStore(keyspace, table, primaryKeyValue, lockRef);
@@ -175,7 +176,7 @@ public class MusicCassaCore implements MusicCoreService {
//check to see if the value of the key has to be synced in case there was a forceful release
String syncTable = keyspace+".unsyncedKeys_"+table;
- String query = "select * from "+syncTable+" where key='"+fullyQualifiedKey+"';";
+ String query = "select * from "+syncTable+" where key='"+localFullyQualifiedKey+"';";
PreparedQueryObject readQueryObject = new PreparedQueryObject();
readQueryObject.appendQueryString(query);
ResultSet results = MusicDataStoreHandle.getDSHandle().executeQuorumConsistencyGet(readQueryObject);
@@ -189,7 +190,7 @@ public class MusicCassaCore implements MusicCoreService {
String exceptionAsString = sw.toString();
return new ReturnType(ResultType.FAILURE, "Exception thrown while syncing key:\n" + exceptionAsString);
}
- String cleanQuery = "delete from music_internal.unsynced_keys where key='"+fullyQualifiedKey+"';";
+ String cleanQuery = "delete from music_internal.unsynced_keys where key='"+localFullyQualifiedKey+"';";
PreparedQueryObject deleteQueryObject = new PreparedQueryObject();
deleteQueryObject.appendQueryString(cleanQuery);
MusicDataStoreHandle.getDSHandle().executePut(deleteQueryObject, "critical");
diff --git a/src/test/java/org/onap/music/exceptions/MusicLockingExceptionTest.java b/src/test/java/org/onap/music/exceptions/MusicLockingExceptionTest.java
new file mode 100644
index 00000000..583a9fd4
--- /dev/null
+++ b/src/test/java/org/onap/music/exceptions/MusicLockingExceptionTest.java
@@ -0,0 +1,104 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM Intellectual Property
+ * ===================================================================
+ * 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.
+ *
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+package org.onap.music.exceptions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class MusicLockingExceptionTest {
+
+ @Test
+ public void TestException1() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicLockingException();
+ }
+ } catch (MusicLockingException mle) {
+ assertEquals("org.onap.music.exceptions.MusicLockingException", mle.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException2() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicLockingException("MusicLockingException Exception occured..");
+ }
+ } catch (MusicLockingException mle) {
+ assertEquals(mle.getMessage(), "MusicLockingException Exception occured..");
+ }
+
+ }
+
+ @Test
+ public void TestException3() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicLockingException(new Throwable());
+ }
+ } catch (MusicLockingException mle) {
+ assertEquals("org.onap.music.exceptions.MusicLockingException", mle.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException4() {
+ String message = "Exception occured";
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicLockingException(message, new Throwable());
+ }
+ } catch (MusicLockingException mle) {
+ assertEquals("org.onap.music.exceptions.MusicLockingException", mle.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException5() {
+ String message = "Exception occured";
+ boolean enableSuppression = true;
+ boolean writableStackTrace = false;
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicLockingException(message, new Throwable(), enableSuppression, writableStackTrace);
+ }
+ } catch (MusicLockingException mle) {
+ assertEquals("org.onap.music.exceptions.MusicLockingException", mle.getClass().getName());
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/onap/music/exceptions/MusicPolicyVoilationExceptionTest.java b/src/test/java/org/onap/music/exceptions/MusicPolicyVoilationExceptionTest.java
new file mode 100644
index 00000000..22e2d728
--- /dev/null
+++ b/src/test/java/org/onap/music/exceptions/MusicPolicyVoilationExceptionTest.java
@@ -0,0 +1,106 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM Intellectual Property
+ * ===================================================================
+ * 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.
+ *
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+
+package org.onap.music.exceptions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class MusicPolicyVoilationExceptionTest {
+
+ @Test
+ public void TestException1() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicPolicyVoilationException();
+ }
+ } catch (MusicPolicyVoilationException mve) {
+ assertEquals("org.onap.music.exceptions.MusicPolicyVoilationException", mve.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException2() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicPolicyVoilationException("MusicPolicyVoilationException Exception occured..");
+ }
+ } catch (MusicPolicyVoilationException mve) {
+ assertEquals(mve.getMessage(), "MusicPolicyVoilationException Exception occured..");
+ }
+
+ }
+
+ @Test
+ public void TestException3() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicPolicyVoilationException(new Throwable());
+ }
+ } catch (MusicPolicyVoilationException mve) {
+ assertEquals("org.onap.music.exceptions.MusicPolicyVoilationException", mve.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException4() {
+ String message = "Exception occured";
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicPolicyVoilationException(message, new Throwable());
+ }
+ } catch (MusicPolicyVoilationException mve) {
+ assertEquals("org.onap.music.exceptions.MusicPolicyVoilationException", mve.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException5() {
+ String message = "Exception occured";
+ boolean enableSuppression = true;
+ boolean writableStackTrace = false;
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicPolicyVoilationException(message, new Throwable(), enableSuppression,
+ writableStackTrace);
+ }
+ } catch (MusicPolicyVoilationException mve) {
+ assertEquals("org.onap.music.exceptions.MusicPolicyVoilationException", mve.getClass().getName());
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/onap/music/exceptions/MusicQueryExceptionTest.java b/src/test/java/org/onap/music/exceptions/MusicQueryExceptionTest.java
new file mode 100644
index 00000000..9096506a
--- /dev/null
+++ b/src/test/java/org/onap/music/exceptions/MusicQueryExceptionTest.java
@@ -0,0 +1,118 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM Intellectual Property
+ * ===================================================================
+ * 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.
+ *
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+package org.onap.music.exceptions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class MusicQueryExceptionTest {
+
+ @Test
+ public void TestException1() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicQueryException();
+ }
+ } catch (MusicQueryException mqe) {
+ assertEquals("org.onap.music.exceptions.MusicQueryException", mqe.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException2() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicQueryException("MusicQueryException Exception occured..");
+ }
+ } catch (MusicQueryException mqe) {
+ assertEquals(mqe.getMessage(), "MusicQueryException Exception occured..");
+ }
+
+ }
+
+ @Test
+ public void TestException3() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicQueryException("MusicQueryException Exception occured..", 001);
+ }
+ } catch (MusicQueryException mqe) {
+ assertEquals(mqe.getMessage(), "MusicQueryException Exception occured..");
+ }
+
+ }
+
+ @Test
+ public void TestException4() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicQueryException(new Throwable());
+ }
+ } catch (MusicQueryException mqe) {
+ assertEquals("org.onap.music.exceptions.MusicQueryException", mqe.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException5() {
+ String message = "Exception occured";
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicQueryException(message, new Throwable());
+ }
+ } catch (MusicQueryException mqe) {
+ assertEquals("org.onap.music.exceptions.MusicQueryException", mqe.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException6() {
+ String message = "Exception occured";
+ boolean enableSuppression = true;
+ boolean writableStackTrace = false;
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicQueryException(message, new Throwable(), enableSuppression, writableStackTrace);
+ }
+ } catch (MusicQueryException mqe) {
+ assertEquals("org.onap.music.exceptions.MusicQueryException", mqe.getClass().getName());
+ }
+
+ }
+
+}
diff --git a/src/test/java/org/onap/music/exceptions/MusicServiceExceptionTest.java b/src/test/java/org/onap/music/exceptions/MusicServiceExceptionTest.java
new file mode 100644
index 00000000..bf056b61
--- /dev/null
+++ b/src/test/java/org/onap/music/exceptions/MusicServiceExceptionTest.java
@@ -0,0 +1,145 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM Intellectual Property
+ * ===================================================================
+ * 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.
+ *
+ * ============LICENSE_END=============================================
+ * ====================================================================
+ */
+package org.onap.music.exceptions;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class MusicServiceExceptionTest {
+ @Test
+ public void TestException1() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicServiceException();
+ }
+ } catch (MusicServiceException mse) {
+ assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException2() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicServiceException("MusicServiceException Exception occured..");
+ }
+ } catch (MusicServiceException mse) {
+ assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
+ }
+
+ }
+
+ @Test
+ public void TestException3() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicServiceException("MusicServiceException Exception occured..", 001);
+ }
+ } catch (MusicServiceException mse) {
+ assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
+ }
+
+ }
+
+ @Test
+ public void TestException4() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicServiceException("MusicServiceException Exception occured..", 001, "errorMsg");
+ }
+ } catch (MusicServiceException mse) {
+ assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
+ }
+
+ }
+
+ @Test
+ public void TestException5() {
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicServiceException(new Throwable());
+ }
+ } catch (MusicServiceException mse) {
+ assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException6() {
+ String message = "Exception occured";
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicServiceException(message, new Throwable());
+ }
+ } catch (MusicServiceException mse) {
+ assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void TestException7() {
+ String message = "Exception occured";
+ boolean enableSuppression = true;
+ boolean writableStackTrace = false;
+ String s1 = "Value1";
+ String s2 = "value2";
+ try {
+ if (!s1.equalsIgnoreCase(s2)) {
+ throw new MusicServiceException(message, new Throwable(), enableSuppression, writableStackTrace);
+ }
+ } catch (MusicServiceException mse) {
+ assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
+ }
+
+ }
+
+ @Test
+ public void testErrorCode() {
+ MusicServiceException musicServiceException = new MusicServiceException();
+ musicServiceException.setErrorCode(0001);
+ assertEquals(0001, musicServiceException.getErrorCode());
+ }
+
+ @Test
+ public void testSetErrorMsg() {
+ MusicServiceException musicServiceException = new MusicServiceException();
+ musicServiceException.setErrorMessage("errorMsg");
+ assertEquals("errorMsg", musicServiceException.getErrorMessage());
+ }
+
+}