Fix 'Substitution Node not updated during import'-bug
[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  * Modifications copyright (c) 2019 Nokia
20  * ================================================================================
21  */
22
23 package org.openecomp.sdc.be.components;
24
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
27
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;
35
36 public class HealthCheckBusinessLogicTest {
37
38     final HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
39
40     @Test
41     public void checkStatusUpdated() {
42
43         boolean statusChanged = healthCheckBusinessLogic.anyStatusChanged(null, null);
44         assertFalse("check false", statusChanged);
45
46         List<HealthCheckInfo> checkInfosLeft = new ArrayList<>();
47         List<HealthCheckInfo> checkInfosRight = new ArrayList<>();
48
49         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
50         assertFalse("check false", statusChanged);
51
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);
54
55         HealthCheckInfo checkInfoDmaapProducerUp = new HealthCheckInfo(Constants.HC_COMPONENT_DMAAP_PRODUCER, HealthCheckStatus.UP, null, null);
56
57         HealthCheckInfo healthCheckInfoCADIUp = new HealthCheckInfo(Constants.HC_COMPONENT_CADI, HealthCheckStatus.UP, null, null);
58
59         /*
60          * HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null);
61          */
62
63         checkInfosLeft.add(checkInfoJanusGraphUp);
64
65         checkInfosRight.add(checkInfoJanusGraphUp);
66
67         checkInfosLeft.add(checkInfoDmaapProducerUp);
68
69         checkInfosRight.add(checkInfoDmaapProducerUp);
70
71         checkInfosLeft.add(healthCheckInfoCADIUp);
72
73         checkInfosRight.add(healthCheckInfoCADIUp);
74
75         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
76         assertFalse("check false", statusChanged);
77
78         checkInfosRight.remove(checkInfoJanusGraphUp);
79         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
80         assertTrue("check true", statusChanged);
81
82         checkInfosRight.add(checkInfoJanusGraphDown);
83         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
84         assertTrue("check true", statusChanged);
85
86         checkInfosRight.remove(checkInfoJanusGraphDown);
87         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
88         assertTrue("check true", statusChanged);
89
90         checkInfosRight.add(checkInfoJanusGraphUp);
91         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
92         assertFalse("check false", statusChanged);
93
94         checkInfosRight.remove(healthCheckInfoCADIUp);
95         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
96         assertTrue("check true", statusChanged);
97
98         checkInfosRight.add(healthCheckInfoCADIUp);
99         statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, null);
100         assertTrue("check true", statusChanged);
101
102     }
103
104 }