diff options
author | vasraz <vasyl.razinkov@est.tech> | 2023-06-14 20:56:59 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2023-06-20 10:07:41 +0000 |
commit | f845ac23cdd262b7624785283531952e38557deb (patch) | |
tree | 51dc173b216240b2b1881363f56df15b99bd7c8c /catalog-be/src/test/java | |
parent | c465f8fac8cc8be671319fca2100e98fc4a4c13f (diff) |
Improve test coverage
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: Ib5c265567973369a9061ce611ab018857016bff1
Issue-ID: SDC-4536
Diffstat (limited to 'catalog-be/src/test/java')
-rw-r--r-- | catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java | 289 |
1 files changed, 146 insertions, 143 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java index 5f2b412743..7997814a95 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineClusterHealthTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,150 +20,153 @@ package org.openecomp.sdc.be.components.distribution.engine; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - +import java.util.HashMap; +import java.util.LinkedList; +import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import mockit.Deencapsulation; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.components.distribution.engine.DistributionEngineClusterHealth.HealthCheckScheduledTask; import org.openecomp.sdc.common.api.HealthCheckInfo; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import org.openecomp.sdc.be.resources.data.OperationalEnvironmentEntry; - -public class DistributionEngineClusterHealthTest extends BeConfDependentTest{ - - private DistributionEngineClusterHealth createTestSubject() { - return new DistributionEngineClusterHealth(); - } - - @Test - public void testDestroy() throws Exception { - DistributionEngineClusterHealth testSubject; - - // default test - testSubject = createTestSubject(); - Deencapsulation.invoke(testSubject, "destroy"); - } - - @Test - public void testStartHealthCheckTask() throws Exception { - DistributionEngineClusterHealth testSubject; - Map<String, AtomicBoolean> envNamePerStatus = null; - boolean startTask = false; - - // default test - testSubject = createTestSubject(); - testSubject.startHealthCheckTask(envNamePerStatus, startTask); - } - - @Test - public void testStartHealthCheckTask_1() { - final DistributionEngineClusterHealth distributionEngineClusterHealth = new DistributionEngineClusterHealth(); - final Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); - distributionEngineClusterHealth.init("myKey"); - distributionEngineClusterHealth.startHealthCheckTask(envNamePerStatus); - } - - @Test - public void testHealthCheckScheduledTask() throws Exception { - DistributionEngineClusterHealth testSubject; - Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); - - // default test - testSubject = createTestSubject(); - HealthCheckScheduledTask healthCheckScheduledTask = testSubject. new HealthCheckScheduledTask(new LinkedList<>()); - LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); - UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); - healthCheckCalls.add(hcc); - healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; - - Deencapsulation.invoke(healthCheckScheduledTask, "queryUeb"); - } - - @Test - public void testHealthCheckScheduledTaskRun() throws Exception { - DistributionEngineClusterHealth testSubject; - Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); - envNamePerStatus.put("mock", new AtomicBoolean(true)); - // default test - testSubject = createTestSubject(); - testSubject.startHealthCheckTask(envNamePerStatus, false); - HealthCheckScheduledTask healthCheckScheduledTask = testSubject. new HealthCheckScheduledTask(new LinkedList<>()); - LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); - UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); - healthCheckCalls.add(hcc); - healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; - - Deencapsulation.invoke(healthCheckScheduledTask, "run"); - } - - @Test - public void testHealthCheckScheduledTaskRun_2() throws Exception { - DistributionEngineClusterHealth testSubject; - Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); - envNamePerStatus.put("mock", new AtomicBoolean(false)); - // default test - testSubject = createTestSubject(); - testSubject.startHealthCheckTask(envNamePerStatus, false); - HealthCheckScheduledTask healthCheckScheduledTask = testSubject. new HealthCheckScheduledTask(new LinkedList<>()); - LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); - UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); - healthCheckCalls.add(hcc); - healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; - - Deencapsulation.invoke(healthCheckScheduledTask, "run"); - } - - @Test - public void testLogAlarm() throws Exception { - DistributionEngineClusterHealth testSubject; - boolean lastHealthState = false; - - // default test - testSubject = createTestSubject(); - Deencapsulation.invoke(testSubject, "logAlarm", new Object[] { lastHealthState }); - } - - @Test - public void testGetHealthCheckInfo() throws Exception { - DistributionEngineClusterHealth testSubject; - HealthCheckInfo result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getHealthCheckInfo(); - } - - @Test - public void testSetHealthCheckUebIsDisabled() throws Exception { - DistributionEngineClusterHealth testSubject; - - // default test - testSubject = createTestSubject(); - testSubject.setHealthCheckUebIsDisabled(); - } - - @Test - public void testSetHealthCheckUebConfigurationError() throws Exception { - DistributionEngineClusterHealth testSubject; - - // default test - testSubject = createTestSubject(); - testSubject.setHealthCheckUebConfigurationError(); - } - - @Test - public void testSetHealthCheckOkAndReportInCaseLastStateIsDown() throws Exception { - DistributionEngineClusterHealth testSubject; - - // default test - testSubject = createTestSubject(); - testSubject.setHealthCheckOkAndReportInCaseLastStateIsDown(); - } +class DistributionEngineClusterHealthTest extends BeConfDependentTest { + + private DistributionEngineClusterHealth createTestSubject() { + return new DistributionEngineClusterHealth(); + } + + // TODO - move to BeConfDependentTest after migration to Junit 5 + @BeforeAll + public static void setupBeforeClass() { + componentName = "catalog-be"; + confPath = "src/test/resources/config"; + setUp(); + } + + @Test + void testDestroy() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "destroy"); + } + + @Test + void testStartHealthCheckTask() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = null; + boolean startTask = false; + + // default test + testSubject = createTestSubject(); + testSubject.startHealthCheckTask(envNamePerStatus, startTask); + } + + @Test + void testStartHealthCheckTask_1() { + final DistributionEngineClusterHealth distributionEngineClusterHealth = new DistributionEngineClusterHealth(); + final Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + distributionEngineClusterHealth.init("myKey"); + distributionEngineClusterHealth.startHealthCheckTask(envNamePerStatus); + } + + @Test + void testHealthCheckScheduledTask() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + + // default test + testSubject = createTestSubject(); + HealthCheckScheduledTask healthCheckScheduledTask = testSubject.new HealthCheckScheduledTask(new LinkedList<>()); + LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); + UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); + healthCheckCalls.add(hcc); + healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; + + Deencapsulation.invoke(healthCheckScheduledTask, "queryUeb"); + } + + @Test + void testHealthCheckScheduledTaskRun() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + envNamePerStatus.put("mock", new AtomicBoolean(true)); + // default test + testSubject = createTestSubject(); + testSubject.startHealthCheckTask(envNamePerStatus, false); + HealthCheckScheduledTask healthCheckScheduledTask = testSubject.new HealthCheckScheduledTask(new LinkedList<>()); + LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); + UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); + healthCheckCalls.add(hcc); + healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; + + Deencapsulation.invoke(healthCheckScheduledTask, "run"); + } + + @Test + void testHealthCheckScheduledTaskRun_2() throws Exception { + DistributionEngineClusterHealth testSubject; + Map<String, AtomicBoolean> envNamePerStatus = new HashMap<>(); + envNamePerStatus.put("mock", new AtomicBoolean(false)); + // default test + testSubject = createTestSubject(); + testSubject.startHealthCheckTask(envNamePerStatus, false); + HealthCheckScheduledTask healthCheckScheduledTask = testSubject.new HealthCheckScheduledTask(new LinkedList<>()); + LinkedList<UebHealthCheckCall> healthCheckCalls = new LinkedList<>(); + UebHealthCheckCall hcc = new UebHealthCheckCall("mock", "mock"); + healthCheckCalls.add(hcc); + healthCheckScheduledTask.healthCheckCalls = healthCheckCalls; + + Deencapsulation.invoke(healthCheckScheduledTask, "run"); + } + + @Test + void testLogAlarm() throws Exception { + DistributionEngineClusterHealth testSubject; + boolean lastHealthState = false; + + // default test + testSubject = createTestSubject(); + Deencapsulation.invoke(testSubject, "logAlarm", new Object[]{lastHealthState}); + } + + @Test + void testGetHealthCheckInfo() throws Exception { + DistributionEngineClusterHealth testSubject; + HealthCheckInfo result; + + // default test + testSubject = createTestSubject(); + result = testSubject.getHealthCheckInfo(); + } + + @Test + void testSetHealthCheckUebIsDisabled() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.setHealthCheckUebIsDisabled(); + } + + @Test + void testSetHealthCheckUebConfigurationError() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.setHealthCheckUebConfigurationError(); + } + + @Test + void testSetHealthCheckOkAndReportInCaseLastStateIsDown() throws Exception { + DistributionEngineClusterHealth testSubject; + + // default test + testSubject = createTestSubject(); + testSubject.setHealthCheckOkAndReportInCaseLastStateIsDown(); + } } |