aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authoradheli.tavares <adheli.tavares@est.tech>2024-11-06 11:46:41 +0000
committeradheli.tavares <adheli.tavares@est.tech>2024-11-07 11:33:37 +0000
commitd101f30f39531b45d568a177cb32e73e07486433 (patch)
tree52b4d574d16d68056054bd8ecec4d75cfb24baf1 /main/src
parenta7577cb59e90ef1c6ba5031b138fb1b45b828f95 (diff)
Fix references and organize dependencies in xacml-pdp after
splitting policy-endpoints and message-bus Issue-ID: POLICY-5131 Change-Id: I6181f763f140589f681beb602c56b4290e3fab1a Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'main/src')
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisher.java5
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistration.java6
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java6
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListener.java9
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListener.java15
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterGroup.java17
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/parameters/XacmlPdpParameterHandler.java12
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java4
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpActivator.java22
-rw-r--r--main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java4
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java17
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHeartbeatPublisherTest.java (renamed from main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisherTest.java)6
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java2
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java2
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java4
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java4
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/CommonTestData.java13
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/parameters/TestXacmlPdpParameterGroup.java6
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestAbbreviateDecisionResults.java20
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestDecision.java14
-rw-r--r--main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java2
21 files changed, 100 insertions, 90 deletions
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisher.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisher.java
index 8c1f7928..ddd372fa 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisher.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisher.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -25,7 +26,7 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import lombok.Getter;
-import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClient;
+import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClient;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -69,7 +70,7 @@ public class XacmlPdpHearbeatPublisher implements Runnable {
* @param state tracks the state of this PDP
*/
public XacmlPdpHearbeatPublisher(BidirectionalTopicClient topicChecker, long probeHeartbeatTopicMs,
- XacmlState state) {
+ XacmlState state) {
LOGGER.info("heartbeat topic probe {}ms", probeHeartbeatTopicMs);
this.topicChecker = topicChecker;
this.probeHeartbeatTopicMs = probeHeartbeatTopicMs;
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistration.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistration.java
index d477ed0b..abfc6370 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistration.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistration.java
@@ -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,8 +24,8 @@
package org.onap.policy.pdpx.main.comm;
import lombok.AllArgsConstructor;
-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.message.bus.event.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClientException;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,6 +38,7 @@ public class XacmlPdpPapRegistration {
/**
* Sends PDP register and unregister message to the PAP.
+ *
* @param status of the PDP
* @throws TopicSinkClientException if the topic sink does not exist
*/
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
index b6801d82..08879d41 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisher.java
@@ -28,7 +28,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -63,12 +63,12 @@ public class XacmlPdpUpdatePublisher {
// incoming data
Map<ToscaConceptIdentifier, ToscaPolicy> toBeDeployedPolicies = policyToMap(message.getPoliciesToBeDeployed());
List<ToscaConceptIdentifier> toBeUndeployedIds =
- Optional.ofNullable(message.getPoliciesToBeUndeployed()).orElse(Collections.emptyList());
+ Optional.ofNullable(message.getPoliciesToBeUndeployed()).orElse(Collections.emptyList());
var stats = XacmlPdpStatisticsManager.getCurrent();
// Undeploy policies
- for (ToscaConceptIdentifier policyId: toBeUndeployedIds) {
+ for (ToscaConceptIdentifier policyId : toBeUndeployedIds) {
ToscaPolicy policy = deployedPolicies.get(policyId);
if (policy == null) {
LOGGER.warn("attempt to undeploy policy that has not been previously deployed: {}", policyId);
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListener.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListener.java
index 98f6d0e1..a676a043 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListener.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListener.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 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.
@@ -20,10 +21,10 @@
package org.onap.policy.pdpx.main.comm.listeners;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-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.listeners.ScoListener;
+import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClientException;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
@@ -43,7 +44,7 @@ public class XacmlPdpStateChangeListener extends ScoListener<PdpStateChange> {
* Constructs the object.
*
* @param client used to send back response after receiving state change message
- * @param state tracks the state of this PDP
+ * @param state tracks the state of this PDP
*/
public XacmlPdpStateChangeListener(TopicSinkClient client, XacmlState state) {
super(PdpStateChange.class);
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListener.java b/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListener.java
index 1e275c15..8efc2bc5 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListener.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListener.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 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.
@@ -20,9 +21,9 @@
package org.onap.policy.pdpx.main.comm.listeners;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
import org.onap.policy.common.endpoints.listeners.ScoListener;
+import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.onap.policy.common.utils.coder.StandardCoderObject;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.pdpx.main.XacmlState;
@@ -45,13 +46,13 @@ public class XacmlPdpUpdateListener extends ScoListener<PdpUpdate> {
/**
* Constructs the object.
*
- * @param client used to send back response after receiving state change message
- * @param state tracks the state of this PDP
- * @param heartbeat heart beat publisher
+ * @param client used to send back response after receiving state change message
+ * @param state tracks the state of this PDP
+ * @param heartbeat heart beat publisher
* @param appManager application manager
*/
public XacmlPdpUpdateListener(TopicSinkClient client, XacmlState state, XacmlPdpHearbeatPublisher heartbeat,
- XacmlPdpApplicationManager appManager) {
+ XacmlPdpApplicationManager appManager) {
super(PdpUpdate.class);
this.state = state;
this.heartbeat = heartbeat;
@@ -79,7 +80,7 @@ public class XacmlPdpUpdateListener extends ScoListener<PdpUpdate> {
// these may be overridden by junit tests
protected XacmlPdpUpdatePublisher makePublisher(TopicSinkClient client, XacmlState state,
- XacmlPdpApplicationManager appManager) {
+ XacmlPdpApplicationManager appManager) {
return new XacmlPdpUpdatePublisher(client, state, appManager);
}
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 a9332e90..424b596b 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 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.
@@ -24,9 +24,6 @@ package org.onap.policy.pdpx.main.parameters;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
-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;
import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ValidationStatus;
@@ -34,11 +31,13 @@ import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.parameters.annotations.Valid;
+import org.onap.policy.common.parameters.rest.RestClientParameters;
+import org.onap.policy.common.parameters.rest.RestServerParameters;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
import org.onap.policy.models.base.Validated;
/**
* Class to hold all parameters needed for xacml pdp component.
- *
*/
@Getter
@NotNull
@@ -68,12 +67,14 @@ public class XacmlPdpParameterGroup extends ParameterGroupImpl {
/**
* Create the xacml pdp parameter group.
*
- * @param name the parameter group name
+ * @param name the parameter group name
* @param pdpGroup the pdp group name
*/
public XacmlPdpParameterGroup(final String name, final String pdpGroup, final String pdpType,
- final RestServerParameters restServerParameters, final RestClientParameters policyApiParameters,
- final TopicParameterGroup topicParameterGroup, final XacmlApplicationParameters applicationParameters) {
+ final RestServerParameters restServerParameters,
+ final RestClientParameters policyApiParameters,
+ final TopicParameterGroup topicParameterGroup,
+ final XacmlApplicationParameters applicationParameters) {
super(name);
this.pdpGroup = pdpGroup;
this.pdpType = pdpType;
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 649a642f..69f566b8 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
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -21,8 +22,8 @@
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.parameters.rest.RestClientParameters;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.pdpx.main.PolicyXacmlPdpException;
@@ -31,7 +32,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
/**
* This class handles reading, parsing and validating of policy xacml pdp parameters from JSON
* files.
@@ -48,16 +48,16 @@ public class XacmlPdpParameterHandler {
* @throws PolicyXacmlPdpException on parameter exceptions
*/
public XacmlPdpParameterGroup getParameters(final XacmlPdpCommandLineArguments arguments)
- throws PolicyXacmlPdpException {
+ throws PolicyXacmlPdpException {
XacmlPdpParameterGroup xacmlPdpParameterGroup = null;
try {
// Read the parameters from JSON
xacmlPdpParameterGroup = CODER.decode(new File(arguments.getFullConfigurationFilePath()),
- XacmlPdpParameterGroup.class);
+ XacmlPdpParameterGroup.class);
} catch (final Exception e) {
final String errorMessage = "error reading parameters from \"" + arguments.getConfigurationFilePath()
- + "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
+ + "\"\n" + "(" + e.getClass().getSimpleName() + "):" + e.getMessage();
LOGGER.error(errorMessage);
throw new PolicyXacmlPdpException(errorMessage, e);
}
@@ -77,7 +77,7 @@ public class XacmlPdpParameterHandler {
final ValidationResult validationResult = xacmlPdpParameterGroup.validate();
if (!validationResult.isValid()) {
String returnMessage =
- "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
+ "validation error(s) on parameters from \"" + arguments.getConfigurationFilePath() + "\"\n";
returnMessage += validationResult.getResult();
LOGGER.error(returnMessage);
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java b/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java
index 01c4997c..84806377 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/rest/provider/HealthCheckProvider.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* 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.
@@ -20,13 +21,12 @@
package org.onap.policy.pdpx.main.rest.provider;
-import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.common.utils.report.HealthCheckReport;
import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.startstop.XacmlPdpActivator;
/**
* Class to fetch health check of xacml pdp service.
- *
*/
public class HealthCheckProvider {
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 d62b6f47..ed944a7d 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-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.
@@ -24,16 +24,16 @@ package org.onap.policy.pdpx.main.startstop;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
-import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClient;
-import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClientException;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
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.message.bus.event.TopicEndpointManager;
+import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClient;
+import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClientException;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.parameters.rest.RestClientParameters;
import org.onap.policy.common.utils.services.ServiceManagerContainer;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.enums.PdpMessageType;
@@ -101,7 +101,7 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
HttpClient apiClient = HttpClientFactoryInstance.getClientFactory().build(apiClientParams);
var appmgr = new XacmlPdpApplicationManager(xacmlPdpParameterGroup.getApplicationParameters(),
- apiClient);
+ apiClient);
XacmlPdpApplicationManager.setCurrent(appmgr);
var stats = new XacmlPdpStatisticsManager();
@@ -118,21 +118,21 @@ public class XacmlPdpActivator extends ServiceManagerContainer {
sinkClient = new TopicSinkClient(topicClient.getSink());
heartbeat = new XacmlPdpHearbeatPublisher(topicClient,
- xacmlPdpParameterGroup.getProbeHeartbeatTopicSec() * 1000, state);
+ xacmlPdpParameterGroup.getProbeHeartbeatTopicSec() * 1000, state);
/*
* since the dispatcher isn't registered with the topic yet, we can go ahead
* and register the listeners with it.
*/
msgDispatcher.register(PdpMessageType.PDP_STATE_CHANGE.name(),
- new XacmlPdpStateChangeListener(sinkClient, state));
+ new XacmlPdpStateChangeListener(sinkClient, state));
msgDispatcher.register(PdpMessageType.PDP_UPDATE.name(),
- new XacmlPdpUpdateListener(sinkClient, state, heartbeat, appmgr));
+ new XacmlPdpUpdateListener(sinkClient, state, heartbeat, appmgr));
XacmlPdpServiceFilter.disableApi();
restServer = new XacmlPdpRestServer(xacmlPdpParameterGroup.getRestServerParameters(),
- List.of(XacmlPdpServiceFilter.class), List.of(XacmlPdpRestController.class));
+ List.of(XacmlPdpServiceFilter.class), List.of(XacmlPdpRestController.class));
} catch (RuntimeException | HttpClientConfigException | BidirectionalTopicClientException e) {
throw new PolicyXacmlPdpRuntimeException(e.getMessage(), e);
diff --git a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java
index 33cf8934..1717c5c7 100644
--- a/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java
+++ b/main/src/main/java/org/onap/policy/pdpx/main/startstop/XacmlPdpRestServer.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2023-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.
@@ -28,9 +28,9 @@ import org.onap.policy.common.endpoints.http.server.JsonExceptionMapper;
import org.onap.policy.common.endpoints.http.server.RestServer;
import org.onap.policy.common.endpoints.http.server.YamlExceptionMapper;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
-import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.onap.policy.common.gson.GsonMessageBodyHandler;
+import org.onap.policy.common.parameters.rest.RestServerParameters;
import org.onap.policy.pdpx.main.rest.serialization.XacmlJsonExceptionMapper;
import org.onap.policy.pdpx.main.rest.serialization.XacmlJsonMessageBodyHandler;
import org.onap.policy.pdpx.main.rest.serialization.XacmlXmlExceptionMapper;
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java b/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
index d2baff20..24c3d234 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/CommonRest.java
@@ -30,10 +30,10 @@ import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.MediaType;
import java.io.File;
import java.io.IOException;
-import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.security.SecureRandom;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.net.ssl.SSLContext;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
@@ -90,7 +90,7 @@ public class CommonRest {
static {
try {
File file = new File(ResourceUtils.getFilePath4Resource("parameters/XacmlPdpConfigParameters_Std.json"));
- STD_CONFIG = new String(Files.readAllBytes(file.toPath()), StandardCharsets.UTF_8);
+ STD_CONFIG = Files.readString(file.toPath());
file = new File(file.getParentFile(), "Test_XacmlPdpConfigParameters.json");
file.deleteOnExit();
@@ -165,16 +165,14 @@ public class CommonRest {
* Writes a JSON config file, substituting an allocated port number for occurrences of
* "${port}".
*
- * @return the allocated server port
* @throws IOException if the config file cannot be created
*/
- public static int writeJsonConfig() throws IOException {
+ public static void writeJsonConfig() throws IOException {
port = NetworkUtil.allocPort();
String config = STD_CONFIG.replace("${port}", String.valueOf(port));
- Files.write(CONFIG_PATH, config.getBytes(StandardCharsets.UTF_8));
+ Files.writeString(CONFIG_PATH, config);
- return port;
}
/**
@@ -191,7 +189,7 @@ public class CommonRest {
// always trust the host name
final ClientBuilder clientBuilder =
- ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
+ ClientBuilder.newBuilder().sslContext(sc).hostnameVerifier((host, session) -> true);
final Client client = clientBuilder.build();
final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("healthcheck", "zb!XztG34");
@@ -216,7 +214,8 @@ public class CommonRest {
*/
private void markActivator(boolean newAlive) {
Object manager = ReflectionTestUtils.getField(XacmlPdpActivator.getCurrent(), "serviceManager");
- AtomicBoolean running = (AtomicBoolean) ReflectionTestUtils.getField(manager, "running");
- running.set(newAlive);
+ AtomicBoolean running = (AtomicBoolean) ReflectionTestUtils
+ .getField(Objects.requireNonNull(manager), "running");
+ Objects.requireNonNull(running).set(newAlive);
}
}
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisherTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHeartbeatPublisherTest.java
index 29dc10e7..04615921 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHearbeatPublisherTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpHeartbeatPublisherTest.java
@@ -43,14 +43,14 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.event.comm.client.BidirectionalTopicClient;
+import org.onap.policy.common.message.bus.event.TopicSink;
+import org.onap.policy.common.message.bus.event.client.BidirectionalTopicClient;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.pdpx.main.XacmlState;
@ExtendWith(MockitoExtension.class)
-class XacmlPdpHearbeatPublisherTest {
+class XacmlPdpHeartbeatPublisherTest {
private static final long INTERVAL1 = 1000L;
private static final long INTERVAL2 = 2000L;
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java
index 3d3ed864..1293420c 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpPapRegistrationTest.java
@@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpStatus;
@ExtendWith(MockitoExtension.class)
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java
index 0a10eb7a..914654b9 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/XacmlPdpUpdatePublisherTest.java
@@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java
index f646ef29..8d802bef 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpStateChangeListenerTest.java
@@ -31,8 +31,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpStateChange;
import org.onap.policy.models.pdp.concepts.PdpStatus;
import org.onap.policy.pdpx.main.XacmlState;
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java
index 7d23b742..afb8b1a3 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/comm/listeners/XacmlPdpUpdateListenerTest.java
@@ -33,8 +33,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.client.TopicSinkClient;
+import org.onap.policy.common.message.bus.event.Topic.CommInfrastructure;
+import org.onap.policy.common.message.bus.event.client.TopicSinkClient;
import org.onap.policy.models.pdp.concepts.PdpUpdate;
import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.comm.XacmlPdpHearbeatPublisher;
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 ef338cd8..17f08b3a 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
- * Modifications Copyright (C) 2019, 2023 Nordix Foundation.
+ * Modifications Copyright (C) 2019, 2023-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.
@@ -24,14 +24,13 @@ package org.onap.policy.pdpx.main.parameters;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import org.onap.policy.common.endpoints.parameters.TopicParameters;
+import org.onap.policy.common.parameters.topic.TopicParameters;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
/**
* Class to hold/create all parameters for test cases.
- *
*/
public class CommonTestData {
@@ -114,7 +113,7 @@ public class CommonTestData {
* Converts the contents of a map to a parameter class.
*
* @param source property map
- * @param clazz class of object to be created from the map
+ * @param clazz class of object to be created from the map
* @return a new object represented by the map
*/
public <T> T toObject(final Map<String, Object> source, final Class<T> clazz) {
@@ -165,13 +164,13 @@ public class CommonTestData {
/**
* Returns a property map for a XacmlApplicationParameters map for test cases.
*
- * @param isEmpty boolean value to represent that object created should be empty or not
- * @param tempPath Application Path string
+ * @param isEmpty boolean value to represent that object created should be empty or not
+ * @param tempPath Application Path string
* @param exclusions An optional list of application classnames for exclusion
* @return a property map suitable for constructing an object
*/
public Map<String, Object> getXacmlapplicationParametersMap(boolean isEmpty, String tempPath,
- String... exclusions) {
+ String... exclusions) {
final Map<String, Object> map = new TreeMap<>();
if (!isEmpty) {
map.put("applicationPath", tempPath);
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 614f9bee..ff1c600f 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,10 +33,10 @@ import java.nio.file.Path;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-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;
+import org.onap.policy.common.parameters.rest.RestClientParameters;
+import org.onap.policy.common.parameters.rest.RestServerParameters;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
/**
* Class to perform unit test of XacmlPdpParameterGroup.
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 5bfc4372..0894cca8 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
@@ -42,15 +42,16 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceLoader;
+import java.util.stream.Stream;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.onap.policy.common.endpoints.http.client.HttpClient;
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.parameters.rest.RestClientParameters;
+import org.onap.policy.common.parameters.rest.RestServerParameters;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
@@ -79,7 +80,6 @@ class TestAbbreviateDecisionResults {
private static final CommonTestData testData = new CommonTestData();
private static final Properties properties = new Properties();
- private static File propertiesFile;
private static XacmlApplicationServiceProvider service;
@TempDir
@@ -99,7 +99,10 @@ class TestAbbreviateDecisionResults {
//
Path src = Paths.get("src/test/resources/apps");
File apps = appsFolder.resolve("apps").toFile();
- Files.walk(src).forEach(source -> copy(source, apps.toPath().resolve(src.relativize(source))));
+
+ try (Stream<Path> sources = Files.walk(src)) {
+ sources.forEach(source -> copy(source, apps.toPath().resolve(src.relativize(source))));
+ }
// Start the Monitoring Application
startXacmlApplicationService(apps);
@@ -243,13 +246,14 @@ class TestAbbreviateDecisionResults {
throws XacmlApplicationException, IOException {
LOGGER.info("****** Starting Xacml Application Service ******");
//
- // Setup our temporary folder
+ // Set up our temporary folder
//
XacmlPolicyUtils.FileCreator myCreator = (String filename) -> {
- new File(apps, "monitoring/" + filename).delete();
+ var deleted = new File(apps, "monitoring/" + filename).delete();
+ LOGGER.info("was file deleted? {}", deleted);
return appsFolder.resolve("apps/monitoring/" + filename).toFile();
};
- propertiesFile = XacmlPolicyUtils.copyXacmlPropertiesContents(
+ File propertiesFile = XacmlPolicyUtils.copyXacmlPropertiesContents(
"../applications/monitoring/src/test/resources/xacml.properties", properties, myCreator);
//
// Load XacmlApplicationServiceProvider service
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 9e2c9893..82d5c9fd 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
@@ -39,6 +39,7 @@ import java.nio.file.StandardCopyOption;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.stream.Stream;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -46,9 +47,9 @@ import org.junit.jupiter.api.io.TempDir;
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.parameters.rest.RestClientParameters;
+import org.onap.policy.common.parameters.rest.RestServerParameters;
+import org.onap.policy.common.parameters.topic.TopicParameterGroup;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.decisions.concepts.DecisionRequest;
@@ -95,9 +96,10 @@ class TestDecision {
//
Path src = Paths.get("src/test/resources/apps");
File apps = appsFolder.resolve("apps").toFile();
- Files.walk(src).forEach(source -> {
- copy(source, apps.toPath().resolve(src.relativize(source)));
- });
+
+ try (Stream<Path> sources = Files.walk(src)) {
+ sources.forEach(source -> copy(source, apps.toPath().resolve(src.relativize(source))));
+ }
//
// Get the parameters file correct.
//
diff --git a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java
index 6be2e7a0..2b1e4f09 100644
--- a/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java
+++ b/main/src/test/java/org/onap/policy/pdpx/main/rest/TestXacmlPdpRestServer.java
@@ -27,7 +27,7 @@ import jakarta.ws.rs.client.Invocation;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;
-import org.onap.policy.common.endpoints.report.HealthCheckReport;
+import org.onap.policy.common.utils.report.HealthCheckReport;
import org.onap.policy.pdpx.main.CommonRest;
import org.onap.policy.pdpx.main.XacmlState;
import org.onap.policy.pdpx.main.rest.model.StatisticsReport;