diff options
27 files changed, 123 insertions, 156 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java index 52ecd84b..0f0f7ea2 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java @@ -23,10 +23,7 @@ package org.onap.policy.pdp.xacml.application.common; import java.net.HttpURLConnection; import javax.ws.rs.core.Response; -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.HttpClientConfigException; -import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.slf4j.Logger; @@ -46,16 +43,10 @@ public class PolicyApiCaller { /** * Constructs the object. * - * @param params target specification - * @throws PolicyApiException if an error occurs + * @param httpClient API REST client */ - public PolicyApiCaller(BusTopicParams params) throws PolicyApiException { - try { - params.setClientName("policy-api"); - httpClient = makeClient(params); - } catch (HttpClientConfigException e) { - throw new PolicyApiException("connection to host: " + params.getHostname(), e); - } + public PolicyApiCaller(HttpClient httpClient) { + this.httpClient = httpClient; } /** @@ -87,10 +78,4 @@ public class PolicyApiCaller { throw new PolicyApiException(type.toString(), e); } } - - // these methods may be overridden by junit tests - - protected HttpClient makeClient(BusTopicParams busParams) throws HttpClientConfigException { - return HttpClientFactoryInstance.getClientFactory().build(busParams); - } } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java index 7512fb76..8d1bf617 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java @@ -27,7 +27,7 @@ import java.nio.file.Path; import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -64,9 +64,9 @@ public interface XacmlApplicationServiceProvider { * Also gives api rest parameters if needed. * * @param pathForData Local Path - * @param policyApiParameters API rest parameters + * @param policyApiClient API rest client */ - void initialize(Path pathForData, BusTopicParams policyApiParameters) + void initialize(Path pathForData, HttpClient policyApiClient) throws XacmlApplicationException; /** diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java index cca2d218..e473de88 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java @@ -52,7 +52,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; import org.apache.commons.lang3.tuple.Pair; -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.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardYamlCoder; @@ -94,7 +94,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha private final Map<ToscaConceptIdentifier, MatchablePolicyType> matchableCache = new HashMap<>(); @Setter - private BusTopicParams apiRestParameters; + private HttpClient apiClient; @Setter private Path pathForData; @@ -572,7 +572,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha // ToscaServiceTemplate policyTemplate = null; try { - var api = new PolicyApiCaller(this.apiRestParameters); + var api = new PolicyApiCaller(this.apiClient); policyTemplate = api.getPolicyType(policyTypeId); } catch (PolicyApiException e) { diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java index 40968758..466aae12 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java @@ -43,7 +43,7 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -67,7 +67,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica private Path pathForData = null; @Getter - private BusTopicParams policyApiParameters; + private HttpClient policyApiClient; private Properties pdpProperties = null; private PDPEngine pdpEngine = null; private Map<ToscaPolicy, Path> mapLoadedPolicies = new HashMap<>(); @@ -83,7 +83,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica } @Override - public void initialize(Path pathForData, BusTopicParams policyApiParameters) + public void initialize(Path pathForData, HttpClient policyApiClient) throws XacmlApplicationException { // // Save our path @@ -93,7 +93,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica // // Save our params // - this.policyApiParameters = policyApiParameters; + this.policyApiClient = policyApiClient; // // Look for and load the properties object // diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java index 23ebbaa9..8a856698 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCallerTest.java @@ -42,11 +42,11 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.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.HttpClientConfigException; +import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.onap.policy.common.utils.network.NetworkUtil; @@ -68,7 +68,9 @@ public class PolicyApiCallerTest { private static final String UNKNOWN_TYPE = "unknown"; private static int port; - private static BusTopicParams clientParams; + private static RestClientParameters clientParams; + + private static HttpClient apiClient; private PolicyApiCaller api; @@ -82,7 +84,8 @@ public class PolicyApiCallerTest { public static void setUpBeforeClass() throws Exception { port = NetworkUtil.allocPort(); - clientParams = mock(BusTopicParams.class); + clientParams = mock(RestClientParameters.class); + when(clientParams.getClientName()).thenReturn("apiClient"); when(clientParams.getHostname()).thenReturn("localhost"); when(clientParams.getPort()).thenReturn(port); @@ -104,6 +107,7 @@ public class PolicyApiCallerTest { GsonMessageBodyHandler.class.getName()); HttpServletServerFactoryInstance.getServerFactory().build(props).forEach(HttpServletServer::start); + apiClient = HttpClientFactoryInstance.getClientFactory().build(clientParams); assertTrue(NetworkUtil.isTcpPortOpen(clientParams.getHostname(), clientParams.getPort(), 100, 100)); } @@ -122,17 +126,7 @@ public class PolicyApiCallerTest { public void setUp() throws PolicyApiException { when(clientParams.getPort()).thenReturn(port); - api = new PolicyApiCaller(clientParams); - } - - @Test - public void testPolicyApi() { - assertThatThrownBy(() -> new PolicyApiCaller(clientParams) { - @Override - protected HttpClient makeClient(BusTopicParams busParams) throws HttpClientConfigException { - throw new HttpClientConfigException("expected exception"); - } - }).isInstanceOf(PolicyApiException.class); + api = new PolicyApiCaller(apiClient); } @Test @@ -150,8 +144,13 @@ public class PolicyApiCallerTest { .isInstanceOf(PolicyApiException.class); // connect to a port that has no server - when(clientParams.getPort()).thenReturn(NetworkUtil.allocPort()); - api = new PolicyApiCaller(clientParams); + RestClientParameters params2 = mock(RestClientParameters.class); + when(params2.getClientName()).thenReturn("apiClient"); + when(params2.getHostname()).thenReturn("localhost"); + when(params2.getPort()).thenReturn(NetworkUtil.allocPort()); + + HttpClient apiClient2 = HttpClientFactoryInstance.getClientFactory().build(params2); + api = new PolicyApiCaller(apiClient2); assertThatThrownBy(() -> api.getPolicyType(new ToscaConceptIdentifier(MY_TYPE, MY_VERSION))) .isInstanceOf(PolicyApiException.class); diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java index 5cd54e8f..1d2754b8 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslatorTest.java @@ -58,9 +58,11 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -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.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.common.gson.GsonMessageBodyHandler; import org.onap.policy.common.utils.coder.CoderException; @@ -85,8 +87,9 @@ public class StdMatchableTranslatorTest { private static final String CLIENT_NAME = "policy-api"; private static final StandardYamlCoder yamlCoder = new StandardYamlCoder(); private static int port; - private static BusTopicParams clientParams; + private static RestClientParameters clientParams; private static ToscaServiceTemplate testTemplate; + private static HttpClient apiClient; @ClassRule public static final TemporaryFolder policyFolder = new TemporaryFolder(); @@ -106,7 +109,8 @@ public class StdMatchableTranslatorTest { // port = NetworkUtil.allocPort(); - clientParams = mock(BusTopicParams.class); + clientParams = mock(RestClientParameters.class); + when(clientParams.getClientName()).thenReturn("apiClient"); when(clientParams.getHostname()).thenReturn("localhost"); when(clientParams.getPort()).thenReturn(port); @@ -128,6 +132,7 @@ public class StdMatchableTranslatorTest { GsonMessageBodyHandler.class.getName()); HttpServletServerFactoryInstance.getServerFactory().build(props).forEach(HttpServletServer::start); + apiClient = HttpClientFactoryInstance.getClientFactory().build(clientParams); assertTrue(NetworkUtil.isTcpPortOpen(clientParams.getHostname(), clientParams.getPort(), 100, 100)); // @@ -170,7 +175,7 @@ public class StdMatchableTranslatorTest { // Set it up // translator.setPathForData(policyFolder.getRoot().toPath()); - translator.setApiRestParameters(clientParams); + translator.setApiClient(apiClient); // // Load policies to test // diff --git a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java index 76f22551..ea1e04d1 100644 --- a/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java +++ b/applications/common/src/test/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProviderTest.java @@ -56,7 +56,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; @@ -80,7 +80,9 @@ public class StdXacmlApplicationServiceProviderTest { private static final String POLICY_NAME = "my-name"; private static final String POLICY_VERSION = "1.2.3"; private static final String POLICY_TYPE = "my-type"; - private static final BusTopicParams apiRestParameters = new BusTopicParams(); + + @Mock + private HttpClient apiClient; @Mock private ToscaPolicyTranslator trans; @@ -165,7 +167,7 @@ public class StdXacmlApplicationServiceProviderTest { @Test public void testInitialize_testGetXxx() throws XacmlApplicationException { - prov.initialize(TEMP_PATH, apiRestParameters); + prov.initialize(TEMP_PATH, apiClient); assertEquals(TEMP_PATH, prov.getDataPath()); assertNotNull(prov.getEngine()); @@ -176,7 +178,7 @@ public class StdXacmlApplicationServiceProviderTest { @Test public void testInitialize_Ex() throws XacmlApplicationException { - assertThatThrownBy(() -> prov.initialize(new File(TEMP_DIR_NAME + "-nonExistent").toPath(), apiRestParameters)) + assertThatThrownBy(() -> prov.initialize(new File(TEMP_DIR_NAME + "-nonExistent").toPath(), apiClient)) .isInstanceOf(XacmlApplicationException.class).hasMessage("Failed to load xacml.properties"); } @@ -199,7 +201,7 @@ public class StdXacmlApplicationServiceProviderTest { @Test public void testLoadPolicy_testUnloadPolicy() throws Exception { - prov.initialize(TEMP_PATH, apiRestParameters); + prov.initialize(TEMP_PATH, apiClient); PROP_FILE.delete(); final Set<String> set = XACMLProperties.getRootPolicyIDs(prov.getProperties()); @@ -247,7 +249,7 @@ public class StdXacmlApplicationServiceProviderTest { @Test public void testUnloadPolicy_NotDeployed() throws Exception { - prov.initialize(TEMP_PATH, apiRestParameters); + prov.initialize(TEMP_PATH, apiClient); assertFalse(prov.unloadPolicy(policy)); @@ -313,7 +315,7 @@ public class StdXacmlApplicationServiceProviderTest { engineFactory = null; prov = new MyProv(); - prov.initialize(TEMP_PATH, apiRestParameters); + prov.initialize(TEMP_PATH, apiClient); assertNotNull(prov.getEngine()); } diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java index 07d1a5ab..29d9e7f3 100644 --- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java +++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/GuardPdpApplicationTest.java @@ -50,7 +50,6 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runners.MethodSorters; -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.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; @@ -73,7 +72,6 @@ public class GuardPdpApplicationTest { private static final Logger LOGGER = LoggerFactory.getLogger(GuardPdpApplicationTest.class); private static Properties properties = new Properties(); private static File propertiesFile; - private static BusTopicParams clientParams = new BusTopicParams(); private static XacmlApplicationServiceProvider service; private static DecisionRequest requestVfCount; private static StandardCoder gson = new StandardCoder(); @@ -129,7 +127,7 @@ public class GuardPdpApplicationTest { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), clientParams); + service.initialize(propertiesFile.toPath().getParent(), null); // // Load Decision Requests // diff --git a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java index a4f47789..873df756 100644 --- a/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java +++ b/applications/guard/src/test/java/org/onap/policy/xacml/pdp/application/guard/SonCoordinationTest.java @@ -45,7 +45,6 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runners.MethodSorters; -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.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; @@ -66,7 +65,6 @@ public class SonCoordinationTest { private static final Logger LOGGER = LoggerFactory.getLogger(SonCoordinationTest.class); private static Properties properties = new Properties(); private static File propertiesFile; - private static BusTopicParams clientParams = new BusTopicParams(); private static XacmlApplicationServiceProvider service; private static DecisionRequest requestVpciNode1; private static DecisionRequest requestVsonhNode1; @@ -126,7 +124,7 @@ public class SonCoordinationTest { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), clientParams); + service.initialize(propertiesFile.toPath().getParent(), null); // // Load Decision Requests // diff --git a/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java b/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java index cd16a2ce..9cf56878 100644 --- a/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java +++ b/applications/match/src/main/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplication.java @@ -25,7 +25,7 @@ package org.onap.policy.xacml.pdp.application.match; import java.nio.file.Path; import java.util.Arrays; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.pdp.xacml.application.common.ToscaPolicyTranslator; import org.onap.policy.pdp.xacml.application.common.XacmlApplicationException; @@ -54,18 +54,18 @@ public class MatchPdpApplication extends StdXacmlApplicationServiceProvider { } @Override - public void initialize(Path pathForData, BusTopicParams policyApiParameters) + public void initialize(Path pathForData, HttpClient policyApiClient) throws XacmlApplicationException { // // Store our API parameters and path for translator so it // can go get Policy Types // this.translator.setPathForData(pathForData); - this.translator.setApiRestParameters(policyApiParameters); + this.translator.setApiClient(policyApiClient); // // Let our super class do its thing // - super.initialize(pathForData, policyApiParameters); + super.initialize(pathForData, policyApiClient); } @Override diff --git a/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java b/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java index 3ceaa097..a855f3e2 100644 --- a/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java +++ b/applications/match/src/test/java/org/onap/policy/xacml/pdp/application/match/MatchPdpApplicationTest.java @@ -24,8 +24,6 @@ package org.onap.policy.xacml.pdp.application.match; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.att.research.xacml.api.Response; import java.io.File; @@ -44,7 +42,6 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runners.MethodSorters; -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.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -67,7 +64,6 @@ public class MatchPdpApplicationTest { private static XacmlApplicationServiceProvider service; private static StandardCoder gson = new StandardCoder(); private static DecisionRequest baseRequest; - private static BusTopicParams clientParams; @ClassRule public static final TemporaryFolder policyFolder = new TemporaryFolder(); @@ -79,9 +75,6 @@ public class MatchPdpApplicationTest { */ @BeforeClass public static void setUp() throws Exception { - clientParams = mock(BusTopicParams.class); - when(clientParams.getHostname()).thenReturn("localhost"); - when(clientParams.getPort()).thenReturn(6969); // // Load Single Decision Request // @@ -137,7 +130,7 @@ public class MatchPdpApplicationTest { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), clientParams); + service.initialize(propertiesFile.toPath().getParent(), null); } @Test diff --git a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java index 40414f56..7fab09b2 100644 --- a/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java +++ b/applications/monitoring/src/test/java/org/onap/policy/xacml/pdp/application/monitoring/MonitoringPdpApplicationTest.java @@ -41,7 +41,6 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runners.MethodSorters; -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.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; @@ -67,7 +66,6 @@ public class MonitoringPdpApplicationTest { private static DecisionRequest requestPolicyType; private static StandardCoder gson = new StandardCoder(); - private static BusTopicParams clientParams = new BusTopicParams(); @ClassRule public static final TemporaryFolder policyFolder = new TemporaryFolder(); @@ -130,7 +128,7 @@ public class MonitoringPdpApplicationTest { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), clientParams); + service.initialize(propertiesFile.toPath().getParent(), null); } @Test diff --git a/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java b/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java index 30199088..0c567e11 100644 --- a/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java +++ b/applications/naming/src/test/java/org/onap/policy/xacml/pdp/application/naming/NamingPdpApplicationTest.java @@ -24,8 +24,6 @@ package org.onap.policy.xacml.pdp.application.naming; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.att.research.xacml.api.Response; import java.io.File; @@ -48,7 +46,6 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runners.MethodSorters; -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.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; @@ -71,7 +68,6 @@ public class NamingPdpApplicationTest { private static XacmlApplicationServiceProvider service; private static StandardCoder gson = new StandardCoder(); private static DecisionRequest baseRequest; - private static BusTopicParams clientParams; @ClassRule public static final TemporaryFolder policyFolder = new TemporaryFolder(); @@ -83,9 +79,6 @@ public class NamingPdpApplicationTest { */ @BeforeClass public static void setUp() throws Exception { - clientParams = mock(BusTopicParams.class); - when(clientParams.getHostname()).thenReturn("localhost"); - when(clientParams.getPort()).thenReturn(6969); // // Load Single Decision Request // @@ -143,7 +136,7 @@ public class NamingPdpApplicationTest { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), clientParams); + service.initialize(propertiesFile.toPath().getParent(), null); } @Test diff --git a/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java b/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java index 83b65e5a..6a706760 100644 --- a/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java +++ b/applications/native/src/test/java/org/onap/policy/xacml/pdp/application/nativ/NativePdpApplicationTest.java @@ -39,7 +39,6 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.utils.coder.StandardYamlCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.common.utils.resources.TextFileUtils; @@ -61,7 +60,6 @@ public class NativePdpApplicationTest { private static final StandardYamlCoder yamlCoder = new StandardYamlCoder(); private static Properties properties = new Properties(); private static File propertiesFile; - private static BusTopicParams clientParams = new BusTopicParams(); private static NativePdpApplication service; private static Request request; @@ -112,7 +110,7 @@ public class NativePdpApplicationTest { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), clientParams); + service.initialize(propertiesFile.toPath().getParent(), null); // // Load XACML Request // diff --git a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java index 998ed537..42ceb4b4 100644 --- a/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java +++ b/applications/optimization/src/main/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplication.java @@ -34,7 +34,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -87,18 +87,18 @@ public class OptimizationPdpApplication extends StdXacmlApplicationServiceProvid } @Override - public void initialize(Path pathForData, BusTopicParams policyApiParameters) + public void initialize(Path pathForData, HttpClient policyApiClient) throws XacmlApplicationException { // // Store our API parameters and path for translator so it // can go get Policy Types // this.translator.setPathForData(pathForData); - this.translator.setApiRestParameters(policyApiParameters); + this.translator.setApiClient(policyApiClient); // // Let our super class do its thing // - super.initialize(pathForData, policyApiParameters); + super.initialize(pathForData, policyApiClient); } @Override diff --git a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java index 00855f40..9c922941 100644 --- a/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java +++ b/applications/optimization/src/test/java/org/onap/policy/xacml/pdp/application/optimization/OptimizationPdpApplicationTest.java @@ -25,8 +25,6 @@ package org.onap.policy.xacml.pdp.application.optimization; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.att.research.xacml.api.Response; import com.google.common.collect.Lists; @@ -48,7 +46,6 @@ import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.junit.runners.MethodSorters; -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.StandardCoder; import org.onap.policy.common.utils.coder.StandardYamlCoder; @@ -76,7 +73,6 @@ public class OptimizationPdpApplicationTest { private static XacmlApplicationServiceProvider service; private static StandardCoder gson = new StandardCoder(); private static DecisionRequest baseRequest; - private static BusTopicParams clientParams; private static String[] listPolicyTypeFiles = { "onap.policies.Optimization", "onap.policies.optimization.Resource", @@ -101,9 +97,6 @@ public class OptimizationPdpApplicationTest { */ @BeforeClass public static void setUp() throws Exception { - clientParams = mock(BusTopicParams.class); - when(clientParams.getHostname()).thenReturn("localhost"); - when(clientParams.getPort()).thenReturn(6969); // // Load Single Decision Request // @@ -162,7 +155,7 @@ public class OptimizationPdpApplicationTest { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), clientParams); + service.initialize(propertiesFile.toPath().getParent(), null); } /** diff --git a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java index 7fde514a..b994fe9e 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java @@ -23,7 +23,7 @@ package org.onap.policy.pdpx.main.parameters; import lombok.Getter; import org.apache.commons.lang3.StringUtils; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; import org.onap.policy.common.parameters.BeanValidationResult; @@ -42,14 +42,14 @@ import org.onap.policy.models.base.Validated; @NotNull @NotBlank public class XacmlPdpParameterGroup extends ParameterGroupImpl { - private static final String PARAM_POLICY_API = "policyApiParameters"; + public static final String PARAM_POLICY_API = "policyApiParameters"; private String pdpGroup; private String pdpType; @Valid private RestServerParameters restServerParameters; @Valid - private BusTopicParams policyApiParameters; + private RestClientParameters policyApiParameters; @Valid private TopicParameterGroup topicParameterGroup; @Valid @@ -62,7 +62,7 @@ public class XacmlPdpParameterGroup extends ParameterGroupImpl { * @param pdpGroup the pdp group name */ public XacmlPdpParameterGroup(final String name, final String pdpGroup, final String pdpType, - final RestServerParameters restServerParameters, final BusTopicParams policyApiParameters, + final RestServerParameters restServerParameters, final RestClientParameters policyApiParameters, final TopicParameterGroup topicParameterGroup, final XacmlApplicationParameters applicationParameters) { super(name); this.pdpGroup = pdpGroup; diff --git a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterHandler.java b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterHandler.java index 539716b8..649a642f 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterHandler.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterHandler.java @@ -21,6 +21,7 @@ package org.onap.policy.pdpx.main.parameters; import java.io.File; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.parameters.ValidationResult; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.StandardCoder; @@ -68,6 +69,10 @@ public class XacmlPdpParameterHandler { throw new PolicyXacmlPdpException(errorMessage); } + RestClientParameters apiClientParams = xacmlPdpParameterGroup.getPolicyApiParameters(); + apiClientParams.setName(XacmlPdpParameterGroup.PARAM_POLICY_API); + apiClientParams.setManaged(false); + // validate the parameters final ValidationResult validationResult = xacmlPdpParameterGroup.validate(); if (!validationResult.isValid()) { diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java index 6cd46838..10f2046a 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManager.java @@ -33,7 +33,7 @@ import java.util.ServiceLoader; import java.util.stream.Collectors; import lombok.Getter; import lombok.Setter; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy; @@ -60,9 +60,9 @@ public class XacmlPdpApplicationManager { * One time to initialize the applications upon startup. */ public XacmlPdpApplicationManager(XacmlApplicationParameters applicationParameters, - BusTopicParams policyApiParameters) { + HttpClient policyApiClient) { if (LOGGER.isInfoEnabled()) { - LOGGER.info("Initialization applications {} {}", applicationParameters, policyApiParameters); + LOGGER.info("Initialization applications {} {}", applicationParameters, policyApiClient); } // // Load service @@ -93,7 +93,7 @@ public class XacmlPdpApplicationManager { // try { initializeApplicationPath(Paths.get(applicationParameters.getApplicationPath()), application, - policyApiParameters); + policyApiClient); // // We are initialized // @@ -238,7 +238,7 @@ public class XacmlPdpApplicationManager { } private void initializeApplicationPath(Path basePath, XacmlApplicationServiceProvider application, - BusTopicParams policyApiParameters) throws XacmlApplicationException { + HttpClient policyApiClient) throws XacmlApplicationException { // // Making an assumption that all application names are unique, and // they can result in a valid directory being created. @@ -267,6 +267,6 @@ public class XacmlPdpApplicationManager { // // Have the application initialize // - application.initialize(path, policyApiParameters); + application.initialize(path, policyApiClient); } } diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java index d3b59c4a..e74ab9bf 100644 --- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java +++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java @@ -27,7 +27,11 @@ import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicSource; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient; import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClientException; +import org.onap.policy.common.endpoints.http.client.HttpClient; +import org.onap.policy.common.endpoints.http.client.HttpClientConfigException; +import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.common.utils.services.ServiceManagerContainer; import org.onap.policy.models.pdp.concepts.PdpStatus; @@ -79,6 +83,8 @@ public class XacmlPdpActivator extends ServiceManagerContainer { public XacmlPdpActivator(final XacmlPdpParameterGroup xacmlPdpParameterGroup) { LOGGER.info("Activator initializing using {}", xacmlPdpParameterGroup); + RestClientParameters apiClientParams = xacmlPdpParameterGroup.getPolicyApiParameters(); + TopicEndpointManager.getManager().addTopics(xacmlPdpParameterGroup.getTopicParameterGroup()); final XacmlPdpHearbeatPublisher heartbeat; @@ -86,9 +92,10 @@ public class XacmlPdpActivator extends ServiceManagerContainer { final XacmlState state; try { - var appmgr = - new XacmlPdpApplicationManager(xacmlPdpParameterGroup.getApplicationParameters(), - xacmlPdpParameterGroup.getPolicyApiParameters()); + HttpClient apiClient = HttpClientFactoryInstance.getClientFactory().build(apiClientParams); + + var appmgr = new XacmlPdpApplicationManager(xacmlPdpParameterGroup.getApplicationParameters(), + apiClient); XacmlPdpApplicationManager.setCurrent(appmgr); var stats = new XacmlPdpStatisticsManager(); @@ -116,7 +123,7 @@ public class XacmlPdpActivator extends ServiceManagerContainer { restServer = new XacmlPdpRestServer(xacmlPdpParameterGroup.getRestServerParameters(), XacmlPdpAafFilter.class, XacmlPdpRestController.class); - } catch (RuntimeException | TopicSinkClientException e) { + } catch (RuntimeException | TopicSinkClientException | HttpClientConfigException e) { throw new PolicyXacmlPdpRuntimeException(e.getMessage(), e); } diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java index 21475da8..e4352181 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java @@ -37,6 +37,7 @@ import org.onap.policy.common.utils.coder.StandardCoder; */ public class CommonTestData { + private static final String CLIENT_NAME = "clientName"; private static final String PASS_KEY = "password"; private static final String USER_KEY = "userName"; private static final String PORT_KEY = "port"; @@ -143,6 +144,7 @@ public class CommonTestData { */ public Map<String, Object> getPolicyApiParametersMap(final boolean isEmpty) { final Map<String, Object> map = new TreeMap<>(); + map.put(CLIENT_NAME, XacmlPdpParameterGroup.PARAM_POLICY_API); map.put(HTTPS_KEY, POLICY_API_HTTPS); map.put(AAF_KEY, POLICY_API_AAF); diff --git a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java index cb9825cc..a9f3f12d 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java @@ -33,7 +33,7 @@ import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; import org.onap.policy.common.parameters.ValidationResult; @@ -59,8 +59,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup() throws IOException { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -88,8 +88,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_NullParameterGroupName() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -107,8 +107,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_EmptyParameterGroupName() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -127,8 +127,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_NullPdpGroup() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -147,8 +147,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_EmptyPdpGroup() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -167,8 +167,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_EmptyRestServerParameters() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(true), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -187,8 +187,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_EmptyPolicyApiParameters() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(true), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(true), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -207,8 +207,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_EmptyTopicParameterGroup() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(true), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -227,8 +227,8 @@ public class TestXacmlPdpParameterGroup { public void testXacmlPdpParameterGroup_EmptyApplicationParameterGroup() { final RestServerParameters restServerParameters = testData.toObject(testData.getRestServerParametersMap(false), RestServerParameters.class); - final BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + final RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); final TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java index 54d7432f..8d80b832 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java @@ -47,10 +47,10 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -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.HttpClientConfigException; import org.onap.policy.common.endpoints.http.client.internal.JerseyClient; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; import org.onap.policy.common.utils.coder.CoderException; @@ -85,7 +85,7 @@ public class TestAbbreviateDecisionResults { private static File propertiesFile; private static XacmlApplicationServiceProvider service; - private static BusTopicParams policyApiParameters; + private static RestClientParameters policyApiParameters; @ClassRule public static final TemporaryFolder appsFolder = new TemporaryFolder(); @@ -117,7 +117,7 @@ public class TestAbbreviateDecisionResults { // Create parameters for XacmlPdPService RestServerParameters rest = testData.toObject(testData.getRestServerParametersMap(port), RestServerParameters.class); - policyApiParameters = testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + policyApiParameters = testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -219,7 +219,7 @@ public class TestAbbreviateDecisionResults { */ private static HttpClient getNoAuthHttpClient() throws HttpClientConfigException, KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException { - BusTopicParams clientParams = new BusTopicParams(); + RestClientParameters clientParams = new RestClientParameters(); clientParams.setClientName("testName"); clientParams.setUseHttps(false); clientParams.setAllowSelfSignedCerts(false); @@ -289,6 +289,6 @@ public class TestAbbreviateDecisionResults { // Tell it to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), policyApiParameters); + service.initialize(propertiesFile.toPath().getParent(), null); } } diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java index 5f6a2796..77e8873f 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java @@ -46,10 +46,10 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -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.HttpClientConfigException; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; +import org.onap.policy.common.endpoints.parameters.RestClientParameters; import org.onap.policy.common.endpoints.parameters.RestServerParameters; import org.onap.policy.common.endpoints.parameters.TopicParameterGroup; import org.onap.policy.common.utils.network.NetworkUtil; @@ -105,8 +105,8 @@ public class TestDecision { // RestServerParameters rest = testData.toObject(testData.getRestServerParametersMap(port), RestServerParameters.class); - BusTopicParams policyApiParameters = - testData.toObject(testData.getPolicyApiParametersMap(false), BusTopicParams.class); + RestClientParameters policyApiParameters = + testData.toObject(testData.getPolicyApiParametersMap(false), RestClientParameters.class); TopicParameterGroup topicParameterGroup = testData.toObject(testData.getTopicParametersMap(false), TopicParameterGroup.class); final XacmlApplicationParameters xacmlApplicationParameters = @@ -245,7 +245,7 @@ public class TestDecision { } private static HttpClient getNoAuthHttpClient() throws HttpClientConfigException { - return HttpClientFactoryInstance.getClientFactory().build(BusTopicParams.builder() + return HttpClientFactoryInstance.getClientFactory().build(RestClientParameters.builder() .clientName("testDecisionClient") .useHttps(false).allowSelfSignedCerts(false).hostname("localhost").port(port) .basePath("policy/pdpx/v1") diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java index c79ebb52..036d4e35 100644 --- a/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java +++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/XacmlPdpApplicationManagerTest.java @@ -35,7 +35,6 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -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; @@ -54,7 +53,6 @@ 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 BusTopicParams params = new BusTopicParams(); private static Path appsDirectory; private static ToscaServiceTemplate completedJtst; private static CommonTestData testData = new CommonTestData(); @@ -70,10 +68,6 @@ public class XacmlPdpApplicationManagerTest { @BeforeClass public static void setupTestEnvironment() throws Exception { // - // No need to do more than this - // - params.setClientName("policyApiParameters"); - // // Load an example policy // String policyYaml = ResourceUtils @@ -121,7 +115,7 @@ public class XacmlPdpApplicationManagerTest { // // Create our app manager // - XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, params); + XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, null); // // Still creates the manager, but the apps were not able to initialize // @@ -131,7 +125,7 @@ public class XacmlPdpApplicationManagerTest { // Now create the directory // Files.createDirectory(nonExistentPath); - manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, params); + manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, null); // // Now it should have initialized the apps // @@ -146,7 +140,7 @@ public class XacmlPdpApplicationManagerTest { final XacmlApplicationParameters xacmlApplicationParameters = testData.toObject(testData.getXacmlapplicationParametersMap(false, appsDirectory.toString(), exclusions), XacmlApplicationParameters.class); - XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, params); + XacmlPdpApplicationManager manager = new XacmlPdpApplicationManager(xacmlApplicationParameters, null); // // Test the basics from the startup // diff --git a/packages/policy-xacmlpdp-docker/pom.xml b/packages/policy-xacmlpdp-docker/pom.xml index 473c90a3..e2cba71f 100644 --- a/packages/policy-xacmlpdp-docker/pom.xml +++ b/packages/policy-xacmlpdp-docker/pom.xml @@ -1,6 +1,6 @@ <!-- ============LICENSE_START======================================================= - Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved. Modifications Copyright (C) 2020 Bell Canada. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,8 +42,6 @@ <docker.skip>false</docker.skip> <docker.skip.build>false</docker.skip.build> <docker.skip.push>false</docker.skip.push> - <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry> - <docker.push.registry>nexus3.onap.org:10003</docker.push.registry> <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format> </properties> diff --git a/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java b/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java index c72f0746..4fda0983 100644 --- a/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java +++ b/tutorials/tutorial-xacml-application/src/test/java/org/onap/policy/tutorial/tutorial/TutorialApplicationTest.java @@ -30,7 +30,6 @@ import org.junit.BeforeClass; import org.junit.ClassRule; import org.junit.Test; import org.junit.rules.TemporaryFolder; -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.StandardCoder; import org.onap.policy.common.utils.resources.TextFileUtils; @@ -86,7 +85,7 @@ public class TutorialApplicationTest { // Tell the application to initialize based on the properties file // we just built for it. // - service.initialize(propertiesFile.toPath().getParent(), new BusTopicParams()); + service.initialize(propertiesFile.toPath().getParent(), null); } @Test |