Sync Integ to Master
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / HealthCheckBusinessLogicTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  */
20
21 package org.openecomp.sdc.be.components;
22
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;
28
29 import java.util.ArrayList;
30 import java.util.List;
31
32 import static org.junit.Assert.assertFalse;
33 import static org.junit.Assert.assertTrue;
34 public class HealthCheckBusinessLogicTest {
35
36     HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
37
38     @Test
39     public void checkStausUpdated() {
40
41         boolean statusChanged = healthCheckBusinessLogic.anyStatusChanged(null, null);
42         assertFalse("check false", statusChanged);
43
44         List<HealthCheckInfo> checkInfosLeft = new ArrayList<HealthCheckInfo>();
45         List<HealthCheckInfo> checkInfosRight = new ArrayList<HealthCheckInfo>();
46
47         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
48         assertFalse("check false", statusChanged);
49
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);
52
53         /*
54          * HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null);
55          */
56
57         checkInfosLeft.add(checkInfoTitanUp);
58
59         checkInfosRight.add(checkInfoTitanUp);
60
61         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
62         assertFalse("check false", statusChanged);
63
64         checkInfosRight.remove(checkInfoTitanUp);
65         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
66         assertTrue("check true", statusChanged);
67
68         checkInfosRight.add(checkInfoTitanDown);
69         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
70         assertTrue("check true", statusChanged);
71
72         checkInfosRight.remove(checkInfoTitanDown);
73         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
74         assertTrue("check true", statusChanged);
75
76         checkInfosRight.add(checkInfoTitanUp);
77         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
78         assertFalse("check false", statusChanged);
79
80         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, null);
81         assertTrue("check true", statusChanged);
82
83     }
84
85 }