Some bug fixes and Minor Chages.
[music.git] / src / main / java / org / onap / music / rest / RestMusicTestAPI.java
1 /*
2  * ============LICENSE_START==========================================
3  * org.onap.music
4  * ===================================================================
5  *  Copyright (c) 2017 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
23 package org.onap.music.rest;
24
25 import java.util.HashMap;
26 import java.util.Map;
27
28 import javax.servlet.http.HttpServletResponse;
29 import javax.ws.rs.GET;
30 import javax.ws.rs.Path;
31 import javax.ws.rs.Produces;
32 import javax.ws.rs.core.Context;
33 import javax.ws.rs.core.MediaType;
34
35 import org.onap.music.eelf.logging.EELFLoggerDelegate;
36 import org.onap.music.main.MusicUtil;
37
38 import io.swagger.annotations.Api;
39 import io.swagger.annotations.ApiOperation;
40
41
42 @Path("/v{version: [0-9]+}/test")
43 @Api(value="Test Api")
44 public class RestMusicTestAPI {
45     
46     @SuppressWarnings("unused")
47     private EELFLoggerDelegate logger =EELFLoggerDelegate.getLogger(RestMusicTestAPI.class);
48
49     /**
50      * Returns a test JSON. This will confirm that REST is working.
51      * @return
52      */
53     @GET
54     @Path("/")
55     @ApiOperation(value = "Get Test", response = Map.class)
56     @Produces(MediaType.APPLICATION_JSON)
57     public Map<String, HashMap<String, String>> simpleTests(
58             @Context HttpServletResponse response) {
59         response.addHeader("X-latestVersion",MusicUtil.getVersion());
60         Map<String, HashMap<String, String>> testMap = new HashMap<>();
61         for(int i=0; i < 3; i++){
62             HashMap<String, String> innerMap = new HashMap<>();
63             innerMap.put("Music Version",MusicUtil.getVersion());
64             innerMap.put("Music Build",MusicUtil.getBuild());
65             innerMap.put(i+1+"", i+2+"");
66             testMap.put(i+"", innerMap);
67         }
68         return testMap;
69     }
70 }