Change config to add Application group
[policy/xacml-pdp.git] / main / src / test / java / org / onap / policy / pdpx / main / rest / XacmlPdpApplicationManagerTest.java
index cd7041e..4619b2a 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.junit.BeforeClass;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardYamlCoder;
 import org.onap.policy.common.utils.resources.ResourceUtils;
@@ -44,6 +44,8 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
 import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
 import org.onap.policy.models.tosca.simple.concepts.JpaToscaServiceTemplate;
 import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException;
+import org.onap.policy.pdpx.main.parameters.CommonTestData;
+import org.onap.policy.pdpx.main.parameters.XacmlApplicationParameters;
 import org.onap.policy.xacml.pdp.application.guard.GuardPdpApplication;
 import org.onap.policy.xacml.pdp.application.nativ.NativePdpApplication;
 import org.onap.policy.xacml.pdp.application.optimization.OptimizationPdpApplication;
@@ -53,9 +55,10 @@ import org.slf4j.LoggerFactory;
 public class XacmlPdpApplicationManagerTest {
     private static final Logger LOGGER = LoggerFactory.getLogger(XacmlPdpApplicationManagerTest.class);
     private static final StandardYamlCoder yamlCoder = new StandardYamlCoder();
-    private static final RestServerParameters params = new RestServerParameters();
+    private static final BusTopicParams params = new BusTopicParams();
     private static Path appsDirectory;
     private static ToscaServiceTemplate completedJtst;
+    private static CommonTestData testData = new CommonTestData();
 
     @ClassRule
     public static final TemporaryFolder appsFolder = new TemporaryFolder();
@@ -70,7 +73,7 @@ public class XacmlPdpApplicationManagerTest {
         //
         // No need to do more than this
         //
-        params.setName("policyApiParameters");
+        params.setClientName("policyApiParameters");
         //
         // Load an example policy
         //
@@ -113,10 +116,13 @@ public class XacmlPdpApplicationManagerTest {
         // Make up a non existent directory to initialize from
         //
         Path nonExistentPath = Paths.get(appsFolder.getRoot().getAbsolutePath(), "nonexistent");
+        final XacmlApplicationParameters xacmlApplicationParameters =
+                testData.toObject(testData.getXacmlapplicationParametersMap(false,
+                        nonExistentPath.toString()), XacmlApplicationParameters.class);
         //
         // Create our app manager
         //
-        XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(nonExistentPath, params);
+        XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, params);
         //
         // Still creates the manager, but the apps were not able to initialize
         //
@@ -126,7 +132,7 @@ public class XacmlPdpApplicationManagerTest {
         // Now create the directory
         //
         Files.createDirectory(nonExistentPath);
-        manager = new XacmlPdpApplicationManager(nonExistentPath, params);
+        manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, params);
         //
         // Now it should have initialized the apps
         //
@@ -136,16 +142,19 @@ public class XacmlPdpApplicationManagerTest {
 
     @Test
     public void testXacmlPdpApplicationManagerSimple() {
-        XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(appsDirectory, params);
+        final XacmlApplicationParameters xacmlApplicationParameters =
+                testData.toObject(testData.getXacmlapplicationParametersMap(false,
+                        appsDirectory.toString()), XacmlApplicationParameters.class);
+        XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, params);
         //
         // Test the basics from the startup
         //
         assertThat(manager).isNotNull();
         assertThat(manager.getPolicyCount()).isZero();
-        assertThat(manager.getPolicyTypeCount()).isEqualTo(20);
+        assertThat(manager.getPolicyTypeCount()).isEqualTo(18);
         assertThat(manager.getToscaPolicies()).isEmpty();
         assertThat(manager.getToscaPolicyIdentifiers()).isEmpty();
-        assertThat(manager.getToscaPolicyTypeIdents()).hasSize(20);
+        assertThat(manager.getToscaPolicyTypeIdents()).hasSize(18);
 
         assertThat(manager.findNativeApplication()).isInstanceOf(NativePdpApplication.class);