Split music src into music-core and music-rest
[music.git] / music-core / src / test / java / org / onap / music / exceptions / MusicServiceExceptionTest.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
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
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  * ============LICENSE_END=============================================
20  * ====================================================================
21  */
22 package org.onap.music.exceptions;
23
24 import static org.junit.Assert.assertEquals;
25
26 import org.junit.Test;
27
28 public class MusicServiceExceptionTest {
29     @Test
30     public void TestException1() {
31         String s1 = "Value1";
32         String s2 = "value2";
33         try {
34             if (!s1.equalsIgnoreCase(s2)) {
35                 throw new MusicServiceException();
36             }
37         } catch (MusicServiceException mse) {
38             assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
39         }
40
41     }
42
43     @Test
44     public void TestException2() {
45         String s1 = "Value1";
46         String s2 = "value2";
47         try {
48             if (!s1.equalsIgnoreCase(s2)) {
49                 throw new MusicServiceException("MusicServiceException Exception occured..");
50             }
51         } catch (MusicServiceException mse) {
52             assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
53         }
54
55     }
56
57     @Test
58     public void TestException3() {
59         String s1 = "Value1";
60         String s2 = "value2";
61         try {
62             if (!s1.equalsIgnoreCase(s2)) {
63                 throw new MusicServiceException("MusicServiceException Exception occured..", 001);
64             }
65         } catch (MusicServiceException mse) {
66             assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
67         }
68
69     }
70
71     @Test
72     public void TestException4() {
73         String s1 = "Value1";
74         String s2 = "value2";
75         try {
76             if (!s1.equalsIgnoreCase(s2)) {
77                 throw new MusicServiceException("MusicServiceException Exception occured..", 001, "errorMsg");
78             }
79         } catch (MusicServiceException mse) {
80             assertEquals(mse.getMessage(), "MusicServiceException Exception occured..");
81         }
82
83     }
84
85     @Test
86     public void TestException5() {
87         String s1 = "Value1";
88         String s2 = "value2";
89         try {
90             if (!s1.equalsIgnoreCase(s2)) {
91                 throw new MusicServiceException(new Throwable());
92             }
93         } catch (MusicServiceException mse) {
94             assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
95         }
96
97     }
98
99     @Test
100     public void TestException6() {
101         String message = "Exception occured";
102         String s1 = "Value1";
103         String s2 = "value2";
104         try {
105             if (!s1.equalsIgnoreCase(s2)) {
106                 throw new MusicServiceException(message, new Throwable());
107             }
108         } catch (MusicServiceException mse) {
109             assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
110         }
111
112     }
113
114     @Test
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";
121         try {
122             if (!s1.equalsIgnoreCase(s2)) {
123                 throw new MusicServiceException(message, new Throwable(), enableSuppression, writableStackTrace);
124             }
125         } catch (MusicServiceException mse) {
126             assertEquals("org.onap.music.exceptions.MusicServiceException", mse.getClass().getName());
127         }
128
129     }
130
131     @Test
132     public void testErrorCode() {
133         MusicServiceException musicServiceException = new MusicServiceException();
134         musicServiceException.setErrorCode(0001);
135         assertEquals(0001, musicServiceException.getErrorCode());
136     }
137
138     @Test
139     public void testSetErrorMsg() {
140         MusicServiceException musicServiceException = new MusicServiceException();
141         musicServiceException.setErrorMessage("errorMsg");
142         assertEquals("errorMsg", musicServiceException.getErrorMessage());
143     }
144
145 }