aboutsummaryrefslogtreecommitdiffstats
path: root/feature-healthcheck/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'feature-healthcheck/src/test/java')
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java27
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java39
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java21
-rw-r--r--feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java23
4 files changed, 57 insertions, 53 deletions
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
index 0567595f..7cf7ed5f 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckFeatureTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2017-2019,2022 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,9 +21,9 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doThrow;
@@ -38,9 +39,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import org.eclipse.jetty.http.HttpStatus;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.kie.api.builder.ReleaseId;
import org.mockito.AdditionalAnswers;
import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
@@ -65,7 +66,7 @@ public class HealthCheckFeatureTest {
/**
* Set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException {
SystemPersistenceConstants.getManager().setConfigurationDir("target/test-classes");
@@ -92,7 +93,7 @@ public class HealthCheckFeatureTest {
/**
* Tear down.
*/
- @AfterClass
+ @AfterAll
public static void teardown() {
PolicyControllerConstants.getFactory().destroy();
HttpClientFactoryInstance.getClientFactory().destroy();
@@ -100,7 +101,7 @@ public class HealthCheckFeatureTest {
}
@Test
- public void test() throws InterruptedException {
+ void test() throws InterruptedException {
var manager = spy(HealthCheckManager.class);
var feature = new HealthCheckFeatureImpl(manager);
when(manager.isEngineAlive()).thenReturn(true);
@@ -167,12 +168,12 @@ public class HealthCheckFeatureTest {
}
@Test
- public void testGetSequenceNumber() {
+ void testGetSequenceNumber() {
assertEquals(1000, new HealthCheckFeature().getSequenceNumber());
}
@Test
- public void testAfterStart() {
+ void testAfterStart() {
HealthCheck checker = mock(HealthCheck.class);
HealthCheckFeature feature = new HealthCheckFeatureImpl(checker);
@@ -187,7 +188,7 @@ public class HealthCheckFeatureTest {
}
@Test
- public void testAfterOpen() {
+ void testAfterOpen() {
HealthCheck checker = mock(HealthCheck.class);
HealthCheckFeature feature = new HealthCheckFeatureImpl(checker);
@@ -203,7 +204,7 @@ public class HealthCheckFeatureTest {
}
@Test
- public void testAfterShutdown() {
+ void testAfterShutdown() {
HealthCheck checker = mock(HealthCheck.class);
HealthCheckFeature feature = new HealthCheckFeatureImpl(checker);
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java
index 9e081015..8553301f 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckManagerTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +21,11 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -41,8 +42,8 @@ import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
import org.eclipse.jetty.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.AdditionalAnswers;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
@@ -57,7 +58,7 @@ import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class HealthCheckManagerTest {
+class HealthCheckManagerTest {
private static final Logger logger = LoggerFactory.getLogger(HealthCheckManagerTest.class);
@@ -101,7 +102,7 @@ public class HealthCheckManagerTest {
/**
* Initializes the object to be tested.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
properties = new Properties();
mocks();
@@ -186,7 +187,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testHealthcheck() {
+ void testHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
@@ -210,7 +211,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testControllerHealthcheck() {
+ void testControllerHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
@@ -248,7 +249,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testClientHealthcheck() {
+ void testClientHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
@@ -278,7 +279,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void reportOnController() {
+ void reportOnController() {
/* controller not alive */
@@ -336,7 +337,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testReportOnUnknown() {
+ void testReportOnUnknown() {
var reports = monitor.summary(monitor.engineHealthcheck(), monitor.futures(List.of(1)));
logger.info("{}", reports);
@@ -346,7 +347,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testStart() {
+ void testStart() {
// good start
when(server1.start()).thenReturn(true);
@@ -381,7 +382,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testOpen() {
+ void testOpen() {
/* nothing done */
@@ -412,7 +413,7 @@ public class HealthCheckManagerTest {
}
@Test
- public void testShutdown() {
+ void testShutdown() {
monitor.healthcheckServer = server1;
monitor.livenessServer = server2;
monitor.clients = List.of(client1, client2, client3);
@@ -429,12 +430,12 @@ public class HealthCheckManagerTest {
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
assertFalse(monitor.isAlive());
}
@Test
- public void testToString() {
+ void testToString() {
assertTrue(monitor.toString().contains("HealthCheckManager"));
}
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
index 01f5063d..375c1622 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/HealthCheckTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2018, 2021-2022 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,27 +21,27 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.onap.policy.drools.healthcheck.HealthCheck.Report;
import org.onap.policy.drools.healthcheck.HealthCheck.Reports;
-public class HealthCheckTest {
+class HealthCheckTest {
private static final long RPT_CODE = 100;
private static final String RPT_MSG = "report-message";
private static final String RPT_NAME = "report-name";
private static final String RPT_URL = "report-url";
@Test
- public void testReport() {
+ void testReport() {
Report rpt = new Report();
assertNotNull(rpt.toString());
@@ -73,7 +74,7 @@ public class HealthCheckTest {
}
@Test
- public void testReports() {
+ void testReports() {
Reports reports = new Reports();
// toString should work with un-populated data
diff --git a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java
index 2ab1fe82..63825fa8 100644
--- a/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java
+++ b/feature-healthcheck/src/test/java/org/onap/policy/drools/healthcheck/RestHealthCheckTest.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,15 +21,15 @@
package org.onap.policy.drools.healthcheck;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import jakarta.ws.rs.core.Response;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
@@ -60,7 +61,7 @@ public class RestHealthCheckTest {
* Set up.
*/
- @BeforeClass
+ @BeforeAll
public static void setUp() throws Exception {
LoggerUtils.setLevel("org.onap.policy.common.endpoints", "WARN");
LoggerUtils.setLevel("org.eclipse", "ERROR");
@@ -103,26 +104,26 @@ public class RestHealthCheckTest {
* Tear down.
*/
- @AfterClass
+ @AfterAll
public static void tearDown() {
HttpClientFactoryInstance.getClientFactory().destroy();
HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
- public void healthcheck() {
+ void healthcheck() {
when(healthcheckManager.healthCheck()).thenReturn(summary);
assertHttp("/");
}
@Test
- public void engine() {
+ void engine() {
when(healthcheckManager.engineHealthcheck()).thenReturn(summary);
assertHttp("engine");
}
@Test
- public void controllers() {
+ void controllers() {
when(healthcheckManager.controllerHealthcheck()).thenReturn(summary);
assertHttp("controllers");
@@ -140,7 +141,7 @@ public class RestHealthCheckTest {
}
@Test
- public void clients() {
+ void clients() {
when(healthcheckManager.clientHealthcheck()).thenReturn(summary);
assertHttp("clients");