summaryrefslogtreecommitdiffstats
path: root/feature-healthcheck/src
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-01-26 15:28:56 +0000
committerAdheli Tavares <adheli.tavares@est.tech>2024-02-09 10:31:15 +0000
commitcc1d3d352771d1fa35d297e90663539e34b022f6 (patch)
treeb1b00d678b0157742b91be1262fbf614a62063b1 /feature-healthcheck/src
parentcce79248655f484e007769ba81b092148f940d27 (diff)
Removing deprecated DMAAP library
Issue-ID: POLICY-4402 Change-Id: I4ce5b303cb3a775010683d3c7102b0bd065280ea Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'feature-healthcheck/src')
-rw-r--r--feature-healthcheck/src/main/feature/config/feature-healthcheck.properties2
-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
-rw-r--r--feature-healthcheck/src/test/resources/echo.drl3
-rw-r--r--feature-healthcheck/src/test/resources/echo.kmodule3
7 files changed, 62 insertions, 56 deletions
diff --git a/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties b/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties
index 98247a89..d8e22b4f 100644
--- a/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties
+++ b/feature-healthcheck/src/main/feature/config/feature-healthcheck.properties
@@ -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.
@@ -28,7 +29,6 @@ http.server.services.HEALTHCHECK.swagger=true
http.server.services.HEALTHCHECK.userName=${envd:HEALTHCHECK_USER}
http.server.services.HEALTHCHECK.password=${envd:HEALTHCHECK_PASSWORD}
http.server.services.HEALTHCHECK.https=${envd:HTTP_SERVER_HTTPS:false}
-http.server.services.HEALTHCHECK.aaf=${envd:AAF:false}
http.server.services.HEALTHCHECK.serialization.provider=org.onap.policy.common.gson.JacksonHandler,org.onap.policy.common.endpoints.http.server.YamlJacksonHandler
http.server.services.LIVENESS.host=0.0.0.0
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");
diff --git a/feature-healthcheck/src/test/resources/echo.drl b/feature-healthcheck/src/test/resources/echo.drl
index 54847da9..189c8a51 100644
--- a/feature-healthcheck/src/test/resources/echo.drl
+++ b/feature-healthcheck/src/test/resources/echo.drl
@@ -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.
@@ -29,7 +30,7 @@ end
rule "ECHO"
when
- $o : Object();
+ $o : Object()
then
System.out.println("ECHO: " + $o.toString());
end
diff --git a/feature-healthcheck/src/test/resources/echo.kmodule b/feature-healthcheck/src/test/resources/echo.kmodule
index 7a1acc70..fd972ab0 100644
--- a/feature-healthcheck/src/test/resources/echo.kmodule
+++ b/feature-healthcheck/src/test/resources/echo.kmodule
@@ -4,6 +4,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.
@@ -19,7 +20,7 @@
============LICENSE_END=========================================================
-->
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
+<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="onap.policies.drools.healthcheck">
<ksession name="echo"/>
</kbase>