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=========================================================
21 package org.openecomp.sdc.be.components;
23 import org.junit.Test;
24 import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic;
25 import org.openecomp.sdc.common.api.Constants;
26 import org.openecomp.sdc.common.api.HealthCheckInfo;
27 import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
29 import java.util.ArrayList;
30 import java.util.List;
32 import static org.junit.Assert.assertFalse;
33 import static org.junit.Assert.assertTrue;
34 public class HealthCheckBusinessLogicTest {
36 HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
39 public void checkStausUpdated() {
41 boolean statusChanged = healthCheckBusinessLogic.anyStatusChanged(null, null);
42 assertFalse("check false", statusChanged);
44 List<HealthCheckInfo> checkInfosLeft = new ArrayList<HealthCheckInfo>();
45 List<HealthCheckInfo> checkInfosRight = new ArrayList<HealthCheckInfo>();
47 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
48 assertFalse("check false", statusChanged);
50 HealthCheckInfo checkInfoTitanUp = new HealthCheckInfo(Constants.HC_COMPONENT_TITAN, HealthCheckStatus.UP, null, null);
51 HealthCheckInfo checkInfoTitanDown = new HealthCheckInfo(Constants.HC_COMPONENT_TITAN, HealthCheckStatus.DOWN, null, null);
54 * HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null);
57 checkInfosLeft.add(checkInfoTitanUp);
59 checkInfosRight.add(checkInfoTitanUp);
61 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
62 assertFalse("check false", statusChanged);
64 checkInfosRight.remove(checkInfoTitanUp);
65 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
66 assertTrue("check true", statusChanged);
68 checkInfosRight.add(checkInfoTitanDown);
69 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
70 assertTrue("check true", statusChanged);
72 checkInfosRight.remove(checkInfoTitanDown);
73 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
74 assertTrue("check true", statusChanged);
76 checkInfosRight.add(checkInfoTitanUp);
77 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
78 assertFalse("check false", statusChanged);
80 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, null);
81 assertTrue("check true", statusChanged);