2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.ccsdk.sli.plugins.grtoolkit.data;
24 import org.junit.Test;
26 import static org.junit.Assert.*;
28 public class SiteHealthTest {
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());
38 public void withAdminHealth() {
39 SiteHealth health = new SiteHealth().withAdminHealth(new AdminHealth(Health.HEALTHY));
40 assertEquals(Health.HEALTHY, health.getAdminHealth().get(0).getHealth());
44 public void withDatabaseHealth() {
45 SiteHealth health = new SiteHealth().withDatabaseHealth(new DatabaseHealth(Health.HEALTHY));
46 assertEquals(Health.HEALTHY, health.getDatabaseHealth().get(0).getHealth());
50 public void withClusterHealth() {
51 SiteHealth health = new SiteHealth().withClusterHealth(new ClusterHealth());
52 assertEquals(Health.FAULTY, health.getClusterHealth().get(0).getHealth());
56 public void withId() {
57 SiteHealth health = new SiteHealth().withId("My_ID");
58 assertEquals("My_ID", health.getId());
62 public void withRole() {
63 SiteHealth health = new SiteHealth().withRole("My_role");
64 assertEquals("My_role", health.getRole());
68 public void setHealth() {
69 SiteHealth health = new SiteHealth();
70 health.setHealth(Health.HEALTHY);
71 assertEquals(Health.HEALTHY, health.getHealth());
75 public void setAdminHealth() {
76 SiteHealth health = new SiteHealth().withAdminHealth(new AdminHealth(Health.HEALTHY));
77 health.setAdminHealth(null);
78 assertNull(health.getAdminHealth());
82 public void setDatabaseHealth() {
83 SiteHealth health = new SiteHealth().withDatabaseHealth(new DatabaseHealth(Health.HEALTHY));
84 health.setDatabaseHealth(null);
85 assertNull(health.getDatabaseHealth());
89 public void setClusterHealth() {
90 SiteHealth health = new SiteHealth().withClusterHealth(new ClusterHealth());
91 health.setClusterHealth(null);
92 assertNull(health.getClusterHealth());
97 SiteHealth health = new SiteHealth().withId("My_ID");
98 health.setId("My_new_ID");
99 assertEquals("My_new_ID", health.getId());
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());