Removing deprecated DMAAP library
[policy/drools-pdp.git] / feature-pooling-messages / src / test / java / org / onap / policy / drools / pooling / PoolingPropertiesTest.java
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2018, 2020 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.
@@ -21,7 +22,7 @@
 package org.onap.policy.drools.pooling;
 
 import static org.assertj.core.api.Assertions.assertThatCode;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.onap.policy.drools.pooling.PoolingProperties.ACTIVE_HEARTBEAT_MS;
 import static org.onap.policy.drools.pooling.PoolingProperties.FEATURE_ENABLED;
 import static org.onap.policy.drools.pooling.PoolingProperties.IDENTIFICATION_MS;
@@ -36,8 +37,8 @@ import static org.onap.policy.drools.pooling.PoolingProperties.START_HEARTBEAT_M
 
 import java.util.Properties;
 import java.util.function.Function;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.onap.policy.common.utils.properties.exception.PropertyException;
 
 public class PoolingPropertiesTest {
@@ -52,7 +53,6 @@ public class PoolingPropertiesTest {
     public static final long STD_START_HEARTBEAT_MS = 3000L;
     public static final long STD_REACTIVATE_MS = 4000L;
     public static final long STD_IDENTIFICATION_MS = 5000L;
-    public static final long STD_LEADER_MS = 6000L;
     public static final long STD_ACTIVE_HEARTBEAT_MS = 7000L;
     public static final long STD_INTER_HEARTBEAT_MS = 8000L;
 
@@ -64,7 +64,7 @@ public class PoolingPropertiesTest {
      *
      * @throws Exception throws an exception
      */
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         plain = makeProperties();
 
@@ -72,58 +72,58 @@ public class PoolingPropertiesTest {
     }
 
     @Test
-    public void testPoolingProperties() throws PropertyException {
+    void testPoolingProperties() {
         // ensure no exceptions
         assertThatCode(() -> new PoolingProperties(CONTROLLER, plain)).doesNotThrowAnyException();
     }
 
     @Test
-    public void testGetSource() {
+    void testGetSource() {
         assertEquals(plain, pooling.getSource());
     }
 
     @Test
-    public void testGetPoolingTopic() {
+    void testGetPoolingTopic() {
         assertEquals(STD_POOLING_TOPIC, pooling.getPoolingTopic());
     }
 
     @Test
-    public void testGetOfflineLimit() throws PropertyException {
+    void testGetOfflineLimit() throws PropertyException {
         doTest(OFFLINE_LIMIT, STD_OFFLINE_LIMIT, 1000, xxx -> pooling.getOfflineLimit());
     }
 
     @Test
-    public void testGetOfflineAgeMs() throws PropertyException {
+    void testGetOfflineAgeMs() throws PropertyException {
         doTest(OFFLINE_AGE_MS, STD_OFFLINE_AGE_MS, 60000L, xxx -> pooling.getOfflineAgeMs());
     }
 
     @Test
-    public void testGetOfflinePubWaitMs() throws PropertyException {
+    void testGetOfflinePubWaitMs() throws PropertyException {
         doTest(OFFLINE_PUB_WAIT_MS, STD_OFFLINE_PUB_WAIT_MS, 3000L, xxx -> pooling.getOfflinePubWaitMs());
     }
 
     @Test
-    public void testGetStartHeartbeatMs() throws PropertyException {
+    void testGetStartHeartbeatMs() throws PropertyException {
         doTest(START_HEARTBEAT_MS, STD_START_HEARTBEAT_MS, 100000L, xxx -> pooling.getStartHeartbeatMs());
     }
 
     @Test
-    public void testGetReactivateMs() throws PropertyException {
+    void testGetReactivateMs() throws PropertyException {
         doTest(REACTIVATE_MS, STD_REACTIVATE_MS, 50000L, xxx -> pooling.getReactivateMs());
     }
 
     @Test
-    public void testGetIdentificationMs() throws PropertyException {
+    void testGetIdentificationMs() throws PropertyException {
         doTest(IDENTIFICATION_MS, STD_IDENTIFICATION_MS, 50000L, xxx -> pooling.getIdentificationMs());
     }
 
     @Test
-    public void testGetActiveHeartbeatMs() throws PropertyException {
+    void testGetActiveHeartbeatMs() throws PropertyException {
         doTest(ACTIVE_HEARTBEAT_MS, STD_ACTIVE_HEARTBEAT_MS, 50000L, xxx -> pooling.getActiveHeartbeatMs());
     }
 
     @Test
-    public void testGetInterHeartbeatMs() throws PropertyException {
+    void testGetInterHeartbeatMs() throws PropertyException {
         doTest(INTER_HEARTBEAT_MS, STD_INTER_HEARTBEAT_MS, 15000L, xxx -> pooling.getInterHeartbeatMs());
     }
 
@@ -143,19 +143,19 @@ public class PoolingPropertiesTest {
          * With specialized property
          */
         pooling = new PoolingProperties(CONTROLLER, plain);
-        assertEquals("special " + propnm, specValue, func.apply(null));
+        assertEquals(specValue, func.apply(null), "special " + propnm);
 
         /*
          * Without the property - should use the default value.
          */
-        plain.remove(specialize(propnm, CONTROLLER));
+        plain.remove(specialize(propnm));
         plain.remove(propnm);
         pooling = new PoolingProperties(CONTROLLER, plain);
-        assertEquals("default " + propnm, dfltValue, func.apply(null));
+        assertEquals(dfltValue, func.apply(null), "default " + propnm);
     }
 
     /**
-     * Makes a set of properties, where all of the properties are specialized for the
+     * Makes a set of properties, where all the properties are specialized for the
      * controller.
      *
      * @return a new property set
@@ -163,16 +163,16 @@ public class PoolingPropertiesTest {
     private Properties makeProperties() {
         Properties props = new Properties();
 
-        props.setProperty(specialize(POOLING_TOPIC, CONTROLLER), STD_POOLING_TOPIC);
-        props.setProperty(specialize(FEATURE_ENABLED, CONTROLLER), "" + STD_FEATURE_ENABLED);
-        props.setProperty(specialize(OFFLINE_LIMIT, CONTROLLER), "" + STD_OFFLINE_LIMIT);
-        props.setProperty(specialize(OFFLINE_AGE_MS, CONTROLLER), "" + STD_OFFLINE_AGE_MS);
-        props.setProperty(specialize(OFFLINE_PUB_WAIT_MS, CONTROLLER), "" + STD_OFFLINE_PUB_WAIT_MS);
-        props.setProperty(specialize(START_HEARTBEAT_MS, CONTROLLER), "" + STD_START_HEARTBEAT_MS);
-        props.setProperty(specialize(REACTIVATE_MS, CONTROLLER), "" + STD_REACTIVATE_MS);
-        props.setProperty(specialize(IDENTIFICATION_MS, CONTROLLER), "" + STD_IDENTIFICATION_MS);
-        props.setProperty(specialize(ACTIVE_HEARTBEAT_MS, CONTROLLER), "" + STD_ACTIVE_HEARTBEAT_MS);
-        props.setProperty(specialize(INTER_HEARTBEAT_MS, CONTROLLER), "" + STD_INTER_HEARTBEAT_MS);
+        props.setProperty(specialize(POOLING_TOPIC), STD_POOLING_TOPIC);
+        props.setProperty(specialize(FEATURE_ENABLED), "" + STD_FEATURE_ENABLED);
+        props.setProperty(specialize(OFFLINE_LIMIT), "" + STD_OFFLINE_LIMIT);
+        props.setProperty(specialize(OFFLINE_AGE_MS), "" + STD_OFFLINE_AGE_MS);
+        props.setProperty(specialize(OFFLINE_PUB_WAIT_MS), "" + STD_OFFLINE_PUB_WAIT_MS);
+        props.setProperty(specialize(START_HEARTBEAT_MS), "" + STD_START_HEARTBEAT_MS);
+        props.setProperty(specialize(REACTIVATE_MS), "" + STD_REACTIVATE_MS);
+        props.setProperty(specialize(IDENTIFICATION_MS), "" + STD_IDENTIFICATION_MS);
+        props.setProperty(specialize(ACTIVE_HEARTBEAT_MS), "" + STD_ACTIVE_HEARTBEAT_MS);
+        props.setProperty(specialize(INTER_HEARTBEAT_MS), "" + STD_INTER_HEARTBEAT_MS);
 
         return props;
     }
@@ -181,11 +181,10 @@ public class PoolingPropertiesTest {
      * Embeds a specializer within a property name, after the prefix.
      *
      * @param propnm property name into which it should be embedded
-     * @param spec specializer to be embedded
      * @return the property name, with the specializer embedded within it
      */
-    private String specialize(String propnm, String spec) {
+    private String specialize(String propnm) {
         String suffix = propnm.substring(PREFIX.length());
-        return PREFIX + spec + "." + suffix;
+        return PREFIX + PoolingPropertiesTest.CONTROLLER + "." + suffix;
     }
 }