Junit test case coverage for some classes in music-rest
[music.git] / music-rest / src / test / java / org / onap / music / eelf / healthcheck / MusicHealthCheckTest.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
23 package org.onap.music.eelf.healthcheck;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.mockito.Mockito.doNothing;
27 import static org.mockito.Mockito.doReturn;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.mockito.Mockito;
31 import org.onap.music.datastore.MusicDataStore;
32 import org.onap.music.datastore.MusicDataStoreHandle;
33 import org.onap.music.exceptions.MusicQueryException;
34 import org.onap.music.exceptions.MusicServiceException;
35 import org.onap.music.main.MusicCore;
36 import org.onap.music.main.ResultType;
37
38 public class MusicHealthCheckTest {
39
40     MusicHealthCheck musicHealthCheck;
41     
42     @Before
43     public void setup() {
44         musicHealthCheck = new MusicHealthCheck();
45     }
46     
47     @Test
48     public void testSetCassandrHost() {
49         musicHealthCheck.setCassandrHost("127.0.0.1");
50         assertEquals("127.0.0.1", musicHealthCheck.getCassandrHost());
51     }
52     
53     @Test
54     public void testGetCassandraStatus() throws MusicServiceException, MusicQueryException {
55         MusicHealthCheck mHealthCheck = Mockito.spy(MusicHealthCheck.class);
56         doReturn(ResultType.SUCCESS).when(mHealthCheck).nonKeyRelatedPut(Mockito.any(), Mockito.anyString());
57         doNothing().when(mHealthCheck).executeEventualPut(Mockito.any());
58         assertEquals("ACTIVE", mHealthCheck.getCassandraStatus("consistency"));
59     }
60     
61 }