Sonar and CLM fixes and Unit test
[music.git] / src / test / java / org / onap / music / benchmarks / MicroBenchMarkRestClient.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 package org.onap.music.benchmarks;
23
24 import javax.ws.rs.GET;
25 import javax.ws.rs.Path;
26 import javax.ws.rs.Produces;
27 import javax.ws.rs.core.MediaType;
28 import org.onap.music.main.MusicUtil;
29
30
31 @Path("/tests")
32 public class MicroBenchMarkRestClient {
33     static double version = 9.7;
34
35     @GET
36     @Path("/run")
37     @Produces(MediaType.TEXT_PLAIN)
38     public String runTests() {
39         String testType = MusicUtil.getTestType();
40         String candidateName = "shankar" + System.currentTimeMillis();
41         MicroBenchMarks msHandle = new MicroBenchMarks();
42         switch (testType) {
43             case "musicPut":
44                 return msHandle.musicPutAndUpdate(candidateName);
45
46             case "musicCriticalPut":
47                 return msHandle.musicCriticalPutAndUpdate(candidateName);
48
49             case "musicGet":
50                 return msHandle.musicGet();
51
52             case "cassaPut":
53                 return msHandle.cassaPutAndUpdate(candidateName);
54
55             case "cassaQuorumPut":
56                 return msHandle.cassaQuorumPutAndUpdate(candidateName);
57
58             case "cassaGet":
59                 return msHandle.cassaGet();
60
61             case "zkPut":
62                 return msHandle.zkPutAndUpdate(candidateName);
63
64             case "zkGet":
65                 return msHandle.zkGet();
66
67         }
68         return "something wrong!";
69
70     }
71
72 }
73