Removing deprecated DMAAP library
[policy/drools-pdp.git] / feature-lifecycle / src / test / java / org / onap / policy / drools / lifecycle / ControllerSupport.java
index 4e0b4bf..858e849 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP
  * ================================================================================
  * Copyright (C) 2019, 2021 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.
@@ -23,7 +24,6 @@ package org.onap.policy.drools.lifecycle;
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
 import java.nio.file.Paths;
 import java.util.List;
 import java.util.Properties;
@@ -39,6 +39,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
 /**
  * Controller Test Support.
  */
+@Getter
 public class ControllerSupport {
 
     protected static final String JUNIT_KMODULE_DRL_PATH = "src/test/resources/lifecycle.drl";
@@ -52,7 +53,6 @@ public class ControllerSupport {
 
     protected static final String SESSION_NAME = "junits";
 
-    @Getter
     private final String name;
 
     public ControllerSupport(@NonNull String name) {
@@ -73,21 +73,26 @@ public class ControllerSupport {
 
         ReleaseId coordinates = installArtifact();
 
+        Properties controllerProps = getControllerProps(coordinates);
+
+        return PolicyControllerConstants.getFactory().build(name, controllerProps);
+    }
+
+    private Properties getControllerProps(ReleaseId coordinates) {
         Properties controllerProps = new Properties();
         controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, name);
         controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_POLICY_TYPES, getPolicyType());
         controllerProps.put(DroolsPropertyConstants.RULES_GROUPID, coordinates.getGroupId());
         controllerProps.put(DroolsPropertyConstants.RULES_ARTIFACTID, coordinates.getArtifactId());
         controllerProps.put(DroolsPropertyConstants.RULES_VERSION, coordinates.getVersion());
-
-        return PolicyControllerConstants.getFactory().build(name, controllerProps);
+        return controllerProps;
     }
 
     /**
      * Install a maven artifact.
      */
     public static ReleaseId installArtifact(File kmodule, File pom,
-            String drlKjarPath, List<File> drls) throws IOException {
+                                            String drlKjarPath, List<File> drls) throws IOException {
         return KieUtils.installArtifact(kmodule, pom, drlKjarPath, drls);
     }
 
@@ -96,9 +101,9 @@ public class ControllerSupport {
      */
     public ReleaseId installArtifact() throws IOException {
         return ControllerSupport.installArtifact(Paths.get(JUNIT_KMODULE_PATH).toFile(),
-                Paths.get(JUNIT_KMODULE_POM_PATH).toFile(),
-                JUNIT_KJAR_DRL_PATH,
-                List.of(Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()));
+            Paths.get(JUNIT_KMODULE_POM_PATH).toFile(),
+            JUNIT_KJAR_DRL_PATH,
+            List.of(Paths.get(JUNIT_KMODULE_DRL_PATH).toFile()));
     }
 
     /**
@@ -146,7 +151,7 @@ public class ControllerSupport {
      * Reassign static field.
      */
     public static <T, E> void setStaticField(Class<T> clazz, String fieldName, E newValue)
-            throws NoSuchFieldException, IllegalAccessException {
+        throws NoSuchFieldException, IllegalAccessException {
         unsetFinalStaticAccess(clazz, fieldName).set(null, newValue);
     }
 }