[CCSDK-1985]GR Toolkit Refactor
[ccsdk/sli/plugins.git] / grToolkit / provider / src / test / java / org / onap / ccsdk / sli / plugins / grtoolkit / data / SiteHealthTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights
6  *                      reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.sli.plugins.grtoolkit.data;
23
24 import org.junit.Test;
25
26 import static org.junit.Assert.*;
27
28 public class SiteHealthTest {
29     @Test
30     public void constructorTest() {
31         SiteHealth health = new SiteHealth();
32         assertNotNull(health.getAdminHealth());
33         assertNotNull(health.getDatabaseHealth());
34         assertNotNull(health.getClusterHealth());
35         assertEquals(Health.FAULTY, health.getHealth());
36     }
37     @Test
38     public void withAdminHealth() {
39         SiteHealth health = new SiteHealth().withAdminHealth(new AdminHealth(Health.HEALTHY));
40         assertEquals(Health.HEALTHY, health.getAdminHealth().get(0).getHealth());
41     }
42
43     @Test
44     public void withDatabaseHealth() {
45         SiteHealth health = new SiteHealth().withDatabaseHealth(new DatabaseHealth(Health.HEALTHY));
46         assertEquals(Health.HEALTHY, health.getDatabaseHealth().get(0).getHealth());
47     }
48
49     @Test
50     public void withClusterHealth() {
51         SiteHealth health = new SiteHealth().withClusterHealth(new ClusterHealth());
52         assertEquals(Health.FAULTY, health.getClusterHealth().get(0).getHealth());
53     }
54
55     @Test
56     public void withId() {
57         SiteHealth health = new SiteHealth().withId("My_ID");
58         assertEquals("My_ID", health.getId());
59     }
60
61     @Test
62     public void withRole() {
63         SiteHealth health = new SiteHealth().withRole("My_role");
64         assertEquals("My_role", health.getRole());
65     }
66
67     @Test
68     public void setHealth() {
69         SiteHealth health = new SiteHealth();
70         health.setHealth(Health.HEALTHY);
71         assertEquals(Health.HEALTHY, health.getHealth());
72     }
73
74     @Test
75     public void setAdminHealth() {
76         SiteHealth health = new SiteHealth().withAdminHealth(new AdminHealth(Health.HEALTHY));
77         health.setAdminHealth(null);
78         assertNull(health.getAdminHealth());
79     }
80
81     @Test
82     public void setDatabaseHealth() {
83         SiteHealth health = new SiteHealth().withDatabaseHealth(new DatabaseHealth(Health.HEALTHY));
84         health.setDatabaseHealth(null);
85         assertNull(health.getDatabaseHealth());
86     }
87
88     @Test
89     public void setClusterHealth() {
90         SiteHealth health = new SiteHealth().withClusterHealth(new ClusterHealth());
91         health.setClusterHealth(null);
92         assertNull(health.getClusterHealth());
93     }
94
95     @Test
96     public void setId() {
97         SiteHealth health = new SiteHealth().withId("My_ID");
98         health.setId("My_new_ID");
99         assertEquals("My_new_ID", health.getId());
100     }
101
102     @Test
103     public void setRole() {
104         SiteHealth health = new SiteHealth().withRole("My_role");
105         health.setRole("My_new_role");
106         assertEquals("My_new_role", health.getRole());
107     }
108 }