1 /*******************************************************************************
2 * ============LICENSE_START==========================================
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
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 * ====================================================================
21 *******************************************************************************/
22 package org.onap.music.rest;
24 import static org.junit.Assert.assertEquals;
25 import static org.mockito.Mockito.doNothing;
27 import javax.servlet.http.HttpServletResponse;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.mockito.Mockito;
31 import org.onap.music.main.MusicUtil;
33 public class RestMusicVersionAPITest {
35 RestMusicVersionAPI restMusicVersionAPI;
39 restMusicVersionAPI = new RestMusicVersionAPI();
43 public void testVersion() {
44 MusicUtil.setVersion("x.x.x");
45 HttpServletResponse httpServletResponse = Mockito.mock(HttpServletResponse.class);
46 doNothing().when(httpServletResponse).addHeader(Mockito.anyString(), Mockito.anyString());
47 Map<String,Object> map = restMusicVersionAPI.version(httpServletResponse);
48 assertEquals("MUSIC:x.x.x", map.get("version").toString());
49 assertEquals("SUCCESS", map.get("status").toString());
53 public void testBuild() {
54 MusicUtil.setBuild("y.y");
55 MusicUtil.setVersion("x.x.x");
56 HttpServletResponse httpServletResponse = Mockito.mock(HttpServletResponse.class);
57 doNothing().when(httpServletResponse).addHeader(Mockito.anyString(), Mockito.anyString());
58 Map<String,Object> map = restMusicVersionAPI.build(httpServletResponse);
59 assertEquals("MUSIC:x.x.x", map.get("version").toString());
60 assertEquals("SUCCESS", map.get("status").toString());
61 assertEquals("MUSIC:y.y", map.get("build").toString());