2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END=========================================================
19 * Modifications copyright (c) 2019 Nokia
20 * ================================================================================
23 package org.openecomp.sdc.be.components;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
28 import java.util.ArrayList;
29 import java.util.List;
30 import org.junit.jupiter.api.Test;
31 import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic;
32 import org.openecomp.sdc.common.api.Constants;
33 import org.openecomp.sdc.common.api.HealthCheckInfo;
34 import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
36 public class HealthCheckBusinessLogicTest {
38 final HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
41 public void checkStatusUpdated() {
43 boolean statusChanged = healthCheckBusinessLogic.anyStatusChanged(null, null);
44 assertFalse("check false", statusChanged);
46 List<HealthCheckInfo> checkInfosLeft = new ArrayList<>();
47 List<HealthCheckInfo> checkInfosRight = new ArrayList<>();
49 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
50 assertFalse("check false", statusChanged);
52 HealthCheckInfo checkInfoJanusGraphUp = new HealthCheckInfo(Constants.HC_COMPONENT_JANUSGRAPH, HealthCheckStatus.UP, null, null);
53 HealthCheckInfo checkInfoJanusGraphDown = new HealthCheckInfo(Constants.HC_COMPONENT_JANUSGRAPH, HealthCheckStatus.DOWN, null, null);
55 HealthCheckInfo checkInfoDmaapProducerUp = new HealthCheckInfo(Constants.HC_COMPONENT_DMAAP_PRODUCER, HealthCheckStatus.UP, null, null);
57 HealthCheckInfo healthCheckInfoCADIUp = new HealthCheckInfo(Constants.HC_COMPONENT_CADI, HealthCheckStatus.UP, null, null);
60 * HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null);
63 checkInfosLeft.add(checkInfoJanusGraphUp);
65 checkInfosRight.add(checkInfoJanusGraphUp);
67 checkInfosLeft.add(checkInfoDmaapProducerUp);
69 checkInfosRight.add(checkInfoDmaapProducerUp);
71 checkInfosLeft.add(healthCheckInfoCADIUp);
73 checkInfosRight.add(healthCheckInfoCADIUp);
75 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
76 assertFalse("check false", statusChanged);
78 checkInfosRight.remove(checkInfoJanusGraphUp);
79 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
80 assertTrue("check true", statusChanged);
82 checkInfosRight.add(checkInfoJanusGraphDown);
83 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
84 assertTrue("check true", statusChanged);
86 checkInfosRight.remove(checkInfoJanusGraphDown);
87 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
88 assertTrue("check true", statusChanged);
90 checkInfosRight.add(checkInfoJanusGraphUp);
91 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
92 assertFalse("check false", statusChanged);
94 checkInfosRight.remove(healthCheckInfoCADIUp);
95 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
96 assertTrue("check true", statusChanged);
98 checkInfosRight.add(healthCheckInfoCADIUp);
99 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, null);
100 assertTrue("check true", statusChanged);