* 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.
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;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class HealthCheckManagerTest {
+class HealthCheckManagerTest {
private static final Logger logger = LoggerFactory.getLogger(HealthCheckManagerTest.class);
/**
* Initializes the object to be tested.
*/
- @Before
+ @BeforeEach
public void setUp() throws Exception {
properties = new Properties();
mocks();
}
@Test
- public void testHealthcheck() {
+ void testHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
}
@Test
- public void testControllerHealthcheck() {
+ void testControllerHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
}
@Test
- public void testClientHealthcheck() {
+ void testClientHealthcheck() {
/* engine not alive */
when(engineMgr.isAlive()).thenReturn(false);
}
@Test
- public void reportOnController() {
+ void reportOnController() {
/* controller not alive */
}
@Test
- public void testReportOnUnknown() {
+ void testReportOnUnknown() {
var reports = monitor.summary(monitor.engineHealthcheck(), monitor.futures(List.of(1)));
logger.info("{}", reports);
}
@Test
- public void testStart() {
+ void testStart() {
// good start
when(server1.start()).thenReturn(true);
}
@Test
- public void testOpen() {
+ void testOpen() {
/* nothing done */
}
@Test
- public void testShutdown() {
+ void testShutdown() {
monitor.healthcheckServer = server1;
monitor.livenessServer = server2;
monitor.clients = List.of(client1, client2, client3);
}
@Test
- public void testIsAlive() {
+ void testIsAlive() {
assertFalse(monitor.isAlive());
}
@Test
- public void testToString() {
+ void testToString() {
assertTrue(monitor.toString().contains("HealthCheckManager"));
}