Junit test case coverage for some classes in music-rest
[music.git] / music-rest / src / test / java / org / onap / music / rest / RestMusicTestAPITest.java
1 /*******************************************************************************
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  *  Copyright (c) 2019 AT&T 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.rest;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.Mockito.doNothing;
26 import java.util.HashMap;
27 import java.util.Map;
28 import javax.servlet.http.HttpServletResponse;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.mockito.Mockito;
32 import org.onap.music.main.MusicUtil;
33
34 public class RestMusicTestAPITest {
35
36     RestMusicTestAPI restMusicTestAPI;
37     
38     @Before
39     public void setup() {
40         restMusicTestAPI = new RestMusicTestAPI();
41     }
42     
43     @Test
44     public void testSimpleTests() {
45         HttpServletResponse httpServletResponse = Mockito.mock(HttpServletResponse.class);
46         doNothing().when(httpServletResponse).addHeader(Mockito.anyString(), Mockito.anyString());
47         MusicUtil.setVersion("x.x.x");
48         MusicUtil.setBuild("y.y");
49         Map<String, HashMap<String, String>> map = restMusicTestAPI.simpleTests(httpServletResponse);
50         
51         Map<String, String> map1 = map.get("0");
52         assertEquals("2", map1.get("1").toString());
53         assertEquals("x.x.x", map1.get("Music Version").toString());
54         assertEquals("y.y", map1.get("Music Build").toString());
55         
56         Map<String, String> map2 = map.get("1");
57         assertEquals("3", map2.get("2").toString());
58         assertEquals("x.x.x", map2.get("Music Version").toString());
59         assertEquals("y.y", map2.get("Music Build").toString());
60         
61         Map<String, String> map3 = map.get("2");
62         assertEquals("4", map3.get("3").toString());
63         assertEquals("x.x.x", map3.get("Music Version").toString());
64         assertEquals("y.y", map3.get("Music Build").toString());
65     }
66 }