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 java.util.ArrayList;
24 import java.util.List;
26 import javax.annotation.Resource;
28 import org.junit.Test;
29 import org.openecomp.sdc.be.components.impl.HealthCheckBusinessLogic;
30 import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaUtils;
31 import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
32 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
33 import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
34 import org.openecomp.sdc.be.resources.data.UserData;
35 import org.openecomp.sdc.common.api.HealthCheckInfo;
36 import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckComponent;
37 import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
39 import com.datastax.driver.core.Cluster;
41 import fj.data.Either;
43 import static org.junit.Assert.assertTrue;
44 import static org.junit.Assert.assertFalse;
46 public class HealthCheckBusinessLogicTest {
48 HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
51 public void checkStausUpdated() {
53 boolean statusChanged = healthCheckBusinessLogic.anyStatusChanged(null, null);
54 assertFalse("check false", statusChanged);
56 List<HealthCheckInfo> checkInfosLeft = new ArrayList<HealthCheckInfo>();
57 List<HealthCheckInfo> checkInfosRight = new ArrayList<HealthCheckInfo>();
59 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
60 assertFalse("check false", statusChanged);
62 HealthCheckInfo checkInfoTitanUp = new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.UP, null, null);
63 HealthCheckInfo checkInfoTitanDown = new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.DOWN, null, null);
66 * HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null);
69 checkInfosLeft.add(checkInfoTitanUp);
71 checkInfosRight.add(checkInfoTitanUp);
73 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
74 assertFalse("check false", statusChanged);
76 checkInfosRight.remove(checkInfoTitanUp);
77 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
78 assertTrue("check true", statusChanged);
80 checkInfosRight.add(checkInfoTitanDown);
81 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
82 assertTrue("check true", statusChanged);
84 checkInfosRight.remove(checkInfoTitanDown);
85 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
86 assertTrue("check true", statusChanged);
88 checkInfosRight.add(checkInfoTitanUp);
89 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
90 assertFalse("check false", statusChanged);
92 statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, null);
93 assertTrue("check true", statusChanged);