2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2019 IBM Intellectual Property
6 * ===================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=============================================
20 * ====================================================================
22 package org.onap.music.exceptions;
24 import static org.junit.Assert.assertEquals;
26 import org.junit.Test;
28 public class MusicServiceExceptionTest {
30 public void TestException1() {
34 if (!s1.equalsIgnoreCase(s2)) {
35 throw new MusicServiceException();
37 } catch (MusicServiceException mse) {
38 assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
44 public void TestException2() {
48 if (!s1.equalsIgnoreCase(s2)) {
49 throw new MusicServiceException("MusicServiceException Exception occured..");
51 } catch (MusicServiceException mse) {
52 assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
58 public void TestException3() {
62 if (!s1.equalsIgnoreCase(s2)) {
63 throw new MusicServiceException("MusicServiceException Exception occured..", 001);
65 } catch (MusicServiceException mse) {
66 assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
72 public void TestException4() {
76 if (!s1.equalsIgnoreCase(s2)) {
77 throw new MusicServiceException("MusicServiceException Exception occured..", 001, "errorMsg");
79 } catch (MusicServiceException mse) {
80 assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
86 public void TestException5() {
90 if (!s1.equalsIgnoreCase(s2)) {
91 throw new MusicServiceException(new Throwable());
93 } catch (MusicServiceException mse) {
94 assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
100 public void TestException6() {
101 String message = "Exception occured";
102 String s1 = "Value1";
103 String s2 = "value2";
105 if (!s1.equalsIgnoreCase(s2)) {
106 throw new MusicServiceException(message, new Throwable());
108 } catch (MusicServiceException mse) {
109 assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
115 public void TestException7() {
116 String message = "Exception occured";
117 boolean enableSuppression = true;
118 boolean writableStackTrace = false;
119 String s1 = "Value1";
120 String s2 = "value2";
122 if (!s1.equalsIgnoreCase(s2)) {
123 throw new MusicServiceException(message, new Throwable(), enableSuppression, writableStackTrace);
125 } catch (MusicServiceException mse) {
126 assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
132 public void testErrorCode() {
133 MusicServiceException musicServiceException = new MusicServiceException();
134 musicServiceException.setErrorCode(0001);
135 assertEquals(0001, musicServiceException.getErrorCode());
139 public void testSetErrorMsg() {
140 MusicServiceException musicServiceException = new MusicServiceException();
141 musicServiceException.setErrorMessage("errorMsg");
142 assertEquals("errorMsg", musicServiceException.getErrorMessage());