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<>();
45 List<HealthCheckInfo> checkInfosRight = new ArrayList<>();
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);
53 checkInfosLeft.add(checkInfoTitanUp);
55 checkInfosRight.add(checkInfoTitanUp);
57 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
58 assertFalse("check false", statusChanged);
60 checkInfosRight.remove(checkInfoTitanUp);
61 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
62 assertTrue("check true", statusChanged);
64 checkInfosRight.add(checkInfoTitanDown);
65 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
66 assertTrue("check true", statusChanged);
68 checkInfosRight.remove(checkInfoTitanDown);
69 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
70 assertTrue("check true", statusChanged);
72 checkInfosRight.add(checkInfoTitanUp);
73 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
74 assertFalse("check false", statusChanged);
76 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, null);
77 assertTrue("check true", statusChanged);